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" type: "raw_stat"
toggle: Optional[bool | str] // default: false; true means create anon. toggle, toggle: Optional[bool | str] // default: false; true means create anon. toggle,
// string value means bind to (or create) named button // 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] bonuses: List[stat_bonus]
} }
stat_bonus: { stat_bonus: {
@ -455,7 +458,7 @@ const atree_collect_spells = new (class extends ComputeNode {
has_spell_def = true; has_spell_def = true;
// replace_spell just replaces all (defined) aspects. // replace_spell just replaces all (defined) aspects.
for (const key in effect) { 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. // Already handled above.
continue; continue;
case 'add_spell_prop': { 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 if (base_spell !== base_spell_id) { continue; } // TODO: redundant? if we assume abils only affect one spell
ret_spell.cost += cost; ret_spell.cost += cost;
if (target_part === null) { if (target_part === null) {
continue; continue;
} }
console.log(effect);
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
@ -500,7 +504,7 @@ const atree_collect_spells = new (class extends ComputeNode {
break; break;
} }
} }
if (!found_part) { // add part. if (!found_part && behavior === 'merge') { // add part. if behavior is merge
let spell_part = deepcopy(effect); let spell_part = deepcopy(effect);
spell_part.name = target_part; // has some extra fields but whatever spell_part.name = target_part; // has some extra fields but whatever
ret_spell.parts.push(spell_part); ret_spell.parts.push(spell_part);

View file

@ -267,16 +267,16 @@ const atrees = {
"blockers": [], "blockers": [],
"cost": 2, "cost": 2,
"display": { "display": {
"row": 19, "row": 19,
"col": 1, "col": 1,
"icon": "node_3" "icon": "node_3"
}, },
"properties": { "properties": {
"range": 4, "range": 4,
"duration": 60, "duration": 60,
"shots": 8, "shots": 8,
"count": 2 "charges": 2
}, },
"effects": [ "effects": [
{ {
"type": "replace_spell", "type": "replace_spell",
@ -1192,7 +1192,7 @@ const atrees = {
"type": "add_spell_prop", "type": "add_spell_prop",
"base_spell": 4, "base_spell": 4,
"target_part": "Total Damage", "target_part": "Total Damage",
"hits": { "Shield Damage": 2 } "hits": { "Shield Damage": 2, "Single Bow": 2 }
}, },
{ {
"type": "raw_stat", "type": "raw_stat",
@ -1304,6 +1304,7 @@ const atrees = {
"type": "add_spell_prop", "type": "add_spell_prop",
"base_spell": 3, "base_spell": 3,
"target_part": "Arrow Shield", "target_part": "Arrow Shield",
"behavior": "modify",
"multipliers": [40, 0, 0, 0, 0, 0] "multipliers": [40, 0, 0, 0, 0, 0]
}, },
{ {
@ -1311,6 +1312,7 @@ const atrees = {
"bonuses": [{ "bonuses": [{
"type": "prop", "type": "prop",
"abil": "Arrow Shield", "abil": "Arrow Shield",
"behavior": "modify",
"name": "aoe", "name": "aoe",
"value": 1 "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']; 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)) { for (const [subpart_name, hits] of Object.entries(part.hits)) {
const subpart = spell_result_map.get(subpart_name); const subpart = spell_result_map.get(subpart_name);
if (!subpart) { continue; }
if (spell_result.type) { if (spell_result.type) {
if (subpart.type !== spell_result.type) { if (subpart.type !== spell_result.type) {
throw "SpellCalc total subpart type mismatch"; 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 // @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.jsA
let db; let db;