From bdd8d563ff3f0eec41cc45d07f6c00622a531a72 Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Tue, 21 May 2024 22:51:55 -0600 Subject: first commit --- rps_game/src/rps.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 rps_game/src/rps.h (limited to 'rps_game/src/rps.h') diff --git a/rps_game/src/rps.h b/rps_game/src/rps.h new file mode 100644 index 0000000..422df51 --- /dev/null +++ b/rps_game/src/rps.h @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include +#include + +#include + +namespace RPS { + enum GAME_OBJECTS { + NONE = -1, + ROCK, + PAPER, + SCISSORS, + DUAL + }; + + typedef int8_t OBJECT; + + struct RPSLog { + OBJECT p1_choice; + OBJECT p2_choice; + }; + + struct RPSStats { + int rock_count; + int paper_count; + int scissors_count; + }; + + constexpr OBJECT ROCK_BEATS = SCISSORS; + constexpr OBJECT PAPER_BEATS = ROCK; + constexpr OBJECT SCISSORS_BEATS = PAPER; + + constexpr OBJECT BEATS_ROCK = PAPER; + constexpr OBJECT BEATS_PAPER = SCISSORS; + constexpr OBJECT BEATS_SCISSORS = ROCK; + + OBJECT what_it_beats(OBJECT obj); + OBJECT what_beats_it(OBJECT obj); + OBJECT who_won(OBJECT a, OBJECT b); + OBJECT who_won(RPSLog log); + bool is_game_object(OBJECT obj); + int obj_to_string(OBJECT obj, char * buf, size_t buf_size); + int update_rps_stat(RPSStats * stats, OBJECT new_obj); // Update the stats structure. +} -- cgit v1.2.3