Fix echo and bamboozle crash

and fix modify to work a bit better... TODO need actual dependency resolution for spell modification
This commit is contained in:
hppeng 2023-03-04 23:15:46 -08:00
parent 39c8357c5d
commit 645f3145f0
4 changed files with 11 additions and 7 deletions

File diff suppressed because one or more lines are too long

View file

@ -844,19 +844,22 @@ const atree_collect_spells = new (class extends ComputeNode {
continue; continue;
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;
const ret_spell = ret_spells.get(base_spell); if (target_part === null) {
// TODO: unjankify this...
if ('cost' in ret_spell) { ret_spell.cost += cost; }
if (target_part === null) {
continue; continue;
} }
if (!ret_spells.has(base_spell)) {
continue;
}
const ret_spell = ret_spells.get(base_spell);
let found_part = false; let found_part = false;
for (let part of ret_spell.parts) { // TODO: replace with Map? to avoid this linear search... idk prolly good since its not more verbose to type in json for (let part of ret_spell.parts) { // TODO: replace with Map? to avoid this linear search... idk prolly good since its not more verbose to type in json
if (part.name !== target_part) { if (part.name !== target_part) {
continue; continue;
} }
// we found the part. merge or modify it!
if ('cost' in ret_spell) { ret_spell.cost += cost; }
if ('multipliers' in effect) { if ('multipliers' in effect) {
for (const [idx, v] of effect.multipliers.entries()) { // python: enumerate() for (const [idx, v] of effect.multipliers.entries()) { // python: enumerate()

View file

@ -8578,6 +8578,7 @@ const atrees = {
{ {
"type": "add_spell_prop", "type": "add_spell_prop",
"base_spell": 8, "base_spell": 8,
"behavior": "modify",
"target_part": "Slash Damage", "target_part": "Slash Damage",
"multipliers": [ 690, 0, 0, 110, 0, 0 ] "multipliers": [ 690, 0, 0, 110, 0, 0 ]
} }

File diff suppressed because one or more lines are too long