Last active
December 11, 2018 17:06
-
-
Save tina1998612/0b069abbbcd273fec46b0ba1960c9c79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uint64_t MAX_ROOM_WAIT_TIME = 2 * 60 * 1000; // 2 mins | |
const uint8_t MAX_PLAYERS = 5; | |
enum game_status : uint8_t { INIT = 0, ONGOING = 1, TIMEOUT = 2 }; | |
enum card_type : uint8_t { | |
EMPTY = 0, // Represents empty slot in hand | |
SPADE = 1, | |
HEART = 2, | |
DIAMOND = 3, | |
CLUB = 4 | |
}; | |
struct [[eosio::table]] card { | |
uint8_t type; | |
uint8_t number; | |
}; | |
typedef uint8_t card_id; | |
struct [[eosio::table]] player { | |
name username; | |
uint64_t bet; | |
vector<uint64_t> game_room_ids = {}; | |
auto primary_key() const { return username.value; } | |
}; | |
struct [[eosio::table]] game_room { | |
uint64_t id; | |
uint8_t room_type; | |
uint8_t status = INIT; | |
uint64_t start_time; | |
// players in this game | |
vector<player> players = {}; | |
vector<card_id> deck_left = { | |
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, | |
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, | |
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54}; | |
auto primary_key() const { return id; } | |
}; | |
typedef eosio::multi_index<name{"minbets"}, room_to_min_bet> room_to_min_bets_table; | |
typedef eosio::multi_index<name{"rooms"}, game_room> game_rooms_table; | |
typedef eosio::multi_index<name{"players"}, player> players_table; | |
room_to_min_bets_table room_to_min_bets; | |
game_rooms_table _game_rooms; | |
players_table _players; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment