From 1337250b07dd0e0b9ae87f5a69d5f2477dbb6db8 Mon Sep 17 00:00:00 2001 From: Egor Savkin Date: Tue, 13 Aug 2024 17:35:15 +0800 Subject: [PATCH] Continue prototype fix Signed-off-by: Egor Savkin --- static/js/shop/warnings.js | 31 +++++++++++++++++++++++-------- static/js/shop_data.js | 2 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/static/js/shop/warnings.js b/static/js/shop/warnings.js index 868187a..010c60a 100644 --- a/static/js/shop/warnings.js +++ b/static/js/shop/warnings.js @@ -52,13 +52,12 @@ const wiring_constraint = (name) => { } } -const phaser_not_fit = (data, index, counters, crate) => { +const phaser_next_card_long = (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) + (data[index+1].consumes && data[index+1].consumes.depth && data[index+1].consumes.depth >= 8.5) + ) : (nbrOccupied >= nbrHP && nbrHP > 0) } const Types = { @@ -97,10 +96,10 @@ 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." + "phaser_next_card_long": { + level: "reminder", + trigger: phaser_next_card_long, + message: "Next card may interfere with this Phaser. Consider placing a short card after this Phaser." }, "default": { level: "warning", @@ -157,6 +156,22 @@ const crate_warnings = { const nbrHPDesktop = useShopStore.getState().crate_modes.desktop.hp; return crate.crate_mode === useShopStore.getState().crate_modes.rack.id && occupied < nbrHPDesktop; } + }, + "phaser_not_fit": { + message: "Since one or more Phasers may interfere with their next cards, they may additional space, that wouldn't fit into the crate. Consider removing cards, placing short cards after Phaser(s), or choosing larger crate.", + level: "warning", + trigger: (crate, occupied) => { + const nbrHP = useShopStore.getState().crateParams(crate.crate_mode).hp; + const stacked_phasers = crate.items.filter((elem, index, data) => { + console.log(elem, index) + return (elem.name_codename === "Phaser") && ((index < data.length - 1) ? ( + (data[index + 1].consumes && data[index + 1].consumes.depth && data[index + 1].consumes.depth >= 8.5) + ) : (occupied >= nbrHP && nbrHP > 0)) + } + ).length; + console.log(stacked_phasers, occupied) + return stacked_phasers > 0 && (occupied + stacked_phasers*2 >= nbrHP) && nbrHP >0; + } } } diff --git a/static/js/shop_data.js b/static/js/shop_data.js index de6cacb..c06c62d 100644 --- a/static/js/shop_data.js +++ b/static/js/shop_data.js @@ -776,7 +776,7 @@ const shop_data = { warnings: [ "no_eem_source", "no_clk_source", - "phaser_not_fit" + "phaser_next_card_long" ], consumes: { hp: 4,