Hello World
This commit is contained in:
commit
7d342af29f
124 files changed
+627642
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import * as e from './common.mjs';
|
||||
export function build(t){
|
||||
const rules=e.dict();
|
||||
for(const r of t.GridFightSeasonExpScoreRow)(rules[r.ScoreRuleID]??=[]).push({
|
||||
chapter:r.ChapterID,
|
||||
section:r.SectionID,
|
||||
weekly:r.WeeklyScore??0,
|
||||
exp:r.Exp??0
|
||||
});
|
||||
for(const rows of Object.values(rules)){
|
||||
rows.sort((a, b)=>a.chapter-b.chapter||a.section-b.section);
|
||||
if(!e.uniqueValues(rows, r=>[r.chapter, r.section].join(':')))e.fail('duplicate score node');
|
||||
}
|
||||
const divisions=e.dict();
|
||||
for(const r of t.GridFightDivisionStageRow){
|
||||
const d={
|
||||
rule:r.ScoreRule??0,
|
||||
oc_rule:r.OCScoreRule??0,
|
||||
weekly_modify:r.WeeklyScoreModify??100,
|
||||
exp_modify:r.ExpModify??100
|
||||
};
|
||||
divisions[r.DivisionID]=d;
|
||||
for(const key of ['rule', 'oc_rule'])if(d[key]&&!(d[key]in rules))e.fail(`division ${r.DivisionID}: score rule ${d[key]} has no rows`);
|
||||
}
|
||||
const ranks=t.GridFightScoreRewardConfigRow.map(r=>({
|
||||
rank:r.ScoreRank,
|
||||
score:r.Score,
|
||||
reward:r.Reward??0
|
||||
})).sort((a, b)=>a.rank-b.rank);
|
||||
if(!ranks.length)e.fail('Empty score reward table');
|
||||
return {
|
||||
rules,
|
||||
divisions,
|
||||
weekly_ranks:ranks,
|
||||
weekly_cap:Math.max(...ranks.map(r=>r.score))
|
||||
};
|
||||
}
|
||||
export function main(){
|
||||
const a=e.cli([], {
|
||||
catalog:e.catalogDefault,
|
||||
output:e.resource('score.json')
|
||||
}),
|
||||
data=build(e.loadJSON(a.catalog).tables);
|
||||
e.atomic_json(a.output, data, 1, true);
|
||||
console.log(`${a.output}: ${Object.keys(data.rules).length} score rules, ${Object.keys(data.divisions).length} divisions, weekly cap ${data.weekly_cap}`);
|
||||
}
|
||||
e.runMain(import.meta.url, main);
|
||||
Reference in new issue
Block a user