Module AFTN.Game_state

Tracking the state of the currently-running game

type state = {
  1. map : Map.map;
    (*

    Game map

    *)
  2. num_scrap : Map.room -> int;
    (*

    How much scrap is in this room

    *)
  3. has_event : Map.room -> bool;
    (*

    Whether the room has an event

    *)
  4. room_items : Map.room -> Item.item list;
    (*

    Items in the room

    *)
  5. characters : Character.character list;
    (*

    characterss in play

    *)
  6. active_character : Character.character option;
    (*

    Currently-playing character

    *)
  7. character_rooms : Character.character -> int;
    (*

    Location of characters in play - index into map.rooms

    *)
  8. xeno_room : int;
    (*

    Location of xenomorph - index into map.rooms

    *)
  9. ash_room : int option;
    (*

    Location of Ash, if in play - index into map.rooms

    *)
  10. ash_health : int;
    (*

    Ash's health for final mission "You Have My Sympathies"

    *)
  11. ash_killed : bool;
  12. jonesy_caught : bool;
    (*

    Whether Jonesy has been caught

    *)
  13. round_count : int;
    (*

    How many rounds have passed

    *)
  14. turn_idx : int;
    (*

    How many turns have passed on this round

    *)
  15. self_destruct_count : int option;
    (*

    How many turns until self destruct

    *)
  16. self_destruct_character : Character.character option;
    (*

    On which character's turn does self-destruct counter decrease?

    *)
  17. character_scraps : Character.character -> int;
    (*

    Scrap per character

    *)
  18. character_items : Character.character -> Item.item list;
    (*

    Items per character

    *)
  19. encounters : Encounter.encounter list;
    (*

    Un-drawn encounters

    *)
  20. discarded_encounters : Encounter.encounter list;
    (*

    Discarded encounters

    *)
  21. morale : int;
    (*

    Team morale

    *)
  22. objectives : Objective.objective list;
    (*

    objectives to complete before the final mission is revealed

    *)
  23. cleared_objectives : Objective.objective list;
    (*

    objectives that have been cleared

    *)
  24. final_mission : Objective.final_mission option;
    (*

    What the game's final objective is

    *)
}

Running game state

val game_state : state Stdlib.ref

Reference to the global game state

val locate_character : Character.character -> Map.room

Get room a character is in

val add_character : Character.character -> Map.room -> unit

Add a character to a room

val set_character_room : Character.character -> Map.room -> unit

Set the position of a character

val get_character_scrap : Character.character -> int

Determine the number of scrap a character has

val set_character_scrap : Character.character -> int -> unit

Set the number of scrap a character has

val get_character_items : Character.character -> Item.item list

Get the items in a character's inventory

val add_character_item : Character.character -> Item.item -> unit

Add an item to a character's inventory

val remove_character_item : Character.character -> Item.item -> unit

Remove an item from a character's inventory

val pop_character_item : Character.character -> int -> Item.item option

Remove an item from a character and return it

val character_has_item : Item.item -> Character.character -> bool

Whether a character has a specific item in their inventory

val character_locations : unit -> (Character.character * Map.room) list

List of characters and their locations

val set_room_scrap : Map.room -> int -> unit

Set the number of scrap in a room

val set_room_has_event : Map.room -> bool -> unit

Set whether a room has an event

val has_coolant : Map.room -> bool

Check whether a room contains coolant

val add_room_item : Map.room -> Item.item -> unit

Add an item to a room

val remove_room_item : Map.room -> Item.item -> unit

Remove an item from a room

val pop_room_item : Map.room -> int -> Item.item option

Remove an item from a room and return it, if one exists

val set_map : string -> unit

Set the game's map

val shuffle_encounters : unit -> unit

Shuffle the list of random encounters

val discard_encounter : unit -> Encounter.encounter option

Remove the top encounter from the list of random encounters

val replace_encounter : unit -> unit

Take the top encounter from the discarded encounters list and replace it in the list of random encounters

val replace_all_encounters : unit -> unit
val replace_alien_encounters : unit -> unit
val replace_order937_encounters : unit -> unit
val get_xeno_room : unit -> Map.room
val set_xeno_room : Map.room -> unit
val set_ash_room : Map.room -> unit
val set_ash_health : int -> unit
val set_ash_killed : bool -> unit
val add_objective : Objective.objective -> unit
val clear_objective : Objective.objective -> unit
val catch_jonesy : unit -> unit
val set_morale : int -> unit
val start_self_destruct : int -> Character.character -> unit
val set_final_mission : Objective.final_mission -> unit
val set_turn : int -> Character.character -> unit
val set_self_destruct_counter : int -> unit
val incr_round : unit -> unit