Open TheoPannetier opened 1 year ago
@TheoPannetier I enjoy these tests! Consider adding this one, as (1) it assures const-correctness of player::get_state
, (2) forces us to write down a default player_state.
{
// (627) A player's state is changed by specific functions, by default a player is active
const player p;
assert(p.get_state() == player_state::active); //Or a better player_state
}
I took the liberty to add this change directly to develop
😇
Context
So far, we use
player::set_state()
to change a player's states, e.g. to kill, revive or stun it. This is ok, but a more robust approach would be to change state only with a member function that takes care of the specific action.This is particularly important if the logic of the game requires other things to happen when a state is changed, e.g. changing colour when a player dies or trigger a timer when the player is stun.
Test