Skip to content

Commit bbdfc16

Browse files
committed
theta passes gamma tests, ufo stuff inpro
1 parent 9bc09c1 commit bbdfc16

4 files changed

Lines changed: 104 additions & 2 deletions

File tree

src/main/java/hotciv/framework/GameType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ public enum GameType {
88
epsilonCiv,
99
zetaCiv,
1010
etaCiv,
11-
semiCiv
11+
semiCiv,
12+
thetaCiv
1213
}

src/main/java/hotciv/helpers/actionManagers/thetaActionManager.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ else if(Objects.equals(g.getTileAt(p).getTypeString(), FOREST)){
2727
}
2828
}
2929

30-
30+
@Override
31+
public void settlerAction(GameImpl g, Position p) {
32+
g.setCityAt(p, g.getUnitOwner(p));
33+
g.removeUnitAt(p);
34+
}
35+
36+
@Override
37+
public void archerAction(GameImpl g, Position p) {
38+
g.getUnitAt(p).fortify();
39+
}
3140

3241
}

src/main/java/hotciv/standard/GameImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ public GameImpl(GameType ruleSet, int numPlayers) {
103103
this.manager_factory = new semiManagerFactory();
104104
break;
105105

106+
case thetaCiv:
107+
this.manager_factory = new thetaManagerFactory();
108+
break;
109+
106110
default:
107111
this.manager_factory = new alphaManagerFactory();
108112
break;
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package hotciv.standard;
2+
3+
import hotciv.framework.*;
4+
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
8+
import static hotciv.framework.GameConstants.ARCHER;
9+
import static hotciv.framework.GameConstants.SETTLER;
10+
import static org.hamcrest.CoreMatchers.is;
11+
import static org.junit.Assert.assertNull;
12+
import static org.junit.Assert.assertThat;
13+
14+
15+
public class thetaCiv_tests {
16+
private GameImpl game; //Changed Game to GameImpl -TPD
17+
18+
/**
19+
* Fixture for thetaCiv testing.
20+
*/
21+
@Before
22+
public void setUp() {
23+
game = new GameImpl(GameType.thetaCiv, 2);
24+
}
25+
26+
//..........Unit Tests...........//
27+
28+
@Test
29+
public void settlerActionToCity(){
30+
//Player red has a settler at (3,4) in the test game constructor
31+
Position posSettler = new Position(3, 4);
32+
game.createUnitAt(posSettler, SETTLER, Player.RED);
33+
//game.setCityAt(posSettler, game.getUnitAt(posSettler).getOwner()); //old code
34+
game.performUnitActionAt(posSettler); //with refactoring
35+
assertThat(game.getCityAt(posSettler).getOwner(), is(Player.RED) );
36+
assertThat(game.getCityAt(posSettler).getSize(), is(1));
37+
assertNull(game.getUnitAt(posSettler));
38+
}
39+
40+
@Test
41+
public void archerFortifyDoublesDefense(){ //simulate fortifying an archer
42+
Position posArcher = new Position(0,2);
43+
game.createUnitAt(posArcher, ARCHER, Player.RED);
44+
game.getUnitAt(posArcher).setDefensiveStrength(2);
45+
game.performUnitActionAt(posArcher);
46+
assertThat(game.getUnitAt(posArcher).getDefensiveStrength(), is(4));
47+
}
48+
@Test
49+
public void archerFortifyHalvesDefense(){ //simulate fortifying an already fortified archer
50+
Position posArcher = new Position(0,2);
51+
game.createUnitAt(posArcher, ARCHER, Player.RED);
52+
game.getUnitAt(posArcher).setDefensiveStrength(1);
53+
game.getUnitAt(posArcher).fortify();
54+
game.performUnitActionAt(posArcher);
55+
assertThat(game.getUnitAt(posArcher).getDefensiveStrength(), is(1));
56+
}
57+
58+
//...............Integration Testing...................//
59+
60+
@Test
61+
public void settlerActionToCityIntegrated(){
62+
//Player red has a settler at (3,4) in the test game constructor
63+
Position posSettler = new Position(3, 4);
64+
game.createUnitAt(posSettler, SETTLER, Player.RED);
65+
game.performUnitActionAt(posSettler);
66+
assertThat(game.getCityAt(posSettler).getOwner(), is(Player.RED) );
67+
assertThat(game.getCityAt(posSettler).getSize(), is(1));
68+
assertNull(game.getUnitAt(posSettler));
69+
}
70+
71+
@Test
72+
public void archerFortifyDoublesDefenseIntegrated(){ //simulate fortifying an archer
73+
Position posArcher = new Position(0,2);
74+
game.createUnitAt(posArcher, ARCHER, Player.RED);
75+
game.getUnitAt(posArcher).setDefensiveStrength(2);
76+
game.performUnitActionAt(posArcher);
77+
assertThat(game.getUnitAt(posArcher).getDefensiveStrength(), is(4));
78+
}
79+
@Test
80+
public void archerFortifyHalvesDefenseIntegrated(){ //simulate fortifying an already fortified archer
81+
Position posArcher = new Position(0,2);
82+
game.createUnitAt(posArcher, ARCHER, Player.RED);
83+
game.getUnitAt(posArcher).setDefensiveStrength(1);
84+
game.getUnitAt(posArcher).fortify();
85+
game.performUnitActionAt(posArcher);
86+
assertThat(game.getUnitAt(posArcher).getDefensiveStrength(), is(1));
87+
}
88+
}

0 commit comments

Comments
 (0)