More misc fix

Bump db version (forgot to do in last commit)
Guardian angels + more shields works now
This commit is contained in:
hppeng 2022-07-04 21:39:35 -07:00
parent a24d3c402d
commit 97ea17565a
5 changed files with 21 additions and 14 deletions

View file

@ -60,6 +60,9 @@ raw_stat: {
type: "raw_stat"
toggle: Optional[bool | str] // default: false; true means create anon. toggle,
// string value means bind to (or create) named button
behavior: Optional[str] // One of: "merge", "modify". default: merge
// merge: add if exist, make new part if not exist
// modify: change existing part. do nothing if not exist
bonuses: List[stat_bonus]
}
stat_bonus: {
@ -455,7 +458,7 @@ const atree_collect_spells = new (class extends ComputeNode {
has_spell_def = true;
// replace_spell just replaces all (defined) aspects.
for (const key in effect) {
ret_spell[key] = effect[key];
ret_spell[key] = deepcopy(effect[key]);
}
}
}
@ -468,13 +471,14 @@ const atree_collect_spells = new (class extends ComputeNode {
// Already handled above.
continue;
case 'add_spell_prop': {
const { base_spell, target_part = null, cost = 0} = 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
ret_spell.cost += cost;
if (target_part === null) {
continue;
}
console.log(effect);
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
@ -500,7 +504,7 @@ const atree_collect_spells = new (class extends ComputeNode {
break;
}
}
if (!found_part) { // add part.
if (!found_part && behavior === 'merge') { // add part. if behavior is merge
let spell_part = deepcopy(effect);
spell_part.name = target_part; // has some extra fields but whatever
ret_spell.parts.push(spell_part);

View file

@ -267,16 +267,16 @@ const atrees = {
"blockers": [],
"cost": 2,
"display": {
"row": 19,
"col": 1,
"icon": "node_3"
"row": 19,
"col": 1,
"icon": "node_3"
},
"properties": {
"range": 4,
"duration": 60,
"shots": 8,
"count": 2
},
"range": 4,
"duration": 60,
"shots": 8,
"charges": 2
},
"effects": [
{
"type": "replace_spell",
@ -1192,7 +1192,7 @@ const atrees = {
"type": "add_spell_prop",
"base_spell": 4,
"target_part": "Total Damage",
"hits": { "Shield Damage": 2 }
"hits": { "Shield Damage": 2, "Single Bow": 2 }
},
{
"type": "raw_stat",
@ -1304,6 +1304,7 @@ const atrees = {
"type": "add_spell_prop",
"base_spell": 3,
"target_part": "Arrow Shield",
"behavior": "modify",
"multipliers": [40, 0, 0, 0, 0, 0]
},
{
@ -1311,6 +1312,7 @@ const atrees = {
"bonuses": [{
"type": "prop",
"abil": "Arrow Shield",
"behavior": "modify",
"name": "aoe",
"value": 1
}]

File diff suppressed because one or more lines are too long

View file

@ -610,6 +610,7 @@ class SpellDamageCalcNode extends ComputeNode {
const dam_res_keys = ['normal_min', 'normal_max', 'normal_total', 'crit_min', 'crit_max', 'crit_total'];
for (const [subpart_name, hits] of Object.entries(part.hits)) {
const subpart = spell_result_map.get(subpart_name);
if (!subpart) { continue; }
if (spell_result.type) {
if (subpart.type !== spell_result.type) {
throw "SpellCalc total subpart type mismatch";

View file

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