
events{ road{
	
// Day-plan types
	
: newbie-day
	
	// 15 %chance if 5 else 7 then to road-countdown // A countdown for number of events to process, 15% chance of it being an extra event
	
	4 to road-countdown // Actually 1 less than the number due to how countdown works
	
	// For normal days with events and blurbs, even number means a blurb, then an event, repeating until it gets to a final blurb at 1 countdown and then a camp event at 0.
	// 6 to road countdown - 3 blurbs, 2 events, camping
	// 8 to road countdown - 5 blurbs, 3 events, camping
;

: 3cyoa-day // 3 events, double common CYOA
	familiar-stack depths 0= not if 
		10 to road-countdown "INNER-DAY-FAMILIAR" print
		3CYOA-FAM-DECK shuffles to daily-deck
	then;
	8 to road-countdown "3CYOA-DAY" print
	3CYOA-DECK shuffles to daily-deck
;

: inner-day // 2 events, one is an inner location
	20 %chance if 3cyoa-day then;
	familiar-stack depths 0= not if 
		8 to road-countdown "INNER-DAY-FAMILIAR" print
		INNERDAY-FAM-DECK shuffles to daily-deck
	then;
	6 to road-countdown "INNER-DAY" print
	INNERDAY-DECK shuffles to daily-deck
;

: easyinner-day // 2 events, one is an inner location
	6 to road-countdown "EASYINNER-DAY" print
	EASYINNERDAY-DECK shuffles to daily-deck
;

: easycity-day // Formerly 8 because it did an easyinnerevent before
	6 to road-countdown "EASYCITY-DAY" print
	EASYCITYDAY-DECK shuffles to daily-deck
;

: city-day // Formerly 8 as it did an innervent before
	6 to road-countdown "CITY-DAY" print
	CITYDAY-DECK shuffles to daily-deck
;

: trade-day // 3 events, one is a trading event
	8 to road-countdown "TRADE-DAY" print
	TRADEDAY-DECK shuffles to daily-deck
;

: recruit-day // 3 events, one is a recruiting
	8 to road-countdown "RECRUIT-DAY" print
	RECRUITDAY-DECK shuffles to daily-deck
;

// Sorter that shuffles and balances the days you get

	deck-new // You'll always start the game with this day-pick-deck
		// card: inner-day
		// card: inner-day
		// card: easyinner-day
		card: easycity-day
	constant START-DAY-DECK
	START-DAY-DECK var day-pick-deck

	deck-new
		card: inner-day
		card: city-day
		card: trade-day
	constant DAY-PICK-DECK1
	
	deck-new
		card: 3cyoa-day
	constant DAY-PICK-DECK2
	
	deck-new
		card: recruit-day
	constant DAY-PICK-DECK3
	
	deck-new
		card: city-day
		card: recruit-day
		card: trade-day
	constant DAY-PICK-DECK4
	
	deck-new
		card: recruit-day
		card: city-day
		card: inner-day // I comment this on/off all the time, it's a lot of recruits
	constant DAY-PICK-DECK5
	
: day-pick-1 DAY-PICK-DECK1 shuffles to day-pick-deck "DAY-PICK-DECK1" print ;
: day-pick-2 DAY-PICK-DECK2 shuffles to day-pick-deck "DAY-PICK-DECK2" print ;
: day-pick-3 DAY-PICK-DECK3 shuffles to day-pick-deck "DAY-PICK-DECK3" print ;
: day-pick-4 DAY-PICK-DECK4 shuffles to day-pick-deck "DAY-PICK-DECK4 SC" print ;
: day-pick-5 DAY-PICK-DECK5 shuffles to day-pick-deck "DAY-PICK-DECK5 RECRUIT" print ;
	
	deck-new
		card: day-pick-1
		card: day-pick-2
		card: day-pick-3
		card: day-pick-4
		card: day-pick-5 
	constant DAY-SHUFFLE-DECK
	DAY-SHUFFLE-DECK var day-shuffle-deck
	
	DAY-SHUFFLE-DECK shuffles to day-shuffle-deck
	
: day-pick-shuffle
	day-shuffle-deck depths 0= if DAY-SHUFFLE-DECK shuffles to day-shuffle-deck then
	day-shuffle-deck drawcard
;
	
: day-pick

	day-pick-deck depths 0= if day-pick-shuffle then
	day-pick-deck drawcard
;

// "BOSS" days
	
: boss0-day 
	12 to road-countdown "EASY-HAZARD-DAY" print
	EASYHAZARDDAY-DECK to daily-deck
;
	
: boss1-day // 5 events, not shuffled, last one is a big mandatory challenge. Formerly 12.
	10 to road-countdown "HAZARD-DAY" print
	HAZARDDAY-DECK to daily-deck // puts the cards in the deck in order	
;

: canada-day
	8 to road-countdown "CANADA-DAY" print
	CANADADAY-DECK to daily-deck
;

: precanada-day
	10 to road-countdown "PRECANADA-DAY" print
	PRECANADA-DECK to daily-deck
;
	
: old-day-diffset
	road-trip-days 3 = if diff-scalar 0.8 * to road-difficulty then
	road-trip-days 6 = if diff-scalar 0.9 * to road-difficulty then
	road-trip-days 9 = if diff-scalar to road-difficulty then
	road-trip-days 12 = if diff-scalar 1.1 * to road-difficulty then
	road-trip-days 15 = if diff-scalar 1.2 * to road-difficulty then
	road-trip-days 18 = if diff-scalar 1.3 * to road-difficulty then
	road-trip-days 21 = if diff-scalar 1.4 * to road-difficulty then
	road-trip-days 24 = if diff-scalar 1.5 * to road-difficulty then
	road-trip-days 27 = if diff-scalar 1.6 * to road-difficulty then
;

: new-day-diffset
	road-trip-days 3 = if diff-scalar 0.8 * to road-difficulty then
	road-trip-days 5 = if diff-scalar 0.9 * to road-difficulty then
	road-trip-days 7 = if diff-scalar to road-difficulty then
	road-trip-days 11 = if diff-scalar 1.1 * to road-difficulty then
	road-trip-days 14 = if diff-scalar 1.2 * to road-difficulty then
	road-trip-days 17 = if diff-scalar 1.3 * to road-difficulty then
	road-trip-days 20 = if diff-scalar 1.4 * to road-difficulty then
	road-trip-days 23 = if diff-scalar 1.5 * to road-difficulty then
	road-trip-days 26 = if diff-scalar 1.6 * to road-difficulty then
;

(* Old difficulty 
	road-trip-days 3 = if diff-scalar 0.9 * to road-difficulty then
	road-trip-days 5 = if diff-scalar to road-difficulty then
	road-trip-days 7 = if diff-scalar 1.1 * to road-difficulty then
	road-trip-days 9 = if diff-scalar 1.2 * to road-difficulty then
	road-trip-days 11 = if diff-scalar 1.3 * to road-difficulty then
	road-trip-days 13 = if diff-scalar 1.4 * to road-difficulty then
	road-trip-days 15 = if diff-scalar 1.5 * to road-difficulty then
	road-trip-days 17 = if diff-scalar 1.6 * to road-difficulty then
	road-trip-days 19 = if diff-scalar 1.7 * to road-difficulty then
	road-trip-days 21 = if diff-scalar 1.8 * to road-difficulty then
	road-trip-days 23 = if diff-scalar 1.9 * to road-difficulty then
	road-trip-days 25 = if diff-scalar 2 * to road-difficulty then
*)

: road-trip-quarter
	nearcanada-day 1 + 4 / 0.5 + >int
;

: new-day-tileset
	road-trip-days road-trip-quarter = if
		1 road_theme!
	then
	road-trip-days road-trip-quarter 2 * = if
		2 road_theme!
	then	
	road-trip-days road-trip-quarter 3 * = if
		3 road_theme!
	then
;

: days-left road{ nearcanada-day 1 + road-trip-days - } ;

: road-days-report
	($ GREEN .. days-left .. WHITE .. " DRIVING DAYS UNTIL " .. BLUE .. "CANADA!" $)
	60 3 *
	view_w 0.5 * 16
	msgtickxy
;
	

: new-day // Logic for what happens every new day
	' road-trip-days ++
	days-left travel_days!
	' calendar-days ++
	80 %chance if 0 weather! -1 1 frnd wind_force! then
	road-trip-days 2 < if 
		diff-scalar 0.7 * to road-difficulty
		newbie-day // no day 0 due to how increments work
	then; 
	new-day-diffset
	new-day-tileset
	road-trip-days 3 = if
		boss0-day then;
	road-trip-days nearcanada-day = if
		precanada-day then;
	road-trip-days nearcanada-day > if
		canada-day then;
	road-trip-days 7 = road-trip-days 11 = or if // 6, 9
		boss1-day then;
	road-trip-days 15 = road-trip-days 19 = or if // 12, 15
		boss1-day then;
	road-trip-days 18 = road-trip-days 21 = or if
		boss1-day then;
	road-trip-days 24 = road-trip-days 27 = or if
		boss1-day then;
	day-pick
;

: end-demo cyoa-new "You won the demo! But the Death Road continues much further!" cyoa-text! 0 cyoa-image-icon! 1 500 tone
	delete-the-game
	choice( "OK" )choice: quit-to-title ;

: end-demo-old cyoa-new "You won for now! Send us a message via Kickstarter if you noticed anything break or the game crashed!" cyoa-text! 0 cyoa-image-icon! 1 500 tone
	delete-the-game
	choice( "OK" )choice: quit-to-title ;
	
: dog-driver cyoa-new "More Victims for the Death Road" cyoa-title! ($ "With no idea how to drive a car, " .. somename .. " drives it into a ditch and wanders off. The journey to Canada is over." $) cyoa-text! 0 cyoa-image-icon! 1 500 tone
	delete-the-game
	choice( "DANG IT" )choice: quit-to-title ;
	
: no-driver cyoa-new "More Victims for the Death Road" cyoa-title! ($ "With no one left" vehicle.which@
	if .. " to drive the car" then .. ", the journey to Canada is at an end." $) cyoa-text!
	0 cyoa-image-icon! 1 500 tone
	delete-the-game
	choice( "DANG IT" )choice: quit-to-title ;
		
} }
