修复removeAdditionalSkills运作不正常的bug

This commit is contained in:
Spmario233 2024-03-03 17:02:25 +08:00
parent 3a46dbde5b
commit a00ad6f772
3 changed files with 25 additions and 9 deletions

View File

@ -97,7 +97,7 @@ export const Content = {
event.addSkill.removeArray(duplicatedSkills); event.addSkill.removeArray(duplicatedSkills);
event.removeSkill.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('changeSkillsBefore');
await event.trigger('changeSkillsBegin'); await event.trigger('changeSkillsBegin');

View File

@ -310,7 +310,7 @@ export const Contents = {
event.addSkill.removeArray(duplicatedSkills); event.addSkill.removeArray(duplicatedSkills);
event.removeSkill.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('changeSkillsBefore');
}, },

View File

@ -7465,6 +7465,22 @@ export class Player extends HTMLDivElement {
_status.event.clearStepCache(); _status.event.clearStepCache();
return this; return this;
} }
$removeAdditionalSkills(skill, target){
const additionalSkills = this.additionalSkills[skill];
if (Array.isArray(additionalSkills)) {
if (typeof target === 'string') {
if (additionalSkills.includes(target)) {
additionalSkills.remove(target);
if (!additionalSkills.length) {
delete this.additionalSkills[skill];
}
}
}
else {
delete this.additionalSkills[skill];
}
}
}
getRemovableAdditionalSkills(skill, target){ getRemovableAdditionalSkills(skill, target){
const player = this, removableSkills = []; const player = this, removableSkills = [];
if (this.additionalSkills[skill]) { if (this.additionalSkills[skill]) {
@ -7493,22 +7509,22 @@ export class Player extends HTMLDivElement {
const player = this, skills = this.getRemovableAdditionalSkills(skill, target); const player = this, skills = this.getRemovableAdditionalSkills(skill, target);
if(skills.length){ if(skills.length){
player.removeSkill(skills); player.removeSkill(skills);
if (player.additionalSkills[skill]&&!player.additionalSkills[skill].length) delete player.additionalSkills[skill];
} }
player.$removeAdditionalSkills(skill, target);
_status.event.clearStepCache(); _status.event.clearStepCache();
return this; return this;
} }
removeAdditionalSkills(skill, target) { removeAdditionalSkills(skill, target) {
const player = this, skills = this.getRemovableAdditionalSkills(skill, target); const player = this, skills = this.getRemovableAdditionalSkills(skill, target);
if(skills.length){ return player.changeSkills([], skills).set('$handle', function(player, addSkills, removeSkills){
return player.changeSkills([], skills).set('$handle', function(player, addSkills, removeSkills){ if(removeSkills.length>0){
game.log(player, '失去了技能', ...removeSkills.map(i => { game.log(player, '失去了技能', ...removeSkills.map(i => {
return '#g【' + get.translation(i) + '】'; return '#g【' + get.translation(i) + '】';
})); }));
player.removeSkill(skills); player.removeSkill(removeSkills);
if (player.additionalSkills[skill]&&!player.additionalSkills[skill].length) delete player.additionalSkills[skill]; }
}); player.$removeAdditionalSkills(skill, target);
} });
} }
awakenSkill(skill, nounmark) { awakenSkill(skill, nounmark) {
if (!nounmark) this.unmarkSkill(skill); if (!nounmark) this.unmarkSkill(skill);