#ifndef H_LOGIC #define H_LOGIC #include #include #include #include "chick.h" struct game_state { uint24_t num_days; bool lamp_on; time_t time; time_t start_time; time_t lamp_switch_time; struct chick chicks[NUM_CHICKS]; }; enum { STATUS_IN_PROGRESS, STATUS_GAME_OVER_HOT, STATUS_GAME_OVER_COLD, STATUS_GAME_OVER_TIME, STATUS_EXIT }; // Returns a status uint8_t update(struct game_state *new, const struct game_state *old); bool lamp_should_be_on(time_t time); bool are_chicks_hot(time_t time, bool lamp_on); bool are_chicks_cold(time_t time, bool lamp_on); // Whether enough time has elapsed to trigger a game over bool have_chicks_overheated(time_t current_time, time_t lamp_switch_time, bool lamp_on); bool have_chicks_underheated(time_t current_time, time_t lamp_switch_time, bool lamp_on); #endif