More setup for sliders/raw stat; fix defMultiplier (base def not fixed yet)
we should really unify the multiplicative effect checking -- this is kinda stupid
This commit is contained in:
parent
3ff4421de4
commit
a28c75e177
5 changed files with 35 additions and 97 deletions
29
js/atree.js
29
js/atree.js
|
@ -176,6 +176,7 @@ const atree_node = new (class extends ComputeNode {
|
|||
|
||||
/**
|
||||
* Create a reverse topological sort of the tree in the result list.
|
||||
* NOTE: our structure isn't a tree... it isn't even acyclic... but do it anyway i guess...
|
||||
*
|
||||
* https://en.wikipedia.org/wiki/Topological_sorting
|
||||
* @param tree: Root of tree to sort
|
||||
|
@ -576,8 +577,6 @@ const atree_make_interactives = new (class extends ComputeNode {
|
|||
const atree_order = input_map.get('atree-order');
|
||||
const atree_html = input_map.get('atree-elements');
|
||||
|
||||
const ret_states = [];
|
||||
|
||||
/**
|
||||
* slider_info {
|
||||
* label_name: str,
|
||||
|
@ -617,7 +616,7 @@ const atree_make_interactives = new (class extends ComputeNode {
|
|||
let slider_container = gen_slider_labeled(slider_info);
|
||||
atree_html.get(slider_info.abil.id).appendChild(slider_container);
|
||||
}
|
||||
return ret_states;
|
||||
//return ret_states;
|
||||
}
|
||||
})().link_to(atree_node, 'atree-order').link_to(atree_merge, 'atree-merged').link_to(atree_render_active, 'atree-elements');
|
||||
|
||||
|
@ -632,8 +631,8 @@ 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
|
||||
const atree_merged = input_map.get('atree-merged');
|
||||
const item_stats = input_map.get('build').statMap;
|
||||
|
||||
let ret_effects = new Map();
|
||||
for (const [abil_id, abil] of atree_merged.entries()) {
|
||||
|
@ -642,7 +641,19 @@ const atree_stats = new (class extends ComputeNode {
|
|||
for (const effect of abil.effects) {
|
||||
switch (effect.type) {
|
||||
case 'stat_scaling':
|
||||
// TODO: handle
|
||||
if (effect.slider) {
|
||||
// TODO: handle
|
||||
}
|
||||
else {
|
||||
const cap = effect.max;
|
||||
// TODO: type: prop?
|
||||
let total = 0;
|
||||
for (const [scaling, input] of zip2(effect.scaling, effect.inputs)) {
|
||||
total += scaling * item_stats.get(input.name);
|
||||
}
|
||||
if (total > cap) { total = cap; }
|
||||
// TODO: output (list...)
|
||||
}
|
||||
continue;
|
||||
case 'raw_stat':
|
||||
// TODO: toggles...
|
||||
|
@ -650,7 +661,11 @@ const atree_stats = new (class extends ComputeNode {
|
|||
const { type, name, abil = "", value } = bonus;
|
||||
// TODO: prop
|
||||
if (type === "stat") {
|
||||
if (ret_effects.has(name)) { ret_effects.set(name, ret_effects.get(name) + value); }
|
||||
if (ret_effects.has(name)) {
|
||||
if (name === 'damageMultiplier' || name === 'defMultiplier') {
|
||||
ret_effects.set(name, ret_effects.get(name) * value);
|
||||
}
|
||||
else { ret_effects.set(name, ret_effects.get(name) + value); }
|
||||
else { ret_effects.set(name, value); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1875,6 +1875,7 @@ const atrees = {
|
|||
"desc": "Condense Arrow Storm into a single ray that damages enemies 10 times per second",
|
||||
"archetype": "Sharpshooter",
|
||||
"archetype_req": 0,
|
||||
"base_abil": "Arrow Storm",
|
||||
"parents": ["Water Mastery", "Fire Creep"],
|
||||
"dependencies": ["Arrow Storm"],
|
||||
"blockers": ["Windstorm", "Nimble String", "Arrow Hurricane"],
|
||||
|
@ -2774,7 +2775,7 @@ const atrees = {
|
|||
{
|
||||
"type": "raw_stat",
|
||||
"toggle": true,
|
||||
"bonuses": [{ "type": "stat", "name": "defPct", "value": 70}]
|
||||
"bonuses": [{ "type": "stat", "name": "defMultiplier", "value": 0.3}]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -3919,7 +3920,13 @@ const atrees = {
|
|||
"icon": "node_2"
|
||||
},
|
||||
"properties": {},
|
||||
"effects": []
|
||||
"effects": [
|
||||
{
|
||||
"type": "raw_stat",
|
||||
"toggle": true,
|
||||
"bonuses": [{ "type": "stat", "name": "defMultiplier", "value": 0.6}]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
|
|
File diff suppressed because one or more lines are too long
89
js/build.js
89
js/build.js
|
@ -2,94 +2,9 @@
|
|||
|
||||
const classDefenseMultipliers = new Map([ ["relik",0.50], ["bow",0.60], ["wand", 0.80], ["dagger", 1.0], ["spear",1.20], ["sword", 1.10]]);
|
||||
|
||||
/**
|
||||
* @description Error to catch items that don't exist.
|
||||
* @module ItemNotFound
|
||||
/*
|
||||
* Class that represents a wynn player's build.
|
||||
*/
|
||||
class ItemNotFound {
|
||||
/**
|
||||
* @class
|
||||
* @param {String} item the item name entered
|
||||
* @param {String} type the type of item
|
||||
* @param {Boolean} genElement whether to generate an element from inputs
|
||||
* @param {String} override override for item type
|
||||
*/
|
||||
constructor(item, type, genElement, override) {
|
||||
/**
|
||||
* @public
|
||||
* @type {String}
|
||||
*/
|
||||
this.message = `Cannot find ${override||type} named ${item}`;
|
||||
if (genElement)
|
||||
/**
|
||||
* @public
|
||||
* @type {Element}
|
||||
*/
|
||||
this.element = document.getElementById(`${type}-choice`).parentElement.querySelectorAll("p.error")[0];
|
||||
else
|
||||
this.element = document.createElement("div");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Error to catch incorrect input.
|
||||
* @module IncorrectInput
|
||||
*/
|
||||
class IncorrectInput {
|
||||
/**
|
||||
* @class
|
||||
* @param {String} input the inputted text
|
||||
* @param {String} format the correct format
|
||||
* @param {String} sibling the id of the error node's sibling
|
||||
*/
|
||||
constructor(input, format, sibling) {
|
||||
/**
|
||||
* @public
|
||||
* @type {String}
|
||||
*/
|
||||
this.message = `${input} is incorrect. Example: ${format}`;
|
||||
/**
|
||||
* @public
|
||||
* @type {String}
|
||||
*/
|
||||
this.id = sibling;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Error that inputs an array of items to generate errors of.
|
||||
* @module ListError
|
||||
* @extends Error
|
||||
*/
|
||||
class ListError extends Error {
|
||||
/**
|
||||
* @class
|
||||
* @param {Array} errors array of errors
|
||||
*/
|
||||
constructor(errors) {
|
||||
let ret = [];
|
||||
if (typeof errors[0] == "string") {
|
||||
super(errors[0]);
|
||||
} else {
|
||||
super(errors[0].message);
|
||||
}
|
||||
for (let i of errors) {
|
||||
if (typeof i == "string") {
|
||||
ret.push(new Error(i));
|
||||
} else {
|
||||
ret.push(i);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
* @type {Object[]}
|
||||
*/
|
||||
this.errors = ret;
|
||||
}
|
||||
}
|
||||
|
||||
/*Class that represents a wynn player's build.
|
||||
*/
|
||||
class Build{
|
||||
|
||||
/**
|
||||
|
|
|
@ -1084,6 +1084,7 @@ function builder_graph_init() {
|
|||
atree_merge.link_to(build_node, 'build');
|
||||
atree_graph_creator = new AbilityTreeEnsureNodesNode(build_node, stat_agg_node)
|
||||
.link_to(atree_collect_spells, 'spells');
|
||||
atree_stats.link_to(build_node, 'build');
|
||||
stat_agg_node.link_to(atree_stats, 'atree-stats');
|
||||
|
||||
build_encode_node.link_to(atree_node, 'atree').link_to(atree_state_node, 'atree-state');
|
||||
|
|
Loading…
Add table
Reference in a new issue