add: support template prop

This commit is contained in:
Vick Scarlet
2026-01-26 14:47:35 +08:00
parent 39388c6eaf
commit 9088ab0eb1
3 changed files with 20 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -174,7 +174,7 @@ class Life {
type: this.PropertyTypes.TLT, type: this.PropertyTypes.TLT,
name, name,
grade, grade,
description, description: this.format(description),
}) })
if(!effect) continue; if(!effect) continue;
this.#property.effect(effect); this.#property.effect(effect);
@@ -188,8 +188,8 @@ class Life {
this.#property.effect(effect); this.#property.effect(effect);
const content = { const content = {
type: this.PropertyTypes.EVT, type: this.PropertyTypes.EVT,
description, description: this.format(description),
postEvent, postEvent: postEvent && this.format(postEvent),
grade, grade,
} }
if(next) return [content, this.doEvent(next)].flat(); if(next) return [content, this.doEvent(next)].flat();
@@ -245,6 +245,23 @@ class Life {
return util.getListValuesMap(types.flat(), key => this.#property.get(key)); return util.getListValuesMap(types.flat(), key => this.#property.get(key));
} }
format(discription) {
return discription.replaceAll(/\{\s*[0-9a-zA-Z_-]+\s*?\}/g, (match) => this.#format(match));
}
#format(key) {
switch (key.slice(1, -1).trim().toLowerCase()) {
case 'currentyear': return new Date().getFullYear()
case 'age': return this.#property.get(this.PropertyTypes.AGE)
case 'charm': return this.#property.get(this.PropertyTypes.CHR)
case 'intelligence': return this.#property.get(this.PropertyTypes.INT)
case 'strength': return this.#property.get(this.PropertyTypes.STR)
case 'money': return this.#property.get(this.PropertyTypes.MNY)
case 'spirit': return this.#property.get(this.PropertyTypes.SPR)
default: return key
}
}
get lastExtendTalent() { get lastExtendTalent() {
return this.#property.get(this.PropertyTypes.EXT); return this.#property.get(this.PropertyTypes.EXT);
} }