diff --git a/.gitignore b/.gitignore index 0f3d2f550..8771d4bfc 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ account loot-survivor.pem contracts/game_entropy/target/CACHEDIR.TAG contracts/game_entropy/target/dev/game_entropy.sierra + +scripts/stress_test.py diff --git a/ui/src/app/components/upgrade/PurchaseHealth.tsx b/ui/src/app/components/upgrade/PurchaseHealth.tsx index 658048ec9..9171f36ca 100644 --- a/ui/src/app/components/upgrade/PurchaseHealth.tsx +++ b/ui/src/app/components/upgrade/PurchaseHealth.tsx @@ -17,6 +17,7 @@ interface PurchaseHealthProps { items?: any[] ) => void; totalVitality: number; + vitBoostRemoved: number; } const PurchaseHealth = ({ @@ -25,6 +26,7 @@ const PurchaseHealth = ({ setPotionAmount, totalCharisma, upgradeHandler, + vitBoostRemoved, }: PurchaseHealthProps) => { const adventurer = useAdventurerStore((state) => state.adventurer); const prevAmountRef = useRef(0); @@ -37,7 +39,9 @@ const PurchaseHealth = ({ const maxHealth = 100 + (adventurer?.vitality ?? 0) * 10; const max = Math.min( - Math.ceil((maxHealth - (adventurer?.health ?? 0)) / 10), + Math.ceil( + (maxHealth - (adventurer?.health ?? 0) - vitBoostRemoved * 10) / 10 + ), Math.floor( (adventurer?.gold! - (upgradeTotalCost - potionAmount * potionCost)) / potionCost @@ -109,9 +113,15 @@ const PurchaseHealth = ({ Fill to Max
-

- You can only buy up to Max Health! 1 Potion = 10 Health -

+ {!vitBoostRemoved ? ( +

+ You can only buy up to Max Health! 1 Potion = 10 Health +

+ ) : ( +

+ You are removing VIT boost so max potions are lower than usual! +

+ )}
); diff --git a/ui/src/app/containers/UpgradeScreen.tsx b/ui/src/app/containers/UpgradeScreen.tsx index 99ca5d3a3..7bae7ddb9 100644 --- a/ui/src/app/containers/UpgradeScreen.tsx +++ b/ui/src/app/containers/UpgradeScreen.tsx @@ -279,34 +279,37 @@ export default function UpgradeScreen({ return upgradeTx; }; + const adventurerItems = useQueriesStore( + (state) => state.data.itemsByAdventurerQuery?.items || [] + ); + + const vitBoostRemoved = calculateVitBoostRemoved( + purchaseItems, + adventurer!, + adventurerItems + ); + + const maxHealth = Math.min(100 + totalVitality * 10, 511); + const newMaxHealth = 100 + (totalVitality - vitBoostRemoved) * 10; + const currentHealth = adventurer?.health! + selectedVitality * 10; + const healthPlusPots = Math.min( + currentHealth! + potionAmount * 10, + maxHealth + ); + const healthOverflow = healthPlusPots > newMaxHealth; + const handleSubmitUpgradeTx = async () => { renderSummary(); resetNotification(); // Handle for vitBoostRemoval - const vitBoostRemoved = calculateVitBoostRemoved( - purchaseItems, - adventurer!, - adventurerItems - ); let upgradeTx: any; - if (potionAmount > 0) { - // Check whether health + pots is within vitBoostRemoved of the maxHealth - const maxHealth = 100 + totalVitality * 10; - const newMaxHealth = 100 + (totalVitality - vitBoostRemoved) * 10; - const currentHealth = adventurer?.health! + selectedVitality * 10; - const healthPlusPots = Math.min( - currentHealth! + potionAmount * 10, - maxHealth + if (healthOverflow) { + const newUpgradeTx = handleAddUpgradeTx( + undefined, + Math.max(potionAmount - vitBoostRemoved, 0), + undefined ); - const healthOverflow = healthPlusPots > newMaxHealth; - if (healthOverflow) { - const newUpgradeTx = handleAddUpgradeTx( - undefined, - Math.max(potionAmount - vitBoostRemoved, 0), - undefined - ); - upgradeTx = newUpgradeTx; - } + upgradeTx = newUpgradeTx; } try { await upgrade( @@ -345,8 +348,6 @@ export default function UpgradeScreen({ const totalStatUpgrades = (adventurer?.statUpgrades ?? 0) - upgradesTotal; - const maxHealth = Math.min(100 + totalVitality * 10, 720); - const healthPlus = Math.min( (selectedVitality + potionAmount) * 10, maxHealth - (adventurer?.health ?? 0) @@ -371,9 +372,11 @@ export default function UpgradeScreen({ getNoBoostedStats(); }, []); - const adventurerItems = useQueriesStore( - (state) => state.data.itemsByAdventurerQuery?.items || [] - ); + useEffect(() => { + if (healthOverflow) { + setPotionAmount(Math.max(potionAmount - vitBoostRemoved, 0)); + } + }, [newMaxHealth]); return ( <> @@ -538,6 +541,7 @@ export default function UpgradeScreen({ totalCharisma={totalCharisma} upgradeHandler={handleAddUpgradeTx} totalVitality={totalVitality} + vitBoostRemoved={vitBoostRemoved} /> )}