Skip to content

Commit

Permalink
Prepare for GamePhaseController implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Lukoťka committed Nov 3, 2024
1 parent 88415aa commit 1a33c90
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/sk/uniba/fmph/dcs/game_board/Building.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Collection;
import java.util.OptionalInt;
import sk.uniba.fmph.dcs.stone_age.Effect;
import sk.uniba.fmph.dcs.stone_age.Effect;

interface Building {
OptionalInt build(Collection<Effect> resources);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import org.apache.commons.collections4.CollectionUtils;

import sk.uniba.fmph.dcs.stone_age.Effect;
import sk.uniba.fmph.dcs.stone_age.Effect;

public final class SimpleBuilding implements Building {
private ArrayList<Effect> requiredResources;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/sk/uniba/fmph/dcs/stone_age/ActionResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package sk.uniba.fmph.dcs.stone_age;

public enum ActionResult {
FAILURE,
ACTION_DONE,
ACTION_DONE_WAIT_FOR_TOOL_USE,
ACTION_DONE_ALL_PLAYERS_TAKE_A_REWARD,
}
7 changes: 7 additions & 0 deletions src/main/java/sk/uniba/fmph/dcs/stone_age/HasAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package sk.uniba.fmph.dcs.stone_age;

public enum HasAction {
WAITING_FOR_PLAYER_ACTION,
AUTOMATIC_ACTION_DONE,
NO_ACTION_POSSIBLE,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package sk.uniba.fmph.dcs.stone_age;

import java.util.Collection;

public interface InterfaceGamePhaseController {
boolean placeFigures(PlayerOrder player, Location location, int figuresCount);

boolean makeAction(
PlayerOrder player,
Location location,
Collection<Effect> inputResources,
Collection<Effect> outputResources);

boolean skipAction(PlayerOrder player, Location location);

boolean useTools(PlayerOrder player, int toolIndex);

boolean noMoreToolsThisThrow(PlayerOrder player);

boolean feedTribe(PlayerOrder player, Collection<Effect> resources);

boolean doNotFeedThisTurn(PlayerOrder player);

boolean makeAllPlayersTakeARewardChoice(PlayerOrder player, Effect reward);

String state();
}
20 changes: 20 additions & 0 deletions src/main/java/sk/uniba/fmph/dcs/stone_age/Location.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package sk.uniba.fmph.dcs.stone_age;

public enum Location {
TOOL_MAKER,
HUT,
FIELD,
HUNTING_GROUNDS,
FOREST,
CLAY_MOUND,
QUARY,
RIVER,
CIVILISATION_CARD1,
CIVILISATION_CARD2,
CIVILISATION_CARD3,
CIVILISATION_CARD4,
BUILDING_TILE1,
BUILDING_TILE2,
BUILDING_TILE3,
BUILDING_TILE4,
}
59 changes: 59 additions & 0 deletions src/main/java/sk/uniba/fmph/dcs/stone_age/PlayerOrder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package sk.uniba.fmph.dcs.stone_age;

public final class PlayerOrder {
private int order;
private int players;

public PlayerOrder(final int order, final int players) {
this.order = order;
this.players = players;
}

public int getOrder() {
return order;
}

public int getPlayers() {
return players;
}

public PlayerOrder forward() {
int forward = (this.order + 1) % this.players;
return new PlayerOrder(forward, this.players);
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + order;
result = prime * result + players;
return result;
}

@Override
public boolean equals(final Object obj) throws IllegalArgumentException {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
PlayerOrder other = (PlayerOrder) obj;
if (order != other.order) {
return false;
}
if (players != other.players) {
throw new IllegalStateException();
}
return true;
}

@Override
public String toString() {
return "PlayerOrder [order=" + order + "]";
}
}

0 comments on commit 1a33c90

Please sign in to comment.