uses base.df
uses charfilt.df
uses charstats.df
uses road.df

(* Basic Template
: EFFECT cyoa-good-dialog ($ cname .. " farts on "  .. someone .colourname .. "." $) cyoa-text!
: OLDERSTYLE "CARD 1A EVENT EXAMPLE" $cyoa-ok-dialog 0 cyoa-image-icon! 3 500 tone ;
: card1-cyoa
	cyoa-start
	" " cyoa-title!
	0 to cyoaicon cyoaicon
	" " cyoa-text! 3 500 tone
	choice( "DESCRIPTION" )choice: EFFECT
	// NOTE that only 4 choices are shown max, with choices on top/first taking priority.
	; 
*)

(* CYOA standard types:
1. GRAB BAG - Examples: Abandoned Gun Range, Quiet Town, Lost Stronghold
Variety of simple options. No really complex rolls for the most part. Choices tend to involve the entire group. 2-4 choices, or even a "do or don't" style choice.
2. INSTANT RESULT - Example: Muscle Fan
No choice! Something happens instantly. Can do simple or complex rolls to modify the result. The most board-game like option.
3. PERSON PICK - Example: Candy Finding
You're given an action and then have to pick a person to perform that action. The check/roll can be simple or complex. It should usually be a choice of up to 3 people, then a choice for an alternate group option. This makes things more interesting if you're currently solo.
4. ACTION PICK - Example: Traffic Jam
You're given a situation and provided 2-3 choices as to what to do. The choices then pick a person to carry out that action based on stats. These stats do not have to be revealed, and the stat rolls can be more complex than the GRAB BAG type. This example also has an alternate, less specific group option.
5. SPOTLIGHT - Example: Parkouuur
A situation is presented and then a person is chosen from your group at random. You're given two, rarely three options for that person to perform. They can be pretty complex rolls or checks. The stats used for the rolls are then revealed, whether the check was good or bad.

REVEALED STATS
It's up to the CYOA writer as to whether or not the result should reveal stats to the group. Generally, loyalty is really rare to reveal, where something like making a really great shot in CYOA reveals your shooting stat outright.

REVEALED STAT SPECIAL OPTIONS - Examples: Parkouuur
All CYOA types have the option of checking your party for combinations of high, or really low, revealed stats. If the checks are successful, additional options can be added to the list of choices. Generally these should use combinations of stats instead of single stats, to make them rarer to trigger. If you can think of one or two of these to include in a CYOA, do so, but overall it should be hard for a single character to get a lot of these in succession.

See charstats.df and charfilt.df for details on what the words do

*)


