diff --git a/character/diy.js b/character/diy.js index 0d906d141..e5baa65b7 100755 --- a/character/diy.js +++ b/character/diy.js @@ -4625,7 +4625,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ content(){ 'step 0' player.awakenSkill('yukito_yaxiang'); - player.reinit('key_yukito','key_crow'); + player.reinitCharacter('key_yukito', 'key_crow', false); 'step 1' if(target.hp<3) target.recover(3-target.hp); 'step 2' @@ -7815,9 +7815,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player.recover(num); player.draw(num); if(_status.characterlist&&_status.characterlist.includes('key_midori')){ - player.reinit('key_mio','key_midori',false); - _status.characterlist.remove('key_midori'); - _status.characterlist.add('key_mio'); + player.reinitCharacter('key_mio','key_midori', false); } }, }, @@ -7890,9 +7888,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player.recover(num); player.draw(num); if(_status.characterlist&&_status.characterlist.includes('key_mio')){ - player.reinit('key_midori','key_mio',false); - _status.characterlist.remove('key_mio'); - _status.characterlist.add('key_midori'); + player.reinitCharacter('key_midori', 'key_mio', false); } }, }, @@ -10754,7 +10750,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ content(){ 'step 0' player.awakenSkill('umi_qihuan'); - player.reinit('key_umi','key_umi2'); + player.reinitCharacter('key_umi', 'key_umi2', false); player.recover(game.countGroup()||1); if(!game.dead.length) event.finish(); 'step 1' diff --git a/noname/library/element/content.js b/noname/library/element/content.js index 1975c9900..bc3ca9291 100644 --- a/noname/library/element/content.js +++ b/noname/library/element/content.js @@ -14,24 +14,34 @@ export const Content = { //变更武将牌 async changeCharacter(event,trigger,player) { const rawPairs = [player.name1]; - if (player.name2) rawPairs.push(player.name2); + if (player.name2 && lib.character[player.name2]) rawPairs.push(player.name2); event.rawPairs = rawPairs; const newPairs = event.newPairs; + for(let name of newPairs){ + if(!lib.character[name]){ + console.warn(`警告:Player[${player.name}]试图将武将牌变更为不存在的武将“${name}”`); + return; + } + } 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]) + addSkills.addArray(lib.character[newName][3]); } } } + if(_status.characterlist){ + _status.characterlist.removeArray(newPairs); + _status.characterlist.addArray(rawPairs); + } //变更一下获得前后的技能 player.changeSkills(addSkills, removeSkills); }, @@ -54,8 +64,18 @@ export const Content = { event.$handle(player, event.addSkill, event.removeSkill, event); } else { - if(event.addSkill.length) player.addSkillLog(event.addSkill); - if(event.removeSkill.length) player.removeSkillLog(event.removeSkill); + if(event.addSkill.length){ + player.addSkill(event.addSkill); + game.log(player, '获得了技能', ...event.addSkill.map(i => { + return '#g【' + get.translation(i) + '】'; + })); + } + if(event.removeSkill.length){ + player.removeSkill(event.removeSkill); + game.log(player, '失去了技能', ...event.removeSkill.map(i => { + return '#g【' + get.translation(i) + '】'; + })); + } } //手动触发时机 await event.trigger('changeSkillsEnd'); diff --git a/noname/library/element/player.js b/noname/library/element/player.js index fb6fca479..9d0d13b48 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -1560,7 +1560,7 @@ export class Player extends HTMLDivElement { * @param { String } to * @returns { GameEventPromise } */ - reinitCharacter(from, to){ + reinitCharacter(from, to, log = true){ const rawPairs = [this.name1]; if (this.name2) rawPairs.push(this.name2); for (let i=0; i