<commit_before>// Copyright (c) 2016 <NAME>
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the MIT License. See LICENSE for more details.

#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "example/blackjack_server.h"

// Declare blackjack game structure for server
struct card {
	int id;
	int highValue;
	int lowValue;
	char *display;
};

struct hand {
	int stay;
	int cards[HAND_CARD_MAX];
};

struct deck {
	struct card cards[DECK_CARD_MAX];
};

struct seat {
	int id;
	int socket;
	struct hand hands[HAND_MAX];
};

struct table {
	int id;
	int dealDeckIndex;
	int dealCardIndex;
	struct seat seats[SEAT_MAX];
	struct deck decks[DECK_MAX];
	int dealerCards[HAND_CARD_MAX];
};

struct blackjack {
	struct table tables[TABLE_MAX];
};

// Define static structures
static struct blackjack myBlackjack;
static struct card masterDeck[DECK_CARD_MAX] = {
	{ 1, 7,  7,  "7-H" },
	{ 2, 8,  8,  "8-H" },
	{ 3, 9,  9,  "9-H" },
	{ 4, 10, 10, "10-H" },
	{ 5, 10, 10, "J-H" },
	{ 6, 10, 10, "Q-H" },
	{ 7, 10, 10, "K-H" },
	{ 8, 11, 1,  "A-H" },
	{ 9, 7,  7,  "7-D" },
	{ 10, 8,  8,  "8-D" },
	{ 11, 9,  9,  "9-D" },
	{ 12, 10, 10, "10-D" },
	{ 13, 10, 10, "J-D" },
	{ 14, 10, 10, "Q-D" },
	{ 15, 10, 10, "K-D" },
	{ 16, 11, 1,  "A-D" },
	{ 17, 7,  7,  "7-C" },
	{ 18, 8,  8,  "8-C" },
	{ 19, 9,  9,  "9-C" },
	{ 20, 10, 10, "10-C" },
	{ 21, 10, 10, "J-C" },
	{ 22, 10, 10, "Q-C" },
	{ 23, 10, 10, "K-C" },
	{ 24, 11, 1,  "A-C" },
	{ 25, 7,  7,  "7-S" },
	{ 26, 8,  8,  "8-S" },
	{ 27, 9,  9,  "9-S" },
	{ 28, 10, 10, "10-S" },
	{ 29, 10, 10, "J-S" },
	{ 30, 10, 10, "Q-S" },
	{ 31, 10, 10, "K-S" },
	{ 32, 11, 1,  "A-S" },
};

// Game functions

