This commit is contained in:
Vick Scarlet
2021-08-17 12:12:25 +08:00
parent df85e62138
commit 0865df55ee
9 changed files with 227 additions and 118 deletions

View File

@@ -1,10 +1,11 @@
import { clone } from './functions/util.js';
class Talent {
constructor(initialData={}) {
this.initial(initialData);
}
constructor() {}
initial({talent}) {
this.#talent = talent;
#talents;
initial({talents}) {
this.#talents = talents;
}
check(talentId) {
@@ -13,20 +14,22 @@ class Talent {
}
get(talentId) {
const talent = this.#talent[talentId];
const talent = this.#talents[talentId];
if(!talent) throw new Error(`[ERROR] No Talent[${talentId}]`);
return clone(talent);
}
description(talentId) {
return this.get(talentId).description;
information(talentId) {
const { rate, name, description } = this.get(talentId)
return { rate, name, description };
}
do(talentId) {
const { effect, condition } = this.get(talentId);
const { effect, condition, initiative, rate, name, description } = this.get(talentId);
if(!initiative) return null;
if(condition && !checkCondition(condition))
return null;
return { effect };
return { effect, rate, name, description };
}
}