微件

微件:配队模拟器

来自卡厄思梦境WIKI

律Rhyme留言 | 贡献2025年10月18日 (六) 20:08的版本

<script> // 存储当前选择状态 let currentSelection = {

   character: null,
   partner: null,
   cards: [],
   weapon: null,
   armor: null,
   ring: null

};

// 打开选择模态框 function openSelectionModal(type) {

   const modal = document.getElementById('selection-modal');
   const content = document.getElementById('modal-content');
   
   switch(type) {
       case 'character':

content.innerHTML = `

凯隆
小春
雨果
蕾欧娜
维若妮卡
梅铃
奥尔莱亚
麦格纳
卡莉佩
路克
蕾伊
欧文
凯西乌斯
百丽儿
米卡
玛丽贝尔
卢卡斯
艾美
德蕾莎
席琳娜
妮雅

`;

           break;
           
       case 'partner':

content.innerHTML = `

`;

           break;
           
       case 'card':
           // 需要先选择角色才能选择卡牌
           if (!currentSelection.character) {
               alert('请先选择角色');
               return;
           }
           content.innerHTML = generateCardSelection();
           break;
           
       case 'weapon':
           content.innerHTML = generateEquipmentSelection('武器');
           break;
           
       case 'armor':
           content.innerHTML = generateEquipmentSelection('装甲');
           break;
           
       case 'ring':
           content.innerHTML = generateEquipmentSelection('戒指');
           break;
   }
   
   modal.style.display = 'block';
   document.body.style.overflow = 'hidden';
   
   // 为生成的元素添加点击事件
   setTimeout(() => {
       addSelectionEvents(type);
   }, 100);

}

// 关闭选择模态框 function closeSelectionModal() {

   const modal = document.getElementById('selection-modal');
   modal.style.display = 'none';
   document.body.style.overflow = 'auto';

}

// 生成卡牌选择界面 function generateCardSelection() {

   if (!currentSelection.character) return ;
   
   // 这里需要根据选择的角色获取对应的卡牌数据
   // 假设从模板中获取卡牌信息
   return `

选择卡牌 - ${currentSelection.character}

               错误: 找不到模块 "Module:卡牌/角色模块"
               错误: 找不到模块 "Module:卡牌/角色模块"
               错误: 找不到模块 "Module:卡牌/角色模块"
               错误: 找不到模块 "Module:卡牌/角色模块"
               错误: 找不到模块 "Module:卡牌/角色模块"
               错误: 找不到模块 "Module:卡牌/角色模块"
               错误: 找不到模块 "Module:卡牌/角色模块"
               错误: 找不到模块 "Module:卡牌/角色模块"
               错误: 找不到模块 "Module:卡牌/角色模块"

`;

}

// 生成装备选择界面 function generateEquipmentSelection(type) {

   return `

选择${type}

`;

}

// 添加选择事件 function addSelectionEvents(type) {

   const items = document.querySelectorAll('.selection-item');
   
   items.forEach(item => {
       item.addEventListener('click', function() {
           const name = this.getAttribute('data-name');
           const id = this.getAttribute('data-id');
           
           switch(type) {
               case 'character':
                   selectCharacter(name, id);
                   break;
               case 'partner':
                   selectPartner(name, id);
                   break;
               case 'card':
                   selectCard(name, this.getAttribute('data-card-type'));
                   break;
               case 'weapon':
                   selectWeapon(name, id);
                   break;
               case 'armor':
                   selectArmor(name, id);
                   break;
               case 'ring':
                   selectRing(name, id);
                   break;
           }
           
           closeSelectionModal();
       });
   });

}

// 选择角色 function selectCharacter(name, id) {

   currentSelection.character = name;
   const slot = document.getElementById('character-slot');
   slot.innerHTML = `[[File:战斗员图鉴_${name}.png|150px|link=]]`;
   slot.style.justifyContent = 'center';

}

// 选择伙伴 function selectPartner(name, id) {

   currentSelection.partner = name;
   const slot = document.getElementById('partner-slot');
   slot.innerHTML = `[[File:face_character_wide_${id}.png|150px|link=]]`;
   slot.style.justifyContent = 'center';

}

// 选择卡牌 function selectCard(name, cardType) {

   currentSelection.cards.push({name, type: cardType});
   updateDeckDisplay();

}

// 选择武器 function selectWeapon(name, id) {

   currentSelection.weapon = name;
   const slot = document.getElementById('weapon-slot');
   slot.innerHTML = generateEquipmentDisplay(name, id);
   slot.style.justifyContent = 'center';

}

// 选择装甲 function selectArmor(name, id) {

   currentSelection.armor = name;
   const slot = document.getElementById('armor-slot');
   slot.innerHTML = generateEquipmentDisplay(name, id);
   slot.style.justifyContent = 'center';

}

// 选择戒指 function selectRing(name, id) {

   currentSelection.ring = name;
   const slot = document.getElementById('ring-slot');
   slot.innerHTML = generateEquipmentDisplay(name, id);
   slot.style.justifyContent = 'center';

}

// 生成装备显示 function generateEquipmentDisplay(name, id) {

   return `
[[File:relic_${id.toString().padStart(4, '0')}.png|112px|center]]
${name}

`;

}

// 更新卡组显示 function updateDeckDisplay() {

   const deckArea = document.getElementById('deck-area');
   if (currentSelection.cards.length === 0) {

deckArea.innerHTML = '

+

';

       return;
   }
   

let cardsHTML = '

';
   currentSelection.cards.forEach(card => {
cardsHTML += `
           错误: 找不到模块 "Module:卡牌/角色模块"}
`;
   });
cardsHTML += '

';

   deckArea.innerHTML = cardsHTML;

}

// 初始化点击事件 document.addEventListener('DOMContentLoaded', function() {

   // 战斗员选择
   document.getElementById('character-slot').addEventListener('click', function() {
       openSelectionModal('character');
   });
   
   // 伙伴选择
   document.getElementById('partner-slot').addEventListener('click', function() {
       openSelectionModal('partner');
   });
   
   // 卡组选择
   document.getElementById('deck-area').addEventListener('click', function() {
       openSelectionModal('card');
   });
   
   // 装备选择
   document.getElementById('weapon-slot').addEventListener('click', function() {
       openSelectionModal('weapon');
   });
   
   document.getElementById('armor-slot').addEventListener('click', function() {
       openSelectionModal('armor');
   });
   
   document.getElementById('ring-slot').addEventListener('click', function() {
       openSelectionModal('ring');
   });

}); </script>

<style> .selection-slot {

   transition: all 0.3s ease;

}

.selection-slot:hover {

   border-color: #666;
   background: #f8f8f8;

}

.selection-item {

   cursor: pointer;
   transition: transform 0.2s ease;

}

.selection-item:hover {

   transform: scale(1.05);

}

.card-in-deck {

   cursor: pointer;

}

.card-in-deck:hover {

   opacity: 0.8;

} </style>