void blackjack_init(void) {
	int t, s, h, c;
	
	// Initialize tables
	for (t = 0; t < TABLE_MAX; ++t) {
		
		// Assign table id
		myBlackjack.tables[t].id = t+1;
		
		// Assign seat ids and set socket asignments to zero
		for (s = 0; s < SEAT_MAX; ++s) {
			myBlackjack.tables[t].seats[s].id = s+1;
			myBlackjack.tables[t].seats[s].socket = 0;
		}
		
		// Shuffling cards
		blackjack_shuffle_table(t);

	}
	
	// Initialize all player cards to zero (empty)
	for (t = 0; t < TABLE_MAX; ++t)
		for (s = 0; s < SEAT_MAX; ++s)
			for (h = 0; h < HAND_MAX; ++h)
				for (c = 0; c < HAND_CARD_MAX; ++c)
					myBlackjack.tables[t].seats[s].hands[h].cards[c] = 0;
	
	// Initialize all player 'stay' state to zero
	for (t = 0; t < TABLE_MAX; ++t)
		for (s = 0; s < SEAT_MAX; ++s)
			for (h = 0; h < HAND_MAX; ++h)
				myBlackjack.tables[t].seats[s].hands[h].stay = 0;

	// Initalize all dealer cards to zero
	for (t = 0; t < TABLE_MAX; ++t)<commit_msg>Add waiting flag to hand struct<commit_after>// Copyright (c) 2016 <NAME>
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the MIT License. See LICENSE for more details.

#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "example/blackjack_server.h"

// Declare blackjack game structure for server
struct card {
	int id;
	int highValue;
	int lowValue;
	char *display;
};

struct hand {
	int stay;
	int waiting;
	int cards[HAND_CARD_MAX];
};

struct deck {
	struct card cards[DECK_CARD_MAX];
};

struct seat {
	int id;
	int socket;
	struct hand hands[HAND_MAX];
};

struct table {
	int id;
	int dealDeckIndex;
	int dealCardIndex;
	struct seat seats[SEAT_MAX];
	struct deck decks[DECK_MAX];
	int dealerCards[HAND_CARD_MAX];
};

struct blackjack {
	struct table tables[TABLE_MAX];
};

// Define static structures
static struct blackjack myBlackjack;
static struct card masterDeck[DECK_CARD_MAX] = {
	{ 1, 7,  7,  "7-H" },
	{ 2, 8,  8,  "8-H" },
	{ 3, 9,  9,  "9-H" },
	{ 4, 10, 10, "10-H" },
	{ 5, 10, 10, "J-H" },
	{ 6, 10, 10, "Q-H" },
	{ 7, 10, 10, "K-H" },
	{ 8, 11, 1,  "A-H" },
	{ 9, 7,  7,  "7-D" },
	{ 10, 8,  8,  "8-D" },
	{ 11, 9,  9,  "9-D" },
	{ 12, 10, 10, "10-D" },
	{ 13, 10, 10, "J-D" },
	{ 14, 10, 10, "Q-D" },
	{ 15, 10, 10, "K-D" },
	{ 16, 11, 1,  "A-D" },
	{ 17, 7,  7,  "7-C" },
	{ 18, 8,  8,  "8-C" },
	{ 19, 9,  9,  "9-C" },
	{ 20, 10, 10, "10-C" },
	{ 21, 10, 10, "J-C" },
	{ 22, 10, 10, "Q-C" },
	{ 23, 10, 10, "K-C" },
	{ 24, 11, 1,  "A-C" },
	{ 25, 7,  7,  "7-S" },
	{ 26, 8,  8,  "8-S" },
	{ 27, 9,  9,  "9-S" },
	{ 28, 10, 10, "10-S" },
	{ 29, 10, 10, "J-S" },
	{ 30, 10, 10, "Q-S" },
	{ 31, 10, 10, "K-S" },
	{ 32, 11, 1,  "A-S" },
};

// Game functions

void blackjack_init(void) {
	int t, s, h, c;
	
	// Initialize tables
	for (t = 0; t < TABLE_MAX; ++t) {
		
		// Assign table id
		myBlackjack.tables[t].id = t+1;
		
		// Assign seat ids and set socket asignments to zero
		for (s = 0; s < SEAT_MAX; ++s) {
			myBlackjack.tables[t].seats[s].id = s+1;
			myBlackjack.tables[t].seats[s].socket = 0;
		}
		
		// Shuffling cards
		blackjack_shuffle_table(t);

	}
	
	// Initialize all player cards to zero (empty)
	for (t = 0; t < TABLE_MAX; ++t)
		for (s = 0; s < SEAT_MAX; ++s)
			for (h = 0; h < HAND_MAX; ++h)
				for (c = 0; c < HAND_CARD_MAX; ++c)
					myBlackjack.tables[t].seats[s].hands[h].cards[c] = 0;
	
	// Initialize all player 'stay' state to zero
	for (t = 0; t < TABLE_MAX; ++t)
		for (s = 0; s < SEAT_MAX; ++s)
			for (h = 0; h < HAND_MAX; ++h)
				myBlackjack.tables[t].seats[s].hands[h].stay = 0;
	
	// Initialize all player 'waiting' state to zero
	for (t = 0; t < TABLE_MAX; ++t)
		for (s = 0; s < SEAT_MAX; ++s)
			for (h = 0; h < HAND_MAX; ++h)
				myBlackjack.tables[t].seats[s].hands[h].waiting = 0;

	// Initalize all dealer cards to zero
	for (t = 0; t < TABLE_MAX; ++t)
{'fraction_non_alphanumeric': 0.20635493771438887, 'fraction_numerical': 0.07077089727387616, 'mean_word_length': 2.7306397306397305, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3688822', 'n_tokens_mistral': 2994, 'n_tokens_neox': 2542, 'n_words': 731}