Skip to content

Commit 2fe5b9c

Browse files
committed
thetaCiv testing done
1 parent bbdfc16 commit 2fe5b9c

2 files changed

Lines changed: 117 additions & 2 deletions

File tree

src/main/java/hotciv/standard/CityImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,12 @@ private boolean valid_production_type(String unitType) {
166166
return UnitImpl.valid_unit_type(unitType);
167167
}
168168

169+
//....................testing functions....................//
170+
public void setPopulation(int population) {
171+
this.population = population;
172+
}
173+
174+
public void setProductionRate(int production_rate) {
175+
this.production_rate = production_rate;
176+
}
169177
}

src/test/java/hotciv/standard/thetaCiv_tests.java

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import org.junit.Before;
66
import org.junit.Test;
77

8-
import static hotciv.framework.GameConstants.ARCHER;
9-
import static hotciv.framework.GameConstants.SETTLER;
8+
import static hotciv.framework.GameConstants.*;
109
import static org.hamcrest.CoreMatchers.is;
1110
import static org.junit.Assert.assertNull;
1211
import static org.junit.Assert.assertThat;
@@ -23,6 +22,114 @@ public void setUp() {
2322
game = new GameImpl(GameType.thetaCiv, 2);
2423
}
2524

25+
//............Unique Theta Stuff............//
26+
27+
28+
@Test
29+
public void ufoHas1Attack8Defense(){
30+
Position posUFO = new Position(3, 4);
31+
game.createUnitAt(posUFO, UFO, Player.RED);
32+
assertThat(game.getUnitAt(posUFO).getAttackingStrength(), is(1));
33+
assertThat(game.getUnitAt(posUFO).getDefensiveStrength(), is(8));
34+
}
35+
36+
@Test
37+
public void ufoHasTravelDistance2(){
38+
Position posUFO = new Position(3, 4);
39+
game.createUnitAt(posUFO, UFO, Player.RED);
40+
assertThat(game.getUnitAt(posUFO).getMoveCount(), is(2));
41+
}
42+
43+
@Test
44+
public void ufoCanTravelOverOceans(){
45+
Position posUFO = new Position(3, 4);
46+
game.createUnitAt(posUFO, UFO, Player.RED);
47+
Position posOcean = new Position(3, 5);
48+
assertThat(game.getUnitAt(posUFO).getMoveCount(), is(2));
49+
game.moveUnit(posUFO, posOcean);
50+
assertThat(game.getUnitAt(posOcean).getTypeString(), is(UFO));
51+
}
52+
53+
@Test
54+
public void ufoCanTravelOverMountains(){
55+
Position posUFO = new Position(3, 4);
56+
game.createUnitAt(posUFO, UFO, Player.RED);
57+
Position posMountain = new Position(4, 4);
58+
assertThat(game.getUnitAt(posUFO).getMoveCount(), is(2));
59+
game.moveUnit(posUFO, posMountain);
60+
assertThat(game.getUnitAt(posMountain).getTypeString(), is(UFO));
61+
}
62+
63+
@Test
64+
public void cityCanProduceUFO(){
65+
Position posCity = new Position(4, 4);
66+
game.setCityAt(posCity, Player.RED);
67+
game.getCityAt(posCity).setProductionRate(60);
68+
game.changeProductionInCityAt(posCity, UFO);
69+
game.endOfTurn();
70+
game.endOfTurn();
71+
assertThat(game.getUnitAt(posCity).getTypeString(), is(UFO));
72+
}
73+
74+
@Test
75+
public void ufoCanFlyOverEnemyCityIfThereAreNoUnits(){
76+
Position posUFO = new Position(3, 4);
77+
game.createUnitAt(posUFO, UFO, Player.RED);
78+
Position posCity = new Position(4, 4);
79+
game.setCityAt(posCity, Player.BLUE);
80+
game.moveUnit(posUFO, posCity);
81+
assertThat(game.getUnitAt(posCity).getTypeString(), is(UFO));
82+
assertThat(game.getUnitAt(posCity).getOwner(), is(Player.RED)); //ensures ownership of ufo is correct
83+
assertThat(game.getCityAt(posCity).getOwner(), is(Player.BLUE)); //ensures ownership of city is correct
84+
}
85+
86+
@Test
87+
public void ufoWillBatlleEnemyUnitOnEnemyCity(){
88+
Position posUFO = new Position(3, 4);
89+
game.createUnitAt(posUFO, UFO, Player.RED);
90+
Position posCity = new Position(4, 4);
91+
game.setCityAt(posCity, Player.BLUE);
92+
game.createUnitAt(posCity, ARCHER, Player.BLUE);
93+
game.moveUnit(posUFO, posCity);
94+
assertThat(game.getUnitAt(posCity).getTypeString(), is(UFO));
95+
assertThat(game.getUnitAt(posCity).getOwner(), is(Player.RED));
96+
assertThat(game.getCityAt(posCity).getOwner(), is(Player.BLUE));
97+
}
98+
99+
@Test
100+
public void ufoAbductsCityPopulation1(){
101+
Position posUFO = new Position(3, 4);
102+
game.createUnitAt(posUFO, "ufo", Player.RED);
103+
game.setCityAt(posUFO, Player.BLUE); //default population 1
104+
game.performUnitActionAt(posUFO);
105+
assertNull(game.getCityAt(posUFO));
106+
}
107+
108+
@Test
109+
public void ufoAbductsCityPopulation2(){
110+
Position posUFO = new Position(3, 4);
111+
game.createUnitAt(posUFO, UFO, Player.RED);
112+
game.setCityAt(posUFO, Player.BLUE); //default population 1
113+
game.getCityAt(posUFO).setPopulation(2); //increase pop to 2
114+
game.performUnitActionAt(posUFO);
115+
assertThat(game.getCityAt(posUFO).getSize(), is(1));
116+
}
117+
118+
@Test
119+
public void ufoChangesForestToPlains(){
120+
Position posUFO = new Position(3, 4);
121+
game.createUnitAt(posUFO, UFO, Player.RED);
122+
Position posForest = new Position(3, 5);
123+
game.getTileAt(posForest).setTerrain(FOREST);
124+
game.moveUnit(posUFO, posForest);
125+
game.performUnitActionAt(posForest);
126+
assertThat(game.getTileAt(posForest).getTypeString(), is(PLAINS));
127+
}
128+
129+
130+
131+
132+
//..........Gamma Tests Carryover...........//
26133
//..........Unit Tests...........//
27134

28135
@Test

0 commit comments

Comments
 (0)