Skip to content

Commit 5e2dec0

Browse files
committed
tests for composition
1 parent 1579a66 commit 5e2dec0

2 files changed

Lines changed: 66 additions & 2 deletions

File tree

src/main/java/hotciv/framework/GameConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ public class GameConstants {
4545
// Valid production balance types
4646
public static final String productionFocus = "hammer";
4747
public static final String foodFocus = "apple";
48+
public static final boolean WINNER_FOUND = false;
4849
}

src/test/java/hotciv/standard/game_tests.java

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.ArrayList;
1010
import java.util.List;
1111

12+
import static hotciv.framework.GameConstants.WINNER_FOUND;
1213
import static org.hamcrest.CoreMatchers.*;
1314
import static org.junit.Assert.assertThat;
1415

@@ -73,24 +74,86 @@ public void gameStartIs4000BC() {
7374
}
7475

7576
@Test
76-
public void progress100YearsEveryTurn() {
77+
public void alphaCiv_Progress100YearsEveryTurn() {
7778
int turn1 = game.getAge();
7879
game.endOfTurn();
7980
int turn2 = game.getAge();
8081

8182
assertThat((turn2 - turn1), is(100));
8283
}
8384

85+
@Test
86+
public void betaCiv_DynamicWorldAging() {
87+
88+
// 100 Years per turn pre- 100BC
89+
for (int i = 0; i < 38; i++){
90+
game.endOfTurn();
91+
}
92+
assertThat(game.getAge(), is(-100));
93+
94+
// Next turn is 1BC
95+
game.endOfTurn();
96+
assertThat(game.getAge(), is(-1));
97+
98+
// Next turn is 1AD
99+
game.endOfTurn();
100+
assertThat(game.getAge(), is(1));
101+
102+
// Next turn is 50AD
103+
game.endOfTurn();
104+
assertThat(game.getAge(), is(50));
105+
106+
107+
// 50 years per turn until 1750
108+
for (int j = 0; j < 33; j++) {
109+
game.endOfTurn();
110+
}
111+
assertThat(game.getAge(), is(1750));
112+
113+
// 25 years per turn until 1900
114+
for (int h = 0; h < 5; h++) {
115+
game.endOfTurn();
116+
}
117+
assertThat(game.getAge(), is(1900));
118+
119+
// 5 years per turn until 1970
120+
for (int k = 0; k < 34; k++) {
121+
game.endOfTurn();
122+
}
123+
assertThat(game.getAge(), is(1970));
124+
125+
// 1 year per turn for the rest of the game
126+
for (int m = 0; m < 99; m++) {
127+
game.endOfTurn();
128+
}
129+
assertThat(game.getAge(), is(2070));
130+
}
131+
84132

85133
@Test
86-
public void redWinsIf3000BC() {
134+
public void alphaCiv_RedWinsIf3000BC() {
87135
for (int i = 0; i < 10; i++) {
88136
game.endOfTurn();
89137
}
90138
assertThat(game.getAge(), is(-3000));
91139
assertThat(game.getWinner(), is(Player.RED));
92140
}
93141

142+
@Test
143+
public void betaCiv_FirstPlayerThatConquersWorldWins() {
144+
Position city1 = new Position(1,1);
145+
Position city2 = new Position(1,4);
146+
147+
game.setCityAt(city1, Player.BLUE);
148+
149+
assertThat(game.getWinner(), is(Player.BLUE)); // Blue owns both cities and should win
150+
151+
game.setCityAt(city1, Player.RED);
152+
game.setCityAt(city2, Player.RED);
153+
154+
assertThat(game.getWinner(), is(Player.BLUE)); // Blue already won the game, so they remain the winner.
155+
}
156+
94157
@Test //TPD
95158
public void attackingUnitAlwaysWins(){
96159
Position posArcher = new Position(0, 2); //Attacker

0 commit comments

Comments
 (0)