diff --git a/static/js/shop/shop_store.js b/static/js/shop/shop_store.js index d02e9fd..14d9cce 100644 --- a/static/js/shop/shop_store.js +++ b/static/js/shop/shop_store.js @@ -480,7 +480,7 @@ const useCart = ((set, get) => ({ let itemsCopy = Array.from(crate.items); const disabled = !!get().crateParams(crate.crate_mode).warnings_disabled; itemsCopy = FillResources(itemsCopy, disabled); - itemsCopy = TriggerWarnings(itemsCopy, disabled); + itemsCopy = TriggerWarnings(itemsCopy, disabled, crate); const [crate_warnings, occupied] = TriggerCrateWarnings(crate); return { ...crate, diff --git a/static/js/shop/warnings.js b/static/js/shop/warnings.js index 7562c23..868187a 100644 --- a/static/js/shop/warnings.js +++ b/static/js/shop/warnings.js @@ -30,14 +30,14 @@ const find_next_source_index = (data, index, source) => { } const not_enough_resource_trigger = (name) => { - return (_data, _index, counters) => { + return (_data, _index, counters, _crate) => { const resource = find_in_counters(counters, name); return resource.occupied > resource.max; } } const no_source_trigger = (name) => { - return (data, index, _counters) => { + return (data, index, _counters, _crate) => { const occupied = item_occupied_counters[name](data[index]); if (occupied > 0) return !find_previous_source(data, index, name); @@ -46,12 +46,21 @@ const no_source_trigger = (name) => { } const wiring_constraint = (name) => { - return (data, index, _counters) => { + return (data, index, _counters, _crate) => { const next = find_next_source_index(data, index, name); return next - index === 1; } } +const phaser_not_fit = (data, index, counters, crate) => { + const nbrOccupied = resource_counters.hp(crate.items, -1); + const nbrHP = useShopStore.getState().crateParams(crate.crate_mode).hp; + console.log(data, index, counters, crate) + return (index < data.length - 1) ? ( + (data[index+1].consumes && data[index+1].consumes.depth && data[index+1].consumes.depth >= 8.5 && nbrOccupied >= nbrHP && nbrHP > 0) + ) : (nbrOccupied >= nbrHP-2 && nbrHP > 0) +} + const Types = { "eem_resource": { level: "warning", @@ -88,22 +97,27 @@ const Types = { trigger: wiring_constraint("eem"), message: "Due to wiring constraints, the carrier can only connect to EEM cards immediately at its right, without crossing another carrier." }, + "phaser_not_fit": { + level: "warning", + trigger: phaser_not_fit, + message: "PHASER." + }, "default": { level: "warning", - trigger: (_a, _b, _c) => { + trigger: (_a, _b, _c, _d) => { return true; }, message: 'This item has unimplemented warning' } } -export function TriggerWarnings(data, disabled) { +export function TriggerWarnings(data, disabled, crate) { return data.map((element, index) => { if (!element.warnings) return element; element.show_warnings = disabled ? [] :element.warnings .map((warning, _) => { if (!!Types[warning]) - return Types[warning].trigger(data, index, element.counted_resources) ? {trigger: undefined, name: warning, ...Types[warning]} : null; + return Types[warning].trigger(data, index, element.counted_resources, crate) ? {trigger: undefined, name: warning, ...Types[warning]} : null; else return Types.default; }) diff --git a/static/js/shop_data.js b/static/js/shop_data.js index e81aa36..de6cacb 100644 --- a/static/js/shop_data.js +++ b/static/js/shop_data.js @@ -221,7 +221,8 @@ const shop_data = { "eem_wiring_constraint" ], consumes: { - hp: 8 + hp: 8, + depth: 20 } }, 'kaslisoc': { @@ -297,7 +298,8 @@ const shop_data = { "eem_wiring_constraint" ], consumes: { - hp: 8 + hp: 8, + depth: 20 } }, 'vhdcicarrier': { @@ -322,7 +324,8 @@ const shop_data = { "eem_wiring_constraint" ], consumes: { - hp: 8 + hp: 8, + depth: 16 } }, 'bnc-dio': { @@ -393,7 +396,8 @@ const shop_data = { ], consumes: { hp: 8, - eem: 1 + eem: 1, + depth: 7 } }, 'sma-dio': { @@ -458,7 +462,8 @@ const shop_data = { ], consumes: { hp: 4, - eem: 1 + eem: 1, + depth: 7 } }, 'mcx-dio': { @@ -549,7 +554,8 @@ const shop_data = { ], consumes: { hp: 4, - eem: 2 + eem: 2, + depth: 23 } }, 'rj45-dio': { @@ -635,7 +641,8 @@ const shop_data = { ], consumes: { hp: 4, - eem: 2 + eem: 2, + depth: 7 } }, 'urukul': { @@ -700,7 +707,8 @@ const shop_data = { consumes: { hp: 4, eem: 2, - clk: 1 + clk: 1, + depth: 16 } }, 'urukul_4412': { @@ -738,7 +746,8 @@ const shop_data = { consumes: { hp: 4, eem: 2, - clk: 1 + clk: 1, + depth: 16 } }, 'phaser': { @@ -766,12 +775,14 @@ const shop_data = { size: 'small', warnings: [ "no_eem_source", - "no_clk_source" + "no_clk_source", + "phaser_not_fit" ], consumes: { hp: 4, eem: 1, - clk: 1 + clk: 1, + depth: 16 // heatsink 8.5 } }, 'zotino': { @@ -813,7 +824,8 @@ const shop_data = { consumes: { hp: 4, eem: 1, - tec: 1 + tec: 1, + depth: 16 }, resources: [ {name: "idc", max: 4} @@ -841,7 +853,8 @@ const shop_data = { ], consumes: { hp: 4, - eem: 1 + eem: 1, + depth: 17 }, resources: [ {name: "idc", max: 4} @@ -865,7 +878,8 @@ const shop_data = { ], consumes: { hp: 8, - idc: 1 + idc: 1, + depth: 6 } }, 'hvamp32': { @@ -902,7 +916,8 @@ const shop_data = { ], consumes: { hp: 4, - idc: 4 + idc: 4, + depth: 16 } }, 'idc-sma-adapter': { @@ -923,7 +938,8 @@ const shop_data = { ], consumes: { hp: 4, - idc: 1 + idc: 1, + depth: 6 } }, 'hd68-idc-adapter': { @@ -945,7 +961,8 @@ const shop_data = { "idc_resource" ], consumes: { - hp: 4 + hp: 4, + depth: 5 }, resources: [ {name: "idc", max: 4} @@ -998,7 +1015,8 @@ const shop_data = { ], consumes: { hp: 8, - eem: 2 + eem: 2, + depth: 16 } }, 'koster': { @@ -1024,7 +1042,8 @@ const shop_data = { ], consumes: { hp: 4, - eem: 2 + eem: 2, + depth: 7.5 } }, 'clocker': { @@ -1055,7 +1074,8 @@ const shop_data = { consumes: { hp: 4, eem: 1, - clk: 1 + clk: 1, + depth: 7 }, resources: [ {name: "clk", max: 6} @@ -1092,7 +1112,8 @@ const shop_data = { ], consumes: { hp: 4, - eem: 1 + eem: 1, + depth: 16 }, }, 'fast_servo': { @@ -1126,7 +1147,8 @@ const shop_data = { ], consumes: { hp: 4, - eem: 1 + eem: 1, + depth: 16 }, }, 'mirny': { @@ -1157,7 +1179,8 @@ const shop_data = { consumes: { hp: 4, eem: 1, - clk: 1 + clk: 1, + depth: 16 }, }, 'almazny': { @@ -1185,7 +1208,8 @@ const shop_data = { consumes: { hp: 8, eem: 1, - clk: 1 + clk: 1, + depth: 16 }, }, 'thermostat-eem': { @@ -1213,6 +1237,7 @@ const shop_data = { consumes: { hp: 4, eem: 1, + depth: 16 } }, 'thermostat2ch': { @@ -1231,7 +1256,8 @@ const shop_data = { ], size: 'small', consumes: { - hp: 4 + hp: 4, + depth: 12 }, resources: [ {name: "tec", max: 2} @@ -1260,7 +1286,8 @@ const shop_data = { consumes: { hp: 8, eem: 1, - clk: 1 + clk: 1, + depth: 8 }, }, 'pounder': { @@ -1294,7 +1321,8 @@ const shop_data = { consumes: { hp: 8, eem: 1, - clk: 1 + clk: 1, + depth: 16 } }, 'eem_pwr_mod': { @@ -1319,6 +1347,7 @@ const shop_data = { warnings: [], consumes: { hp: 8, + depth: 20 }, }, 'kirdy': { @@ -1350,6 +1379,7 @@ const shop_data = { warnings: [], consumes: { hp: 8, + depth: 16 }, }, },