update data add talent exclusive

This commit is contained in:
Vick Scarlet
2021-08-22 16:46:13 +08:00
parent 34cbefb31a
commit 7b14f93417
9 changed files with 2960 additions and 146 deletions

View File

@@ -89,6 +89,20 @@ class App{
this.hint('只能选3个天赋');
return;
}
const exclusive = this.#life.exclusive(
Array.from(this.#talentSelected).map(({id})=>id),
talent.id
);
if(exclusive != null) {
for(const { name, id } of this.#talentSelected) {
if(id == exclusive) {
this.hint(`与已选择的天赋【${name}】冲突`);
return;
}
}
return;
}
li.addClass('selected');
this.#talentSelected.add(talent);
}

View File

@@ -109,6 +109,10 @@ class Life {
getRecord() {
return this.#property.getRecord();
}
exclusive(talents, exclusive) {
return this.#talent.exclusive(talents, exclusive);
}
}
export default Life;

View File

@@ -31,6 +31,17 @@ class Talent {
return { grade, name, description };
}
exclusive(talends, exclusiveId) {
const { exclusive } = this.get(exclusiveId);
if(!exclusive) return null;
for(const talent of talends) {
for(const e of exclusive) {
if(talent == e) return talent;
}
}
return null;
}
talentRandom(include) {
// 1000, 100, 10, 1
const talentList = {};