cyoa{ road{

// Abandoned Gun Range
// Example of a GRAB BAG style CYOA. Give someone a point of shooting, get some ammo instead, or gamble health.
 
 // ammosearch1 gives ammo. See the bottom of chartstats.df for loot words.
: card1-search ($ Thegroup .. " finds a small amount of ammunition." $) $cyoa-ok-dialog ammosearch1 goodfx cyoaicon ;

// One selected person shoots
cyoa-choice: card1-picked
	// Later make it so you get humor messages for trying to train without a gun or ammo
	"Target Practice" cyoa-title!
	
	chumany? if
		($ cname .. " gets some time to practice shooting. 
		The targets were even zombie themed!" $) cyoa-text! +cr goodfx
		shootingREV shooting++
	else
		($ cname .. " gnaws on the gun for awhile. 
		It gets drooly." $) cyoa-text! morale++ goodfx
	then
;

cyoa-choice: card1-one "Who should spend some time with shooting practice?" cyoa-text! 
	' card1-picked cyoa-team-choice
;
// For entire group, individually rolls a 40% chance of gaining a point in shooting skill.
: card1-spray 100 %chance if 
	dup notpet? over superpet? or if 
		.shooting++ else .morale-- then
	else 
		.ouch-- then ;

cyoa-choice: card1-group "Everyone decides to all blast the targets at once, in the dark gun range. No thought is given as to whether or not this is a good idea. WHATEVER." cyoa-text! badfx
	' card1-spray foreach-team-char 
	// Note syntax: ' <single word, make shortcut if more> foreach-team-char
	someone .ouch--
;

cyoa: card1-cyoa
	"Abandoned Gun Range" cyoa-title!
	0 to cyoaicon cyoaicon // picks a CYOA image, displays it using "cyoaicon"
	"You find a gun range. It's empty and mostly picked clean of supplies. However, you find some shooting targets." cyoa-text! 3 500 tone
	
	choice( "Search for Ammo" )choice: card1-search
	// SOLO CHOICE, cancels group choices after it if solo
	solo if
		soloer charchoice( " trains shooting" )choice: card1-picked
		then;
	choice( "Train Group Haphazardly" )choice: card1-group
	choice( "Carefully Train One Person" )choice: card1-one
;

// END Abandoned Gun Range

// Muscle Fan
// Example of an INSTANT RESULT CYOA with no choices.

: card2-jerk ($ cname .. " cruelly calls the woman a MUSCLE NERD." $) +text cyoa-text-cr
	temperREV morale++
;
: card2-pumped ($ cname .. " feels PUMPED UP about this story and benches a nearby log." $) +text cyoa-text-cr
	strengthREV	strength++ morale++
;
cyoa: card2-cyoa ($ someone .colourname .. " meets another survivor who rants about seeing an oiled up bodybuilder that was 'too swole to control', ripping zombies in half after bench-pressing them." $) cyoa-text! +cr 1 cyoa-image-icon! 4 500 tone 

	strongest-pass
	if strongest choosechar card2-pumped then;

	most-ahole
	if choosechar card2-jerk then;

	solo if ($ soloer .colourname .. " wonders what that was all about." $) +text then;

	"Everyone in your group looks at each other nervously." +text
;

// END Muscle Fan

// Quiet Town
// Rest up if you have food, find some ammo for no penalty, or get more supplies in exchange for health if you don't have a paranoid character.

: card3-3rest 60 %chance if .morale2+ else .morale3+ then ;
cyoa-choice: card3-3day ($ Thegroup .. " picks one of the houses for barricading, then rests there for a few days. It's a welcome break, though it was getting boring near the end." $) cyoa-text! 3 500 tone 
	// Food amount currently placeholder till we put in more accurate food consumption tracking
	team-count -6 * LOOT_FOOD trunk.loot+
	' card3-3rest foreach-team-char
;
cyoa-choice: card3-1day ($ Thegroup .. " barricades one of the houses and gets some much needed rest." $) cyoa-text! 3 500 tone 
	team-count -2 *  LOOT_FOOD trunk.loot+
	' .morale++ foreach-team-char
;
cyoa-choice: card3-qloot ($ Thegroup .. " does a quick search of the most obvious places to stash supplies. Some ammunition is found." $) cyoa-text! 3 500 tone ammosearch1 ;

: card3-zomb 
	most-paranoid
	if choosechar
		($ cname .. ", always paranoid, is not surprised by the zombie and easily avoids it." $) +text 50 %chance if witsREV else attitudeREV then goodfx
	else
		someone choosechar ($ "Unfortunately the zombie found " .. cname .. " first." $)
		+text ouch2- bitefx
	then
	cicon // forces the icon to be the chosen character
;
cyoa-choice: card3-search ($ Thegroup .. " combs the town for supplies left behind, but gets ambushed by a single zombie. " $) cyoa-text! card3-zomb ammosearch1 homesearch1 ;

cyoa: card3-cyoa
	"Quiet Town" cyoa-title!
	"It's so quiet here. There's no signs of life or unlife. It seems like everyone took what they could and evacuated this town immediately." cyoa-text! 0 to cyoaicon cyoaicon 3 500 tone
		choice( "Scavenge town thoroughly" )choice: card3-search
		choice( "Loot quickly and run" )choice: card3-qloot
		trunk-food team-count 2 * 1 - > if 
			choice( "Rest for a day" )choice: card3-1day
		then
		trunk-food team-count 6 * 1 - > if 
			choice( "Rest for three days" )choice: card3-3day 
		then
;

// END Quiet Town

// Lost Stronghold
// Ultra simple DO A TOUGH CITY EVENT OR DON'T choice.

cyoa: card4-cyoa
	"Lost Stronghold" cyoa-title!

	"This apartment building was turned into a barricaded fortress. It has been completely overrun by a horde of zombies. On the plus side, they seem fairly docile for now." cyoa-text!
	1.5 2.2 frnd 9 15 frnd 0 1 rnd zforecast
	"events/inner/region/hellhotel.df" $load-region
		choice( "Attack the Fortress" )choice: premission
		gas-draw
;

// END Lost Stronghold

// Traffic Jam
// Examples of manual stat checks in this one. Mostly we should use the shortcuts like cwits+

: card5-wacheck cchar .attitude 4 < cchar .wits 3 > and ;

cyoa-choice: card5-walk good
	($ Thegroup .. " abandons the old car and starts walking through, searching cars for supplies on the way." $) cyoa-text! car-abandon ammosearch1
;

: card5-detadd
	card5-wacheck if
		good "The detour goes unexpectedly well!"
	then;

	""

	cchar .attitude 3 > if 
		bad "Taking this route was too optimistic, it lasted for days! " $cat
	then 

	cchar .wits 4 < if 
		bad "The route ended up being TOTAL GARBAGE, and the car was damaged." $cat
	then
;

: card5-detadd2
	card5-wacheck if
		morale++
	then;

	cchar .wits 4 < if 
		 morale-- -2 car-health+
	then

	cchar .attitude 3 > if 
		attitude-- +cr chowtime -80 car-gas+
	then;

;

cyoa-choice: card5-detour

//	($ cname .. " decides to make a detour. " .. card5-detadd $) $cyoa-ok-dialog // <<< THIS clears the character icon that's set for the CYOA

	chumany? if 
		($ cname .. " decides to make a detour. " .. card5-detadd $) 
	else
		($ cname .. " barks out the window at a hidden, overgrown path! " .. card5-detadd $)
	then cyoa-text!

	witsREV	attitudeREV	card5-detadd2
;

cyoa-choice: card5-bench
	($ cname .. " bench presses a ruined car. This accomplishes little for clearing the wreckage, and your car still has to be abandoned." $) cyoa-text! goodfx
	car-abandon
	morale++ strengthREV strength++ 
;

: card5-mudadd2 cwits+ if morale++ witsREV then;
	morale-- ouch--all -3 car-health+ ;

: card5-mudadd cwits+ if
		good "With a combination of being pissed and perceptive, the car doesn't crash."
	then;

	bad "It's going fine until the car slams into a rock."
;

cyoa-choice: card5-mudding
	($ cname .. " plows through the shoulder near the road. " $) card5-mudadd $cat cyoa-text!
	temperREV
	card5-mudadd2
;

cyoa: card5-cyoa
	"Traffic Jam" cyoa-title!
	"A sea of cars blocks the road ahead. The pileup is so bad that there is no obvious way through." cyoa-text! 0 cyoa-image-icon!
		angriest-pass if
			angriest choosechar chumany? if cchar charchoice( ": Aggressive offroading!" )choice: card5-mudding then
		then

		strongest-pass if
			strongest charchoice( ": Bench press a car" )choice: card5-bench
		then

		smartest charchoice( ": Find a new route" )choice: card5-detour

		choice( "Abandon car and walk" )choice: card5-walk
;

// END Traffic Jam

// Candy finding
// Pretty similar GRAB BAG to Abandoned Gun Shop, but with interesting solo options.

: candysharesolo soloer .morale-- soloer .strength++ soloer .temper-- soloer .attitude-- ;
: candyshareroll 60 %chance if .morale-- else .loyalty++ then ;
cyoa-choice: candyshare
solo if 
	bad ($ soloname .. " is really annoyed that the candy has to be shared with friends, even though they are imaginary. " .. soloer xHe .. " rages and stomps on the candy. Now no one can have it!" $) cyoa-text! candysharesolo
else 
	good ($ "Everyone learns a valuable lesson about sharing by trying to split an already tiny candy bar. Maybe. Sort of." $) cyoa-text! ' candyshareroll foreach-team-char
then
;

cyoa-choice: candyresult
	"It Really Is Fun Sized" cyoa-title!
	($ cname .. " eats that candy, big time. The sugary sweetness makes " .. chim .. " feel a little better about " .. chis .. " current life in not-Canada." $) cyoa-text! cyoa-text-cr goodfx
	solo if 
		cyoa-text-cr ($ cHe .. " feels pretty smug about not having to share." $) +text attitude++ 
	then
	morale++ cyoa-text-cr 
;

cyoa: card6-cyoa
	"Lucky Candy Bar" cyoa-title! 
	0 to cyoaicon cyoaicon
	($ Thegroup .. " finds a candy bar on the side of the road! It's 'fun sized'.
	Who gets to eat it?" $) cyoa-text! 3 500 tone
	' candyresult 3 #cyoa-team-choice
	choice( "Share with everyone" )choice: candyshare 
;

// END Candy finding

// Parkouuur - A Spotlight CYOA. Also has an extra TRUMP option if you have revealed stats.
// Pretty standard layout for stat checks that we should reuse frequently. Result if over 4, result if under 2, if average do a stat roll which amounts to a weighted coin toss.

: card7-pcheck 
	cpet? if
		($ cname .. " does a sweet parkour move involving just kind of walking through the zombies' legs. Whatever!" $) cyoa-text! goodfx morale++
	then;
	
	cfitness+ if
		($ cname .. " does a" .. RED .. " SICK PARKOUR FLIP" .. WHITE .. " off some garbage and over the fence. No big deal. It's all too trivial a move for " .. cname .. "." $) cyoa-text! goodfx 
	then;
	
	cfitness- if
		($ cname .. " awkwardly tries to scale the fence but is way too out of shape to do so. The zombies attack." $) cyoa-text! ouch2- bitefx
	then;
	
	fitnessroll if
		($ cname .. " manages to climb up the fence in time, avoiding being ripped apart for now. God bless parkouring." $) cyoa-text! goodfx
		fitness++ 
	then;
	
		($ cname .. " struggles to climb the fence. A zombie manages to get in a leg bite." $) cyoa-text! bitefx ouch--
;
cyoa-choice: card7-parkour card7-pcheck fitnessREV ;

// Doesn't check Strength for high/low, just does a roll no matter what. Advantage: Can use it to go from 5 to 6 str. Disadvantage: Pointless and dangerous at 6.
: card7-scheck 
	strengthroll if
		($ cname .. " bowls several zombies over by throwing garbage cans. " .. cHe .. " escapes and gets a great workout at the same time." $) cyoa-text! goodfx
		strength++ 
	then;
		($ cname .. " tries to fight the zombies off by throwing garbage cans at them, but doesn't manage to throw enough to stop their attack." $) cyoa-text! bitefx ouch2-
;
cyoa-choice: card7-throw card7-scheck strengthREV ;

cyoa-choice: card7-flip
($ cname .. " COMPLETELY flips out and starts flinging stuff at zombies followed by stomping on them. It's both effective and very therapeutic for " .. cname .. "." $)
cyoa-text! goodfx
	morale++ temper++ strength++ 
;
: card7-tryflip 
	cchar angrystrong-revealed? not if then;
	cchar angrystrong? if
		choice( "COMPLETELY FLIP OUT" )choice: card7-flip
	then
;

cyoa: card7-cyoa
	"Fight or Flip" cyoa-title!
	choosehuman cicon
	($ cname .. " makes mistakes while scouting a town, and gets cornered by a large group of zombies while unarmed. 
	" .. cHe .. " is trapped in an alley. At the end of the alley is heavy garbage and a large fence." $) cyoa-text! 3 500 tone
		card7-tryflip
		choice( "Use Parkour Abilities" )choice: card7-parkour
		choice( "Throw Garbage" )choice: card7-throw
;

// END Parkouuur

} }
