先这样改改吧

This commit is contained in:
枫谷剑仙 2021-03-25 20:30:51 +08:00
parent d7ad433f20
commit 04fe16dfac
2 changed files with 103 additions and 110 deletions

View File

@ -9,9 +9,9 @@ const localTranslating = {
mass_attack: tp`${'icon'}所有攻击变为全体攻击`, mass_attack: tp`${'icon'}所有攻击变为全体攻击`,
leader_change: tp`${'icon'}将自身换为队长,再次使用则换回来`, leader_change: tp`${'icon'}将自身换为队长,再次使用则换回来`,
no_skyfall: tp`${'icon'}天降的宝珠不会消除`, no_skyfall: tp`${'icon'}天降的宝珠不会消除`,
heal: tp`${'icon'}回复 ${'value'}HP`, heal: tp`${'icon'}回复 ${'value'}${'stats'}`,
defense_break: tp`${'icon'}敌方的防御力减少 ${'value'}`, defense_break: tp`${'icon'}敌方的防御力减少 ${'value'}`,
poison: (valueElement)=> [`使敌方全体中毒,每回合损失`, valueElement, `的 HP`], poison: tp`${'icon'}使${'target'}全体中毒,每回合损失${'belong_to'} ${'value'}${'stats'}`,
time_extend: (valueElement)=> [`宝珠移动时间`, valueElement], time_extend: (valueElement)=> [`宝珠移动时间`, valueElement],
follow_attack: (valueElement)=> [`消除宝珠的回合,以`, valueElement, `的伤害追打敌人`], follow_attack: (valueElement)=> [`消除宝珠的回合,以`, valueElement, `的伤害追打敌人`],
auto_heal: (valueElement)=> [`消除宝珠的回合,回复`, valueElement, `的 HP`], auto_heal: (valueElement)=> [`消除宝珠的回合,回复`, valueElement, `的 HP`],
@ -22,14 +22,14 @@ const localTranslating = {
}, },
value: { value: {
unknown: tp`[ 未知数值: ${'type'}]`, //type unknown: tp`[ 未知数值: ${'type'}]`, //type
const: tp`${'value'}${'unit'}`, // (value, unit)=> `${value}${unit ? ` ${unit}` : ''}`, const: tp`${'value'}${'unit'}`,
mul_percent: tp`${'value'}%`, mul_percent: tp`${'value'}%`,
mul_times: tp`×${'value'}`, mul_times: tp`×${'value'}`,
mul_of_percent: tp`${'stats'}${'value'}%`, mul_of_percent: tp`${'stats'}${'value'}%`,
mul_of_times: tp`${'stats'}×${'value'}`, mul_of_times: tp`${'stats'}×${'value'}`,
}, },
target: { target: {
self: tp`自身`, self: tp`发动者自身`,
enemy: tp`敌人`, enemy: tp`敌人`,
}, },
stats: { stats: {

View File

@ -697,7 +697,7 @@ function renderSkills(skills)
} }
function renderSkill(skill, option = {}) function renderSkill(skill, option = {})
{ {
function appendToFragment(arg){ function atf(arg){
return _appendToFragment(fragment, arg); return _appendToFragment(fragment, arg);
} }
function createIcon(iconType, className){ function createIcon(iconType, className){
@ -709,16 +709,14 @@ function renderSkill(skill, option = {})
const fragment = document.createDocumentFragment(); const fragment = document.createDocumentFragment();
if (typeof localTranslating == "undefined") return fragment; if (typeof localTranslating == "undefined") return fragment;
const tsp = localTranslating.skill_parse; const tsp = localTranslating.skill_parse;
const tsps = localTranslating.skill_parse.skill;
const tspu = localTranslating.skill_parse.unit;
const tspt = localTranslating.skill_parse.stats;
let dict; let dict;
switch (skill.kind) { switch (skill.kind) {
case SkillKinds.Unknown: { case SkillKinds.Unknown: {
dict = { dict = {
type: skill.kind type: skill.kind
}; };
appendToFragment(tsps.unknown(dict)); atf(tsp.skill.unknown(dict));
break; break;
} }
case SkillKinds.ActiveTurns: { //有回合的行动 case SkillKinds.ActiveTurns: { //有回合的行动
@ -726,7 +724,7 @@ function renderSkill(skill, option = {})
turns: skill.turns, turns: skill.turns,
active: renderSkill(skill.skill, { forTurns: true }), active: renderSkill(skill.skill, { forTurns: true }),
}; };
appendToFragment(tsps.active_turns(dict)); atf(tsp.skill.active_turns(dict));
break; break;
} }
case SkillKinds.RandomSkills: { //随机技能 case SkillKinds.RandomSkills: { //随机技能
@ -739,35 +737,35 @@ function renderSkill(skill, option = {})
dict = { dict = {
"skill-list": ul, "skill-list": ul,
}; };
appendToFragment(tsps.random_skills(dict)); atf(tsp.skill.random_skills(dict));
break; break;
} }
case SkillKinds.Delay: { //威吓 case SkillKinds.Delay: { //威吓
dict = { dict = {
icon: createIcon("delay"), icon: createIcon("delay"),
}; };
appendToFragment(tsps.delay(dict)); atf(tsp.skill.delay(dict));
break; break;
} }
case SkillKinds.MassAttack: { //全体攻击 case SkillKinds.MassAttack: { //全体攻击
dict = { dict = {
icon: createIcon("mass-attack"), icon: createIcon("mass-attack"),
}; };
appendToFragment(tsps.mass_attack(dict)); atf(tsp.skill.mass_attack(dict));
break; break;
} }
case SkillKinds.LeaderChange: { //切换队长 case SkillKinds.LeaderChange: { //切换队长
dict = { dict = {
icon: createIcon("leader-change"), icon: createIcon("leader-change"),
}; };
appendToFragment(tsps.leader_change(dict)); atf(tsp.skill.leader_change(dict));
break; break;
} }
case SkillKinds.NoSkyfall: { //无天降 case SkillKinds.NoSkyfall: { //无天降
dict = { dict = {
icon: createIcon("no-skyfall"), icon: createIcon("no-skyfall"),
}; };
appendToFragment(tsps.no_skyfall(dict)); atf(tsp.skill.no_skyfall(dict));
break; break;
} }
case SkillKinds.Heal: { //回血主动 case SkillKinds.Heal: { //回血主动
@ -775,55 +773,61 @@ function renderSkill(skill, option = {})
dict = { dict = {
icon: option.forTurns ? createIcon("auto-heal") : createIcon("heal", "hp-incr"), icon: option.forTurns ? createIcon("auto-heal") : createIcon("heal", "hp-incr"),
value: renderValue(skill.value), value: renderValue(skill.value),
stats: tsp.stats.hp(),
}; };
appendToFragment(tsps.heal(dict)); atf(tsp.skill.heal(dict));
break; break;
} }
case SkillKinds.DefenseBreak: { //破防 case SkillKinds.DefenseBreak: { //破防
console.log(skill)
dict = { dict = {
icon: createIcon("defense-break"), icon: createIcon("defense-break"),
value: renderValue(skill.value), value: renderValue(skill.value, {percent: true}),
}; };
appendToFragment(tsps.defense_break(dict)); atf(tsp.skill.defense_break(dict));
break; break;
} }
case SkillKinds.Poison: { //毒 case SkillKinds.Poison: { //毒
appendToFragment(createIcon("poison")); dict = {
appendToFragment(tsps.poison(renderValue(skill.value))); icon: createIcon("poison"),
belong_to: tsp.target.self(),
target: tsp.target.enemy(),
stats: tsp.stats.hp(),
value: renderValue(skill.value),
};
atf(tsp.skill.poison(dict));
break; break;
} }
case SkillKinds.TimeExtend: { //时间变化buff case SkillKinds.TimeExtend: { //时间变化buff
appendToFragment(createIcon("status-time", SkillValue.isLess(skill.value) ? "time-decr" : "time-incr")); atf(createIcon("status-time", SkillValue.isLess(skill.value) ? "time-decr" : "time-incr"));
appendToFragment(tsps.time_extend(renderValue(skill.value, { unit: tspu.seconds, showsPlusSign:true, showPercent:true }))); atf(tsp.skill.time_extend(renderValue(skill.value, { unit: tsp.unit.seconds, plusSign:true, percent:true })));
break; break;
} }
case SkillKinds.FollowAttack: { //队长技追打 case SkillKinds.FollowAttack: { //队长技追打
appendToFragment(tsps.follow_attack(renderValue(skill.value))); atf(tsp.skill.follow_attack(renderValue(skill.value)));
break; break;
} }
case SkillKinds.AutoHeal: { //队长技自动回血 case SkillKinds.AutoHeal: { //队长技自动回血
appendToFragment(createIcon("auto-heal")); atf(createIcon("auto-heal"));
appendToFragment(tsps.auto_heal(renderValue(skill.value))); atf(tsp.skill.auto_heal(renderValue(skill.value)));
break; break;
} }
case SkillKinds.CTW: { //时间暂停 case SkillKinds.CTW: { //时间暂停
appendToFragment(createIcon("ctw")); atf(createIcon("ctw"));
appendToFragment(tsps.ctw(renderValue(skill.value, { unit: tspu.seconds }))); atf(tsp.skill.ctw(renderValue(skill.value, { unit: tsp.unit.seconds })));
break; break;
} }
case SkillKinds.Gravity: { //重力 case SkillKinds.Gravity: { //重力
console.log(skill.value) console.log(skill.value)
appendToFragment(tsps.gravity({ atf(tsp.skill.gravity({
icon: createIcon("gravity"), icon: createIcon("gravity"),
target: tsp.target.enemy(), target: tsp.target.enemy(),
value: renderValue(skill.value, { showPercent:true }), value: renderValue(skill.value, { percent:true }),
})); }));
break; break;
} }
case SkillKinds.Resolve: { //根性 case SkillKinds.Resolve: { //根性
appendToFragment(createIcon("resolve")); atf(createIcon("resolve"));
appendToFragment(tsps.resolve(renderStat('hp'), renderValue(skill.min, { showPercent:true }), skill.condition.probability)); atf(tsp.skill.resolve(renderStat('hp'), renderValue(skill.min, { percent:true }), skill.condition.probability));
break; break;
} }
/* /*
@ -1124,25 +1128,25 @@ function renderSkill(skill, option = {})
*/ */
default: { default: {
console.log("未处理的技能类型",skill.kind, skill); console.log("未处理的技能类型",skill.kind, skill);
appendToFragment(skill.kind); atf(skill.kind);
} }
} }
return fragment; return fragment;
}; };
function renderStat(stat) { function renderStat(stat) {
function appendToFragment(arg){ function atf(arg){
return _appendToFragment(fragment, arg); return _appendToFragment(fragment, arg);
} }
const fragment = document.createDocumentFragment(); const fragment = document.createDocumentFragment();
if (typeof localTranslating == "undefined") return fragment; if (typeof localTranslating == "undefined") return fragment;
const tspt = localTranslating.skill_parse.stats; const tspt = localTranslating.skill_parse.stats;
if (tspt[stat]) if (tspt[stat])
appendToFragment(tspt[stat]()); atf(tspt[stat]());
else else
{ {
console.log("未知状态类型",stat); console.log("未知状态类型",stat);
appendToFragment(tspt.unknown({ type: stat })); atf(tspt.unknown({ type: stat }));
} }
return fragment; return fragment;
} }
@ -1280,114 +1284,103 @@ function renderPowerUp(powerUp: SkillPowerUp) {
} }
*/ */
function renderValue(_value, option = {}) { function renderValue(_value, option = {}) {
function appendToFragment(arg){ function atf(arg){
return _appendToFragment(fragment, arg); return _appendToFragment(fragment, arg);
} }
const fragment = document.createDocumentFragment(); const fragment = document.createDocumentFragment();
if (typeof localTranslating == "undefined") return fragment; if (typeof localTranslating == "undefined") return fragment;
const tspv = localTranslating.skill_parse.value; const tspv = localTranslating.skill_parse.value;
const od = option.decimalDigits, os = option.showsPlusSign; const od = option.decimalDigits, os = option.plusSign;
let dict; let dict;
switch (_value.kind) { switch (_value.kind) {
case SkillValueKind.Percent: { case SkillValueKind.Percent: {
appendToFragment( dict = {
option.showPercent ? value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
tspv.mul_percent({value: (_value.value * 100).keepCounts(od,os)}) : };
tspv.mul_times({value: _value.value.keepCounts(od,os)}) atf(
option.percent ?
tspv.mul_percent(dict) :
tspv.mul_times(dict)
); );
break; break;
} }
case SkillValueKind.Constant: { case SkillValueKind.Constant: {
appendToFragment( dict = {
tspv.const({ value: _value.value.keepCounts(od,os),
value: _value.value.keepCounts(od,os), unit: option.unit ? option.unit() : undefined,
unit: option.unit ? option.unit() : undefined, };
}) atf(tspv.const(dict));
);
break; break;
} }
case SkillValueKind.xMaxHP: { case SkillValueKind.xMaxHP: {
console.log(renderStat('maxhp')) dict = {
appendToFragment( value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
option.showPercent ? stats: renderStat('maxhp'),
tspv.mul_of_percent({ };
value: (_value.value * 100).keepCounts(od,os), atf(
stats: renderStat('maxhp'), option.percent ?
}) : tspv.mul_of_percent(dict) :
tspv.mul_of_times({ tspv.mul_of_times(dict)
value: _value.value.keepCounts(od,os),
stats: renderStat('maxhp'),
})
); );
break; break;
} }
case SkillValueKind.xHP: { case SkillValueKind.xHP: {
appendToFragment( dict = {
option.showPercent ? value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
tspv.mul_of_percent({ stats: renderStat('hp'),
value: (_value.value * 100).keepCounts(od,os), };
stats: renderStat('hp'), atf(
}) : option.percent ?
tspv.mul_of_times({ tspv.mul_of_percent(dict) :
value: _value.value.keepCounts(od,os), tspv.mul_of_times(dict)
stats: renderStat('hp'),
})
); );
break; break;
} }
case SkillValueKind.xATK: { case SkillValueKind.xATK: {
appendToFragment( dict = {
option.showPercent ? value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
tspv.mul_of_percent({ stats: renderStat('atk'),
value: (_value.value * 100).keepCounts(od,os), };
stats: renderStat('atk'), atf(
}) : option.percent ?
tspv.mul_of_times({ tspv.mul_of_percent(dict) :
value: _value.value.keepCounts(od,os), tspv.mul_of_times(dict)
stats: renderStat('atk'),
})
); );
break; break;
} }
case SkillValueKind.xRCV: { case SkillValueKind.xRCV: {
appendToFragment( dict = {
option.showPercent ? value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
tspv.mul_of_percent({ stats: renderStat('rcv'),
value: (_value.value * 100).keepCounts(od,os), };
stats: renderStat('rcv'), atf(
}) : option.percent ?
tspv.mul_of_times({ tspv.mul_of_percent(dict) :
value: _value.value.keepCounts(od,os), tspv.mul_of_times(dict)
stats: renderStat('rcv'),
})
); );
break; break;
} }
case SkillValueKind.xTeamRCV: { case SkillValueKind.xTeamRCV: {
appendToFragment( dict = {
option.showPercent ? value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
tspv.mul_of_percent({ stats: renderStat('teamrcv'),
value: (_value.value * 100).keepCounts(od,os), };
stats: renderStat('teamrcv'), atf(
}) : option.percent ?
tspv.mul_of_times({ tspv.mul_of_percent(dict) :
value: _value.value.keepCounts(od,os), tspv.mul_of_times(dict)
stats: renderStat('teamrcv'),
})
); );
break; break;
} }
case SkillValueKind.xTeamATK: { case SkillValueKind.xTeamATK: {
appendToFragment( dict = {
option.showPercent ? value: option.percent ? (_value.value * 100).keepCounts(od,os) : _value.value.keepCounts(od,os),
tspv.mul_of_percent({ stats: renderStat('teamatk'),
value: (_value.value * 100).keepCounts(od,os), };
stats: renderStat('teamatk'), atf(
}) : option.percent ?
tspv.mul_of_times({ tspv.mul_of_percent(dict) :
value: _value.value.keepCounts(od,os), tspv.mul_of_times(dict)
stats: renderStat('teamatk'),
})
); );
break; break;
} }
@ -1445,7 +1438,7 @@ function renderValue(_value, option = {}) {
*/ */
default: { default: {
console.log("未知数值类型",_value.kind, _value); console.log("未知数值类型",_value.kind, _value);
appendToFragment(tspv.unknown({ type: _value.kind })); atf(tspv.unknown({ type: _value.kind }));
} }
} }
return fragment; return fragment;