예제 #1
0
// advance the game to the next turn,
// assuming that the dice has just been rolled and produced diceScore
// the game starts in turn -1 (we call this state "Terra Nullis") and
// moves to turn 0 as soon as the first dice is thrown->
void throwDice(Game g, int diceScore) {
    g->currentTurn++;

    // give out resources based on diceScore
        int x = 0;
    while (x < NUM_REGIONS_X) {
        int y = 0;
        while (y < NUM_REGIONS_Y) {
            if (validRegion(x, y)) {
                if (g->gameBoard->regions[x][y]->diceValue == diceScore) {
                    int resource = g->gameBoard->regions[x][y]->discipline;
                    giveResource(g, x, y, resource);
                }
            }
            y++;
        }
        x++;
    }
    if (diceScore == 7) {
        int i = 0;
        while (i < NUM_UNIS) {
            g->players[i]->students[STUDENT_THD] +=
                g->players[i]->students[STUDENT_MMONEY] +
                g->players[i]->students[STUDENT_MTV];
            g->players[i]->students[STUDENT_MMONEY] = 0;
            g->players[i]->students[STUDENT_MTV] = 0;
            i++;
        }
    }
}
예제 #2
0
// Create the board
static void createBoard(Game g, int discipline[], int dice[]) {
    g->gameBoard = malloc (sizeof (struct _board));
    assert(g->gameBoard != NULL);

    // Create the points that exist
    int x = 0;
    while (x < NUM_POINTS_X) {
        int y = 0;
        while (y < NUM_POINTS_Y) {
            if (validPoint(x, y)) {
                createPoint(g, x, y);
            }
            y++;
        }
        x++;
    }

    // Create the regions that exist
    x = 0;
    int i = 0;

    while (x < NUM_REGIONS_X) {
        int y = 0;
        while (y < NUM_REGIONS_Y) {
            if (validRegion(x, y)) {
                createRegion(g, x, y, i, dice[i], discipline[i]);
                // Add the region to the points around it
                addRegionToPoints(g, x, y);
                i++;
            }
            y++;
        }
        x++;
    }
}
예제 #3
0
TEST(TiledLayerBuffer, EmptyUpdate) {
  TestTiledLayerBuffer buffer;

  nsIntRegion validRegion(nsIntRect(0, 0, 10, 10));
  buffer.TestUpdate(validRegion, validRegion);

  ASSERT_EQ(buffer.GetValidRegion(), validRegion);
}
예제 #4
0
TEST(TiledLayerBuffer, EmptyUpdate) {
  gfxPlatform::GetPlatform()->ComputeTileSize();

  TestTiledLayerBuffer buffer;

  nsIntRegion validRegion(nsIntRect(0, 0, 10, 10));
  buffer.TestUpdate(validRegion, validRegion);

  ASSERT_EQ(buffer.GetValidRegion(), validRegion);
}
예제 #5
0
// free all the memory malloced for regions
static void disposeRegions(Game g) {
    int x = 0;
    int y = 0;

    while (x < NUM_REGIONS_X) {
        y = 0;
        while (y < NUM_REGIONS_Y) {
            if (validRegion(x, y)) {
                free(g->gameBoard->regions[x][y]);
            }
            y++;
        }
        x++;
    }
}
예제 #6
0
// what dice value produces students in the specified region?
// 2->->12
int getDiceValue(Game g, int regionID) {
    int x = 0;
    int dice = 0;
    while (x < NUM_REGIONS_X) {
        int y = 0;
        while (y < NUM_REGIONS_Y) {
            if (validRegion(x, y)) {
                if (g->gameBoard->regions[x][y]->regionID == regionID) {
                    dice = g->gameBoard->regions[x][y]->diceValue;
                }
            }
            y++;
        }
        x++;
    }
    return dice;
}