,,{(set: $hp to 10)
(set: $potion_Health to 3)
(set: $days to 0)
(set: $restock_Potionsss to 1)
(set: $restock_FHP to 7)
(set: $restock_IP to (random:3,5))
(set: $stock_Potions to 3)
(set: $otherPotionsExist to false)
(set: $stock_FHP to 1)
(set: $stock_IP to 1)
(set: $coins to 0)
(set: $fight to false)
(set: $invincible to false)
(set: $midBattle to false)
(set: $streak to 0)
(set: $monstersDefeated to 0)
}(display: "main"){(if: $fight is false)[You are an adventurer and you're here to fight monsters!](if: $defeat is true)[You return to camp exhausted and beat up.(set: $defeat to false) ](else-if: $flee is true)[You turn tail and run back to camp. (set: $flee to false)You sleep through the whole night.](else-if: $rest is true)[You return to camp and rest for the night. (set: $hp to 10)(set: $rest to false)](set: $spoils to 0)}
(if: $hp < 7)[[[rest up|rest]]
[[buy potions|Potions Merchant]]
[[onward!->start adventure]]](else:)[[[onward!->start adventure]]
[[rest]]
[[buy potions|Potions Merchant]]]
(if: $hp is 10)[You don't need to rest.](else:)[(set: $hp to 10) (set: $days to $days + 1)
You sleep through the night and feel refreshed. You have $hp hp.]
[[back to camp|main]]
[[onward!|start adventure]]
A monster appears! (set: $monster_hp to (random:3,6))
[[fight]]
[(link: "flee")[(text-colour:red)[Warning:] if you flee now, you will lose $spoils coins.
[[flee anyway|flee]]]]
{(set: $fight to true)(set: $midBattle to true)}(if: (random: 0,5) < 3)
[The monster bites you! (either: "Ouch.","Yikes.","Oof.")(set: $hp to it - (either: 1, 2, 3))
(if: $hp < 1)[Your wounds are grievous and you are dying!
[[Quick, use a potion|dead]]](else:)[(either: "That hurt.","That's not ideal.","Why are you doing this, again?") Your health is $hp.
[[fight]]
(link: "flee")[(text-colour:red)[Warning:] if you flee now, you will lose $spoils coins.
[[flee anyway|flee]]]]
(if: $otherPotionsExist is true and $potion_Invincibility > 0)[[[use an invincibility potion]]]](else:)[You hit the monster! (print:(either: "Great work!","Right on!","That'll show 'em!"))(set:$monster_hp to it - 1)
(if: $monster_hp < 1)[The monster is dead!
(display:"monster is dead")](else:)[Its health is $monster_hp.
[[fight]]
[(link: "flee")[(text-colour:red)[Warning:] if you flee now, you will lose $spoils coins.
[[flee anyway|flee]]]]]
{}
{(if: $potion_Invincibility > 0)[[[use an invincibility potion]]]}]
(set: $midBattle to true)(if: $potion_Health <= 0)[
[You have no potions left. It's the end for you.
[[restart?|init]]]](else:)[(set: $use_Potion to true)(display: "use a potion")]
{(set: $streak to $streak + 1)(set: $monstersDefeated to it + $streak)
(set: $drop to (random: 3,10) * $streak)}You collect $drop coins from the monster carcass. You have $potion_Health health potions and $hp hp left. You've killed $streak monster(if: not($streak is 1))[s] and earned (set: $spoils to $spoils + $drop)$spoils coins today.
[[continue|monster battle]]
[[head home to rest|collect spoils]]
(if: $potion_Health > 0)[(if: $hp < 10)[(link: "use a potion")[(set: $use_Potion to true)(display: "use a potion")]]](rerun:?stats){(set: $spoils to 0) (set: $streak to 0)(set: $fight to true)}(display: "monster battle"){(set: $coins to $coins + $spoils)
(set: $hp to 10) (set: $days to $days + 1)(set: $rest to true)}
(display: "main")(if: $use_Potion is true)[(set: $potion_Health to it - 1)(set: $hp to $hp + (random:3,7))(if: $hp >= 10)[(set: $hp to 10) The potion restores you to full health.](else:)[The potion heals some of your wounds.
You have $hp hp.
(if: $midBattle is true and $use_Potion is true)[[[keep fighting|fight]]
(link:"flee with your life")
[Warning:(change: "Warning:", (text-colour: red) + (text-style:'bold')) you will lose $spoils coins if you return home now.
[[flee anyway|defeated]] (set: $midBattle to false)(set: $use_Potion to false)
]]]
(if: $otherPotionsExist is true)[[[use an invincibility potion]]]]{
}(if: $use_FHP is true)[(set: $potion_FullHealth to it - 1)(set: $hp to 12)The potion restores you to full health. You feel invigorated.]{
}(if: $midBattle is true and $use_FHP is true)[[[keep fighting|fight]]
(link: "retreat")[(text-colour:red)[Warning:] if you flee now, you will lose $spoils coins.
[[retreat anyway|defeated]]](set: $midBattle to false)(set: $use_FHP to false)]{
}(if: $use_IP is true)[(set: $potion_Invincibility to it - 1)(set: $invincible to true)You feel a mighty power coursing through your veins.(set: $use_IP to false)
[[back to battle!|fight]]]{(rerun:?stats)}
{(set: $defeat to true)(set: $days to it + 1)}
(display: "main"){(set: $flee to true)(set: $days to it + 1)}
(display: 'main')The merchant has (set: $stock_Potionsss to $stock_Potionsss + $days) $stock_Potionsss potions available for 15 coins each. You have $potion_Health (unless: $potion_Health is 1)[potion](else:)[potions] and $coins coins.(set: $days to 0)
(link-rerun: "buy a health potion")[<br>(if: $stock_Potionsss is <= 0)[The merchant is out of stock. Come back tomorrow.] (else-if: $coins - 15 < 0)[You don't have enough coins.] (else:)[(set: $coins to it - 15)(set: $potion_Health to it + 1)(set: $stock_Potionsss to it - 1)You buy a potion. You have $coins coins and $potion_Health health potions. The merchant has $stock_Potionsss potions remaining.(rerun:?stats)]]
(link-rerun: "buy a full-health potion")[<br>(if: $stock_FHP is <= 0)[The merchant is out of stock. Come back tomorrow.] (else-if: $coins - 15 < 0)[You don't have enough coins.] (else:)[(set: $coins to it - 15)(set: $potion_Health to it + 1)(set: $stock_Potionsss to it - 1)You buy a potion. You have $coins coins and $potion_Health health potions. The merchant has $stock_Potionsss potions remaining.(rerun:?stats)]]
[[onward!|start adventure]]
[[back to camp|main]]
[ ''HP:'' $hp | ''Coins:'' (print: $spoils + $coins) | ''Health Potions:'' $potion_Health(if: $otherPotionsExist is true)[ | ''Full-health Potions:'' $potion_FullHealth | ''Invincibility Potions:'' $potion_Invincibility]]<stats|
{(if: $days > $restock_Potions)[(set: $stock_Potions to it + 1)(set: $restock_Potions to it + 1)]
(if: $days > $restock_FHP)[(set: $stock_FHP to it + 1)(set: $restock_FHP to it + 7)]
(if: $days > $restock_IP)[(set: $stock_IP to it + 1)(set: $restock_IP to it + (random:3,5))]}
$potion_Health Heals between 3-7 HP
Restock var: $days
$potion_FullHealth Heals to full health and adjusts temporary max health to 12.
Restock var: $restock_FHP
$potion_Invincibility Makes the player invulnerable to attacks for one turn. Turns on the "$\invincible" status.
Restock var: $restock_IP (restocks randomly between 3-5 days)
The merchant displays their wares to you.
---
''Merchant's Stock:''
(link-rerun: "buy a health potion")[
(if: $stock_Potions < 1)[''Out of stock.''](else-if: $coins - 15 < 0)[You don't have enough coins. Go adventuring to earn more.](else:)[(set: $coins to it - 15)(set: $potion_Health to it + 1)(set: $stock_Potions to it - 1)You buy a health potion. (rerun:?stats)(rerun:?healthPotions)You have $coins coins remaining.]]
[Merchant's stock: $stock_Potions]<healthPotions|
Price: 15 coins{
(if: $otherPotionsExist is true)[(link-rerun: "buy a full-health potion")[
(if: $stock_FHP < 1)[''Out of stock.''](else-if: $coins - 45 < 0)[You don't have enough coins. Go put that sword to use and come back later.](else:)[(set: $coins to it - 45)(set: $potion_FullHealth to it + 1)(set: $stock_FHP to it - 1)You buy a full-health potion. (rerun:?stats)(rerun:?FHP)You have $coins coins remaining.]]
[Merchant's stock: $stock_FHP]<FHP|
Price: 45 coins
(link-rerun: "buy an invincibility potion")[
(if: $stock_IP < 1)[''Out of stock.''](else-if: $coins - 100 < 0)[You don't have enough coins. I hear you can get more by slaying monsters.](else:)[(set: $coins to it - 100)(set: $potion_Invincibility to it + 1)(set: $stock_IP to it - 1)You buy an invincibility potion.(rerun:?stats)(rerun:?IP) You now have $coins coins and $potion_Invincibility invincibility potions.]]
[Merchant's stock: $stock_IP]<IP|
Price: 100 coins]}
---
[[onward!|start adventure]]
[[back to camp|main]]
In-game days:
Total monsters fought: $monstersDefeated
Longest streak: merchant restocks: (set: $stock_Potionsss to it + $restock)(set: $stock_FHP to it + (round: $restock/7))(set: $stock_IP to it + (round: $restock/10)) (if: $potion_Invincibility > 0)[(set: $use_IP to true)(display:"use a potion")](else:)[You don't have any of those.
[[back to battle|fight]]
(link: "flee")[(text-colour:red)[Warning:] if you flee now, you will lose $spoils coins.
[[flee anyway|flee]]]]Double-click this passage to edit it.