@@ 2,4 2,4 @@
(name panacea)
(libraries panacea_lib)
(preprocess
- (pps ppx_let ppx_jane)))
+ (pps ppx_deriving.show ppx_let ppx_jane)))
@@ 3,4 3,4 @@
(inline_tests)
(libraries core re2 logs)
(preprocess
- (pps ppx_let ppx_jane ppx_inline_test)))
+ (pps ppx_deriving.show ppx_let ppx_jane ppx_inline_test)))
@@ 1,4 1,5 @@
open Base
+
(**
* The Gamestate contains everything you need to properly model a game in-progress.
*)
@@ 7,6 8,7 @@ type difficulty =
| Introductory (* 4 Epidemic cards *)
| Standard (* 5 Epidemic cards *)
| Heroic (* 6 Epidemic cards *)
+ [@@deriving show]
type role =
(* - As an action, take any discarded Event card and store it on this card.
@@ 45,12 47,14 @@ type role =
(* - You only need 4 cards of the same color to do the Discover a Cure action.
*)
| Scientist
+ [@@deriving show]
type infection_color =
| Black
| Blue
| Red
| Yellow
+ [@@deriving show]
type infection_city =
| Algiers | Atlanta | Baghdad | Bangkok | Beijing | Bogota | BuenosAires | Cairo
@@ 59,23 63,25 @@ type infection_city =
| LosAngeles | Madrid | Manila | MexicoCity | Miami | Milan | Montreal | Moscow
| Mumbai | NewYork | Osaka | Paris | Riyadh | SanFrancisco | Santiago | SaoPaolo
| Seoul | Shanghai | StPetersburg | Sydney | Taipei | Tehran | Tokyo | Washington
- [@@deriving sexp, compare]
+ [@@deriving sexp, compare, show]
type player_card_event = {
name: string;
description: string;
-}
+} [@@deriving show]
+
type player_card =
| Event of player_card_event
| Epidemic
| City of infection_city
+ [@@deriving show]
type player = {
role : role;
hand : player_card list;
location : infection_city;
-}
+} [@@deriving show]
type board_city = {
name : string;
@@ 86,7 92,8 @@ type board_city = {
num_yellow : int;
has_research_station : bool;
neighbors : infection_city list;
-}
+} [@@deriving show]
+
module CityCompare = struct
module T = struct
@@ 96,9 103,12 @@ module CityCompare = struct
include Comparable.Make(T)
end
-type board = (infection_city, board_city, CityCompare.comparator_witness) Map.t
+type board =
+ (infection_city, board_city, CityCompare.comparator_witness) Map.t
-type infection_card = infection_city
+let pp_board _ = "Board"
+
+type infection_card = infection_city [@@deriving show]
type gamestate = {
players : player list;
@@ 121,6 131,8 @@ type gamestate = {
is_yellow_cured : bool;
}
+let pp_gamestate _ = "Gamestate"
+
let empty_board =
let initial = Map.empty (module CityCompare) in
@@ 218,16 230,11 @@ let starting_player_deck =
City Taipei; City Tehran; City Tokyo; City Washington
]
-let empty_gamestate () =
- let players = [
- {role=Dispatcher; hand=[]; location=Atlanta};
- {role=ContingencyPlannner; hand=[]; location=Atlanta};
- {role=Medic; hand=[]; location=Atlanta};
- ] in
- let board = empty_board in
+(** Core Gamestate, unshuffled. *)
+let empty_gamestate =
{
- players=players;
- board=board;
+ players=[];
+ board=empty_board;
curr_turn=0;
actions_remaining=4;
research_stations_remaining=6;
@@ 245,3 252,45 @@ let empty_gamestate () =
is_black_cured=false;
is_yellow_cured=false;
}
+
+
+(** Returns the Gamestate with the list of _n_ players in the same order we received them in,
+ * each with a random role. *)
+let draw_players gs = gs
+
+(** Returns the gamestate with the infection deck shuffled. *)
+let shuffle_infection_deck gs = gs
+
+(** Returns the gamestate with the player deck shuffled. *)
+let shuffle_player_deck gs = gs
+
+(** Gives each player _n_ cards from the Player deck, per the starting rules. *)
+let hand_out_cards gs = gs
+
+(** Infects 9 cities with varying severity, per the starting rules. *)
+let infect_cities gs = gs
+
+(** Places the outbreak cards in the remaining Player deck, per the difficulty level. *)
+let place_outbreaks gs = gs
+
+(** Places the first research center in Atlanta. *)
+let place_research_station_in_atlanta gs = gs
+
+(** Gives us a Gamestate that's ready to play! *)
+let starting_game _player_names _difficulty =
+ let transformations =
+ [
+ draw_players;
+ shuffle_infection_deck;
+ shuffle_player_deck;
+ hand_out_cards;
+ infect_cities;
+ place_outbreaks;
+ place_research_station_in_atlanta;
+ ]
+ in
+ List.fold_left
+ ~init:empty_gamestate
+ ~f:(fun accum x -> x accum)
+ transformations
+