diff --git a/character/collab.js b/character/collab.js index b1bc7f330..0d5ed1258 100644 --- a/character/collab.js +++ b/character/collab.js @@ -618,7 +618,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player.addMark('dcbianzhuang',1,false); if(player.countMark('dcbianzhuang')>2){ player.storage.dcbianzhuang_inited=true; - player.reinit('zhutiexiong','wu_zhutiexiong'); + player.reinitCharacter('zhutiexiong','wu_zhutiexiong'); } } }, diff --git a/noname/library/element/content.js b/noname/library/element/content.js index ec92e7798..1975c9900 100644 --- a/noname/library/element/content.js +++ b/noname/library/element/content.js @@ -11,25 +11,49 @@ export const Content = { emptyEvent: () => { event.trigger(event.name); }, + //变更武将牌 + async changeCharacter(event,trigger,player) { + const rawPairs = [player.name1]; + if (player.name2) rawPairs.push(player.name2); + event.rawPairs = rawPairs; + const newPairs = event.newPairs; + const removeSkills = [], addSkills = []; + //变更前后数量相同的情况 + if (rawPairs.length == newPairs.length){ + for (let i = 0; i{ + player.reinit(rawName, newName, null, true); + },player, rawName, newName); + removeSkills.addArray(lib.character[rawName][3]); + addSkills.addArray(lib.character[newName][3]) + } + } + } + //变更一下获得前后的技能 + player.changeSkills(addSkills, removeSkills); + }, //变更技能 async changeSkills (event,trigger,player) { //去重检查 event.addSkill.unique(); event.removeSkill.unique(); const duplicatedSkills = event.addSkill.filter(skill => event.removeSkill.includes(skill)); - if(duplicatedSkills.length){ + if (duplicatedSkills.length) { event.addSkill.removeArray(duplicatedSkills); event.removeSkill.removeArray(duplicatedSkills); } - if(!event.addSkill.length&&!event.removeSkill.length) return; + if (!event.addSkill.length&&!event.removeSkill.length) return; //手动触发时机 await event.trigger('changeSkillsBefore'); await event.trigger('changeSkillsBegin'); //处理失去和获得的技能 - if(event.$handle){ - event.$handle(player,event.addSkill,event.removeSkill,event); + if (event.$handle) { + event.$handle(player, event.addSkill, event.removeSkill, event); } - else{ + else { if(event.addSkill.length) player.addSkillLog(event.addSkill); if(event.removeSkill.length) player.removeSkillLog(event.removeSkill); } diff --git a/noname/library/element/player.js b/noname/library/element/player.js index 316d7152b..fb6fca479 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -1555,6 +1555,33 @@ export class Player extends HTMLDivElement { if (typeof savable == 'function') savable = savable(card, this, target); return savable; } + /** + * @param { String } from + * @param { String } to + * @returns { GameEventPromise } + */ + reinitCharacter(from, to){ + const rawPairs = [this.name1]; + if (this.name2) rawPairs.push(this.name2); + for (let i=0; i