Implement int and costs jankily

also fix rounding jankily with -cost items
This commit is contained in:
hppeng 2022-07-05 23:43:44 -07:00
parent 5391b08b37
commit 8d077b3b4b
7 changed files with 121 additions and 67 deletions

View file

@ -3730,7 +3730,7 @@
"sdRaw": 200, "sdRaw": 200,
"wDamPct": -20, "wDamPct": -20,
"eDamPct": 25, "eDamPct": 25,
"spPct4": -46, "spPct4": -45,
"id": 131 "id": 131
}, },
{ {
@ -7287,8 +7287,8 @@
"agi": 11, "agi": 11,
"def": 11, "def": 11,
"hpBonus": -300, "hpBonus": -300,
"spPct2": 24, "spPct2": 25,
"spPct4": -24, "spPct4": -23,
"id": 359 "id": 359
}, },
{ {
@ -9950,9 +9950,9 @@
"def": -20, "def": -20,
"atkTier": -1, "atkTier": -1,
"hprRaw": -200, "hprRaw": -200,
"spPct2": -32, "spPct2": -31,
"spPct3": -21, "spPct3": -21,
"spPct4": -24, "spPct4": -23,
"id": 482 "id": 482
}, },
{ {
@ -10022,7 +10022,7 @@
"spd": -8, "spd": -8,
"hpBonus": 1750, "hpBonus": 1750,
"hprRaw": 125, "hprRaw": 125,
"spPct1": -48, "spPct1": -47,
"id": 490 "id": 490
}, },
{ {
@ -13227,7 +13227,7 @@
"aDamPct": 12, "aDamPct": 12,
"tDamPct": 15, "tDamPct": 15,
"fixID": true, "fixID": true,
"spPct3": -10, "spPct3": -9,
"id": 629 "id": 629
}, },
{ {
@ -13963,7 +13963,7 @@
"eSteal": 4, "eSteal": 4,
"aDamPct": 12, "aDamPct": 12,
"tDamPct": 10, "tDamPct": 10,
"spPct1": -10, "spPct1": -9,
"spPct4": -14, "spPct4": -14,
"id": 658 "id": 658
}, },
@ -15415,7 +15415,7 @@
"aDamPct": 21, "aDamPct": 21,
"fixID": true, "fixID": true,
"spPct2": -54, "spPct2": -54,
"spPct3": -34, "spPct3": -33,
"id": 726 "id": 726
}, },
{ {
@ -15850,7 +15850,7 @@
"wDefPct": -45, "wDefPct": -45,
"eDefPct": -55, "eDefPct": -55,
"spPct2": -14, "spPct2": -14,
"spPct3": -10, "spPct3": -9,
"id": 2264 "id": 2264
}, },
{ {
@ -16582,10 +16582,10 @@
"wDamPct": 50, "wDamPct": 50,
"type": "necklace", "type": "necklace",
"fixID": true, "fixID": true,
"spPct1": 130, "spPct1": 91,
"spPct2": 85, "spPct2": 61,
"spPct3": 130, "spPct3": 91,
"spPct4": 100, "spPct4": 70,
"id": 3618 "id": 3618
}, },
{ {
@ -16846,7 +16846,7 @@
"mdRaw": 1997, "mdRaw": 1997,
"fixID": true, "fixID": true,
"spPct1": 23, "spPct1": 23,
"spPct2": 15, "spPct2": 16,
"spPct3": 32, "spPct3": 32,
"spPct4": 23, "spPct4": 23,
"id": 782 "id": 782
@ -18545,7 +18545,7 @@
"tDamPct": 10, "tDamPct": 10,
"spPct1": -21, "spPct1": -21,
"spPct2": -14, "spPct2": -14,
"spPct3": -18, "spPct3": -17,
"spPct4": -21, "spPct4": -21,
"id": 860 "id": 860
}, },
@ -19351,8 +19351,8 @@
"mdPct": 15, "mdPct": 15,
"spd": 10, "spd": 10,
"hpBonus": -300, "hpBonus": -300,
"spPct1": 24, "spPct1": 25,
"spPct3": -24, "spPct3": -23,
"jh": 1, "jh": 1,
"id": 898 "id": 898
}, },
@ -23028,10 +23028,10 @@
"ref": 20, "ref": 20,
"int": -40, "int": -40,
"spd": 8, "spd": 8,
"spPct1": -18, "spPct1": -17,
"spPct2": -10, "spPct2": -9,
"spPct3": -18, "spPct3": -17,
"spPct4": -10, "spPct4": -9,
"id": 1070 "id": 1070
}, },
{ {
@ -24203,7 +24203,7 @@
"aDamPct": -33, "aDamPct": -33,
"tDamPct": -33, "tDamPct": -33,
"eDamPct": -33, "eDamPct": -33,
"spPct3": -23, "spPct3": -22,
"id": 1143 "id": 1143
}, },
{ {
@ -26886,7 +26886,7 @@
"str": 4, "str": 4,
"dex": 4, "dex": 4,
"mdRaw": 52, "mdRaw": 52,
"spPct1": 18, "spPct1": 19,
"id": 1261 "id": 1261
}, },
{ {
@ -27362,8 +27362,8 @@
"tDefPct": 40, "tDefPct": 40,
"eDefPct": 40, "eDefPct": 40,
"fixID": true, "fixID": true,
"spPct3": -18, "spPct3": -17,
"spPct4": -18, "spPct4": -17,
"id": 1279 "id": 1279
}, },
{ {
@ -35174,7 +35174,7 @@
"dex": 4, "dex": 4,
"sdRaw": 13, "sdRaw": 13,
"mdRaw": 13, "mdRaw": 13,
"spPct1": 18, "spPct1": 19,
"id": 1658 "id": 1658
}, },
{ {
@ -35953,7 +35953,7 @@
"def": 15, "def": 15,
"fDamPct": 40, "fDamPct": 40,
"wDamPct": 40, "wDamPct": 40,
"spPct1": -23, "spPct1": -22,
"id": 1689 "id": 1689
}, },
{ {
@ -36059,7 +36059,7 @@
"tDamPct": 55, "tDamPct": 55,
"eDamPct": 55, "eDamPct": 55,
"aDefPct": 35, "aDefPct": 35,
"spPct3": -52, "spPct3": -51,
"sprintReg": 43, "sprintReg": 43,
"id": 3643 "id": 3643
}, },
@ -36591,7 +36591,7 @@
"fDamPct": 45, "fDamPct": 45,
"wDamPct": -1000, "wDamPct": -1000,
"aDamPct": 45, "aDamPct": 45,
"spPct3": -16, "spPct3": -15,
"id": 3646 "id": 3646
}, },
{ {
@ -36900,7 +36900,7 @@
"eSteal": 10, "eSteal": 10,
"hprRaw": -270, "hprRaw": -270,
"mdRaw": 285, "mdRaw": 285,
"spPct3": -30, "spPct3": -29,
"id": 1716 "id": 1716
}, },
{ {
@ -44272,7 +44272,7 @@
"fDamPct": 45, "fDamPct": 45,
"wDamPct": -25, "wDamPct": -25,
"eDamPct": -25, "eDamPct": -25,
"spPct3": -23, "spPct3": -22,
"id": 2063 "id": 2063
}, },
{ {
@ -47040,7 +47040,7 @@
"ms": 5, "ms": 5,
"lb": 10, "lb": 10,
"str": -5, "str": -5,
"spPct1": -25, "spPct1": -24,
"id": 2182 "id": 2182
}, },
{ {
@ -49765,8 +49765,8 @@
"agi": 7, "agi": 7,
"def": 7, "def": 7,
"wDamPct": -15, "wDamPct": -15,
"spPct1": -10, "spPct1": -9,
"spPct3": -10, "spPct3": -9,
"id": 2327 "id": 2327
}, },
{ {
@ -54851,7 +54851,7 @@
"def": 4, "def": 4,
"spd": 10, "spd": 10,
"fixID": true, "fixID": true,
"spPct1": -18, "spPct1": -17,
"id": 2579 "id": 2579
}, },
{ {
@ -58543,7 +58543,7 @@
"spRegen": 10, "spRegen": 10,
"aDefPct": 10, "aDefPct": 10,
"fixID": true, "fixID": true,
"spPct1": -18, "spPct1": -17,
"id": 2763 "id": 2763
}, },
{ {
@ -61862,10 +61862,10 @@
"mr": 5, "mr": 5,
"sdPct": -25, "sdPct": -25,
"fixID": true, "fixID": true,
"spPct1": -18, "spPct1": -17,
"spPct2": -18, "spPct2": -17,
"spPct3": -18, "spPct3": -17,
"spPct4": -18, "spPct4": -17,
"id": 2900 "id": 2900
}, },
{ {
@ -62221,7 +62221,7 @@
"hprRaw": -40, "hprRaw": -40,
"sdRaw": 95, "sdRaw": 95,
"fixID": true, "fixID": true,
"spPct3": -10, "spPct3": -9,
"id": 2915 "id": 2915
}, },
{ {
@ -66367,7 +66367,7 @@
"hprRaw": 150, "hprRaw": 150,
"spPct1": -7, "spPct1": -7,
"spPct2": -14, "spPct2": -14,
"spPct3": -10, "spPct3": -9,
"id": 3094 "id": 3094
}, },
{ {
@ -70048,7 +70048,7 @@
"lb": 25, "lb": 25,
"hprRaw": -101, "hprRaw": -101,
"spPct2": -31, "spPct2": -31,
"spPct4": -10, "spPct4": -9,
"jh": 2, "jh": 2,
"id": 3621 "id": 3621
}, },
@ -70785,7 +70785,7 @@
"fDamPct": -30, "fDamPct": -30,
"wDamPct": 20, "wDamPct": 20,
"tDefPct": -25, "tDefPct": -25,
"spPct3": -24, "spPct3": -23,
"id": 3309 "id": 3309
}, },
{ {
@ -71213,9 +71213,9 @@
"spd": 10, "spd": 10,
"fDamPct": 10, "fDamPct": 10,
"wDamPct": -15, "wDamPct": -15,
"spPct1": -10, "spPct1": -9,
"spPct3": -7, "spPct3": -7,
"spPct4": -10, "spPct4": -9,
"id": 3327 "id": 3327
}, },
{ {
@ -72481,9 +72481,9 @@
"int": -24, "int": -24,
"agi": 12, "agi": 12,
"spd": 15, "spd": 15,
"spPct1": -10, "spPct1": -9,
"spPct3": -7, "spPct3": -7,
"spPct4": -18, "spPct4": -17,
"id": 3385 "id": 3385
}, },
{ {
@ -73096,7 +73096,7 @@
"ms": 5, "ms": 5,
"def": -12, "def": -12,
"spd": 12, "spd": 12,
"spPct1": -23, "spPct1": -22,
"id": 3413 "id": 3413
}, },
{ {
@ -77593,4 +77593,4 @@
] ]
} }
} }
} }

