Skip to content

Commit

Permalink
Making mandatory checks for player join
Browse files Browse the repository at this point in the history
  • Loading branch information
sg777 committed Nov 16, 2023
1 parent c4ea685 commit 5ba78ee
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions privatebet/err.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ const char *bet_err_str(int32_t err_no)
return "Error in cashier config args, check if all the necessary args are confiured in verus_cashier.ini";
case ERR_CONFIG_BLOCKCHAIN_ARGS:
return "Error in blockchain config args, check if all the necessary args are confiured in blockchain_config.ini";
case ERR_IDS_NOT_CONFIGURED:
return "The mandatory IDs needed to play poker are not created on CHAIN";
default:
return "This error is not handled yet...";
}
Expand Down
1 change: 1 addition & 0 deletions privatebet/err.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ All the errors that come across in bet are defined here. The error numbers are a
#define ERR_CONFIG_DEALER_ARGS 133
#define ERR_CONFIG_CASHIER_ARGS 134
#define ERR_CONFIG_BLOCKCHAIN_ARGS 135
#define ERR_IDS_NOT_CONFIGURED 136

// clang-format on
const char *bet_err_str(int32_t err_no);
Expand Down
4 changes: 4 additions & 0 deletions privatebet/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ int32_t handle_verus_player()
{
int32_t retval = OK;

if((retval = check_poker_ready()) != OK) {
return retval;
}

bet_parse_verus_player();

if ((retval = find_table()) != OK)
Expand Down
17 changes: 17 additions & 0 deletions privatebet/vdxf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,3 +1239,20 @@ void list_tables()
}
}
}

int32_t check_poker_ready()
{
int32_t retval = OK;
cJSON *dealers = NULL;

if((!is_id_exists(CASHIERS_ID, 1)) || (!is_id_exists(DEALERS_ID, 1))) {
return ERR_IDS_NOT_CONFIGURED;
}

dealers = cJSON_CreateObject();
dealers = get_cJSON_from_id_key("dealers", DEALERS_KEY);
if(!dealers) {
return ERR_NO_DEALERS_FOUND;
}
return retval;
}
2 changes: 2 additions & 0 deletions privatebet/vdxf.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Any entity in the bet ecosystem can register the identities under chips, like fo
under chips as sg777.chips@ which basically been used to hold the tokens.
*/
#define CASHIERS_ID "cashiers.poker.chips10sec@"
#define DEALERS_ID "dealers.poker.chips10sec@"
#define POKER_CHIPS_VDXF_ID "poker.chips10sec@"

#define ID_UPDATE_ESTIMATE_NO 50
Expand Down Expand Up @@ -156,4 +157,5 @@ int32_t do_payin_tx_checks(char *txid, cJSON *payin_tx_data);
void process_block(char *block_hash);
void list_dealers();
void list_tables();
int32_t check_poker_ready();
#endif

0 comments on commit 5ba78ee

Please sign in to comment.