mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-04-16 21:02:42 +08:00
Squashed commit of the following:
commit870d711162Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Jan 27 16:50:19 2022 +0800 update event commitb327eb1765Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Jan 27 16:36:02 2022 +0800 update event commit4e845bc2ebAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Jan 27 16:35:56 2022 +0800 fix ui feel commitbd508913c5Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Jan 27 16:35:22 2022 +0800 update special thanks commitd097b3bc15Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Jan 27 16:04:55 2022 +0800 add unique character commit8d71b73e94Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Jan 25 21:27:29 2022 +0800 fix: bug save load commit286828abe7Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Jan 25 18:15:22 2022 +0800 add game mode commit0e3c885ad3Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Jan 6 20:09:20 2022 +0800 update special thanks commitb421082374Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Fri Dec 31 20:26:20 2021 +0800 update specialthanks commit765a69294bAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Dec 14 19:10:03 2021 +0800 fix ios goto commit8eb8c3ca72Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Dec 14 19:03:37 2021 +0800 add event grade commitab705dd46cAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Dec 14 18:48:42 2021 +0800 build version commita1e4232369Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Dec 14 18:47:05 2021 +0800 change talent replace before property allocate commitf4d7b3ae3cAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Dec 14 18:06:18 2021 +0800 add event grade commit0567e40ddcAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 21:28:10 2021 +0800 add particle commitf17003925eAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 20:14:26 2021 +0800 change ui commitf8beda1d8fAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 19:08:30 2021 +0800 change popup message ui commit915a2aa17dAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 18:34:29 2021 +0800 new build commitb5edabc104Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 18:18:46 2021 +0800 add hint message commita143feadafAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 17:57:31 2021 +0800 fix copy bug commiteab1975791Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 17:56:28 2021 +0800 add save/load commitacf9b92134Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Dec 2 14:35:33 2021 +0800 add theme switch commit488a6054abAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Wed Dec 1 18:30:36 2021 +0800 fix uiManager bug commitf0317eaf14Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Wed Dec 1 16:07:03 2021 +0800 add message popup commiteb02d1ee6fAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 21:22:54 2021 +0800 change relocation commit60503eae47Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 19:27:16 2021 +0800 change ScaleButton -> Laya.runtime.ScaleButton commit52ef5909c1Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 19:26:31 2021 +0800 change ScaleButton -> Laya.runtime.ScaleButton commit0284f6aa71Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 19:05:24 2021 +0800 config webpack commit0e272ffd99Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 13:17:41 2021 +0800 add thanks commite1e2ab4701Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 28 11:40:21 2021 +0800 add light theme commit4f55c00f86Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sat Nov 27 22:27:39 2021 +0800 fix bug commit1d07bdfc46Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sat Nov 27 21:48:47 2021 +0800 daily update commit52d6a0ca8fAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Wed Nov 24 23:10:04 2021 +0800 daily update commitf8dd720d4dAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Wed Nov 24 19:08:13 2021 +0800 daily update commitd088c1a862Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 21 21:41:46 2021 +0800 remove useless commita711fcf3edAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Nov 16 00:53:05 2021 +0800 add achievement popup add page adaptive add talent extends commit05e02de3dbAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Sat Nov 13 01:24:04 2021 +0800 add github and discord commitbff0109cc5Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sat Nov 13 00:30:01 2021 +0800 add trajectory auto mode commit54c04f65c2Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Fri Nov 12 19:54:31 2021 +0800 fix property judge negative number bug commit660739530bAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Fri Nov 12 19:48:58 2021 +0800 update achievement commitc94e9e7433Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Thu Nov 11 21:37:45 2021 +0800 update daily commitc06cd9ea62Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Tue Nov 9 00:08:05 2021 +0800 update daily commit2666983f89Author: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 7 23:00:22 2021 +0800 add uiManager auto scan and load skin resource commit22fa5d755aAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Nov 7 22:17:04 2021 +0800 update framework commitf40698d63eAuthor: Vick Scarlet <scarlet_vick@outlook.com> Date: Sun Oct 31 00:13:22 2021 +0800 add laya
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import './ui/laya.patch.js';
|
||||
import './ui/runtime.js';
|
||||
import './ui/pluginFunction.js'
|
||||
import './ui/promisesLaya.js'
|
||||
@@ -159,11 +160,7 @@ class App{
|
||||
globalThis.$ui = UIManager.getInstance();
|
||||
|
||||
if(theme=='default') {
|
||||
if(!localStorage.getItem('__')) {
|
||||
localStorage.setItem('__', 1);
|
||||
localStorage.setItem('theme', 'cyber');
|
||||
}
|
||||
theme = localStorage.getItem('theme');
|
||||
theme = localStorage.getItem('theme') || 'default';
|
||||
}
|
||||
|
||||
$ui.theme = theme;
|
||||
|
||||
0
src/functions/unique.js
Normal file
0
src/functions/unique.js
Normal file
@@ -27,7 +27,7 @@ export default ({
|
||||
|
||||
UI_Title_Remake: 'Remake Simulate',
|
||||
UI_Title_Subsequent: 'The rubbish life doesn\'t want to stay for a second',
|
||||
UI_Remake: 'Remake Now',
|
||||
UI_Remake: '↻Remake Now',
|
||||
UI_Thanks: 'Thx',
|
||||
UI_Achievement: 'Achv',
|
||||
UI_Cyber_Theme_Art_Design: 'UI Design by 晰晰',
|
||||
@@ -125,17 +125,31 @@ export default ({
|
||||
UI_Write: 'Paste',
|
||||
|
||||
UI_CopySuccess: 'Copy to clipboard success',
|
||||
UI_CopyFaild: 'Copy to clipboard faild',
|
||||
UI_CopyFailed: 'Copy to clipboard Failed',
|
||||
|
||||
UI_PasteSuccessDecodeSuccess: 'Load Success!',
|
||||
UI_PasteSuccessDecodeFaild: 'Paste success, but load faild!',
|
||||
UI_PasteFaildDecodeSuccess: 'Paste faild, use input load success!',
|
||||
UI_PasteFaildDecodeFaild: 'Paste faild, use input load faild!',
|
||||
UI_PasteSuccessDecodeFailed: 'Paste success, but load Failed!',
|
||||
UI_PasteFailedDecodeSuccess: 'Paste Failed, use input load success!',
|
||||
UI_PasteFailedDecodeFailed: 'Paste Failed, use input load Failed!',
|
||||
|
||||
UI_LoadSuccess: 'Load Success!',
|
||||
UI_LoadFaild: 'Load Faild!',
|
||||
UI_LoadFailed: 'Load Failed!',
|
||||
|
||||
UI_Title_Celebrity: 'Past life was...',
|
||||
UI_CustomMode: 'Custom',
|
||||
UI_CustomModeDescription: '10 Talent\nCustom property',
|
||||
UI_CelebrityMode: 'Celebrity',
|
||||
UI_CelebrityModeDescription: 'Past life is celebrity\nRebirth to modern',
|
||||
UI_AllNot: '↻All Not',
|
||||
UI_UniqueWaTaShi: 'Unique of mine',
|
||||
UI_UniqueWaTaShiContent: '\nUnique character card different from other 60 million player\nAll property, All talent, All random\nAll has only one chance',
|
||||
UI_GenerateNow: 'Generate Now',
|
||||
|
||||
|
||||
M_NoRank: 'There is no rank',
|
||||
M_PleaseSelectOne: 'Please Select One',
|
||||
M_UnGenerate: 'Unique Character no generate',
|
||||
M_DisableExtendTalent: 'Celebrity mode can\'t extends talent',
|
||||
|
||||
F_RemakeTimes: 'Remake {0} Times',
|
||||
F_AchievementCount: 'Achievement {0}',
|
||||
@@ -145,4 +159,5 @@ export default ({
|
||||
F_TalentSelectNotComplect: 'Please select {0} talent',
|
||||
F_PropertyPointLeft: 'You have left {0} property point',
|
||||
F_TalentReplace: 'Talent replace [{source.name}] -> [{target.name}]',
|
||||
F_PropertyStr: 'CHR{CHR} INT{INT} STR{STR} MNY{MNY}'
|
||||
});
|
||||
@@ -15,6 +15,8 @@ export default ({
|
||||
UI_Loading: '加载中...',
|
||||
UI_Error: '错误',
|
||||
|
||||
UI_BackupBtn: '上面没有效果就试试这个吧',
|
||||
|
||||
UI_Colon: ':',
|
||||
UI_Times: '次',
|
||||
UI_Count: '个',
|
||||
@@ -27,7 +29,7 @@ export default ({
|
||||
|
||||
UI_Title_Remake: '人生重开模拟器',
|
||||
UI_Title_Subsequent: '这垃圾人生一秒也不想待了',
|
||||
UI_Remake: '立即重开',
|
||||
UI_Remake: '↻立即重开',
|
||||
UI_Thanks: '感谢',
|
||||
UI_Achievement: '成就',
|
||||
UI_Cyber_Theme_Art_Design: 'UI 设计 by 晰晰',
|
||||
@@ -125,17 +127,30 @@ export default ({
|
||||
UI_Write: '粘贴',
|
||||
|
||||
UI_LoadSuccess: '读档成功!',
|
||||
UI_LoadFaild: '读档失败!',
|
||||
UI_LoadFailed: '读档失败!',
|
||||
|
||||
UI_CopySuccess: '成功复制存档到剪贴板',
|
||||
UI_CopyFaild: '复制存档到剪贴板失败,请手动复制存档内容',
|
||||
UI_CopyFailed: '复制存档到剪贴板失败,请手动复制存档内容',
|
||||
|
||||
UI_PasteSuccessDecodeSuccess: '读档成功!',
|
||||
UI_PasteSuccessDecodeFaild: '粘贴剪贴板存档内容成功,但剪贴板内容读档失败',
|
||||
UI_PasteFaildDecodeSuccess: '粘贴剪贴板存档内容失败,使用输入的内容读档成功',
|
||||
UI_PasteFaildDecodeFaild: '粘贴剪贴板存档内容失败,使用输入的内容读档失败',
|
||||
UI_PasteSuccessDecodeFailed: '粘贴剪贴板存档内容成功,但剪贴板内容读档失败',
|
||||
UI_PasteFailedDecodeSuccess: '粘贴剪贴板存档内容失败,使用输入的内容读档成功',
|
||||
UI_PasteFailedDecodeFailed: '粘贴剪贴板存档内容失败,使用输入的内容读档失败',
|
||||
|
||||
UI_Title_Celebrity: '你的前世是...',
|
||||
UI_CustomMode: '经典模式',
|
||||
UI_CustomModeDescription: '10连抽天赋\n自由分配属性',
|
||||
UI_CelebrityMode: '名人模式',
|
||||
UI_CelebrityModeDescription: '前世是古代名人\n重开到了现代',
|
||||
UI_AllNot: '↻都不是',
|
||||
UI_UniqueWaTaShi: '独一无二的我',
|
||||
UI_UniqueWaTaShiContent: '\n6000万玩家中独一无二的角色卡\n所有属性 所有天赋 随机生成\n 每人只能生成一次',
|
||||
UI_GenerateNow: '立即生成',
|
||||
|
||||
M_NoRank: '别卷了,没有排行榜',
|
||||
M_PleaseSelectOne: '请选择一个名人',
|
||||
M_UnGenerate: '独一无二的我还没有生成',
|
||||
M_DisableExtendTalent: '名人模式不能继承天赋',
|
||||
|
||||
F_RemakeTimes: '已重开{0}次',
|
||||
F_AchievementCount: '成就达成{0}个',
|
||||
@@ -145,4 +160,5 @@ export default ({
|
||||
F_TalentSelectNotComplect: '要选满{0}个天赋',
|
||||
F_PropertyPointLeft: '你还有 {0} 属性点没有分配完',
|
||||
F_TalentReplace: '天赋替换【{source.name}】->【{target.name}】',
|
||||
F_PropertyStr: '颜值{CHR} 智力{INT} 体质{STR} 家境{MNY}'
|
||||
});
|
||||
24
src/index.js
24
src/index.js
@@ -196,5 +196,29 @@ core.config({
|
||||
],
|
||||
},
|
||||
},
|
||||
characterConfig: { // config for character
|
||||
characterPullCount: 3,
|
||||
rateableKnife: 10,
|
||||
propertyWeight: [
|
||||
[ 0, 1],
|
||||
[ 1, 2],
|
||||
[ 2, 3],
|
||||
[ 3, 4],
|
||||
[ 4, 5],
|
||||
[ 5, 6],
|
||||
[ 6, 5],
|
||||
[ 7, 4],
|
||||
[ 8, 3],
|
||||
[ 9, 2],
|
||||
[10, 1],
|
||||
],
|
||||
talentWeight: [
|
||||
[ 1, 1],
|
||||
[ 2, 2],
|
||||
[ 3, 3],
|
||||
[ 4, 2],
|
||||
[ 5, 1],
|
||||
],
|
||||
},
|
||||
});
|
||||
game.start(query);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { clone } from '../functions/util.js';
|
||||
import { checkCondition } from '../functions/condition.js';
|
||||
|
||||
class Achievement {
|
||||
constructor() {}
|
||||
constructor(system) {
|
||||
this.#system = system;
|
||||
}
|
||||
|
||||
// 时机
|
||||
Opportunity = {
|
||||
@@ -12,6 +11,7 @@ class Achievement {
|
||||
END: "END", // 游戏完成,点击重开 重开次数在这之后才会+1
|
||||
};
|
||||
|
||||
#system;
|
||||
#achievements;
|
||||
|
||||
initial({achievements}) {
|
||||
@@ -23,7 +23,11 @@ class Achievement {
|
||||
return Object.keys(this.#achievements).length;
|
||||
}
|
||||
|
||||
list(property) {
|
||||
get #prop() {
|
||||
return this.#system.request(this.#system.Module.PROPERTY);
|
||||
}
|
||||
|
||||
list() {
|
||||
return Object
|
||||
.values(this.#achievements)
|
||||
.map(({
|
||||
@@ -32,34 +36,34 @@ class Achievement {
|
||||
})=>({
|
||||
id, name, opportunity,
|
||||
description, hide, grade,
|
||||
isAchieved: this.isAchieved(id, property),
|
||||
isAchieved: this.isAchieved(id, this.#prop),
|
||||
}));
|
||||
}
|
||||
|
||||
get(achievementId) {
|
||||
const achievement = this.#achievements[achievementId];
|
||||
if(!achievement) throw new Error(`[ERROR] No Achievement[${achievementId}]`);
|
||||
return clone(achievement);
|
||||
return this.#system.clone(achievement);
|
||||
}
|
||||
|
||||
check(achievementId, property) {
|
||||
check(achievementId) {
|
||||
const { condition } = this.get(achievementId);
|
||||
return checkCondition(property, condition);
|
||||
return this.#system.check(condition);
|
||||
}
|
||||
|
||||
isAchieved(achievementId, property) {
|
||||
for(const [achieved] of (property.get(property.TYPES.ACHV)||[]))
|
||||
isAchieved(achievementId) {
|
||||
for(const [achieved] of (this.#prop.get(this.#prop.TYPES.ACHV)||[]))
|
||||
if(achieved == achievementId) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
achieve(opportunity, property) {
|
||||
this.list(property)
|
||||
achieve(opportunity) {
|
||||
this.list()
|
||||
.filter(({isAchieved})=>!isAchieved)
|
||||
.filter(({opportunity: o})=>o==opportunity)
|
||||
.filter(({id})=>this.check(id, property))
|
||||
.filter(({id})=>this.check(id, this.#prop))
|
||||
.forEach(({id})=>{
|
||||
property.achieve(property.TYPES.ACHV, id)
|
||||
this.#prop.achieve(this.#prop.TYPES.ACHV, id)
|
||||
$$event('achievement', this.get(id))
|
||||
});
|
||||
}
|
||||
|
||||
134
src/modules/character.js
Normal file
134
src/modules/character.js
Normal file
@@ -0,0 +1,134 @@
|
||||
class Character {
|
||||
constructor(system) {
|
||||
this.#system = system;
|
||||
}
|
||||
|
||||
#system;
|
||||
#characters;
|
||||
#characterPullCount;
|
||||
#rateableKnife;
|
||||
#rate;
|
||||
#pipe = [];
|
||||
#uniqueWaTaShi;
|
||||
#propertyWeight;
|
||||
#talentWeight
|
||||
|
||||
initial({characters}) {
|
||||
this.#characters = characters;
|
||||
const uniqueWaTaShi = localStorage.getItem('uniqueWaTaShi');
|
||||
if(uniqueWaTaShi != null || uniqueWaTaShi != 'undefined')
|
||||
this.#uniqueWaTaShi = JSON.parse(uniqueWaTaShi);
|
||||
return this.count;
|
||||
}
|
||||
|
||||
get count() {
|
||||
return Object.keys(this.#characters).length;
|
||||
}
|
||||
|
||||
config({
|
||||
characterPullCount = 3,
|
||||
rateableKnife = 10,
|
||||
propertyWeight,
|
||||
talentWeight,
|
||||
} = {}) {
|
||||
this.#characterPullCount = characterPullCount;
|
||||
this.#rateableKnife = rateableKnife;
|
||||
this.#propertyWeight = propertyWeight;
|
||||
this.#talentWeight = talentWeight;
|
||||
}
|
||||
|
||||
get #unique() {
|
||||
if(this.#uniqueWaTaShi) {
|
||||
return this.#system.clone(this.#uniqueWaTaShi);
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
this.#pipe.push(now);
|
||||
if(this.#pipe.length < 10) return null;
|
||||
const time = this.#pipe.shift();
|
||||
if(now - time > 10000) return null;
|
||||
return {unique: true, generate: false};
|
||||
}
|
||||
|
||||
set #unique(data) {
|
||||
this.#uniqueWaTaShi = this.#system.clone(data);
|
||||
this.#uniqueWaTaShi.unique = true;
|
||||
this.#uniqueWaTaShi.generate = true;
|
||||
localStorage.setItem(
|
||||
'uniqueWaTaShi',
|
||||
JSON.stringify(this.#uniqueWaTaShi)
|
||||
);
|
||||
}
|
||||
|
||||
get #weightRandom() {
|
||||
return this.#system.function(this.#system.Function.UTIL).weightRandom;
|
||||
}
|
||||
|
||||
generateUnique() {
|
||||
if(this.#uniqueWaTaShi) return this.#unique;
|
||||
const weightRandom = this.#weightRandom;
|
||||
const {CHR, INT, STR, MNY} = this.#system.PropertyTypes;
|
||||
|
||||
this.#unique = {
|
||||
property: {
|
||||
[CHR]: weightRandom(this.#propertyWeight),
|
||||
[INT]: weightRandom(this.#propertyWeight),
|
||||
[STR]: weightRandom(this.#propertyWeight),
|
||||
[MNY]: weightRandom(this.#propertyWeight),
|
||||
},
|
||||
talent: this.#system
|
||||
.request(this.#system.Module.TALENT)
|
||||
.random(weightRandom(this.#talentWeight)),
|
||||
}
|
||||
|
||||
return this.#unique;
|
||||
}
|
||||
|
||||
random() {
|
||||
return {
|
||||
unique: this.#unique,
|
||||
normal: this.#rateable(),
|
||||
}
|
||||
}
|
||||
|
||||
#rateable() {
|
||||
if(!this.#rate) {
|
||||
this.#rate = {};
|
||||
for(const id in this.#characters) {
|
||||
this.#rate[id] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
const r = [];
|
||||
const weightRandom = this.#weightRandom;
|
||||
new Array(this.#characterPullCount)
|
||||
.fill(0)
|
||||
.forEach(()=>{
|
||||
r.push(
|
||||
weightRandom(Object
|
||||
.keys(this.#rate)
|
||||
.filter(id=>!r.includes(id))
|
||||
.map(id=>([id,this.#rate[id]]))
|
||||
)
|
||||
)
|
||||
});
|
||||
|
||||
let min = Infinity;
|
||||
for(const id in this.#rate) {
|
||||
if(r.includes(id)) {
|
||||
min = Math.min(min, this.#rate[id]);
|
||||
continue;
|
||||
}
|
||||
min = Math.min(min, ++ this.#rate[id]);
|
||||
}
|
||||
if(min > this.#rateableKnife) {
|
||||
for(const id in this.#rate) {
|
||||
this.#rate[id] -= this.#rateableKnife;
|
||||
}
|
||||
}
|
||||
return r.map(id=>this.#system.clone(this.#characters[id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Character;
|
||||
@@ -1,9 +1,9 @@
|
||||
import { clone } from '../functions/util.js';
|
||||
import { checkCondition } from '../functions/condition.js';
|
||||
|
||||
class Event {
|
||||
constructor() {}
|
||||
constructor(system) {
|
||||
this.#system = system;
|
||||
}
|
||||
|
||||
#system;
|
||||
#events;
|
||||
|
||||
initial({events}) {
|
||||
@@ -24,18 +24,18 @@ class Event {
|
||||
return Object.keys(this.#events).length;
|
||||
}
|
||||
|
||||
check(eventId, property) {
|
||||
check(eventId) {
|
||||
const { include, exclude, NoRandom } = this.get(eventId);
|
||||
if(NoRandom) return false;
|
||||
if(exclude && checkCondition(property, exclude)) return false;
|
||||
if(include) return checkCondition(property, include);
|
||||
if(exclude && this.#system.check(exclude)) return false;
|
||||
if(include) return this.#system.check(include);
|
||||
return true;
|
||||
}
|
||||
|
||||
get(eventId) {
|
||||
const event = this.#events[eventId];
|
||||
if(!event) throw new Error(`[ERROR] No Event[${eventId}]`);
|
||||
return clone(event);
|
||||
return this.#system.clone(event);
|
||||
}
|
||||
|
||||
information(eventId) {
|
||||
@@ -43,11 +43,11 @@ class Event {
|
||||
return { description };
|
||||
}
|
||||
|
||||
do(eventId, property) {
|
||||
do(eventId) {
|
||||
const { effect, branch, event: description, postEvent, grade } = this.get(eventId);
|
||||
if(branch)
|
||||
for(const [cond, next] of branch)
|
||||
if(checkCondition(property, cond))
|
||||
if(this.#system.check(cond))
|
||||
return { effect, next, description, grade };
|
||||
return { effect, postEvent, description, grade };
|
||||
}
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
import { clone, weightRandom, getListValuesMap, getConvertedMap } from '../functions/util.js'
|
||||
import * as util from '../functions/util.js';
|
||||
import * as fCondition from '../functions/condition.js';
|
||||
|
||||
import Property from './property.js';
|
||||
import Event from './event.js';
|
||||
import Talent from './talent.js';
|
||||
import Achievement from './achievement.js';
|
||||
import Character from './character.js';
|
||||
|
||||
class Life {
|
||||
constructor() {
|
||||
this.#property = new Property();
|
||||
this.#event = new Event();
|
||||
this.#talent = new Talent();
|
||||
this.#achievement = new Achievement();
|
||||
this.#property = new Property(this);
|
||||
this.#event = new Event(this);
|
||||
this.#talent = new Talent(this);
|
||||
this.#achievement = new Achievement(this);
|
||||
this.#character = new Character(this);
|
||||
}
|
||||
|
||||
Module = {
|
||||
PROPERTY: 'PROPERTY',
|
||||
TALENT: 'TALENT',
|
||||
EVENT: 'EVENT',
|
||||
ACHIEVEMENT: 'ACHIEVEMENT',
|
||||
CHARACTER: 'CHARACTER',
|
||||
}
|
||||
|
||||
Function = {
|
||||
CONDITION: 'CONDITION',
|
||||
UTIL: 'UTIL',
|
||||
}
|
||||
|
||||
#property;
|
||||
#event;
|
||||
#talent;
|
||||
#achievement;
|
||||
#character;
|
||||
#triggerTalents;
|
||||
#defaultPropertyPoints;
|
||||
#talentSelectLimit;
|
||||
@@ -25,11 +43,12 @@ class Life {
|
||||
#initialData;
|
||||
|
||||
async initial(i18nLoad, commonLoad) {
|
||||
const [age, talents, events, achievements, specialThanks] = await Promise.all([
|
||||
const [age, talents, events, achievements, characters, specialThanks] = await Promise.all([
|
||||
i18nLoad('age'),
|
||||
i18nLoad('talents'),
|
||||
i18nLoad('events'),
|
||||
i18nLoad('achievement'),
|
||||
i18nLoad('character'),
|
||||
commonLoad('specialthanks'),
|
||||
]);
|
||||
this.#specialThanks = specialThanks;
|
||||
@@ -39,8 +58,8 @@ class Life {
|
||||
[this.PropertyTypes.TEVT]: this.#event.initial({events}),
|
||||
[this.PropertyTypes.TTLT]: this.#talent.initial({talents}),
|
||||
};
|
||||
|
||||
this.#property.initial({age, total});
|
||||
this.#character.initial({characters});
|
||||
}
|
||||
|
||||
config({
|
||||
@@ -50,6 +69,7 @@ class Life {
|
||||
defaultPropertys = {}, // default propertys
|
||||
talentConfig, // config for talent
|
||||
propertyConfig, // config for property
|
||||
characterConfig, // config for character
|
||||
} = {}) {
|
||||
this.#defaultPropertyPoints = defaultPropertyPoints;
|
||||
this.#talentSelectLimit = talentSelectLimit;
|
||||
@@ -57,26 +77,50 @@ class Life {
|
||||
this.#defaultPropertys = defaultPropertys;
|
||||
this.#talent.config(talentConfig);
|
||||
this.#property.config(propertyConfig);
|
||||
this.#character.config(characterConfig);
|
||||
}
|
||||
|
||||
request(module) {
|
||||
switch (module) {
|
||||
case this.Module.ACHIEVEMENT: return this.#achievement;
|
||||
case this.Module.CHARACTER: return this.#character;
|
||||
case this.Module.EVENT: return this.#event;
|
||||
case this.Module.PROPERTY: return this.#property;
|
||||
case this.Module.TALENT: return this.#talent;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
function(type) {
|
||||
switch (type) {
|
||||
case this.Function.CONDITION: return fCondition;
|
||||
case this.Function.UTIL: return util;
|
||||
}
|
||||
}
|
||||
|
||||
check(condition) {
|
||||
return fCondition.checkCondition(this.#property,condition);
|
||||
}
|
||||
|
||||
clone(...args) {
|
||||
return util.clone(...args);
|
||||
}
|
||||
|
||||
remake(talents) {
|
||||
this.#initialData = clone(this.#defaultPropertys);
|
||||
this.#initialData.TLT = clone(talents);
|
||||
this.#initialData = util.clone(this.#defaultPropertys);
|
||||
this.#initialData.TLT = util.clone(talents);
|
||||
this.#triggerTalents = {};
|
||||
return this.talentReplace(this.#initialData.TLT);
|
||||
}
|
||||
|
||||
start(allocation) {
|
||||
for(const key in allocation) {
|
||||
this.#initialData[key] = clone(allocation[key]);
|
||||
this.#initialData[key] = util.clone(allocation[key]);
|
||||
}
|
||||
this.#property.restart(this.#initialData);
|
||||
this.doTalent()
|
||||
this.#property.restartLastStep();
|
||||
this.#achievement.achieve(
|
||||
this.AchievementOpportunity.START,
|
||||
this.#property
|
||||
);
|
||||
this.#achievement.achieve(this.AchievementOpportunity.START);
|
||||
}
|
||||
|
||||
getPropertyPoints() {
|
||||
@@ -96,10 +140,7 @@ class Life {
|
||||
const isEnd = this.#property.isEnd();
|
||||
|
||||
const content = [talentContent, eventContent].flat();
|
||||
this.#achievement.achieve(
|
||||
this.AchievementOpportunity.TRAJECTORY,
|
||||
this.#property
|
||||
)
|
||||
this.#achievement.achieve(this.AchievementOpportunity.TRAJECTORY);
|
||||
return { age, content, isEnd };
|
||||
}
|
||||
|
||||
@@ -125,7 +166,7 @@ class Life {
|
||||
|
||||
const contents = [];
|
||||
for(const talentId of talents) {
|
||||
const result = this.#talent.do(talentId, this.#property);
|
||||
const result = this.#talent.do(talentId);
|
||||
if(!result) continue;
|
||||
this.#triggerTalents[talentId] = this.getTalentCurrentTriggerCount(talentId) + 1;
|
||||
const { effect, name, description, grade } = result;
|
||||
@@ -142,7 +183,7 @@ class Life {
|
||||
}
|
||||
|
||||
doEvent(eventId) {
|
||||
const { effect, next, description, postEvent, grade } = this.#event.do(eventId, this.#property);
|
||||
const { effect, next, description, postEvent, grade } = this.#event.do(eventId);
|
||||
this.#property.change(this.PropertyTypes.EVT, eventId);
|
||||
this.#property.effect(effect);
|
||||
const content = {
|
||||
@@ -156,7 +197,7 @@ class Life {
|
||||
}
|
||||
|
||||
random(events) {
|
||||
return weightRandom(
|
||||
return util.weightRandom(
|
||||
events.filter(
|
||||
([eventId])=>this.#event.check(eventId, this.#property)
|
||||
)
|
||||
@@ -173,20 +214,35 @@ class Life {
|
||||
);
|
||||
}
|
||||
|
||||
characterRandom() {
|
||||
const characters = this.#character.random();
|
||||
const replaceTalent = v=>v.talent=v.talent.map(
|
||||
id=>this.#talent.get(id)
|
||||
);
|
||||
characters.normal.forEach(replaceTalent);
|
||||
if(characters.unique && characters.unique.talent)
|
||||
replaceTalent(characters.unique);
|
||||
return characters;
|
||||
}
|
||||
|
||||
talentExtend(talentId) {
|
||||
this.#property.set(this.PropertyTypes.EXT, talentId);
|
||||
}
|
||||
|
||||
exclusive(talents, exclusive) {
|
||||
return this.#talent.exclusive(talents, exclusive);
|
||||
exclude(talents, exclusive) {
|
||||
return this.#talent.exclude(talents, exclusive);
|
||||
}
|
||||
|
||||
generateUnique() {
|
||||
this.#character.generateUnique();
|
||||
}
|
||||
|
||||
#getJudges(...types) {
|
||||
return getListValuesMap(types.flat(), key => this.#property.judge(key));
|
||||
return util.getListValuesMap(types.flat(), key => this.#property.judge(key));
|
||||
}
|
||||
|
||||
#getPropertys(...types) {
|
||||
return getListValuesMap(types.flat(), key => this.#property.get(key));
|
||||
return util.getListValuesMap(types.flat(), key => this.#property.get(key));
|
||||
}
|
||||
|
||||
get lastExtendTalent() {
|
||||
@@ -194,10 +250,7 @@ class Life {
|
||||
}
|
||||
|
||||
get summary() {
|
||||
this.#achievement.achieve(
|
||||
this.AchievementOpportunity.SUMMARY,
|
||||
this.#property
|
||||
)
|
||||
this.#achievement.achieve(this.AchievementOpportunity.SUMMARY);
|
||||
|
||||
const pt = this.PropertyTypes;
|
||||
|
||||
@@ -243,16 +296,13 @@ class Life {
|
||||
get PropertyTypes() { return this.#property.TYPES; }
|
||||
get AchievementOpportunity() { return this.#achievement.Opportunity; }
|
||||
get talentSelectLimit() { return this.#talentSelectLimit; }
|
||||
get propertyAllocateLimit() { return clone(this.#propertyAllocateLimit); }
|
||||
get propertyAllocateLimit() { return util.clone(this.#propertyAllocateLimit); }
|
||||
|
||||
get propertys() { return this.#property.getPropertys(); }
|
||||
get times() { return this.#property.get(this.PropertyTypes.TMS) || 0; }
|
||||
set times(v) {
|
||||
this.#property.set(this.PropertyTypes.TMS, v);
|
||||
this.#achievement.achieve(
|
||||
this.AchievementOpportunity.END,
|
||||
this.#property
|
||||
)
|
||||
this.#achievement.achieve(this.AchievementOpportunity.END);
|
||||
}
|
||||
get specialThanks() { return this.#specialThanks; }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { max, min, sum, clone, listRandom } from '../functions/util.js';
|
||||
|
||||
class Property {
|
||||
constructor() {}
|
||||
constructor(system) {
|
||||
this.#system = system;
|
||||
}
|
||||
|
||||
TYPES = {
|
||||
// 本局
|
||||
@@ -70,11 +70,16 @@ class Property {
|
||||
]
|
||||
}
|
||||
|
||||
#system;
|
||||
#ageData;
|
||||
#data = {};
|
||||
#total;
|
||||
#judge;
|
||||
|
||||
get #util() {
|
||||
return this.#system.function(this.#system.Function.UTIL);
|
||||
}
|
||||
|
||||
initial({age, total}) {
|
||||
this.#ageData = age;
|
||||
for(const a in age) {
|
||||
@@ -151,6 +156,7 @@ class Property {
|
||||
}
|
||||
|
||||
get(prop) {
|
||||
const util = this.#util;
|
||||
switch(prop) {
|
||||
case this.TYPES.AGE:
|
||||
case this.TYPES.CHR:
|
||||
@@ -161,14 +167,14 @@ class Property {
|
||||
case this.TYPES.LIF:
|
||||
case this.TYPES.TLT:
|
||||
case this.TYPES.EVT:
|
||||
return clone(this.#data[prop]);
|
||||
return util.clone(this.#data[prop]);
|
||||
case this.TYPES.LAGE:
|
||||
case this.TYPES.LCHR:
|
||||
case this.TYPES.LINT:
|
||||
case this.TYPES.LSTR:
|
||||
case this.TYPES.LMNY:
|
||||
case this.TYPES.LSPR:
|
||||
return min(
|
||||
return util.min(
|
||||
this.#data[prop],
|
||||
this.get(this.fallback(prop))
|
||||
);
|
||||
@@ -178,7 +184,7 @@ class Property {
|
||||
case this.TYPES.HSTR:
|
||||
case this.TYPES.HMNY:
|
||||
case this.TYPES.HSPR:
|
||||
return max(
|
||||
return util.max(
|
||||
this.#data[prop],
|
||||
this.get(this.fallback(prop))
|
||||
);
|
||||
@@ -189,7 +195,7 @@ class Property {
|
||||
const HSTR = this.get(this.TYPES.HSTR);
|
||||
const HMNY = this.get(this.TYPES.HMNY);
|
||||
const HSPR = this.get(this.TYPES.HSPR);
|
||||
return Math.floor(sum(HCHR, HINT, HSTR, HMNY, HSPR)*2 + HAGE/2);
|
||||
return Math.floor(util.sum(HCHR, HINT, HSTR, HMNY, HSPR)*2 + HAGE/2);
|
||||
case this.TYPES.TMS:
|
||||
return this.lsget('times') || 0;
|
||||
case this.TYPES.EXT:
|
||||
@@ -253,7 +259,7 @@ class Property {
|
||||
case this.TYPES.LIF:
|
||||
case this.TYPES.TLT:
|
||||
case this.TYPES.EVT:
|
||||
this.hl(prop, this.#data[prop] = clone(value));
|
||||
this.hl(prop, this.#data[prop] = this.#system.clone(value));
|
||||
this.achieve(prop, value);
|
||||
return;
|
||||
case this.TYPES.TMS:
|
||||
@@ -267,7 +273,7 @@ class Property {
|
||||
}
|
||||
|
||||
getPropertys() {
|
||||
return clone({
|
||||
return this.#system.clone({
|
||||
[this.TYPES.AGE]: this.get(this.TYPES.AGE),
|
||||
[this.TYPES.CHR]: this.get(this.TYPES.CHR),
|
||||
[this.TYPES.INT]: this.get(this.TYPES.INT),
|
||||
@@ -315,7 +321,8 @@ class Property {
|
||||
|
||||
hookSpecial(prop) {
|
||||
switch(prop) {
|
||||
case this.TYPES.RDM: return listRandom(this.SPECIAL.RDM);
|
||||
case this.TYPES.RDM:
|
||||
return this.#util.listRandom(this.SPECIAL.RDM);
|
||||
default: return prop;
|
||||
}
|
||||
}
|
||||
@@ -334,15 +341,6 @@ class Property {
|
||||
const d = this.#judge[prop];
|
||||
let length = d.length;
|
||||
|
||||
// progress judge
|
||||
// const p = 1/length;
|
||||
// const progress = () => {
|
||||
// const min = d[length][0] || 0;
|
||||
// const max = d[length+1]?.[0] || value;
|
||||
// if(max == min) return 1;
|
||||
// return p * (length + (value - min) / (max - min));
|
||||
// }
|
||||
|
||||
const progress = () => Math.max(Math.min(value, 10), 0) / 10;
|
||||
|
||||
while(length--) {
|
||||
@@ -363,7 +361,7 @@ class Property {
|
||||
}
|
||||
|
||||
getAgeData(age) {
|
||||
return clone(this.#ageData[age]);
|
||||
return this.#system.clone(this.#ageData[age]);
|
||||
}
|
||||
|
||||
hl(prop, value) {
|
||||
@@ -378,8 +376,8 @@ class Property {
|
||||
default: return;
|
||||
}
|
||||
const [l, h] = keys;
|
||||
this.#data[l] = min(this.#data[l], value);
|
||||
this.#data[h] = max(this.#data[h], value);
|
||||
this.#data[l] = this.#util.min(this.#data[l], value);
|
||||
this.#data[h] = this.#util.max(this.#data[h], value);
|
||||
}
|
||||
|
||||
achieve(prop, newData) {
|
||||
@@ -411,7 +409,7 @@ class Property {
|
||||
|
||||
lsget(key) {
|
||||
const data = localStorage.getItem(key);
|
||||
if(data === null) return;
|
||||
if(data === null || data === 'undefined') return;
|
||||
return JSON.parse(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { clone, weightRandom } from '../functions/util.js';
|
||||
import { checkCondition, extractMaxTriggers } from '../functions/condition.js';
|
||||
|
||||
class Talent {
|
||||
constructor() {}
|
||||
constructor(system) {
|
||||
this.#system = system;
|
||||
}
|
||||
|
||||
#system;
|
||||
#talents;
|
||||
#talentPullCount;
|
||||
#talentRate;
|
||||
@@ -11,11 +11,12 @@ class Talent {
|
||||
|
||||
initial({talents}) {
|
||||
this.#talents = talents;
|
||||
const emt = this.#system.function(this.#system.Function.CONDITION).extractMaxTriggers;
|
||||
for(const id in talents) {
|
||||
const talent = talents[id];
|
||||
talent.id= Number(id);
|
||||
talent.grade = Number(talent.grade);
|
||||
talent.max_triggers = extractMaxTriggers(talent.condition);
|
||||
talent.max_triggers = emt(talent.condition);
|
||||
if(talent.replacement) {
|
||||
for(let key in talent.replacement) {
|
||||
const obj = {};
|
||||
@@ -34,6 +35,10 @@ class Talent {
|
||||
return Object.keys(this.#talents).length;
|
||||
}
|
||||
|
||||
get #prop() {
|
||||
return this.#system.request(this.#system.Module.PROPERTY);
|
||||
}
|
||||
|
||||
config({
|
||||
talentPullCount = 10, // number of talents to pull from the talent pool
|
||||
talentRate = { 1:100, 2:10, 3:1, total: 1000 }, // rate of talent pull
|
||||
@@ -45,15 +50,15 @@ class Talent {
|
||||
}
|
||||
|
||||
|
||||
check(talentId, property) {
|
||||
check(talentId) {
|
||||
const { condition } = this.get(talentId);
|
||||
return checkCondition(property, condition);
|
||||
return this.#system.check(this.#prop, condition);
|
||||
}
|
||||
|
||||
get(talentId) {
|
||||
const talent = this.#talents[talentId];
|
||||
if(!talent) throw new Error(`[ERROR] No Talent[${talentId}]`);
|
||||
return clone(talent);
|
||||
return this.#system.clone(talent);
|
||||
}
|
||||
|
||||
information(talentId) {
|
||||
@@ -61,11 +66,11 @@ class Talent {
|
||||
return { grade, name, description };
|
||||
}
|
||||
|
||||
exclusive(talends, exclusiveId) {
|
||||
const { exclusive } = this.get(exclusiveId);
|
||||
if(!exclusive) return null;
|
||||
for(const talent of talends) {
|
||||
for(const e of exclusive) {
|
||||
exclude(talents, excludeId) {
|
||||
const { exclude } = this.get(excludeId);
|
||||
if(!exclude) return null;
|
||||
for(const talent of talents) {
|
||||
for(const e of exclude) {
|
||||
if(talent == e) return talent;
|
||||
}
|
||||
}
|
||||
@@ -81,7 +86,7 @@ class Talent {
|
||||
}
|
||||
|
||||
getRate(additionValues = {}) {
|
||||
const rate = clone(this.#talentRate);
|
||||
const rate = this.#system.clone(this.#talentRate);
|
||||
const addition = { 1:1, 2:1, 3:1, };
|
||||
|
||||
Object.keys(additionValues).forEach(key => {
|
||||
@@ -103,13 +108,14 @@ class Talent {
|
||||
let randomNumber = Math.floor(Math.random() * rate.total);
|
||||
if((randomNumber -= rate[3]) < 0) return 3;
|
||||
if((randomNumber -= rate[2]) < 0) return 2;
|
||||
if((randomNumber -= rate[1]) < 0) return 1;
|
||||
if((randomNumber - rate[1]) < 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const talentList = {};
|
||||
for(const talentId in this.#talents) {
|
||||
const { id, grade, name, description } = this.#talents[talentId];
|
||||
const { id, grade, name, description, exclusive } = this.#talents[talentId];
|
||||
if(!!exclusive) continue;
|
||||
if(id == include) {
|
||||
include = { grade, name, description, id };
|
||||
continue;
|
||||
@@ -130,6 +136,19 @@ class Talent {
|
||||
});
|
||||
}
|
||||
|
||||
random(count) {
|
||||
const talents = Object
|
||||
.keys(this.#talents)
|
||||
.filter(id=>!this.#talents[id].exclusive);
|
||||
return new Array(count)
|
||||
.fill(1)
|
||||
.map(()=>talents.splice(
|
||||
Math.floor(Math.random()*talents.length)%talents.length,
|
||||
1
|
||||
)[0]
|
||||
);
|
||||
}
|
||||
|
||||
allocationAddition(talents) {
|
||||
if(Array.isArray(talents)) {
|
||||
let addition = 0;
|
||||
@@ -140,9 +159,9 @@ class Talent {
|
||||
return Number(this.get(talents).status) || 0;
|
||||
}
|
||||
|
||||
do(talentId, property) {
|
||||
do(talentId) {
|
||||
const { effect, condition, grade, name, description } = this.get(talentId);
|
||||
if(condition && !checkCondition(property, condition))
|
||||
if(condition && !this.#system.check(condition))
|
||||
return null;
|
||||
return { effect, grade, name, description };
|
||||
}
|
||||
@@ -153,32 +172,34 @@ class Talent {
|
||||
if(!replacement) return null;
|
||||
const list = [];
|
||||
if(replacement.grade) {
|
||||
this.forEach(({id, grade})=>{
|
||||
this.forEach(({id, grade, exclusive})=>{
|
||||
if(exclusive) return;
|
||||
if(!replacement.grade[grade]) return;
|
||||
if(this.exclusive(talents, id)) return;
|
||||
if(this.exclude(talents, id)) return;
|
||||
list.push([id, replacement.grade[grade]]);
|
||||
})
|
||||
}
|
||||
if(replacement.talent) {
|
||||
for(let id in replacement.talent) {
|
||||
id = Number(id);
|
||||
if(this.exclusive(talents, id)) continue;
|
||||
if(this.exclude(talents, id)) continue;
|
||||
list.push([id, replacement.talent[id]]);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
const wr = this.#system.function(this.#system.Function.UTIL).weightRandom;
|
||||
const replace = (talent, talents) => {
|
||||
const replaceList = getReplaceList(talent, talents);
|
||||
if(!replaceList) return talent;
|
||||
const rand = weightRandom(replaceList);
|
||||
const rand = wr(replaceList);
|
||||
return replace(
|
||||
rand, talents.concat(rand)
|
||||
);
|
||||
}
|
||||
|
||||
const newTalents = clone(talents);
|
||||
const newTalents = this.#system.clone(talents);
|
||||
const result = {};
|
||||
for(const talent of talents) {
|
||||
const replaceId = replace(talent, newTalents);
|
||||
@@ -193,7 +214,7 @@ class Talent {
|
||||
forEach(callback) {
|
||||
if(typeof callback != 'function') return;
|
||||
for(const id in this.#talents)
|
||||
callback(clone(this.#talents[id]), id);
|
||||
callback(this.#system.clone(this.#talents[id]), id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
47
src/ui/laya.patch.js
Normal file
47
src/ui/laya.patch.js
Normal file
@@ -0,0 +1,47 @@
|
||||
// 滚动条太灵敏
|
||||
const SCROLL_START_DISTANCE = 30;
|
||||
Laya.ScrollBar.prototype.loop=function(){
|
||||
var mouseY=Laya.stage.mouseY;
|
||||
var mouseX=Laya.stage.mouseX;
|
||||
this._lastOffset=this.isVertical ? (mouseY-this._lastPoint.y):(mouseX-this._lastPoint.x);
|
||||
if (this._clickOnly){
|
||||
if (Math.abs(this._lastOffset *(this.isVertical ? Laya.stage._canvasTransform.getScaleY():Laya.stage._canvasTransform.getScaleX()))> SCROLL_START_DISTANCE){
|
||||
this._clickOnly=false;
|
||||
this._offsets || (this._offsets=[]);
|
||||
this._offsets.length=0;
|
||||
this._target.mouseEnabled=false;
|
||||
if (!this.hide && this.autoHide){
|
||||
this.alpha=1;
|
||||
this.visible=true;
|
||||
}
|
||||
this.event(/*laya.events.Event.START*/"start");
|
||||
}else return;
|
||||
}
|
||||
this._offsets.push(this._lastOffset);
|
||||
this._lastPoint.x=mouseX;
|
||||
this._lastPoint.y=mouseY;
|
||||
if (this._lastOffset===0)return;
|
||||
if (!this._checkElastic){
|
||||
if (this.elasticDistance > 0){
|
||||
if (!this._checkElastic && this._lastOffset !=0){
|
||||
if ((this._lastOffset > 0 && this._value <=this.min)|| (this._lastOffset < 0 && this._value >=this.max)){
|
||||
this._isElastic=true;
|
||||
this._checkElastic=true;
|
||||
}else {
|
||||
this._isElastic=false;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
this._checkElastic=true;
|
||||
}
|
||||
}
|
||||
if (this._isElastic){
|
||||
if (this._value <=this.min){
|
||||
this.value-=this._lastOffset *Math.max(0,(1-((this.min-this._value)/ this.elasticDistance)));
|
||||
}else if (this._value >=this.max){
|
||||
this.value-=this._lastOffset *Math.max(0,(1-((this._value-this.max)/ this.elasticDistance)));
|
||||
}
|
||||
}else {
|
||||
this.value-=this._lastOffset;
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -475,6 +475,12 @@ class ColorfulBox extends Laya.Box {
|
||||
label.text = value;
|
||||
}
|
||||
|
||||
get cacheAs() {return super.cacheAs;}
|
||||
set cacheAs(value) {
|
||||
if(value=='bitmap') debugger;
|
||||
super.cacheAs = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
runtime.BlankBox =
|
||||
@@ -534,4 +540,32 @@ class BlankBox extends Laya.Box {
|
||||
super.height = value;
|
||||
this.#draw();
|
||||
}
|
||||
}
|
||||
|
||||
runtime.ColorAgentLabel =
|
||||
class ColorAgentLabel extends Laya.Label {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
}
|
||||
|
||||
get #brothers() {
|
||||
const brothers = [];
|
||||
if(!this.parent) return brothers;
|
||||
const deepFind = p => {
|
||||
if(!p._childs) return;
|
||||
for(const c of p._childs) {
|
||||
if(c == this) continue;
|
||||
if(c instanceof Laya.Label) brothers.push(c);
|
||||
deepFind(c);
|
||||
}
|
||||
}
|
||||
deepFind(this.parent);
|
||||
return brothers;
|
||||
}
|
||||
|
||||
get color() {return this.super.color;}
|
||||
set color(c) {
|
||||
super.color = c;
|
||||
this.#brothers.forEach(b=>b.color=c);
|
||||
}
|
||||
}
|
||||
136
src/ui/themes/cyber/celebrity.js
Normal file
136
src/ui/themes/cyber/celebrity.js
Normal file
@@ -0,0 +1,136 @@
|
||||
export default class CyberCelebrity extends ui.view.CyberTheme.CelebrityUI {
|
||||
constructor() {
|
||||
super();
|
||||
this.btnRetry.on(Laya.Event.CLICK, this, ()=>this.random());
|
||||
this.btnNext.on(Laya.Event.CLICK, this, this.next);
|
||||
this.panelCharacter.vScrollBar.elasticDistance = 150;
|
||||
}
|
||||
|
||||
#selected;
|
||||
static #createComponent = Laya.plugin.extractComponents(CyberCelebrity.uiView, ['boxCharacter','boxTalent','boxUniqueUnGenerate']);
|
||||
#createCharacterItem(dataSource, click) {
|
||||
const {name, property, talent} = dataSource;
|
||||
const item = CyberCelebrity.#createComponent('boxCharacter');
|
||||
const vboxStates = item.getChildByName('vboxStates');
|
||||
const boxName = item.getChildByName('boxName');
|
||||
boxName.getChildByName('label').text = name;
|
||||
|
||||
const p = $_.clone(property);
|
||||
for(const k in p)
|
||||
if(Math.abs(p[k] - Math.PI) < 0.0000001)
|
||||
p[k] = 'π';
|
||||
|
||||
vboxStates.getChildByName('label').text = $_.format($lang.F_PropertyStr, p);
|
||||
for(const t of talent) {
|
||||
const i = CyberCelebrity.#createComponent('boxTalent');
|
||||
i.getChildByName('label').text = $_.format($lang.F_TalentSelection, t);
|
||||
i.y = vboxStates.height+vboxStates.space;
|
||||
let g = i.getChildByName(`grade${t.grade}`);
|
||||
if(g) g.visible = true;
|
||||
vboxStates.addChild(i);
|
||||
}
|
||||
const box = new Laya.Box();
|
||||
box.height = vboxStates.space;
|
||||
box.y = vboxStates.height;
|
||||
vboxStates.addChild(box);
|
||||
vboxStates.scaleY = 0;
|
||||
|
||||
item.dataSource = dataSource;
|
||||
item.switch = showDetails => vboxStates.scaleY = !!showDetails?1:0;
|
||||
item.click = (cb, caller) => {
|
||||
boxName.offAll(Laya.Event.CLICK);
|
||||
boxName.on(Laya.Event.CLICK, caller || this, cb);
|
||||
}
|
||||
if(click) item.click(click);
|
||||
return item;
|
||||
}
|
||||
#createUniqueUnGenerateItem(generate) {
|
||||
const item = CyberCelebrity.#createComponent('boxUniqueUnGenerate');
|
||||
const boxName = item.getChildByName('boxName');
|
||||
const vboxStates = item.getChildByName('vboxStates');
|
||||
const label = vboxStates.getChildByName('label');
|
||||
const boxBtn = vboxStates.getChildByName('boxBtn');
|
||||
const btn = boxBtn.getChildByName('btn');
|
||||
|
||||
label.event(Laya.Event.RESIZE);
|
||||
vboxStates.scaleY = 0;
|
||||
item.dataSource = false;
|
||||
item.switch = showDetails => vboxStates.scaleY = !!showDetails?1:0;
|
||||
item.click = (cb, caller) => {
|
||||
boxName.offAll(Laya.Event.CLICK);
|
||||
boxName.on(Laya.Event.CLICK, caller || this, cb);
|
||||
}
|
||||
item.generate = (cb, caller) => {
|
||||
btn.offAll(Laya.Event.CLICK);
|
||||
btn.on(Laya.Event.CLICK, caller || this, cb);
|
||||
}
|
||||
if(generate) item.generate(generate);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
init() {
|
||||
this.random();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.#selected = null;
|
||||
this.vboxCharacter.destroyChildren(true);
|
||||
}
|
||||
|
||||
random(g) {
|
||||
this.#selected = null;
|
||||
this.vboxCharacter.destroyChildren(true);
|
||||
const {unique, normal} = core.characterRandom();
|
||||
const items = [];
|
||||
const uniqueItem = this.generateUnique(unique, ()=>{
|
||||
core.generateUnique();
|
||||
this.random(normal);
|
||||
|
||||
});
|
||||
if(uniqueItem) items.push(uniqueItem);
|
||||
(g||normal).forEach(character => items.push(this.#createCharacterItem(character)));
|
||||
|
||||
items.forEach((item, i) => {
|
||||
item.y = i;
|
||||
this.vboxCharacter.addChild(item);
|
||||
item.click(()=>{
|
||||
if(this.#selected) this.#selected.switch(false);
|
||||
this.#selected = item;
|
||||
item.switch(true);
|
||||
item.event(Laya.Event.RESIZE);
|
||||
})
|
||||
});
|
||||
if(g&&uniqueItem) {
|
||||
this.#selected = uniqueItem;
|
||||
uniqueItem.switch(true);
|
||||
uniqueItem.event(Laya.Event.RESIZE);
|
||||
}
|
||||
}
|
||||
|
||||
generateUnique(data, generate) {
|
||||
if(!data) return null;
|
||||
if(!data.generate) return this.#createUniqueUnGenerateItem(generate);
|
||||
data.name = $lang.UI_UniqueWaTaShi;
|
||||
return this.#createCharacterItem(data);
|
||||
}
|
||||
|
||||
next() {
|
||||
if(!this.#selected) return $$event('message', ['M_PleaseSelectOne']);
|
||||
if(!this.#selected.dataSource) return $$event('message', ['M_UnGenerate']);
|
||||
|
||||
const {property: propertyAllocate, talent: talents} = this.#selected.dataSource;
|
||||
const replace = core.remake(talents.map(talent => talent.id));
|
||||
if(replace.length > 0) {
|
||||
$$event('message', [replace.map(v => ['F_TalentReplace', v])]);
|
||||
}
|
||||
$ui.switchView(
|
||||
UI.pages.TRAJECTORY,
|
||||
{
|
||||
propertyAllocate, talents,
|
||||
enableExtend: false,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
export default class CyberMain extends ui.view.CyberTheme.CyberMainUI {
|
||||
constructor() {
|
||||
super();
|
||||
this.btnRemake.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.TALENT));
|
||||
this.btnRemake.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.MODE));
|
||||
this.btnAchievement.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.ACHIEVEMENT));
|
||||
this.btnThanks.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.THANKS));
|
||||
this.btnGithub.on(Laya.Event.CLICK, this, goto, ['github']);
|
||||
|
||||
7
src/ui/themes/cyber/mode.js
Normal file
7
src/ui/themes/cyber/mode.js
Normal file
@@ -0,0 +1,7 @@
|
||||
export default class CyberMode extends ui.view.CyberTheme.ModeUI {
|
||||
constructor() {
|
||||
super();
|
||||
this.btnCustom.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.TALENT));
|
||||
this.btnCelebrity.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.CELEBRITY));
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@ export default class CyberProperty extends ui.view.CyberTheme.CyberPropertyUI {
|
||||
{
|
||||
propertyAllocate: this.#propertyAllocate,
|
||||
talents: this.listSelectedTalents.array,
|
||||
enableExtend: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ export default class CyberSummary extends ui.view.CyberTheme.CyberSummaryUI {
|
||||
}
|
||||
|
||||
#selectedTalent;
|
||||
#enableExtend;
|
||||
|
||||
onAgain() {
|
||||
core.talentExtend(this.#selectedTalent);
|
||||
@@ -13,8 +14,10 @@ export default class CyberSummary extends ui.view.CyberTheme.CyberSummaryUI {
|
||||
$ui.switchView(UI.pages.MAIN);
|
||||
}
|
||||
|
||||
init({talents}) {
|
||||
init({talents, enableExtend}) {
|
||||
const {summary, lastExtendTalent} = core;
|
||||
this.#enableExtend = enableExtend;
|
||||
|
||||
const gradeFilters = $ui.common.filter;
|
||||
const gradeColors = $ui.common.grade;
|
||||
|
||||
@@ -68,7 +71,11 @@ export default class CyberSummary extends ui.view.CyberTheme.CyberSummaryUI {
|
||||
if(b == lastExtendTalent) return 1;
|
||||
return bg - ag;
|
||||
});
|
||||
this.#selectedTalent = talents[0].id;
|
||||
if(this.#enableExtend) {
|
||||
this.#selectedTalent = talents[0].id;
|
||||
} else {
|
||||
this.#selectedTalent = lastExtendTalent;
|
||||
}
|
||||
this.listSelectedTalents.array = talents;
|
||||
}
|
||||
|
||||
@@ -115,6 +122,9 @@ export default class CyberSummary extends ui.view.CyberTheme.CyberSummaryUI {
|
||||
}
|
||||
|
||||
onSelectTalent(talentId) {
|
||||
if(!this.#enableExtend) {
|
||||
return $$event('message', ['M_DisableExtendTalent']);
|
||||
}
|
||||
if(talentId == this.#selectedTalent) {
|
||||
this.#selectedTalent = null;
|
||||
} else {
|
||||
|
||||
@@ -40,7 +40,7 @@ export default class CyberTalent extends ui.view.CyberTheme.CyberTalentUI {
|
||||
}
|
||||
|
||||
const talents = [...this.#selected].map(index => this.listTalents.array[index]);
|
||||
$ui.switchView(UI.pages.PROPERTY, { talents });
|
||||
$ui.switchView(UI.pages.PROPERTY, { talents, enableExtend: true});
|
||||
}
|
||||
|
||||
renderTalent(box, index) {
|
||||
@@ -99,7 +99,7 @@ export default class CyberTalent extends ui.view.CyberTheme.CyberTalentUI {
|
||||
if(this.#selected.size >= core.talentSelectLimit) {
|
||||
return $$event('message', ['F_TalentSelectLimit', core.talentSelectLimit]);
|
||||
}
|
||||
const exclusive = core.exclusive(
|
||||
const exclusive = core.exclude(
|
||||
[...this.#selected].map(index => this.listTalents.array[index].id),
|
||||
this.listTalents.array[index].id
|
||||
);
|
||||
|
||||
@@ -66,8 +66,10 @@ export default class CyberTrajectory extends ui.view.CyberTheme.CyberTrajectoryU
|
||||
#isEnd;
|
||||
#trajectoryItems;
|
||||
#talents;
|
||||
#enableExtend;
|
||||
|
||||
init({propertyAllocate, talents}) {
|
||||
init({propertyAllocate, talents, enableExtend}) {
|
||||
this.#enableExtend = enableExtend;
|
||||
this.boxParticle.visible = false;
|
||||
this.boxSpeed.visible = true;
|
||||
this.btnSummary.visible = false;
|
||||
@@ -109,16 +111,16 @@ export default class CyberTrajectory extends ui.view.CyberTheme.CyberTrajectoryU
|
||||
if(isEnd) {
|
||||
this.boxSpeed.visible = false;
|
||||
this.btnSummary.visible = true;
|
||||
Laya.timer.frameOnce(1,this,()=>{
|
||||
this.panelTrajectory.scrollTo(0, this.panelTrajectory.contentHeight);
|
||||
});
|
||||
}
|
||||
|
||||
this.panelTrajectory.scrollTo(0, this.panelTrajectory.contentHeight);
|
||||
this.renderTrajectory(age, content);
|
||||
|
||||
if(age >= 100) {
|
||||
this.boxParticle.visible = true;
|
||||
}
|
||||
Laya.timer.frameOnce(1, this, () => {
|
||||
this.panelTrajectory.scrollTo(0, this.panelTrajectory.contentHeight);
|
||||
});
|
||||
this.updateProperty();
|
||||
}
|
||||
|
||||
@@ -141,12 +143,12 @@ export default class CyberTrajectory extends ui.view.CyberTheme.CyberTrajectoryU
|
||||
);
|
||||
this.vboxTrajectory.addChild(item);
|
||||
this.#trajectoryItems.push(item);
|
||||
this.#trajectoryItems.forEach((item, index) => item.y = index);
|
||||
item.y = this.vboxTrajectory.height;
|
||||
}
|
||||
|
||||
onSummary() {
|
||||
const talents = this.#talents;
|
||||
$ui.switchView(UI.pages.SUMMARY, {talents});
|
||||
$ui.switchView(UI.pages.SUMMARY, { talents, enableExtend: this.#enableExtend });
|
||||
}
|
||||
|
||||
get speed() {
|
||||
|
||||
143
src/ui/themes/default/celebrity.js
Normal file
143
src/ui/themes/default/celebrity.js
Normal file
@@ -0,0 +1,143 @@
|
||||
export default class Celebrity extends ui.view.DefaultTheme.CelebrityUI {
|
||||
constructor() {
|
||||
super();
|
||||
this.btnRetry.on(Laya.Event.CLICK, this, ()=>this.random());
|
||||
this.btnNext.on(Laya.Event.CLICK, this, this.next);
|
||||
this.panelCharacter.vScrollBar.elasticDistance = 150;
|
||||
}
|
||||
|
||||
#selected;
|
||||
static #createComponent = Laya.plugin.extractComponents(Celebrity.uiView, ['boxCharacter','boxTalent','boxUniqueUnGenerate']);
|
||||
#createCharacterItem(dataSource, click) {
|
||||
const {name, property, talent} = dataSource;
|
||||
const style = $ui.common.characterItem;
|
||||
const item = Celebrity.#createComponent('boxCharacter');
|
||||
const vboxStates = item.getChildByName('vboxStates');
|
||||
const boxName = item.getChildByName('boxName');
|
||||
boxName.label = name;
|
||||
|
||||
const p = $_.clone(property);
|
||||
for(const k in p)
|
||||
if(Math.abs(p[k] - Math.PI) < 0.0000001)
|
||||
p[k] = 'π';
|
||||
|
||||
vboxStates.label = $_.format($lang.F_PropertyStr, p);
|
||||
$_.deepMapSet(boxName, style.name);
|
||||
$_.deepMapSet(vboxStates, style.state);
|
||||
for(const t of talent) {
|
||||
const i = Celebrity.#createComponent('boxTalent');
|
||||
i.label = $_.format($lang.F_TalentSelection, t);
|
||||
i.y = vboxStates.height+vboxStates.space;
|
||||
$_.deepMapSet(i, $ui.common.card[t.grade].normal);
|
||||
vboxStates.addChild(i);
|
||||
}
|
||||
const box = new Laya.Box();
|
||||
box.height = vboxStates.space;
|
||||
box.y = vboxStates.height;
|
||||
vboxStates.addChild(box);
|
||||
vboxStates.scaleY = 0;
|
||||
|
||||
item.dataSource = dataSource;
|
||||
item.switch = showDetails => vboxStates.scaleY = !!showDetails?1:0;
|
||||
item.click = (cb, caller) => {
|
||||
boxName.offAll(Laya.Event.CLICK);
|
||||
boxName.on(Laya.Event.CLICK, caller || this, cb);
|
||||
}
|
||||
if(click) item.click(click);
|
||||
return item;
|
||||
}
|
||||
#createUniqueUnGenerateItem(generate) {
|
||||
const style = $ui.common.characterItem;
|
||||
const item = Celebrity.#createComponent('boxUniqueUnGenerate');
|
||||
const boxName = item.getChildByName('boxName');
|
||||
const vboxStates = item.getChildByName('vboxStates');
|
||||
const label = vboxStates.getChildByName('label');
|
||||
const boxBtn = vboxStates.getChildByName('boxBtn');
|
||||
const btn = boxBtn.getChildByName('btn');
|
||||
|
||||
$_.deepMapSet(boxName, style.name);
|
||||
$_.deepMapSet(vboxStates, style.state);
|
||||
$_.deepMapSet(btn, style.name);
|
||||
|
||||
boxBtn.y = label.height + vboxStates.space;
|
||||
label.event(Laya.Event.RESIZE);
|
||||
vboxStates.scaleY = 0;
|
||||
item.dataSource = false;
|
||||
item.switch = showDetails => vboxStates.scaleY = !!showDetails?1:0;
|
||||
item.click = (cb, caller) => {
|
||||
boxName.offAll(Laya.Event.CLICK);
|
||||
boxName.on(Laya.Event.CLICK, caller || this, cb);
|
||||
}
|
||||
item.generate = (cb, caller) => {
|
||||
btn.offAll(Laya.Event.CLICK);
|
||||
btn.on(Laya.Event.CLICK, caller || this, cb);
|
||||
}
|
||||
if(generate) item.generate(generate);
|
||||
return item;
|
||||
}
|
||||
|
||||
init() {
|
||||
this.random();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.#selected = null;
|
||||
this.vboxCharacter.destroyChildren(true);
|
||||
}
|
||||
|
||||
random(g) {
|
||||
this.#selected = null;
|
||||
this.vboxCharacter.destroyChildren(true);
|
||||
const {unique, normal} = core.characterRandom();
|
||||
const items = [];
|
||||
const uniqueItem = this.generateUnique(unique, ()=>{
|
||||
core.generateUnique();
|
||||
this.random(normal);
|
||||
|
||||
});
|
||||
if(uniqueItem) items.push(uniqueItem);
|
||||
(g||normal).forEach(character => items.push(this.#createCharacterItem(character)));
|
||||
|
||||
items.forEach((item, i) => {
|
||||
item.y = i;
|
||||
this.vboxCharacter.addChild(item);
|
||||
item.click(()=>{
|
||||
if(this.#selected) this.#selected.switch(false);
|
||||
this.#selected = item;
|
||||
item.switch(true);
|
||||
item.event(Laya.Event.RESIZE);
|
||||
})
|
||||
});
|
||||
if(g&&uniqueItem) {
|
||||
this.#selected = uniqueItem;
|
||||
uniqueItem.switch(true);
|
||||
uniqueItem.event(Laya.Event.RESIZE);
|
||||
}
|
||||
}
|
||||
|
||||
generateUnique(data, generate) {
|
||||
if(!data) return null;
|
||||
if(!data.generate) return this.#createUniqueUnGenerateItem(generate);
|
||||
data.name = $lang.UI_UniqueWaTaShi;
|
||||
return this.#createCharacterItem(data);
|
||||
}
|
||||
|
||||
next() {
|
||||
if(!this.#selected) return $$event('message', ['M_PleaseSelectOne']);
|
||||
if(!this.#selected.dataSource) return $$event('message', ['M_UnGenerate']);
|
||||
|
||||
const {property: propertyAllocate, talent: talents} = this.#selected.dataSource;
|
||||
const replace = core.remake(talents.map(talent => talent.id));
|
||||
if(replace.length > 0) {
|
||||
$$event('message', [replace.map(v => ['F_TalentReplace', v])]);
|
||||
}
|
||||
$ui.switchView(
|
||||
UI.pages.TRAJECTORY,
|
||||
{
|
||||
propertyAllocate, talents,
|
||||
enableExtend: false,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
export default class Main extends ui.view.DefaultTheme.MainUI {
|
||||
constructor() {
|
||||
super();
|
||||
this.btnRemake.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.TALENT));
|
||||
this.btnRemake.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.MODE));
|
||||
this.btnAchievement.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.ACHIEVEMENT));
|
||||
this.btnThanks.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.THANKS));
|
||||
this.btnGithub.on(Laya.Event.CLICK, this, goto, ['github']);
|
||||
|
||||
7
src/ui/themes/default/mode.js
Normal file
7
src/ui/themes/default/mode.js
Normal file
@@ -0,0 +1,7 @@
|
||||
export default class Mode extends ui.view.DefaultTheme.ModeUI {
|
||||
constructor() {
|
||||
super();
|
||||
this.btnCustom.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.TALENT));
|
||||
this.btnCelebrity.on(Laya.Event.CLICK, this, ()=>$ui.switchView(UI.pages.CELEBRITY));
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@ export default class Property extends ui.view.DefaultTheme.PropertyUI {
|
||||
{
|
||||
propertyAllocate: this.#propertyAllocate,
|
||||
talents: this.listSelectedTalents.array,
|
||||
enableExtend: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ export default class Summary extends ui.view.DefaultTheme.SummaryUI {
|
||||
}
|
||||
|
||||
#selectedTalent;
|
||||
#enableExtend;
|
||||
|
||||
onAgain() {
|
||||
core.talentExtend(this.#selectedTalent);
|
||||
@@ -14,8 +15,9 @@ export default class Summary extends ui.view.DefaultTheme.SummaryUI {
|
||||
$ui.switchView(UI.pages.MAIN);
|
||||
}
|
||||
|
||||
init({talents}) {
|
||||
init({talents, enableExtend}) {
|
||||
const {summary, lastExtendTalent} = core;
|
||||
this.#enableExtend = enableExtend;
|
||||
|
||||
this.listSummary.array = [
|
||||
[core.PropertyTypes.HCHR, $lang.UI_Property_Charm],
|
||||
@@ -38,7 +40,11 @@ export default class Summary extends ui.view.DefaultTheme.SummaryUI {
|
||||
if(b == lastExtendTalent) return 1;
|
||||
return bg - ag;
|
||||
});
|
||||
this.#selectedTalent = talents[0].id;
|
||||
if(this.#enableExtend) {
|
||||
this.#selectedTalent = talents[0].id;
|
||||
} else {
|
||||
this.#selectedTalent = lastExtendTalent;
|
||||
}
|
||||
this.listSelectedTalents.array = talents;
|
||||
}
|
||||
renderSummary(box) {
|
||||
@@ -57,6 +63,9 @@ export default class Summary extends ui.view.DefaultTheme.SummaryUI {
|
||||
}
|
||||
|
||||
onSelectTalent(talentId) {
|
||||
if(!this.#enableExtend) {
|
||||
return $$event('message', ['M_DisableExtendTalent']);
|
||||
}
|
||||
if(talentId == this.#selectedTalent) {
|
||||
this.#selectedTalent = null;
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,6 @@ export default class Talent extends ui.view.DefaultTheme.TalentUI {
|
||||
}
|
||||
|
||||
#selected = new Set();
|
||||
|
||||
init() {
|
||||
this.pageDrawCard.visible = true;
|
||||
this.pageResult.visible = false;
|
||||
@@ -30,7 +29,7 @@ export default class Talent extends ui.view.DefaultTheme.TalentUI {
|
||||
}
|
||||
|
||||
const talents = [...this.#selected].map(index => this.listTalents.array[index]);
|
||||
$ui.switchView(UI.pages.PROPERTY, { talents });
|
||||
$ui.switchView(UI.pages.PROPERTY, { talents, enableExtend: true });
|
||||
}
|
||||
|
||||
renderTalent(box, index) {
|
||||
@@ -55,7 +54,7 @@ export default class Talent extends ui.view.DefaultTheme.TalentUI {
|
||||
if(this.#selected.size >= core.talentSelectLimit) {
|
||||
return $$event('message', ['F_TalentSelectLimit', core.talentSelectLimit]);
|
||||
}
|
||||
const exclusive = core.exclusive(
|
||||
const exclusive = core.exclude(
|
||||
[...this.#selected].map(index => this.listTalents.array[index].id),
|
||||
this.listTalents.array[index].id
|
||||
);
|
||||
|
||||
@@ -45,8 +45,10 @@ export default class Trajectory extends ui.view.DefaultTheme.TrajectoryUI {
|
||||
#isEnd;
|
||||
#trajectoryItems;
|
||||
#talents;
|
||||
#enableExtend;
|
||||
|
||||
init({propertyAllocate, talents}) {
|
||||
init({propertyAllocate, talents, enableExtend}) {
|
||||
this.#enableExtend = enableExtend;
|
||||
this.boxParticle.visible = false;
|
||||
this.boxSpeed.visible = true;
|
||||
this.btnSummary.visible = false;
|
||||
@@ -88,16 +90,16 @@ export default class Trajectory extends ui.view.DefaultTheme.TrajectoryUI {
|
||||
if(isEnd) {
|
||||
this.boxSpeed.visible = false;
|
||||
this.btnSummary.visible = true;
|
||||
Laya.timer.frameOnce(1,this,()=>{
|
||||
this.panelTrajectory.scrollTo(0, this.panelTrajectory.contentHeight);
|
||||
});
|
||||
}
|
||||
|
||||
this.panelTrajectory.scrollTo(0, this.panelTrajectory.contentHeight);
|
||||
this.renderTrajectory(age, content);
|
||||
|
||||
if(age >= 100) {
|
||||
this.boxParticle.visible = true;
|
||||
}
|
||||
Laya.timer.frameOnce(1, this, () => {
|
||||
this.panelTrajectory.scrollTo(0, this.panelTrajectory.contentHeight);
|
||||
});
|
||||
this.updateProperty();
|
||||
}
|
||||
|
||||
@@ -117,12 +119,12 @@ export default class Trajectory extends ui.view.DefaultTheme.TrajectoryUI {
|
||||
item.grade(content[content.length - 1].grade);
|
||||
this.vboxTrajectory.addChild(item);
|
||||
this.#trajectoryItems.push(item);
|
||||
this.#trajectoryItems.forEach((item, index) => item.y = index);
|
||||
item.y = this.vboxTrajectory.height;
|
||||
}
|
||||
|
||||
onSummary() {
|
||||
const talents = this.#talents;
|
||||
$ui.switchView(UI.pages.SUMMARY, {talents});
|
||||
$ui.switchView(UI.pages.SUMMARY, {talents, enableExtend: this.#enableExtend});
|
||||
}
|
||||
|
||||
get speed() {
|
||||
|
||||
@@ -14,7 +14,7 @@ export default class MessagePopup extends ui.view.MessagePopupUI {
|
||||
Laya.Tween.clearAll(this);
|
||||
this.alpha = 0;
|
||||
this.y = - 2 * this.height;
|
||||
await Laya.promises.Tween.to(this, { y: 0, alpha: 1 }, 300, Laya.Ease.backOut),
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -7,22 +7,22 @@ export default class SaveLoad extends ui.view.SaveLoadUI {
|
||||
});
|
||||
this.btnRead.on(Laya.Event.CLICK, this, async ()=>{
|
||||
const result = await $$copy(this.input.text = this.data);
|
||||
$$event('message', [result? 'UI_CopySuccess': 'UI_CopyFaild']);
|
||||
$$event('message', [result? 'UI_CopySuccess': 'UI_CopyFailed']);
|
||||
});
|
||||
this.btnWrite.on(Laya.Event.CLICK, this, async ()=>{
|
||||
const text = await $$read();
|
||||
if(text == false) {
|
||||
this.data = [
|
||||
this.input.text,
|
||||
'UI_PasteFaildDecodeSuccess',
|
||||
'UI_PasteFaildDecodeFaild'
|
||||
'UI_PasteFailedDecodeSuccess',
|
||||
'UI_PasteFailedDecodeFailed'
|
||||
];
|
||||
} else {
|
||||
this.input.text = text;
|
||||
this.data = [
|
||||
text,
|
||||
'UI_PasteSuccessDecodeSuccess',
|
||||
'UI_PasteSuccessDecodeFaild'
|
||||
'UI_PasteSuccessDecodeFailed'
|
||||
];
|
||||
}
|
||||
});
|
||||
@@ -60,6 +60,71 @@ export default class SaveLoad extends ui.view.SaveLoadUI {
|
||||
this.input.on(Laya.Event.MOUSE_DOWN, this, ()=>{
|
||||
this.input.setSelection(0, this.input.text.length);
|
||||
})
|
||||
|
||||
this.btnBackup.on(Laya.Event.CLICK, this, ()=>{
|
||||
const board = document.createElement("div");
|
||||
document.body.appendChild(board);
|
||||
board.style = `
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
opacity: 0.95`;
|
||||
|
||||
const bg = document.createElement("div");
|
||||
bg.style = `
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: #fff;
|
||||
opacity: 0.95`;
|
||||
document.body.appendChild(board);
|
||||
board.appendChild(bg);
|
||||
const textarea = document.createElement("textarea");
|
||||
textarea.style = `position: absolute; width: ${window.innerWidth}px; height: ${window.innerHeight}px;`
|
||||
textarea.value = JSON.stringify(
|
||||
JSON.parse(this.data),
|
||||
null,
|
||||
4
|
||||
);
|
||||
board.appendChild(textarea);
|
||||
const close = document.createElement("div");
|
||||
close.style = `
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background: red;
|
||||
font-size:100px;
|
||||
padding: 0;
|
||||
line-height: 100px;
|
||||
color: white;
|
||||
opacity: 0.7`;
|
||||
close.innerHTML = '×';
|
||||
board.appendChild(close);
|
||||
close.onclick = ()=>board.remove();
|
||||
|
||||
const load = document.createElement("div");
|
||||
load.style = `
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background: limegreen;
|
||||
font-size: 35px;
|
||||
padding: 0;
|
||||
line-height: 50px;
|
||||
color: white;
|
||||
opacity: 0.7`;
|
||||
load.innerHTML = 'LOAD<br>读取';
|
||||
board.appendChild(load);
|
||||
load.onclick = ()=>this.data = [textarea.value, '成功/success', '失败/failed', true];
|
||||
});
|
||||
}
|
||||
|
||||
static load() {
|
||||
@@ -79,17 +144,19 @@ export default class SaveLoad extends ui.view.SaveLoadUI {
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
|
||||
set data([v, success = 'UI_LoadSuccess', faild = 'UI_LoadFaild']) {
|
||||
set data([v, success = 'UI_LoadSuccess', failed = 'UI_LoadFailed', altMsg]) {
|
||||
try {
|
||||
const data = JSON.parse(v);
|
||||
for(const key in data)
|
||||
localStorage.setItem(key, data[key]);
|
||||
$$event('message', [success]);
|
||||
if(altMsg) alert(success);
|
||||
else $$event('message', [success]);
|
||||
$ui.theme = $ui.theme;
|
||||
this.btnClose.event(Laya.Event.CLICK);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
$$event('message', [faild]);
|
||||
if(altMsg) alert(`${failed}\n${e}`);
|
||||
else $$event('message', [failed]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ const pages = {
|
||||
THANKS: 'THANKS',
|
||||
THEMES: 'THEMES',
|
||||
SAVELOAD: 'SAVELOAD',
|
||||
MODE: 'MODE',
|
||||
CELEBRITY: 'CELEBRITY'
|
||||
};
|
||||
|
||||
const popups = {
|
||||
@@ -28,6 +30,8 @@ const cyber = {
|
||||
[pages.THANKS]: "default/thanks",
|
||||
[pages.THEMES]: 'themes',
|
||||
[pages.SAVELOAD]: 'saveload',
|
||||
[pages.MODE]: 'cyber/mode',
|
||||
[pages.CELEBRITY]: 'cyber/celebrity',
|
||||
},
|
||||
popups: {
|
||||
[popups.ACHIEVEMENT]: "cyber/popup/achievementPopup",
|
||||
@@ -57,20 +61,22 @@ const cyber = {
|
||||
],
|
||||
gradeBlk: [
|
||||
{
|
||||
defaultColor: '#cccccc',
|
||||
hoverColor: '#cccccc',
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
defaultColor: '#55fffe',
|
||||
hoverColor: '#55fffe',
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
defaultColor: '#b17cff',
|
||||
hoverColor: '#b17cff',
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
defaultColor: '#ffce45',
|
||||
hoverColor: '#ffce45',
|
||||
visible: true,
|
||||
},
|
||||
]
|
||||
},
|
||||
@@ -165,6 +171,13 @@ const cyber = {
|
||||
defaultColor: '#fc5531',
|
||||
hoverColor: '#f28b54',
|
||||
},
|
||||
btnBackup: {
|
||||
defaultColor: '#9c30cd',
|
||||
hoverColor: '#bf50fd',
|
||||
radius: 8,
|
||||
defaultLabel: '#ffffff',
|
||||
hoverLabel: '#ffffff',
|
||||
},
|
||||
},
|
||||
names: {
|
||||
btnSmall: {
|
||||
@@ -190,6 +203,8 @@ const dark = {
|
||||
[pages.THANKS]: "default/thanks",
|
||||
[pages.THEMES]: 'themes',
|
||||
[pages.SAVELOAD]: 'saveload',
|
||||
[pages.MODE]: 'default/mode',
|
||||
[pages.CELEBRITY]: 'default/celebrity',
|
||||
},
|
||||
popups: {
|
||||
[popups.ACHIEVEMENT]: "default/popup/achievementPopup",
|
||||
@@ -201,24 +216,27 @@ const dark = {
|
||||
defaultFontColor: '#eeeeee',
|
||||
trajectoryItem: {
|
||||
box: {
|
||||
filters: ()=>[new Laya.GlowFilter("#eeeeee", 8, 0, 0)],
|
||||
// filters: ()=>[new Laya.GlowFilter("#eeeeee", 8, 0, 0)],
|
||||
defaultStroke: '#eeeeee',
|
||||
hoverStroke: '#eeeeee',
|
||||
lineWidth: 2,
|
||||
},
|
||||
grade: [
|
||||
{
|
||||
defaultColor: '#4a5361',
|
||||
defaultColor: '#464646',
|
||||
hoverColor: '#4a5361',
|
||||
},
|
||||
{
|
||||
defaultColor: '#1160b0',
|
||||
hoverColor: '#1160b0',
|
||||
defaultColor: '#6495ed',
|
||||
hoverColor: '#87cefa',
|
||||
},
|
||||
{
|
||||
defaultColor: '#9379ca',
|
||||
hoverColor: '#9379ca',
|
||||
defaultColor: '#e2a7ff',
|
||||
hoverColor: '#e7beff',
|
||||
},
|
||||
{
|
||||
defaultColor: '#ab6157',
|
||||
hoverColor: '#ab6157',
|
||||
defaultColor: '#ffa07a',
|
||||
hoverColor: '#f7a989',
|
||||
},
|
||||
],
|
||||
ageColor: '#ffffee',
|
||||
@@ -411,7 +429,28 @@ const dark = {
|
||||
lineWidth: 4,
|
||||
radius: 0,
|
||||
}
|
||||
]
|
||||
],
|
||||
characterItem: {
|
||||
name: {
|
||||
defaultColor: '#393e46',
|
||||
defaultStroke: '#eeeeee',
|
||||
defaultLabel: '#eeeeee',
|
||||
hoverColor: '#ff7878',
|
||||
hoverStroke: '#eeeeee',
|
||||
hoverLabel: '#eeeeee',
|
||||
lineWidth: 2,
|
||||
},
|
||||
state: {
|
||||
defaultColor: '#393e46',
|
||||
defaultStroke: '#eeeeee',
|
||||
defaultLabel: '#eeeeee',
|
||||
hoverColor: '#393e46',
|
||||
hoverStroke: '#eeeeee',
|
||||
hoverLabel: '#eeeeee',
|
||||
lineWidth: 2,
|
||||
},
|
||||
propertyColor: '#000000',
|
||||
},
|
||||
},
|
||||
class: {
|
||||
btn_main: {
|
||||
@@ -424,6 +463,16 @@ const dark = {
|
||||
lineWidth: 2,
|
||||
radius: 4,
|
||||
},
|
||||
btn_main2: {
|
||||
defaultColor: '#ffa07a',
|
||||
defaultStroke: '#f8f8f8',
|
||||
defaultLabel: '#3b3b3b',
|
||||
hoverColor: '#ff7878',
|
||||
hoverStroke: '#f8f8f8',
|
||||
hoverLabel: '#eeeeee',
|
||||
lineWidth: 2,
|
||||
radius: 4,
|
||||
},
|
||||
btn_small: {
|
||||
defaultColor: '#5865f2',
|
||||
defaultStroke: '#eeeeee',
|
||||
@@ -475,7 +524,7 @@ const dark = {
|
||||
[pages.PROPERTY]: {
|
||||
vars: {
|
||||
btnRandomAllocate: 'btn_main',
|
||||
btnNext: 'btn_main',
|
||||
btnNext: 'btn_main2',
|
||||
title: 'title',
|
||||
},
|
||||
names: {
|
||||
@@ -607,6 +656,13 @@ const dark = {
|
||||
defaultColor: '#fc5531',
|
||||
hoverColor: '#f28b54',
|
||||
},
|
||||
btnBackup: {
|
||||
defaultColor: '#9c30cd',
|
||||
hoverColor: '#bf50fd',
|
||||
radius: 8,
|
||||
defaultLabel: '#ffffff',
|
||||
hoverLabel: '#ffffff',
|
||||
},
|
||||
},
|
||||
names: {
|
||||
btnSmall: {
|
||||
@@ -616,6 +672,18 @@ const dark = {
|
||||
}
|
||||
}
|
||||
},
|
||||
[pages.MODE]: {
|
||||
names: {
|
||||
font_default: 'font_default',
|
||||
btn: 'btn_main',
|
||||
}
|
||||
},
|
||||
[pages.CELEBRITY]: {
|
||||
vars: {
|
||||
btnRetry: 'btn_main',
|
||||
btnNext: 'btn_main2',
|
||||
}
|
||||
},
|
||||
},
|
||||
popups: {
|
||||
[popups.ACHIEVEMENT]: {
|
||||
@@ -644,6 +712,8 @@ const light = {
|
||||
[pages.THANKS]: "default/thanks",
|
||||
[pages.THEMES]: 'themes',
|
||||
[pages.SAVELOAD]: 'saveload',
|
||||
[pages.MODE]: 'default/mode',
|
||||
[pages.CELEBRITY]: 'default/celebrity',
|
||||
},
|
||||
popups: {
|
||||
[popups.ACHIEVEMENT]: "default/popup/achievementPopup",
|
||||
@@ -655,21 +725,27 @@ const light = {
|
||||
defaultFontColor: '#000000',
|
||||
trajectoryItem: {
|
||||
box: {
|
||||
filters: ()=>[new Laya.GlowFilter("#b1b1b1", 8, 0, 0)],
|
||||
// filters: ()=>[new Laya.GlowFilter("#b1b1b1", 8, 0, 0)],
|
||||
defaultStroke: '#b1b1b1',
|
||||
hoverStroke: '#b1b1b1',
|
||||
lineWidth: 2,
|
||||
},
|
||||
grade: [
|
||||
{},
|
||||
{
|
||||
defaultColor: '#55fffe',
|
||||
hoverColor: '#55fffe',
|
||||
defaultColor: '#ffffff',
|
||||
hoverColor: '#ededed',
|
||||
},
|
||||
{
|
||||
defaultColor: '#b17cff',
|
||||
hoverColor: '#b17cff',
|
||||
defaultColor: '#87cefa',
|
||||
hoverColor: '#6495ed',
|
||||
},
|
||||
{
|
||||
defaultColor: '#ffce45',
|
||||
hoverColor: '#ffce45',
|
||||
defaultColor: '#e7beff',
|
||||
hoverColor: '#e2a7ff',
|
||||
},
|
||||
{
|
||||
defaultColor: '#f7a989',
|
||||
hoverColor: '#ffa07a',
|
||||
},
|
||||
],
|
||||
ageColor: '#000000',
|
||||
@@ -860,7 +936,28 @@ const light = {
|
||||
lineWidth: 4,
|
||||
radius: 0,
|
||||
}
|
||||
]
|
||||
],
|
||||
characterItem: {
|
||||
name: {
|
||||
defaultColor: '#ffffff',
|
||||
defaultStroke: '#cccccc',
|
||||
defaultLabel: '#000000',
|
||||
hoverColor: '#ff7878',
|
||||
hoverStroke: '#cccccc',
|
||||
hoverLabel: '#ffffff',
|
||||
lineWidth: 2,
|
||||
},
|
||||
state: {
|
||||
defaultColor: '#ffffff',
|
||||
defaultStroke: '#cccccc',
|
||||
defaultLabel: '#000000',
|
||||
hoverColor: '#ffffff',
|
||||
hoverStroke: '#cccccc',
|
||||
hoverLabel: '#000000',
|
||||
lineWidth: 2,
|
||||
},
|
||||
propertyColor: '#000000',
|
||||
},
|
||||
},
|
||||
class: {
|
||||
btn_main: {
|
||||
@@ -873,6 +970,16 @@ const light = {
|
||||
lineWidth: 2,
|
||||
radius: 4,
|
||||
},
|
||||
btn_main2: {
|
||||
defaultColor: '#f7a989',
|
||||
defaultStroke: '#f8f8f8',
|
||||
defaultLabel: '#ffffff',
|
||||
hoverColor: '#ff7878',
|
||||
hoverStroke: '#f8f8f8',
|
||||
hoverLabel: '#ffffff',
|
||||
lineWidth: 2,
|
||||
radius: 4,
|
||||
},
|
||||
btn_small: {
|
||||
defaultColor: '#5865f2',
|
||||
defaultStroke: '#eeeeee',
|
||||
@@ -924,7 +1031,7 @@ const light = {
|
||||
[pages.PROPERTY]: {
|
||||
vars: {
|
||||
btnRandomAllocate: 'btn_main',
|
||||
btnNext: 'btn_main',
|
||||
btnNext: 'btn_main2',
|
||||
title: 'title',
|
||||
},
|
||||
names: {
|
||||
@@ -1056,6 +1163,13 @@ const light = {
|
||||
defaultColor: '#fc5531',
|
||||
hoverColor: '#f28b54',
|
||||
},
|
||||
btnBackup: {
|
||||
defaultColor: '#9c30cd',
|
||||
hoverColor: '#bf50fd',
|
||||
radius: 8,
|
||||
defaultLabel: '#ffffff',
|
||||
hoverLabel: '#ffffff',
|
||||
},
|
||||
},
|
||||
names: {
|
||||
btnSmall: {
|
||||
@@ -1065,6 +1179,18 @@ const light = {
|
||||
}
|
||||
}
|
||||
},
|
||||
[pages.MODE]: {
|
||||
names: {
|
||||
font_default: 'font_default',
|
||||
btn: 'btn_main',
|
||||
}
|
||||
},
|
||||
[pages.CELEBRITY]: {
|
||||
vars: {
|
||||
btnRetry: 'btn_main',
|
||||
btnNext: 'btn_main2',
|
||||
}
|
||||
},
|
||||
},
|
||||
popups: {
|
||||
[popups.ACHIEVEMENT]: {
|
||||
|
||||
Reference in New Issue
Block a user