Add some stamina upgrades.
This commit is contained in:
parent
453910282a
commit
9ada074b12
|
|
@ -115,6 +115,7 @@ const TempleComponent: React.FC = () => {
|
||||||
pray,
|
pray,
|
||||||
piety,
|
piety,
|
||||||
stamina,
|
stamina,
|
||||||
|
milestones,
|
||||||
} = useGameStore()
|
} = useGameStore()
|
||||||
|
|
||||||
const handlePurchase = (upgradeId: string) => {
|
const handlePurchase = (upgradeId: string) => {
|
||||||
|
|
@ -136,44 +137,13 @@ const TempleComponent: React.FC = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if can afford
|
// Check if can afford
|
||||||
if (!canAffordUpgrade(upgrade.cost)) {
|
return canAffordUpgrade(upgrade.cost)
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check requirements
|
|
||||||
if (
|
|
||||||
upgrade.id === 'aqueous_vigor_2' &&
|
|
||||||
!purchasedUpgrades.includes('aqueous_vigor_1')
|
|
||||||
) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
upgrade.id === 'aqua_diffundere_2' &&
|
|
||||||
!purchasedUpgrades.includes('aqua_diffundere_1')
|
|
||||||
) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const getUpgradeStatus = (upgrade: Upgrade) => {
|
const getUpgradeStatus = (upgrade: Upgrade) => {
|
||||||
if (purchasedUpgrades.includes(upgrade.id)) {
|
if (purchasedUpgrades.includes(upgrade.id)) {
|
||||||
return 'Purchased'
|
return 'Purchased'
|
||||||
}
|
}
|
||||||
if (
|
|
||||||
upgrade.id === 'aqueous_vigor_2' &&
|
|
||||||
!purchasedUpgrades.includes('aqueous_vigor_1')
|
|
||||||
) {
|
|
||||||
return 'Requires Aqueous Vigor I'
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
upgrade.id === 'aqua_diffundere_2' &&
|
|
||||||
!purchasedUpgrades.includes('aqua_diffundere_1')
|
|
||||||
) {
|
|
||||||
return 'Requires Aqua Diffundere I'
|
|
||||||
}
|
|
||||||
if (!canAffordUpgrade(upgrade.cost)) {
|
if (!canAffordUpgrade(upgrade.cost)) {
|
||||||
return 'Cannot Afford'
|
return 'Cannot Afford'
|
||||||
}
|
}
|
||||||
|
|
@ -193,35 +163,37 @@ const TempleComponent: React.FC = () => {
|
||||||
</PrayerSection>
|
</PrayerSection>
|
||||||
|
|
||||||
<UpgradesGrid>
|
<UpgradesGrid>
|
||||||
{Object.values(UPGRADES).map((upgrade) => {
|
{Object.values(UPGRADES)
|
||||||
const isPurchased = purchasedUpgrades.includes(upgrade.id)
|
.filter(upgrade => !upgrade.isAvailable || upgrade.isAvailable({ purchasedUpgrades, milestones }))
|
||||||
const canPurchase = canPurchaseUpgrade(upgrade)
|
.map((upgrade) => {
|
||||||
const status = getUpgradeStatus(upgrade)
|
const isPurchased = purchasedUpgrades.includes(upgrade.id)
|
||||||
|
const canPurchase = canPurchaseUpgrade(upgrade)
|
||||||
|
const status = getUpgradeStatus(upgrade)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UpgradeCard key={upgrade.id} purchased={isPurchased}>
|
<UpgradeCard key={upgrade.id} purchased={isPurchased}>
|
||||||
<UpgradeName>{upgrade.name}</UpgradeName>
|
<UpgradeName>{upgrade.name}</UpgradeName>
|
||||||
<UpgradeDescription>{upgrade.description}</UpgradeDescription>
|
<UpgradeDescription>{upgrade.description}</UpgradeDescription>
|
||||||
<UpgradeCost>
|
<UpgradeCost>
|
||||||
<span>Cost:</span>
|
<span>Cost:</span>
|
||||||
{upgrade.cost.map((cost, index) => (
|
{upgrade.cost.map((cost, index) => (
|
||||||
<CostItem key={index}>
|
<CostItem key={index}>
|
||||||
<span>
|
<span>
|
||||||
{cost.amount} {cost.itemId}
|
{cost.amount} {cost.itemId}
|
||||||
</span>
|
</span>
|
||||||
<span>(You have: {inventory[cost.itemId] || 0})</span>
|
<span>(You have: {inventory[cost.itemId] || 0})</span>
|
||||||
</CostItem>
|
</CostItem>
|
||||||
))}
|
))}
|
||||||
</UpgradeCost>
|
</UpgradeCost>
|
||||||
<PurchaseButton
|
<PurchaseButton
|
||||||
onClick={() => handlePurchase(upgrade.id)}
|
onClick={() => handlePurchase(upgrade.id)}
|
||||||
disabled={!canPurchase}
|
disabled={!canPurchase}
|
||||||
>
|
>
|
||||||
{status}
|
{status}
|
||||||
</PurchaseButton>
|
</PurchaseButton>
|
||||||
</UpgradeCard>
|
</UpgradeCard>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</UpgradesGrid>
|
</UpgradesGrid>
|
||||||
</TempleContainer>
|
</TempleContainer>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ export const CROPS: CropDefinitions = {
|
||||||
celery: {
|
celery: {
|
||||||
id: 'celery',
|
id: 'celery',
|
||||||
name: 'Celery',
|
name: 'Celery',
|
||||||
growthTicks: 36,
|
growthTicks: 10,
|
||||||
waterPerTick: 1 / 20,
|
waterPerTick: 1 / 5,
|
||||||
yield: 1,
|
yield: 1,
|
||||||
yieldType: 'celery',
|
yieldType: 'celery',
|
||||||
fertilityDepletion: 0.1,
|
fertilityDepletion: 0.1,
|
||||||
|
|
@ -65,6 +65,50 @@ export const INITIAL_INVENTORY = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const UPGRADES: Record<string, Upgrade> = {
|
export const UPGRADES: Record<string, Upgrade> = {
|
||||||
|
stamina_1: {
|
||||||
|
id: 'stamina_1',
|
||||||
|
name: 'Stamina I',
|
||||||
|
description: 'Increases maximum stamina by 5',
|
||||||
|
cost: [
|
||||||
|
{
|
||||||
|
itemId: 'celery',
|
||||||
|
amount: 20,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
stamina_2: {
|
||||||
|
id: 'stamina_2',
|
||||||
|
name: 'Stamina II',
|
||||||
|
description: 'Increases maximum stamina by 8',
|
||||||
|
cost: [
|
||||||
|
{
|
||||||
|
itemId: 'corn',
|
||||||
|
amount: 20,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
stamina_3: {
|
||||||
|
id: 'stamina_3',
|
||||||
|
name: 'Stamina III',
|
||||||
|
description: 'Increases maximum stamina by 12',
|
||||||
|
cost: [
|
||||||
|
{
|
||||||
|
itemId: 'olives',
|
||||||
|
amount: 100,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
stamina_4: {
|
||||||
|
id: 'stamina_4',
|
||||||
|
name: 'Stamina IV',
|
||||||
|
description: 'Increases maximum stamina by 15',
|
||||||
|
cost: [
|
||||||
|
{
|
||||||
|
itemId: 'grapes',
|
||||||
|
amount: 100,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
aqueous_vigor_1: {
|
aqueous_vigor_1: {
|
||||||
id: 'aqueous_vigor_1',
|
id: 'aqueous_vigor_1',
|
||||||
name: 'Aqueous Vigor I',
|
name: 'Aqueous Vigor I',
|
||||||
|
|
|
||||||
|
|
@ -505,6 +505,21 @@ export const useGameStore = create<
|
||||||
})
|
})
|
||||||
state.purchasedUpgrades.push(upgradeId)
|
state.purchasedUpgrades.push(upgradeId)
|
||||||
addConsoleMessage(state, `Purchased upgrade: ${upgrade.name}`)
|
addConsoleMessage(state, `Purchased upgrade: ${upgrade.name}`)
|
||||||
|
|
||||||
|
// Handle stamina upgrades
|
||||||
|
if (upgradeId === 'stamina_1') {
|
||||||
|
state.maxStamina += 5
|
||||||
|
state.stamina = Math.min(state.maxStamina, state.stamina + 5)
|
||||||
|
} else if (upgradeId === 'stamina_2') {
|
||||||
|
state.maxStamina += 8
|
||||||
|
state.stamina = Math.min(state.maxStamina, state.stamina + 8)
|
||||||
|
} else if (upgradeId === 'stamina_3') {
|
||||||
|
state.maxStamina += 12
|
||||||
|
state.stamina = Math.min(state.maxStamina, state.stamina + 12)
|
||||||
|
} else if (upgradeId === 'stamina_4') {
|
||||||
|
state.maxStamina += 15
|
||||||
|
state.stamina = Math.min(state.maxStamina, state.stamina + 15)
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ export interface Upgrade {
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
cost: UpgradeCost[]
|
cost: UpgradeCost[]
|
||||||
|
isAvailable?: (state: Pick<GameState, 'purchasedUpgrades' | 'milestones'>) => boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Recipe {
|
export interface Recipe {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue