add record

This commit is contained in:
Vick Scarlet
2021-08-17 21:13:51 +08:00
parent b0e9cbdb0a
commit 495d4a39ec
4 changed files with 99 additions and 1 deletions

76
src/functions/summary.js Normal file
View File

@ -0,0 +1,76 @@
const data = {
"CHR": [
{"judge": "地狱", "grade": 0},
{"min":1, "judge": "折磨", "grade": 0},
{"min":2, "judge": "不佳", "grade": 0},
{"min":4, "judge": "普通", "grade": 0},
{"min":7, "judge": "优秀", "grade": 1},
{"min":9, "judge": "罕见", "grade": 2},
{"min":11, "judge": "逆天", "grade": 3}
],
"MNY": [
{"judge": "地狱", "grade": 0},
{"min":1, "judge": "折磨", "grade": 0},
{"min":2, "judge": "不佳", "grade": 0},
{"min":4, "judge": "普通", "grade": 0},
{"min":7, "judge": "优秀", "grade": 1},
{"min":9, "judge": "罕见", "grade": 2},
{"min":11, "judge": "逆天", "grade": 3},
],
"SPR": [
{"judge": "地狱", "grade": 0},
{"min":1, "judge": "折磨", "grade": 0},
{"min":2, "judge": "不幸", "grade": 0},
{"min":4, "judge": "普通", "grade": 0},
{"min":7, "judge": "幸福", "grade": 1},
{"min":9, "judge": "极乐", "grade": 2},
{"min":11, "judge": "天命", "grade": 3},
],
"INT": [
{"judge": "地狱", "grade": 0},
{"min":1, "judge": "折磨", "grade": 0},
{"min":2, "judge": "不佳", "grade": 0},
{"min":4, "judge": "普通", "grade": 0},
{"min":7, "judge": "优秀", "grade": 1},
{"min":9, "judge": "罕见", "grade": 2},
{"min":11, "judge": "逆天", "grade": 3},
{"min":21, "judge": "识海", "grade": 3},
{"min":131, "judge": "元神", "grade": 3},
{"min":501, "judge": "仙魂", "grade": 3},
],
"STR": [
{"judge": "地狱", "grade": 0},
{"min":1, "judge": "折磨", "grade": 0},
{"min":2, "judge": "不佳", "grade": 0},
{"min":4, "judge": "普通", "grade": 0},
{"min":7, "judge": "优秀", "grade": 1},
{"min":9, "judge": "罕见", "grade": 2},
{"min":11, "judge": "逆天", "grade": 3},
{"min":21, "judge": "凝气", "grade": 3},
{"min":101, "judge": "筑基", "grade": 3},
{"min":401, "judge": "金丹", "grade": 3},
{"min":1001, "judge": "元婴", "grade": 3},
{"min":2001, "judge": "仙体", "grade": 3},
],
"AGE": [
{"judge": "早夭", "grade": 0},
{"min":10, "judge": "少年", "grade": 0},
{"min":18, "judge": "盛年", "grade": 0},
{"min":40, "judge": "中年", "grade": 0},
{"min":60, "judge": "花甲", "grade": 1},
{"min":70, "judge": "古稀", "grade": 1},
{"min":80, "judge": "杖朝", "grade": 2},
{"min":90, "judge": "南山", "grade": 2},
{"min":95, "judge": "不老", "grade": 3},
{"min":100, "judge": "修仙", "grade": 3},
{"min":500, "judge": "仙寿", "grade": 3},
]
}
function summary(type, value) {
let length = data[type].length;
while(length--) {
const {min, judge, grade} = data[type][length];
if(min==void 0 || value >= min) return {judge, grade};
}
}

View File

@ -28,6 +28,7 @@ class Life {
this.#triggerTalents = new Set();
this.#property.restart(allocation);
this.doTalent();
this.#property.record();
}
getTalentAllocationAddition(talents) {
@ -39,6 +40,7 @@ class Life {
const talentContent = this.doTalent(talent);
const eventContent = this.doEvent(this.random(event));
this.#property.record();
const isEnd = this.#property.isEnd();
@ -98,7 +100,10 @@ class Life {
talentRandom() {
return this.#talent.talentRandom();
}
getRecord() {
return this.#property.getRecord();
}
}

View File

@ -17,6 +17,7 @@ class Property {
#ageData;
#data;
#record;
initial({age}) {
@ -45,6 +46,7 @@ class Property {
};
for(const key in data)
this.change(key, data[key]);
this.#record = [];
}
get(prop) {
@ -80,6 +82,21 @@ class Property {
}
}
record() {
this.#record.push({
[this.TYPES.AGE]: this.get(this.TYPES.AGE),
[this.TYPES.CHR]: this.get(this.TYPES.CHR),
[this.TYPES.INT]: this.get(this.TYPES.INT),
[this.TYPES.STR]: this.get(this.TYPES.STR),
[this.TYPES.MNY]: this.get(this.TYPES.MNY),
[this.TYPES.SPR]: this.get(this.TYPES.SPR),
});
}
getRecord() {
return clone(this.#record);
}
change(prop, value) {
if(Array.isArray(value)) {
for(const v of value)

View File

@ -63,7 +63,7 @@ class Talent {
addition += this.allocationAddition(talent);
return addition;
}
return this.get(talents).status || 0;
return Number(this.get(talents).status) || 0;
}
do(talentId) {