mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2025-07-13 15:52:44 +08:00
change talent replace before property allocate
This commit is contained in:
11
src/app.js
11
src/app.js
@ -120,9 +120,14 @@ class App{
|
||||
$ui.popup(UI.popups.ACHIEVEMENT, {achievement});
|
||||
})
|
||||
$$on('message', ([message, ...args]) => {
|
||||
$ui.popup(UI.popups.MESSAGE, {message: $_.format(
|
||||
$lang[message], ...args
|
||||
) });
|
||||
if(Array.isArray(message)) {
|
||||
message = message.map(([m, ...a]) => $_.format($lang[m], ...a)) .join('\n');
|
||||
} else {
|
||||
message = $_.format(
|
||||
$lang[message], ...args
|
||||
);
|
||||
}
|
||||
$ui.popup(UI.popups.MESSAGE, {message});
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -83,10 +83,17 @@ function deepMapSet(target, source) {
|
||||
return target;
|
||||
}
|
||||
|
||||
function deepGet(obj, path) {
|
||||
for(const key of path.split('.')) {
|
||||
if(!(key in obj)) return undefined;
|
||||
obj = obj[key];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function format(str, ...args) {
|
||||
const replace = set => (match, key) => {
|
||||
const value = set[key];
|
||||
const value = deepGet(set, key);
|
||||
switch(typeof value) {
|
||||
case 'object': return JSON.stringify(value);
|
||||
case 'boolean':
|
||||
|
@ -143,5 +143,6 @@ export default ({
|
||||
F_TalentConflict: '与已选的「{0}」天赋冲突',
|
||||
F_TalentSelectLimit: '只能选 {0} 个天赋',
|
||||
F_TalentSelectNotComplect: '要选满{0}个天赋',
|
||||
F_PropertyPointLeft: '你还有 {0} 属性点没有分配完'
|
||||
F_PropertyPointLeft: '你还有 {0} 属性点没有分配完',
|
||||
F_TalentReplace: '天赋替换【{source.name}】->【{target.name}】',
|
||||
});
|
@ -22,6 +22,7 @@ class Life {
|
||||
#propertyAllocateLimit;
|
||||
#defaultPropertys;
|
||||
#specialThanks;
|
||||
#initialData;
|
||||
|
||||
async initial(i18nLoad, commonLoad) {
|
||||
const [age, talents, events, achievements, specialThanks] = await Promise.all([
|
||||
@ -58,25 +59,28 @@ class Life {
|
||||
this.#property.config(propertyConfig);
|
||||
}
|
||||
|
||||
restart(allocation) {
|
||||
const propertys = clone(this.#defaultPropertys);
|
||||
for(const key in allocation) {
|
||||
propertys[key] = clone(allocation[key]);
|
||||
}
|
||||
remake(talents) {
|
||||
this.#initialData = clone(this.#defaultPropertys);
|
||||
this.#initialData.TLT = clone(talents);
|
||||
this.#triggerTalents = {};
|
||||
const contents = this.talentReplace(propertys.TLT);
|
||||
this.#property.restart(propertys);
|
||||
return this.talentReplace(this.#initialData.TLT);
|
||||
}
|
||||
|
||||
start(allocation) {
|
||||
for(const key in allocation) {
|
||||
this.#initialData[key] = clone(allocation[key]);
|
||||
}
|
||||
this.#property.restart(this.#initialData);
|
||||
this.doTalent()
|
||||
this.#property.restartLastStep();
|
||||
this.#achievement.achieve(
|
||||
this.AchievementOpportunity.START,
|
||||
this.#property
|
||||
)
|
||||
return contents;
|
||||
);
|
||||
}
|
||||
|
||||
getPropertyPoints(selectedTalentIds) {
|
||||
return this.#defaultPropertyPoints + this.#talent.allocationAddition(selectedTalentIds);
|
||||
getPropertyPoints() {
|
||||
return this.#defaultPropertyPoints + this.#talent.allocationAddition(this.#initialData.TLT);
|
||||
}
|
||||
|
||||
getTalentCurrentTriggerCount(talentId) {
|
||||
|
@ -41,9 +41,11 @@ export default class CyberProperty extends ui.view.CyberTheme.CyberPropertyUI {
|
||||
|
||||
init({talents}) {
|
||||
this.listSelectedTalents.array = talents;
|
||||
const talentIds = talents.map(talent => talent.id);
|
||||
// core.talentReplace(talentIds);
|
||||
this.#propertyPoints = core.getPropertyPoints(talentIds);
|
||||
const replace = core.remake(talents.map(talent => talent.id));
|
||||
if(replace.length > 0) {
|
||||
$$event('message', [replace.map(v => ['F_TalentReplace', v])]);
|
||||
}
|
||||
this.#propertyPoints = core.getPropertyPoints();
|
||||
this.#propertyAllocateLimit = core.propertyAllocateLimit;
|
||||
this.labLeftPropertyPoint.text = this.#propertyPoints;
|
||||
this.#propertyAllocate = {
|
||||
@ -51,7 +53,6 @@ export default class CyberProperty extends ui.view.CyberTheme.CyberPropertyUI {
|
||||
[this.#types.INT]: 0,
|
||||
[this.#types.STR]: 0,
|
||||
[this.#types.MNY]: 0,
|
||||
[this.#types.TLT]: talentIds,
|
||||
}
|
||||
this.updateAllocate();
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ export default class CyberTrajectory extends ui.view.CyberTheme.CyberTrajectoryU
|
||||
this.#trajectoryItems = [];
|
||||
this.#isEnd = false;
|
||||
this.#talents = talents;
|
||||
core.restart(propertyAllocate);
|
||||
core.start(propertyAllocate);
|
||||
this.updateProperty();
|
||||
this.onNext();
|
||||
}
|
||||
|
@ -41,9 +41,11 @@ export default class Property extends ui.view.DefaultTheme.PropertyUI {
|
||||
|
||||
init({talents}) {
|
||||
this.listSelectedTalents.array = talents;
|
||||
const talentIds = talents.map(talent => talent.id);
|
||||
// core.talentReplace(talentIds);
|
||||
this.#propertyPoints = core.getPropertyPoints(talentIds);
|
||||
const replace = core.remake(talents.map(talent => talent.id));
|
||||
if(replace.length > 0) {
|
||||
$$event('message', [replace.map(v => ['F_TalentReplace', v])]);
|
||||
}
|
||||
this.#propertyPoints = core.getPropertyPoints();
|
||||
this.#propertyAllocateLimit = core.propertyAllocateLimit;
|
||||
this.labLeftPropertyPoint.text = this.#propertyPoints;
|
||||
this.#propertyAllocate = {
|
||||
@ -51,7 +53,6 @@ export default class Property extends ui.view.DefaultTheme.PropertyUI {
|
||||
[this.#types.INT]: 0,
|
||||
[this.#types.STR]: 0,
|
||||
[this.#types.MNY]: 0,
|
||||
[this.#types.TLT]: talentIds,
|
||||
}
|
||||
this.updateAllocate();
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ export default class Trajectory extends ui.view.DefaultTheme.TrajectoryUI {
|
||||
this.#trajectoryItems = [];
|
||||
this.#isEnd = false;
|
||||
this.#talents = talents;
|
||||
core.restart(propertyAllocate);
|
||||
core.start(propertyAllocate);
|
||||
this.updateProperty();
|
||||
this.onNext();
|
||||
}
|
||||
|
@ -8,10 +8,12 @@ export default class MessagePopup extends ui.view.MessagePopupUI {
|
||||
}
|
||||
|
||||
async popup({message}, parent) {
|
||||
this.message.text = message;
|
||||
this.message.commitMeasure();
|
||||
this.height = this.message.height + this.boxBg.radius * 2 + this.message.fontSize;
|
||||
Laya.Tween.clearAll(this);
|
||||
this.alpha = 0;
|
||||
this.y = - 2 * this.height;
|
||||
this.message.text = message;
|
||||
await Laya.promises.Tween.to(this, { y: 0, alpha: 1 }, 300, Laya.Ease.backOut),
|
||||
await Laya.promises.Tween.to(this, { alpha: 0}, 300, Laya.Ease.strongIn, 3000);
|
||||
}
|
||||
|
Reference in New Issue
Block a user