Welcome in this demonstration of an implementation of Reign's like games with Twinery.
At each turn the player can read a description of the situation, and have one or several choices. Each choice as some consequences on internal state of the simulation thanks to variables.
The situation and the choices are described on a card, randomnly picked in a deck. Some cards are dispensable (unique usage) some other go back to the deck.
Events can occurs. At some turns, or if some conditions are met.
In this demo, the simulation is pretty basic. Each turn use 1 stamina. And you have to maintain your health ans stamina not null. The choices may have an impact on health, stamina, money or both.
{<!-- to avoid whitespaces -->
(set: $defaultWaitingMessage to "I am waiting a bit")
}<!-- to avoid whitespaces -->
[[Let’s play…->Main Loop]]
{<!-- to avoid whitespaces -->
<!-- Storyline -->
(if: visits <= 1)[
(set: $eventSelected to false)
]
(display: "Story")
<!-- Domain simulation (Managing internal values) -->
(display: "Domain Simulation")
(unless: $noTurn is 1)[
<div class="card">
<!-- Game simulation (card picking) -->
(display: "Game Simulation")
</div>
]
(if: $noTurn is 1)[
(set: $noTurn to 0)
]
(hidden:)[ [[Main Loop]] ]
}<!-- to avoid whitespaces -->
(display: "Main Controls")
Health: (print: $health)/(print: $maxHealth) ─ Money: (print: $money) ─ Stamina (print: $stam)/(print: $maxStam)
{
(hidden:)[ [[Main Loop]] ]
}{<!-- to avoid whitespaces -->
<!-- Initializations -->
(if: visits <= 1)[
(set: $gameTurns to 0)
(set:$remindStam to false)
]
(if: $eventSelected is not false)[
(unless: $noTurn is 1)[
<!-- New game turn -->
(set: $gameTurns to it + 1)
<!-- testing for event occuring at a specific game turn -->
(set: _eventsSelected to (altered: via its name, ...(passages: where its tags contains all of (array: "turn_"+(text:$gameTurns),"event"))))
<!-- if yes, picking one of the selected events -->
(if: _eventsSelected's length > 0) [
<!-- get a random event in potential events -->
(set: $eventSelected to (either: ..._eventsSelected))
]
(else:)[
<!-- Getting Other Events -->
(set: _eventsSelected to (altered: via its name, ...(passages: where its tags contains all of (array: "event","conditional"))))
<!-- Testing each events and loading them -->
(for: each _item, ..._eventsSelected)[
(display: _item)
]
]
]
]
(hidden:)[ [[Main Loop]] ]
}<!-- to avoid whitespaces -->{<!-- to avoid whitespaces -->
<!-- Initialize Gauges -->
(if: visits <= 1)[(set: $maxHealth to 100)(set: $maxStam to 10)(set: $health to $maxHealth)(set: $money to 42)(set: $stam to $maxStam)]
<!-- limit gauges -->
(set: $health to (min: $health,$maxHealth))
(set: $stam to (min: $stam,$maxStam))
(set: $money to (max: 0,$money))
(unless: $noTurn is 1)[
<!-- One point of stamania for each turn -->
(set: $stam to $stam-1)
]
<!-- Game Over if...-->
(if: $health <= 0)[(go-to: "No More Health")]
(if: $stam <= 0)[(go-to: "No More Stamina")]
(hidden:)[ [[Main Loop]] ]
}<!-- to avoid whitespaces -->{<!-- to avoid whitespaces -->
<!-- Initializations -->
(if: visits <= 1)[
(set: $uniqueVisited to (array:))
(set: $waitingMessage to $defaultWaitingMessage)
]
<!-- No special event: we pick a random card -->
(if: $eventSelected is false)[
<!-- Get all passages with the tag 'card' -->
<!-- cf. https://twine2.neocities.org/#macro_passages -->
(set: _cards to (altered: via its name, ...(passages: where its tags contains "card")))
<!-- get a random card -->
(set: $selectedPassageName to (either: ..._cards))
<!-- verify if it's a recuring or unique event -->
(if: (passage: $selectedPassageName)'s tags contains "unique")[
<!-- The unique passage already occured, back to select a card -->
(if: $uniqueVisited contains $selectedPassageName)[
(set: $noTurn to 1)<!-- FIXME noTurn is not enought: we can't get back here -->
(go-to: "Main Loop")
]
<!-- This unique passage is currently visited -->
(set: $uniqueVisited to it + (array: $selectedPassageName))
]
]
<!-- special event is the selected passage -->
(else-if: $eventSelected is not false)[
(set: $selectedPassageName to $eventSelected)
(set: $eventSelected to false)
]
<!-- Display the choosen passage -->
(display: $selectedPassageName)
(hidden:)[ [[Main Loop]] ]
}<!-- to avoid whitespaces -->Nothing better than a good health... You should know better...
You'r dead...
Game Over
(hidden:)[ [[Domain Simulation]] ]You can't do anything anymore because you are out of stamina... Sorry...
Game Over!
(hidden:)[ [[Domain Simulation]] ]This event occurs after 2 turns (at turn 3)
(hidden:)[ [[Story]] ]This your 5th turn... You can go on!
(hidden:)[ [[Story]] ]{<!-- to avoid whitespaces -->
<!-- displays a reminder about the stamina -->
(if: $stam is (round:$maxStam/2) and $gameTurns > 1 and $remindStam is false)[
(set: $noTurn to 1)
Watch out your stamina, it is running low !
(set: $waitingMessage to "OK. I will check it")
(set:$remindStam to true)
]
(hidden:)[ [[Story]] ]
}<!-- to avoid whitespaces --><!--This the description of the situation -->
This a catastrophy, you slip on a banana peel!
You loose half of your health! Darn!
{<!-- to avoid whitespaces -->
<!--This is what does the card on the gauges-->
<!-- decrease health -->
(set: $health to (round:$health/2))
}<!-- to avoid whitespaces -->
<!--This is the choicies the player can make -->
<!--and their impact on gauges -->
With our actual superpowers, here are the possible actions
(link: "I use my stamina to regenerate my health: -1 stamina → +10 health")[
(set: $stam to $stam-1)
(set: $health to $health+10)
(go-to: "Main Loop")
]
(if: $money >= 20)[
(link: "I spend 20 coins to regenerate my health: -20 coins → +5 health") [
(set: $money to $money-20)
(set: $health to $health+5)
(go-to: "Main Loop")
]
]
(link: "I sacrifice some more health to get more stamina: -20 health → +1 stamina")[
(set: $stam to $stam+1)
(set: $health to $health-20)
(go-to: "Main Loop")
]
(hidden:)[ [[Game Simulation]] ]<!--This the description of the situation -->
Time passes and the more it passes the more nothing happens...
(hidden:)[ [[Game Simulation]] ]<!--This the description of the situation -->
Groovy! You just met the very funky Archimage. he feels the funk in you and propose to give you either:
<!--This is the choicies the player can make -->
<!--and their impact on gauges -->
(link: "more stamina")[
(set: $stam to $stam+5)
(go-to: "Main Loop")
]
(link: "more health")[
(set: $health to $health+50)
(go-to: "Main Loop")
]
(link: "a lot more money!")[
(set: $money to $money+500)
(go-to: "Main Loop")
]
(hidden:)[ [[Game Simulation]] ]<!--This the description of the situation -->
Groovy! You just met the very rocKing Ultra Archimage. He feels the Tatapoum in you and propose to give you either:
<!--This is the choicies the player can make -->
<!--and their impact on gauges -->
(link: "increase your max stamina")[
(set: $maxStam to $maxStam+1)
(go-to: "Main Loop")
]
(link: "increase your max health")[
(set: $maxHealth to $maxHealth+10)
(go-to: "Main Loop")
]
(link: "a looooot more money!")[
(set: $money to $money+5000)
(go-to: "Main Loop")
]
(hidden:)[ [[Game Simulation]] ][[(print: $waitingMessage)->Main Loop]](set: $waitingMessage to $defaultWaitingMessage)
{<!-- to avoid whitespaces -->
(hidden:)[ [[Main Loop]] ]
(hidden:)[ [[Domain Simulation]] ]
(hidden:)[ [[Game Simulation]] ]
(hidden:)[ [[Gauges]] ]
<!-- to avoid whitespaces -->}Double-click this passage to edit it.<!--This the description of the situation -->
Oh God! It is dark in here…
But you manage to glimpse a wonderful yummy peace of delicious cheese on a wookplank.
You remember that cheese is good for you stamina.
<!--This is the choicies the player can make -->
<!--and their impact on gauges -->
(link: "Yummy! Of course I take the cheese!")[
(set: $eventSelected to "Trapped")<!--We trigger a specific card-->
(set: $stam to it + 1)(set: $gameTurns to it - 1)<!--The triggered card is in the same turn -->
(go-to: "Main Loop")
]
(link: "I cannot see it very well…")[
(set: $eventSelected to "Prudent")<!--We trigger a specific card-->
(set: $stam to it + 1)(set: $gameTurns to it - 1)<!--The triggered card is in the same turn -->
(go-to: "Main Loop")
]
(hidden:)[ [[Game Simulation]] ]
(hidden:)[ [[Prudent]] ]
(hidden:)[ [[Trapped]] ]<!--This the description of the situation -->
As you stare the cheese with envy you start to see a grey frame linking it to the wood plank.
That's it, it is a trap, taking the cheese would have triggered the mecanism and hurt you.
Nice to be prudent!
<!--This is the choicies the player can make -->
<!--and their impact on gauges -->
(link: "Would you like to take some risks to get the cheese without triggering the trap")[
(set: _diced to (array:"Got the cheese!","Trapped"))
(set: $eventSelected to (either: ..._diced))<!--We trigger a random card in a list -->
(set: $stam to it + 1)(set: $gameTurns to it - 1)<!--The triggered card is in the same turn -->
(go-to: "Main Loop")
]
(hidden:)[ [[Got the cheese!]] ]
(hidden:)[ [[Trapped]] ]
(hidden:)[ [[Game Simulation]] ]<!--This the description of the situation -->
You pull delicately the cheese… it is resisting a litlle bit…
You pull again… and you do not have time to hear the noise that you loose 10 health!
It was a trap that hurts!
{<!-- to avoid whitespaces -->
<!--This is what does the card on the gauges-->
<!-- decrease health -->
(set: $health to it - 10)
}<!-- to avoid whitespaces -->
(hidden:)[ [[Game Simulation]] ]<!--This the description of the situation -->
You pull delicately the cheese… it is resisting a litlle bit…
You pull again… and TADA! You manage to get it without triggering the trap.
You enjoy the taste of this cheese and gain 2 stamina!
{<!-- to avoid whitespaces -->
<!--This is what does the card on the gauges-->
<!-- increase stam -->
(set: $stam to it + 2)
}<!-- to avoid whitespaces -->
(hidden:)[ [[Game Simulation]] ]