Merge branch 'main' of https://github.com/rubenpirreram/ing-sw-2026-pirrera-radice-pagani-pellegrino into tests-fix
This commit is contained in:
@@ -4,6 +4,9 @@ import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
|||||||
import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
|
import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
|
||||||
import it.polimi.ingsw.gc14.Network.TCP.Client.TCPClient;
|
import it.polimi.ingsw.gc14.Network.TCP.Client.TCPClient;
|
||||||
import it.polimi.ingsw.gc14.View.TUI.TUI;
|
import it.polimi.ingsw.gc14.View.TUI.TUI;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,6 +17,8 @@ import java.util.Scanner;
|
|||||||
*/
|
*/
|
||||||
public class ClientLauncherTUI {
|
public class ClientLauncherTUI {
|
||||||
|
|
||||||
|
List<String> admissibleChar=new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The TUI view associated with this client.
|
* The TUI view associated with this client.
|
||||||
*/
|
*/
|
||||||
@@ -29,6 +34,23 @@ public class ClientLauncherTUI {
|
|||||||
*/
|
*/
|
||||||
public void main() throws InterruptedException {
|
public void main() throws InterruptedException {
|
||||||
view = new TUI(null);
|
view = new TUI(null);
|
||||||
|
admissibleChar.add("0");
|
||||||
|
admissibleChar.add("1");
|
||||||
|
admissibleChar.add("2");
|
||||||
|
admissibleChar.add("3");
|
||||||
|
admissibleChar.add("4");
|
||||||
|
admissibleChar.add("5");
|
||||||
|
admissibleChar.add("6");
|
||||||
|
admissibleChar.add("7");
|
||||||
|
admissibleChar.add("8");
|
||||||
|
admissibleChar.add("9");
|
||||||
|
admissibleChar.add("A");
|
||||||
|
admissibleChar.add("B");
|
||||||
|
admissibleChar.add("C");
|
||||||
|
admissibleChar.add("a");
|
||||||
|
admissibleChar.add("b");
|
||||||
|
admissibleChar.add("c");
|
||||||
|
|
||||||
ClientController controller = new ClientController(view);
|
ClientController controller = new ClientController(view);
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
System.out.println("Insert username: ");
|
System.out.println("Insert username: ");
|
||||||
@@ -103,29 +125,37 @@ public class ClientLauncherTUI {
|
|||||||
private void getInput(Scanner scanner, ClientController controller, String username) {
|
private void getInput(Scanner scanner, ClientController controller, String username) {
|
||||||
String action = scanner.next();
|
String action = scanner.next();
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
if (!action.equals("7") && !action.equals("8") && !action.equals("9") && !action.equals("A") && !action.equals("B") && !action.equals("C")) {
|
|
||||||
try {
|
if(admissibleChar.contains(username))
|
||||||
System.out.println("Insert the required position:");
|
{
|
||||||
pos = scanner.nextInt();
|
if (!action.equals("7") && !action.equals("8") && !action.equals("9") && !action.equals("A") && !action.equals("B") && !action.equals("C")) {
|
||||||
} catch (Exception e) {
|
try {
|
||||||
System.out.println("ERROR: Invalid input(expected number)");
|
System.out.println("Insert the required position:");
|
||||||
|
pos = scanner.nextInt();
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("ERROR: Invalid input(expected number)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (action) {
|
||||||
|
case "0" -> controller.slotChoice(username, pos);
|
||||||
|
case "1" -> controller.drawUpperTribeCard(username, pos);
|
||||||
|
case "2" -> controller.drawUpperBuildingCard(username, pos);
|
||||||
|
case "3" -> controller.drawLowerTribeCard(username, pos);
|
||||||
|
case "4" -> controller.drawLowerBuildingCard(username, pos);
|
||||||
|
case "5" -> controller.pickOptionalTribeCard(username, pos);
|
||||||
|
case "6" -> controller.pickOptionalBuildingCard(username, pos);
|
||||||
|
case "7" -> controller.noOptionalCard(username);
|
||||||
|
case "8" -> controller.skipUpper(username);
|
||||||
|
case "9" -> controller.skipLower(username);
|
||||||
|
case "A", "a" -> view.fullRender();
|
||||||
|
case "B", "b" -> view.renderBoard();
|
||||||
|
case "C", "c" -> view.renderPlayer();
|
||||||
|
default -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (action) {
|
else
|
||||||
case "0" -> controller.slotChoice(username, pos);
|
{
|
||||||
case "1" -> controller.drawUpperTribeCard(username, pos);
|
System.out.println("ERROR: Invalid input(action not valid)");
|
||||||
case "2" -> controller.drawUpperBuildingCard(username, pos);
|
|
||||||
case "3" -> controller.drawLowerTribeCard(username, pos);
|
|
||||||
case "4" -> controller.drawLowerBuildingCard(username, pos);
|
|
||||||
case "5" -> controller.pickOptionalTribeCard(username, pos);
|
|
||||||
case "6" -> controller.pickOptionalBuildingCard(username, pos);
|
|
||||||
case "7" -> controller.noOptionalCard(username);
|
|
||||||
case "8" -> controller.skipUpper(username);
|
|
||||||
case "9" -> controller.skipLower(username);
|
|
||||||
case "A" -> view.fullRender();
|
|
||||||
case "B" -> view.renderBoard();
|
|
||||||
case "C" -> view.renderPlayer();
|
|
||||||
default -> {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,6 +232,16 @@ public class Game implements Serializable {
|
|||||||
orderLogicCard=new Order5(playersList);
|
orderLogicCard=new Order5(playersList);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
for(Player player : playersList)
|
||||||
|
{
|
||||||
|
switch(orderLogicCard.getPosition(player.getUserName()))
|
||||||
|
{
|
||||||
|
case 0: player.addFood(2); break;
|
||||||
|
case 1,2: player.addFood(3); break;
|
||||||
|
case 3,4: player.addFood(4); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
currentState.PlayerUpdate(orderLogicCard.pull(),null);
|
currentState.PlayerUpdate(orderLogicCard.pull(),null);
|
||||||
currentState.GameStageUpdate(GameStages.SLOT_CHOICE);
|
currentState.GameStageUpdate(GameStages.SLOT_CHOICE);
|
||||||
}
|
}
|
||||||
@@ -264,6 +274,10 @@ public class Game implements Serializable {
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(slotPlayerEntry.getKey().getSlotId()=='A')
|
||||||
|
{
|
||||||
|
player.addFood(3);
|
||||||
|
}
|
||||||
slotMap.put(slotPlayerEntry.getKey(),player);
|
slotMap.put(slotPlayerEntry.getKey(),player);
|
||||||
nextPlayerSetup();
|
nextPlayerSetup();
|
||||||
return true;
|
return true;
|
||||||
@@ -288,7 +302,7 @@ public class Game implements Serializable {
|
|||||||
public boolean DrawUpperTribeCardByIndex(Player player,int cardIndex) {
|
public boolean DrawUpperTribeCardByIndex(Player player,int cardIndex) {
|
||||||
if( cardIndex<0 || cardIndex >=board.upperListTribe.size())
|
if( cardIndex<0 || cardIndex >=board.upperListTribe.size())
|
||||||
return false;
|
return false;
|
||||||
if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS)
|
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -324,7 +338,7 @@ public class Game implements Serializable {
|
|||||||
* @return {@code true} if the skip succeeds, {@code false} otherwise.
|
* @return {@code true} if the skip succeeds, {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean SkipUpperDrawing(Player player) {
|
public boolean SkipUpperDrawing(Player player) {
|
||||||
if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS)
|
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -355,7 +369,7 @@ public class Game implements Serializable {
|
|||||||
* @return {@code true} if the skip succeeds, {@code false} otherwise.
|
* @return {@code true} if the skip succeeds, {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean SkipLowerDrawing(Player player) {
|
public boolean SkipLowerDrawing(Player player) {
|
||||||
if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS)
|
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -389,7 +403,7 @@ public class Game implements Serializable {
|
|||||||
public boolean DrawLowerTribeCardByIndex(Player player, int cardIndex) {
|
public boolean DrawLowerTribeCardByIndex(Player player, int cardIndex) {
|
||||||
if( cardIndex<0 || cardIndex >=board.lowerListTribe.size())
|
if( cardIndex<0 || cardIndex >=board.lowerListTribe.size())
|
||||||
return false;
|
return false;
|
||||||
if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS)
|
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -430,7 +444,7 @@ public class Game implements Serializable {
|
|||||||
public boolean DrawUpperBuildingCardByIndex(Player player,int cardIndex) {
|
public boolean DrawUpperBuildingCardByIndex(Player player,int cardIndex) {
|
||||||
if( cardIndex<0 || cardIndex >=board.upperListBuilding.size())
|
if( cardIndex<0 || cardIndex >=board.upperListBuilding.size())
|
||||||
return false;
|
return false;
|
||||||
if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS)
|
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -469,7 +483,7 @@ public class Game implements Serializable {
|
|||||||
public boolean DrawLowerBuildingCardByIndex(Player player,int cardIndex) {
|
public boolean DrawLowerBuildingCardByIndex(Player player,int cardIndex) {
|
||||||
if( cardIndex<0 || cardIndex >=board.lowerListBuilding.size())
|
if( cardIndex<0 || cardIndex >=board.lowerListBuilding.size())
|
||||||
return false;
|
return false;
|
||||||
if(currentState.getGameStage()!= GameStages.RESOLVING_ACTIONS)
|
if(currentState.getGameStage()!= GameStages.RES_ACTIONS)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -514,7 +528,7 @@ public class Game implements Serializable {
|
|||||||
* @return {@code true} if the operation succeeds, {@code false} otherwise.
|
* @return {@code true} if the operation succeeds, {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean PickOptionalTribeCardByIndex(Player player,int cardIndex) {
|
public boolean PickOptionalTribeCardByIndex(Player player,int cardIndex) {
|
||||||
if(currentState.getGameStage() != GameStages.OPTIONAL_CARD_EFFECT){
|
if(currentState.getGameStage() != GameStages.OPT_CARD_E){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!player.equals(currentState.getCurrentPlayer())){
|
if(!player.equals(currentState.getCurrentPlayer())){
|
||||||
@@ -549,7 +563,7 @@ public class Game implements Serializable {
|
|||||||
* @return {@code true} if the operation succeeds, {@code false} otherwise.
|
* @return {@code true} if the operation succeeds, {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean PickOptionalBuildingCard(Player player, int cardIndex) {
|
public boolean PickOptionalBuildingCard(Player player, int cardIndex) {
|
||||||
if(currentState.getGameStage() != GameStages.OPTIONAL_CARD_EFFECT){
|
if(currentState.getGameStage() != GameStages.OPT_CARD_E){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!player.equals(currentState.getCurrentPlayer())){
|
if(!player.equals(currentState.getCurrentPlayer())){
|
||||||
@@ -581,7 +595,7 @@ public class Game implements Serializable {
|
|||||||
* @return {@code true} if the operation succeeds, {@code false} otherwise.
|
* @return {@code true} if the operation succeeds, {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean NoOptionalCard(Player player) {
|
public boolean NoOptionalCard(Player player) {
|
||||||
if(currentState.getGameStage() != GameStages.OPTIONAL_CARD_EFFECT){
|
if(currentState.getGameStage() != GameStages.OPT_CARD_E){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!player.equals(currentState.getCurrentPlayer())){
|
if(!player.equals(currentState.getCurrentPlayer())){
|
||||||
@@ -620,7 +634,7 @@ public class Game implements Serializable {
|
|||||||
currentState.PlayerUpdate(tempPlayer, null);
|
currentState.PlayerUpdate(tempPlayer, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentState.GameStageUpdate(GameStages.RESOLVING_ACTIONS);
|
currentState.GameStageUpdate(GameStages.RES_ACTIONS);
|
||||||
for (Slot s : slotMap.keySet()) {
|
for (Slot s : slotMap.keySet()) {
|
||||||
if (slotMap.get(s) != null) {
|
if (slotMap.get(s) != null) {
|
||||||
currentState.PlayerUpdate(slotMap.get(s), s);
|
currentState.PlayerUpdate(slotMap.get(s), s);
|
||||||
@@ -636,7 +650,7 @@ public class Game implements Serializable {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(GameStages.RESOLVING_ACTIONS==currentState.getGameStage()) {
|
if(GameStages.RES_ACTIONS ==currentState.getGameStage()) {
|
||||||
orderLogicCard.push(currentState.getCurrentPlayer());
|
orderLogicCard.push(currentState.getCurrentPlayer());
|
||||||
slotMap.put(currentState.getSlot(), null);
|
slotMap.put(currentState.getSlot(), null);
|
||||||
for (Slot s : slotMap.keySet()) {
|
for (Slot s : slotMap.keySet()) {
|
||||||
@@ -655,7 +669,7 @@ public class Game implements Serializable {
|
|||||||
}
|
}
|
||||||
if(slotMap.values().stream().allMatch(v -> v == null))
|
if(slotMap.values().stream().allMatch(v -> v == null))
|
||||||
{
|
{
|
||||||
currentState.GameStageUpdate(GameStages.OPTIONAL_CARD_EFFECT);
|
currentState.GameStageUpdate(GameStages.OPT_CARD_E);
|
||||||
HashMap<Player,Integer> optional=new LinkedHashMap<>();
|
HashMap<Player,Integer> optional=new LinkedHashMap<>();
|
||||||
for (Player p : orderLogicCard.players) {
|
for (Player p : orderLogicCard.players) {
|
||||||
int tempCount=(int)p.buildingCards.stream().filter(x->x.getEffectId()==12).count();
|
int tempCount=(int)p.buildingCards.stream().filter(x->x.getEffectId()==12).count();
|
||||||
@@ -676,7 +690,7 @@ public class Game implements Serializable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentState.GameStageUpdate(GameStages.RESOLVING_EVENT);
|
currentState.GameStageUpdate(GameStages.RES_EVENT);
|
||||||
|
|
||||||
if (currentState.getRound() < 10) {
|
if (currentState.getRound() < 10) {
|
||||||
nextRound();
|
nextRound();
|
||||||
@@ -691,7 +705,7 @@ public class Game implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameStages.OPTIONAL_CARD_EFFECT == currentState.getGameStage()) {
|
if (GameStages.OPT_CARD_E == currentState.getGameStage()) {
|
||||||
Player optionalPlayer = OptionalCardQueue.poll();
|
Player optionalPlayer = OptionalCardQueue.poll();
|
||||||
|
|
||||||
if (optionalPlayer != null) {
|
if (optionalPlayer != null) {
|
||||||
@@ -699,7 +713,7 @@ public class Game implements Serializable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentState.GameStageUpdate(GameStages.RESOLVING_EVENT);
|
currentState.GameStageUpdate(GameStages.RES_EVENT);
|
||||||
|
|
||||||
if (currentState.getRound() < 10) {
|
if (currentState.getRound() < 10) {
|
||||||
nextRound();
|
nextRound();
|
||||||
@@ -748,7 +762,7 @@ public class Game implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private void EventResolution() {
|
private void EventResolution() {
|
||||||
|
|
||||||
if(currentState.getGameStage()!= GameStages.RESOLVING_EVENT)
|
if(currentState.getGameStage()!= GameStages.RES_EVENT)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package it.polimi.ingsw.gc14.Model.GamePackage;
|
package it.polimi.ingsw.gc14.Model.GamePackage;
|
||||||
|
|
||||||
public enum GameStages {
|
public enum GameStages {
|
||||||
WAITING, SLOT_CHOICE, RESOLVING_ACTIONS, OPTIONAL_CARD_EFFECT, RESOLVING_EVENT, ENDING, ENDED
|
WAITING, SLOT_CHOICE, RES_ACTIONS, OPT_CARD_E, RES_EVENT, ENDING, ENDED
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class GameControllerTest {
|
|||||||
assertTrue(controller.slotChoice(current.getUserName(), i));
|
assertTrue(controller.slotChoice(current.getUserName(), i));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(GameStages.RESOLVING_ACTIONS, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage());
|
||||||
|
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
@@ -89,12 +89,12 @@ class GameControllerTest {
|
|||||||
private void resolveActionsUntilOptionalCardEffect(Game game, GameController controller) {
|
private void resolveActionsUntilOptionalCardEffect(Game game, GameController controller) {
|
||||||
int guard = 0;
|
int guard = 0;
|
||||||
|
|
||||||
while (game.getCurrentState().getGameStage() == GameStages.RESOLVING_ACTIONS && guard < 100) {
|
while (game.getCurrentState().getGameStage() == GameStages.RES_ACTIONS && guard < 100) {
|
||||||
guard++;
|
guard++;
|
||||||
resolveOneMandatoryAction(game, controller);
|
resolveOneMandatoryAction(game, controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(GameStages.OPTIONAL_CARD_EFFECT, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.OPT_CARD_E, game.getCurrentState().getGameStage());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolveOneMandatoryAction(Game game, GameController controller) {
|
private void resolveOneMandatoryAction(Game game, GameController controller) {
|
||||||
@@ -154,7 +154,7 @@ class GameControllerTest {
|
|||||||
assertTrue(controller.slotChoice(current.getUserName(), slotIndexes[i]));
|
assertTrue(controller.slotChoice(current.getUserName(), slotIndexes[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(GameStages.RESOLVING_ACTIONS, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage());
|
||||||
|
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
@@ -206,7 +206,7 @@ class GameControllerTest {
|
|||||||
|
|
||||||
Queue<Player> order = completeSlotChoice(game, controller);
|
Queue<Player> order = completeSlotChoice(game, controller);
|
||||||
|
|
||||||
assertEquals(GameStages.RESOLVING_ACTIONS, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage());
|
||||||
assertEquals(order.poll(), game.getCurrentState().getCurrentPlayer());
|
assertEquals(order.poll(), game.getCurrentState().getCurrentPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ class GameControllerTest {
|
|||||||
assertTrue(controller.slotChoice(current.getUserName(), i));
|
assertTrue(controller.slotChoice(current.getUserName(), i));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(GameStages.RESOLVING_ACTIONS, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage());
|
||||||
|
|
||||||
Player tempPlayer = players.poll();
|
Player tempPlayer = players.poll();
|
||||||
assertNotNull(tempPlayer);
|
assertNotNull(tempPlayer);
|
||||||
@@ -395,7 +395,7 @@ class GameControllerTest {
|
|||||||
|
|
||||||
completeSlotChoice(game, controller);
|
completeSlotChoice(game, controller);
|
||||||
|
|
||||||
assertEquals(GameStages.RESOLVING_ACTIONS, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage());
|
||||||
|
|
||||||
String cur = game.getCurrentState().getCurrentPlayer().getUserName();
|
String cur = game.getCurrentState().getCurrentPlayer().getUserName();
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class CurrentStateTest {
|
|||||||
void getGameStage() {
|
void getGameStage() {
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
Slot s = new Slot('A');
|
Slot s = new Slot('A');
|
||||||
GameStages g = GameStages.RESOLVING_ACTIONS;
|
GameStages g = GameStages.RES_ACTIONS;
|
||||||
CurrentState curr = new CurrentState();
|
CurrentState curr = new CurrentState();
|
||||||
curr.PlayerUpdate(p, s);
|
curr.PlayerUpdate(p, s);
|
||||||
curr.GameStageUpdate(g);
|
curr.GameStageUpdate(g);
|
||||||
@@ -122,12 +122,12 @@ class CurrentStateTest {
|
|||||||
void gameStageUpdate() {
|
void gameStageUpdate() {
|
||||||
Player p = new Player("test");
|
Player p = new Player("test");
|
||||||
Slot s = new Slot('A');
|
Slot s = new Slot('A');
|
||||||
GameStages g = GameStages.RESOLVING_ACTIONS;
|
GameStages g = GameStages.RES_ACTIONS;
|
||||||
CurrentState curr = new CurrentState();
|
CurrentState curr = new CurrentState();
|
||||||
assertEquals(GameStages.WAITING, curr.getGameStage());
|
assertEquals(GameStages.WAITING, curr.getGameStage());
|
||||||
curr.PlayerUpdate(p, s);
|
curr.PlayerUpdate(p, s);
|
||||||
curr.GameStageUpdate(g);
|
curr.GameStageUpdate(g);
|
||||||
assertEquals(GameStages.RESOLVING_ACTIONS, curr.getGameStage());
|
assertEquals(GameStages.RES_ACTIONS, curr.getGameStage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class GameTest {
|
|||||||
assertTrue(game.SlotChoiceByIndex(current, i));
|
assertTrue(game.SlotChoiceByIndex(current, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(GameStages.RESOLVING_ACTIONS, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage());
|
||||||
|
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ class GameTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void resolveAllMandatoryActions(Game game) {
|
private void resolveAllMandatoryActions(Game game) {
|
||||||
while (game.getCurrentState().getGameStage() == GameStages.RESOLVING_ACTIONS) {
|
while (game.getCurrentState().getGameStage() == GameStages.RES_ACTIONS) {
|
||||||
resolveOneMandatoryAction(game);
|
resolveOneMandatoryAction(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,15 +126,15 @@ class GameTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void resolveActionsUntilOptionalCardEffect(Game game) {
|
private void resolveActionsUntilOptionalCardEffect(Game game) {
|
||||||
while (game.getCurrentState().getGameStage() == GameStages.RESOLVING_ACTIONS) {
|
while (game.getCurrentState().getGameStage() == GameStages.RES_ACTIONS) {
|
||||||
resolveOneMandatoryAction(game);
|
resolveOneMandatoryAction(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(GameStages.OPTIONAL_CARD_EFFECT, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.OPT_CARD_E, game.getCurrentState().getGameStage());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolveOptionalPhaseIfPresent(Game game) {
|
private void resolveOptionalPhaseIfPresent(Game game) {
|
||||||
while (game.getCurrentState().getGameStage() == GameStages.OPTIONAL_CARD_EFFECT) {
|
while (game.getCurrentState().getGameStage() == GameStages.OPT_CARD_E) {
|
||||||
Player current = game.getCurrentState().getCurrentPlayer();
|
Player current = game.getCurrentState().getCurrentPlayer();
|
||||||
assertNotNull(current);
|
assertNotNull(current);
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ class GameTest {
|
|||||||
|
|
||||||
completeSlotChoice(game);
|
completeSlotChoice(game);
|
||||||
|
|
||||||
assertEquals(GameStages.RESOLVING_ACTIONS, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage());
|
||||||
|
|
||||||
resolveAllMandatoryActions(game);
|
resolveAllMandatoryActions(game);
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ class GameTest {
|
|||||||
private void resolveCurrentPlayerCompletely(Game game, Player expectedPlayer) {
|
private void resolveCurrentPlayerCompletely(Game game, Player expectedPlayer) {
|
||||||
assertEquals(expectedPlayer, game.getCurrentState().getCurrentPlayer());
|
assertEquals(expectedPlayer, game.getCurrentState().getCurrentPlayer());
|
||||||
|
|
||||||
while (game.getCurrentState().getGameStage() == GameStages.RESOLVING_ACTIONS
|
while (game.getCurrentState().getGameStage() == GameStages.RES_ACTIONS
|
||||||
&& expectedPlayer.equals(game.getCurrentState().getCurrentPlayer())) {
|
&& expectedPlayer.equals(game.getCurrentState().getCurrentPlayer())) {
|
||||||
resolveOneMandatoryAction(game);
|
resolveOneMandatoryAction(game);
|
||||||
}
|
}
|
||||||
@@ -357,7 +357,7 @@ class GameTest {
|
|||||||
assertNotNull(thirdPlayer);
|
assertNotNull(thirdPlayer);
|
||||||
assertEquals(thirdPlayer, game.getCurrentState().getCurrentPlayer());
|
assertEquals(thirdPlayer, game.getCurrentState().getCurrentPlayer());
|
||||||
|
|
||||||
while (game.getCurrentState().getGameStage() == GameStages.RESOLVING_ACTIONS
|
while (game.getCurrentState().getGameStage() == GameStages.RES_ACTIONS
|
||||||
&& thirdPlayer.equals(game.getCurrentState().getCurrentPlayer())) {
|
&& thirdPlayer.equals(game.getCurrentState().getCurrentPlayer())) {
|
||||||
resolveOneMandatoryAction(game);
|
resolveOneMandatoryAction(game);
|
||||||
}
|
}
|
||||||
@@ -497,7 +497,7 @@ class GameTest {
|
|||||||
|
|
||||||
assertTrue(game.NoOptionalCard(current));
|
assertTrue(game.NoOptionalCard(current));
|
||||||
|
|
||||||
assertEquals(GameStages.OPTIONAL_CARD_EFFECT, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.OPT_CARD_E, game.getCurrentState().getGameStage());
|
||||||
assertNotEquals(current, game.getCurrentState().getCurrentPlayer());
|
assertNotEquals(current, game.getCurrentState().getCurrentPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,7 +662,7 @@ class GameTest {
|
|||||||
|
|
||||||
assertDoesNotThrow(() -> resolveAllMandatoryActions(game));
|
assertDoesNotThrow(() -> resolveAllMandatoryActions(game));
|
||||||
|
|
||||||
assertNotEquals(GameStages.OPTIONAL_CARD_EFFECT, game.getCurrentState().getGameStage());
|
assertNotEquals(GameStages.OPT_CARD_E, game.getCurrentState().getGameStage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -879,7 +879,7 @@ class GameTest {
|
|||||||
completeSlotChoice(game);
|
completeSlotChoice(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.getCurrentState().getGameStage() == GameStages.RESOLVING_ACTIONS) {
|
if (game.getCurrentState().getGameStage() == GameStages.RES_ACTIONS) {
|
||||||
Player current = game.getCurrentState().getCurrentPlayer();
|
Player current = game.getCurrentState().getCurrentPlayer();
|
||||||
assertNotNull(current);
|
assertNotNull(current);
|
||||||
|
|
||||||
@@ -920,7 +920,7 @@ class GameTest {
|
|||||||
resolveOneMandatoryAction(game);
|
resolveOneMandatoryAction(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.getCurrentState().getGameStage() == GameStages.OPTIONAL_CARD_EFFECT) {
|
if (game.getCurrentState().getGameStage() == GameStages.OPT_CARD_E) {
|
||||||
resolveOptionalPhaseIfPresent(game);
|
resolveOptionalPhaseIfPresent(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -939,7 +939,7 @@ class GameTest {
|
|||||||
|
|
||||||
completeSlotChoice(game);
|
completeSlotChoice(game);
|
||||||
|
|
||||||
while (game.getCurrentState().getGameStage() == GameStages.RESOLVING_ACTIONS) {
|
while (game.getCurrentState().getGameStage() == GameStages.RES_ACTIONS) {
|
||||||
Player current = game.getCurrentState().getCurrentPlayer();
|
Player current = game.getCurrentState().getCurrentPlayer();
|
||||||
|
|
||||||
if (game.getCurrentState().getNUpper() > 0
|
if (game.getCurrentState().getNUpper() > 0
|
||||||
@@ -977,7 +977,7 @@ class GameTest {
|
|||||||
Player thirdChooser = game.getCurrentState().getCurrentPlayer();
|
Player thirdChooser = game.getCurrentState().getCurrentPlayer();
|
||||||
assertTrue(game.SlotChoiceByIndex(thirdChooser, 1));
|
assertTrue(game.SlotChoiceByIndex(thirdChooser, 1));
|
||||||
|
|
||||||
assertEquals(GameStages.RESOLVING_ACTIONS, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.RES_ACTIONS, game.getCurrentState().getGameStage());
|
||||||
|
|
||||||
assertEquals(secondChooser, game.getCurrentState().getCurrentPlayer());
|
assertEquals(secondChooser, game.getCurrentState().getCurrentPlayer());
|
||||||
|
|
||||||
@@ -1009,7 +1009,7 @@ class GameTest {
|
|||||||
completeSlotChoice(game);
|
completeSlotChoice(game);
|
||||||
resolveAllMandatoryActions(game);
|
resolveAllMandatoryActions(game);
|
||||||
|
|
||||||
assertEquals(GameStages.OPTIONAL_CARD_EFFECT, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.OPT_CARD_E, game.getCurrentState().getGameStage());
|
||||||
|
|
||||||
assertDoesNotThrow(() -> resolveOptionalPhaseIfPresent(game));
|
assertDoesNotThrow(() -> resolveOptionalPhaseIfPresent(game));
|
||||||
|
|
||||||
@@ -1032,7 +1032,7 @@ class GameTest {
|
|||||||
completeSlotChoice(game);
|
completeSlotChoice(game);
|
||||||
resolveAllMandatoryActions(game);
|
resolveAllMandatoryActions(game);
|
||||||
|
|
||||||
assertEquals(GameStages.OPTIONAL_CARD_EFFECT, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.OPT_CARD_E, game.getCurrentState().getGameStage());
|
||||||
|
|
||||||
Player player = players.get(0);
|
Player player = players.get(0);
|
||||||
|
|
||||||
@@ -1068,7 +1068,7 @@ class GameTest {
|
|||||||
completeSlotChoice(game);
|
completeSlotChoice(game);
|
||||||
resolveAllMandatoryActions(game);
|
resolveAllMandatoryActions(game);
|
||||||
|
|
||||||
assertEquals(GameStages.OPTIONAL_CARD_EFFECT, game.getCurrentState().getGameStage());
|
assertEquals(GameStages.OPT_CARD_E, game.getCurrentState().getGameStage());
|
||||||
|
|
||||||
Player player = players.get(0);
|
Player player = players.get(0);
|
||||||
assertNotNull(player);
|
assertNotNull(player);
|
||||||
|
|||||||
Reference in New Issue
Block a user