Skip to content

Commit

Permalink
The reward and cost wonder's have know the good index, add a conditio…
Browse files Browse the repository at this point in the history
…n in MilitaryStrategy #140
  • Loading branch information
zn508116 committed Oct 16, 2020
1 parent 8de1257 commit 4dd2e90
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions client/src/main/java/player/MilitaryStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public Action chooseAction(Player player) {
}
}

if (player.wonder.getProp().get(player.wonder.getState()+1).y.get(CardPoints.MILITARY) != null &&
(player.wonder.getProp().get(player.wonder.getState()+1).y.get(CardPoints.MILITARY) > mostMilitary.getCardPoints().get(CardPoints.MILITARY) &&
if (!player.wonder.isWonderFinished() && player.wonder.getProp().get(player.wonder.getState()).y.get(CardPoints.MILITARY) != null &&
(player.wonder.getProp().get(player.wonder.getState()).y.get(CardPoints.MILITARY) > mostMilitary.getCardPoints().get(CardPoints.MILITARY) &&
player.wonder.canUpgrade(player.resources))) {
return new Action(mostMilitary, Action.WONDER);
} else if (player.isBuildable(mostMilitary)) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/wonder/Wonder.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Wonder(String name) throws IOException {
if (stages.size() > 0) {
maxState = stages.size();
prop = new ArrayList<>(stages.size());
for (int i = 0; i < stages.size(); i++) {
for (int i = maxState-1; i >= 0; i--) {
EnumMap<Resource, Integer> tmpMap = new EnumMap<>(Resource.class);
EnumMap<CardPoints, Integer> tmpMap2 = new EnumMap<>(CardPoints.class);
JSONObject stage = card.getJSONObject(stages.get(i));
Expand Down
5 changes: 3 additions & 2 deletions client/src/test/java/wonder/WonderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ void getMaxstate() {
assertEquals(state,wonder.getMaxstate());
}

@Ignore //TODO this method return the reward in the reverse order state
@Test
void getCurrentRewardsFromUpgrade() {
//setup wonder = babyloneA
// the key is fix at CardPoints so it can't never return Ressoure.COIN
EnumMap<CardPoints,Integer> oracle = new EnumMap<CardPoints, Integer>(CardPoints.class);
oracle.put(CardPoints.VICTORY, 3);
assertEquals(oracle, this.wonder.getCurrentRewardsFromUpgrade()); //index/state = 0, cost stage 1
assertEquals(oracle, this.wonder.getProp().get(this.wonder.getState()).y); //index/state = 0, cost stage 1

wonder.setState(wonder.getState() + 1); // stage one is build
oracle = new EnumMap<CardPoints, Integer>(CardPoints.class);
Expand Down Expand Up @@ -103,7 +104,7 @@ void parseTest() throws IOException {

}

@Ignore //TODO this method return the cost in the reverse order state
@Test
void getCurrentUpgradeCost() {
//setup wonder = babyloneA
EnumMap<Resource,Integer> oracle = new EnumMap<Resource, Integer>(Resource.class);
Expand Down

0 comments on commit 4dd2e90

Please sign in to comment.