/
cardtest3_council_room
97 lines (78 loc) · 3.05 KB
/
cardtest3_council_room
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <stdlib.h>
#include <time.h> // From study of random in lectures and work
// This is from the cardtest4.c (on steward) that was provided in Lectures_Week_4
// I modified my cardtest3.c for Council_Room (form Assignment 3) and I will use Random variables
#define TESTCARD "council room"
int main()
{
int newCards = 0;
int discarded = 1;
int xtraCoins = 0;
int numActions = 1;
int numBuys = 1; // Every player starts out with 1 buy. Council Room let you buy get an extra buy.
int shuffledCards = 0;
int i, j, m;
int handpos = 0, choice1 = 0, choice2 = 0, choice3 = 0, bonus = 0;
int remove1, remove2;
int seed = 1000;
int numPlayers = 2;
int thisPlayer = 0;
struct gameState G, testG;
int k[10] = {adventurer, village, council_room, embargo, minion, mine,
cutpurse, sea_hag, tribute, smithy};
int myRandNum;
myRandNum = (rand() %(4 - 1 + 1)) + 1; // 4 is upper, 1 is lower
// Initialize a game state and player cards
initializeGame(numPlayers, k, seed, &G);
printf("------------- Testing Card: %s ------------\n", TESTCARD);
// Copy the game state to a test case
memcpy(&testG, &G, sizeof(struct gameState));
cardEffect(council_room, &testG, handPos, thisPlayer);
printf("hand count = %d, expected = %d\n", testG.handCount[thisPlayer], G.handCount[thisPlayer] + myRandNum - discarded); // 4 is replaced by myRandNum
printf("deck count = %d, expected = %d\n", testG.deckCount[thisPlayer], G.deckCount[thisPlayer] - myRandNum + shuffledCards); // 4 is replaced by myRandNum
printf("number of buys = %d, expected = %d\n", testG.numBuys[thisPlayer], G.numBuys[thisPlayer] + 1);
assert(testG.handCount[thisPlayer] == G.handCount[thisPlayer] + myRandNum - discarded); // 4 is replaced by myRandNum
assert(testG.deckCount[thisPlayer] == G.deckCount[thisPlayer] - myRandNum + shuffledCards); // 4 is replaced by myRandNum
assert(testG.numBuys[thisPlayer] == G.numBuys[thisPlayer] + 1);
// Note: for loop is similar to the one for council_room at line 688 from dominion.c
// Each other player draws a card
for (i = 0; i < state->numPlayers; i++)
{
if ( i != currentPlayer )
{
// drawCard(i, state);
printf("hand count = %d, expected = %d\n", testG.handCount[i], G.handCount[i] + 1 - discarded);
printf("deck count = %d, expected = %d\n", testG.deckCount[i], G.deckCount[i] - 1 + shuffledCards);
}
}
return 0;
}
/*
int cardResult_Council_Room(struct gameState *state, int handPos, int currentPlayer) {
int i; // CHANGE
//+4 Cards
for (i = 0; i < 2; i++) // CHANGE 4 to 2
{
drawCard(currentPlayer, state);
}
//+1 Buy
state->numBuys++;
//Each other player draws a card
for (i = 0; i < state->numPlayers; i++)
{
if ( i != currentPlayer )
{
drawCard(i, state);
}
}
//put played card in played card pile
discardCard(handPos, currentPlayer, state, 0);
return 0;
}
*/