File diff suppressed because one or more lines are too long

View file

@ -293,7 +293,7 @@ const atree_merge = new (class extends ComputeNode {
} }
return abils_merged; return abils_merged;
} }
})().link_to(atree_node, 'atree').link_to(atree_state_node, 'atree-state'); // TODO: THIS IS WRONG!!!!! Need one "collect" node... })().link_to(atree_node, 'atree').link_to(atree_state_node, 'atree-state');
/** /**
* Validate ability tree. * Validate ability tree.
@ -475,7 +475,7 @@ const atree_collect_spells = new (class extends ComputeNode {
case 'add_spell_prop': { case 'add_spell_prop': {
const { base_spell, target_part = null, cost = 0, behavior = 'merge'} = effect; const { base_spell, target_part = null, cost = 0, behavior = 'merge'} = effect;
if (base_spell !== base_spell_id) { continue; } // TODO: redundant? if we assume abils only affect one spell if (base_spell !== base_spell_id) { continue; } // TODO: redundant? if we assume abils only affect one spell
if ('cost' in ret_spell) { ret_spell.cost += cost; } // TODO: unjankify this... if ('cost' in ret_spell) { ret_spell.cost += cost; }
if (target_part === null) { if (target_part === null) {
continue; continue;
@ -542,6 +542,49 @@ const atree_collect_spells = new (class extends ComputeNode {
} }
})().link_to(atree_merge, 'atree-merged'); })().link_to(atree_merge, 'atree-merged');
const atree_stats = new (class extends ComputeNode {
constructor() { super('atree-stats-collector'); }
compute_func(input_map) {
if (input_map.size !== 1) { throw "AbilityTreeCollectStats accepts exactly one input (atree-merged)"; }
const [atree_merged] = input_map.values(); // Extract values, pattern match it into size one list and bind to first element
let ret_effects = new Map();
for (const [abil_id, abil] of atree_merged.entries()) {
if (abil.effects.length == 0) { continue; }
for (const effect of abil.effects) {
switch (effect.type) {
case 'stat_scaling':
// TODO: handle
continue;
case 'raw_stat':
// TODO: toggles...
for (const bonus of effect.bonuses) {
const { type, name, abil = "", value } = effect;
// TODO: prop
if (type === "stat") {
if (ret_effects.has(name)) { ret_effects.set(name, ret_effect.get(name) + value); }
else { ret_effects.set(name, value); }
}
}
continue;
case 'add_spell_prop':
const { base_spell, cost = 0} = effect;
if (cost) {
const key = "spRaw"+base_spell;
if (ret_effects.has(key)) { ret_effects.set(key, ret_effect.get(key) + cost); }
else { ret_effects.set(key, cost); }
}
continue;
}
}
}
console.log(ret_effects);
return ret_effects;
}
})().link_to(atree_merge, 'atree-merged');
/** /**
* Construct compute nodes to link builder items and edit IDs to the appropriate display outputs. * Construct compute nodes to link builder items and edit IDs to the appropriate display outputs.

View file

@ -861,6 +861,8 @@ class AggregateStatsNode extends ComputeNode {
compute_func(input_map) { compute_func(input_map) {
const output_stats = new Map(); const output_stats = new Map();
for (const [k, v] of input_map.entries()) { for (const [k, v] of input_map.entries()) {
console.log(k);
console.log(v);
for (const [k2, v2] of v.entries()) { for (const [k2, v2] of v.entries()) {
if (output_stats.has(k2)) { if (output_stats.has(k2)) {
// TODO: ugly AF // TODO: ugly AF
@ -1105,6 +1107,7 @@ function builder_graph_init() {
atree_merge.link_to(build_node, 'build'); atree_merge.link_to(build_node, 'build');
atree_graph_creator = new AbilityTreeEnsureNodesNode(build_node, stat_agg_node) atree_graph_creator = new AbilityTreeEnsureNodesNode(build_node, stat_agg_node)
.link_to(atree_collect_spells, 'spells'); .link_to(atree_collect_spells, 'spells');
stat_agg_node.link_to(atree_stats, 'atree-stats');
build_encode_node.link_to(atree_node, 'atree').link_to(atree_state_node, 'atree-state'); build_encode_node.link_to(atree_node, 'atree').link_to(atree_state_node, 'atree-state');

View file

@ -1572,7 +1572,8 @@ function getSpellCost(stats, spell) {
function getBaseSpellCost(stats, spell) { function getBaseSpellCost(stats, spell) {
// old intelligence: // old intelligence:
let cost = spell.cost; //Math.ceil(spell.cost * (1 - skillPointsToPercentage(stats.get('int')))); let cost = Math.ceil(spell.cost * (1 - skillPointsToPercentage(stats.get('int')) * skillpoint_final_mult[2]));
console.log(stats);
cost += stats.get("spRaw"+spell.base_spell); cost += stats.get("spRaw"+spell.base_spell);
return Math.floor(cost * (1 + stats.get("spPct"+spell.base_spell) / 100)); return Math.floor(cost * (1 + stats.get("spPct"+spell.base_spell) / 100));
} }

View file

@ -1,4 +1,4 @@
const DB_VERSION = 92; const DB_VERSION = 93;
// @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.jsA // @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.jsA
let db; let db;

View file

@ -44,17 +44,18 @@ for item in items:
known_item_names.add(item["name"]) known_item_names.add(item["name"])
# TEMP wynn2 migration # TEMP wynn2 migration
# note: 10x'd
mul_keys = { mul_keys = {
"spPct1": 0.7, "spPct1": 7,
"spPct2": 0.7, "spPct2": 7,
"spPct3": 0.7, "spPct3": 7,
"spPct4": 0.7, "spPct4": 7,
"spRaw1": 5, "spRaw1": 50,
"spRaw2": 5, "spRaw2": 50,
"spRaw3": 5, "spRaw3": 50,
"spRaw4": 5, "spRaw4": 50,
"mr": 5, "mr": 50,
"ms": 5 "ms": 50
} }
remap_items = [] remap_items = []
@ -63,7 +64,13 @@ import math
for item in old_items: for item in old_items:
for k, v in mul_keys.items(): for k, v in mul_keys.items():
if k in item: if k in item:
item[k] = math.floor(round(item[k] * v)) # SUPER JANKY ROUNDING
tentimes = round(item[k] * v)
rem = tentimes % 10
val = math.floor(round(tentimes / 10))
if rem >= 5:
val += 1
item[k] = val
if "remapID" in item: if "remapID" in item:
remap_items.append(item) remap_items.append(item)
elif item["name"] not in known_item_names: elif item["name"] not in known_item_names: