add talent life

This commit is contained in:
Vick Scarlet
2021-08-16 23:28:54 +08:00
parent dcc9cd2383
commit df85e62138
18 changed files with 5703 additions and 335 deletions

33
src/talent.js Normal file
View File

@@ -0,0 +1,33 @@
class Talent {
constructor(initialData={}) {
this.initial(initialData);
}
initial({talent}) {
this.#talent = talent;
}
check(talentId) {
const { condition } = this.get(talentId);
return checkCondition(condition);
}
get(talentId) {
const talent = this.#talent[talentId];
if(!talent) throw new Error(`[ERROR] No Talent[${talentId}]`);
return clone(talent);
}
description(talentId) {
return this.get(talentId).description;
}
do(talentId) {
const { effect, condition } = this.get(talentId);
if(condition && !checkCondition(condition))
return null;
return { effect };
}
}
export default Talent;