Fix: full model refactor
This commit is contained in:
@@ -263,8 +263,8 @@ class GameControllerTest {
|
||||
|
||||
assertTrue(controller.disconnectedPlayer(current.getUserName()));
|
||||
|
||||
assertTrue(game.disconnectedPlayers.containsKey(current));
|
||||
assertTrue(game.disconnectedPlayers.get(current));
|
||||
assertTrue(game.getDisconnectedPlayers().containsKey(current));
|
||||
assertTrue(game.getDisconnectedPlayers().get(current));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -75,7 +75,7 @@ class BoardTest {
|
||||
Board bd3 = new Board(3);
|
||||
Board bd4 = new Board(4);
|
||||
Board bd5 = new Board(5);
|
||||
for(TribeCard tribe : bd2.upperListTribe)
|
||||
for(TribeCard tribe : bd2.getUpperListTribe())
|
||||
{
|
||||
System.out.println(tribe.getIdIMG() +" "+tribe.toStringBoard());
|
||||
assertNotEquals("-1",tribe.getIdIMG());
|
||||
@@ -102,12 +102,12 @@ class BoardTest {
|
||||
|
||||
assertEquals(96 - (numPlayer+4) - (numPlayer+1), bd.getTribeDeckSize()); // Verifica che dal mazzo TribeDeck venga pescato il numero corretto di carte
|
||||
|
||||
assertEquals(numPlayer+1, bd.lowerListTribe.size()); // Verifica che la dimensione della lista inferiore sia corretta
|
||||
assertTrue(bd.lowerListTribe.stream().noneMatch(card -> card.isEventCard())); // Verifica che non ci siano EventCard dentro alla lista inferiore
|
||||
assertEquals(numPlayer+1, bd.getLowerListTribe().size()); // Verifica che la dimensione della lista inferiore sia corretta
|
||||
assertTrue(bd.getLowerListTribe().stream().noneMatch(card -> card.isEventCard())); // Verifica che non ci siano EventCard dentro alla lista inferiore
|
||||
|
||||
assertEquals(numPlayer+4, bd.upperListTribe.size()); // Verifica che la dimensione della lista superiore sia corretta
|
||||
assertEquals(numPlayer+4, bd.getUpperListTribe().size()); // Verifica che la dimensione della lista superiore sia corretta
|
||||
|
||||
assertEquals(2, bd.upperListBuilding.size()); // Verifica che ci sia il giusto numero di buildings (2 edifici per 3+ giocatori)
|
||||
assertEquals(2, bd.getUpperListBuilding().size()); // Verifica che ci sia il giusto numero di buildings (2 edifici per 3+ giocatori)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,7 +116,7 @@ class BoardTest {
|
||||
Board bd = new Board(0);
|
||||
|
||||
Queue<EventCard> eventQueue = new LinkedList<>();
|
||||
for (TribeCard card : bd.lowerListTribe) {
|
||||
for (TribeCard card : bd.getLowerListTribe()) {
|
||||
if (card.isEventCard()) {
|
||||
eventQueue.add((EventCard) card);
|
||||
}
|
||||
@@ -130,13 +130,13 @@ class BoardTest {
|
||||
void removeUpperTribeCard() {
|
||||
Board bd = new Board(3);
|
||||
|
||||
List<TribeCard> before = new ArrayList<>( bd.upperListTribe);
|
||||
List<TribeCard> before = new ArrayList<>( bd.getUpperListTribe());
|
||||
TribeCard cardToRemove = before.get(0);
|
||||
|
||||
assertEquals(cardToRemove, before.remove(0));
|
||||
assertTrue( bd.removeUpperTribeCard(cardToRemove));
|
||||
|
||||
assertEquals(before, bd.upperListTribe);
|
||||
assertEquals(before, bd.getUpperListTribe());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,13 +144,13 @@ class BoardTest {
|
||||
void removeLowerTribeCard() {
|
||||
Board bd = new Board(3);
|
||||
|
||||
List<TribeCard> before = new ArrayList<>(bd.lowerListTribe);
|
||||
List<TribeCard> before = new ArrayList<>(bd.getLowerListTribe());
|
||||
TribeCard cardToRemove = before.get(0);
|
||||
|
||||
assertEquals(cardToRemove, before.remove(0));
|
||||
assertTrue( bd.removeLowerTribeCard(cardToRemove));
|
||||
|
||||
assertEquals(before, bd.lowerListTribe);
|
||||
assertEquals(before, bd.getLowerListTribe());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,13 +158,13 @@ class BoardTest {
|
||||
void removeUpperBuildingCard() {
|
||||
Board bd = new Board(3);
|
||||
|
||||
List<BuildingCard> before = new ArrayList<>(bd.upperListBuilding);
|
||||
List<BuildingCard> before = new ArrayList<>(bd.getUpperListBuilding());
|
||||
BuildingCard cardToRemove = before.get(0);
|
||||
|
||||
assertEquals(cardToRemove, before.remove(0));
|
||||
assertTrue( bd.removeUpperBuildingCard(cardToRemove));
|
||||
|
||||
assertEquals(before, bd.upperListBuilding);
|
||||
assertEquals(before, bd.getUpperListBuilding());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -176,11 +176,11 @@ class BoardTest {
|
||||
bd.nextRound(); // Skip to era 2
|
||||
}
|
||||
|
||||
List<BuildingCard> before = new ArrayList<>( bd.lowerListBuilding);
|
||||
List<BuildingCard> before = new ArrayList<>( bd.getLowerListBuilding());
|
||||
BuildingCard cardToRemove = before.get(0);
|
||||
assertEquals(cardToRemove, before.remove(0));
|
||||
assertTrue(bd.removeLowerBuildingCard(cardToRemove));
|
||||
assertEquals(before, bd.lowerListBuilding);
|
||||
assertEquals(before, bd.getLowerListBuilding());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -188,13 +188,13 @@ class BoardTest {
|
||||
void nextRound() {
|
||||
int numPlayer = 3;
|
||||
Board bd = new Board(numPlayer);
|
||||
assertTrue(!bd.lowerListTribe.isEmpty());
|
||||
List<TribeCard> upperListBefore = new ArrayList<>(bd.upperListTribe);
|
||||
assertTrue(!bd.getLowerListTribe().isEmpty());
|
||||
List<TribeCard> upperListBefore = new ArrayList<>(bd.getUpperListTribe());
|
||||
|
||||
bd.nextRound();
|
||||
assertEquals(upperListBefore, bd.lowerListTribe); // Verifica che la lista superiore è stata spostata sotto
|
||||
assertNotEquals(upperListBefore, bd.upperListTribe); // Verifica che la lista superiore sia stata cambiata
|
||||
assertEquals(numPlayer+4, bd.upperListTribe.size()); // Verifica che la nuova dimensione della lista superiore sia corretta
|
||||
assertEquals(upperListBefore, bd.getLowerListTribe()); // Verifica che la lista superiore è stata spostata sotto
|
||||
assertNotEquals(upperListBefore, bd.getUpperListTribe()); // Verifica che la lista superiore sia stata cambiata
|
||||
assertEquals(numPlayer+4, bd.getUpperListTribe().size()); // Verifica che la nuova dimensione della lista superiore sia corretta
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -209,31 +209,31 @@ class BoardTest {
|
||||
// Era 2, nTotem <= 3
|
||||
numPlayer = 3;
|
||||
Board bd1 = new Board(numPlayer);
|
||||
upperListBefore = new ArrayList<>(bd1.upperListBuilding);
|
||||
upperListBefore = new ArrayList<>(bd1.getUpperListBuilding());
|
||||
for (int i=0;i<3;i++) {
|
||||
bd1.nextRound(); // Skip to era 2
|
||||
}
|
||||
assertEquals(2, bd1.getEra());
|
||||
assertEquals(upperListBefore, bd1.lowerListBuilding);
|
||||
assertNotEquals(upperListBefore, bd1.upperListBuilding);
|
||||
assertEquals(2, bd1.upperListBuilding.size());
|
||||
assertTrue(bd1.upperListBuilding.stream().allMatch(x->x.getEra()==2));
|
||||
assertTrue(bd1.lowerListBuilding.stream().allMatch(x->x.getEra()==1));
|
||||
assertEquals(upperListBefore, bd1.getLowerListBuilding());
|
||||
assertNotEquals(upperListBefore, bd1.getUpperListBuilding());
|
||||
assertEquals(2, bd1.getUpperListBuilding().size());
|
||||
assertTrue(bd1.getUpperListBuilding().stream().allMatch(x->x.getEra()==2));
|
||||
assertTrue(bd1.getLowerListBuilding().stream().allMatch(x->x.getEra()==1));
|
||||
|
||||
|
||||
// Era 2, nTotem > 3
|
||||
numPlayer = 4;
|
||||
Board bd2 = new Board(numPlayer);
|
||||
upperListBefore = new ArrayList<>(bd2.upperListBuilding);
|
||||
upperListBefore = new ArrayList<>(bd2.getUpperListBuilding());
|
||||
for (int i=0;i<3;i++) {
|
||||
bd2.nextRound(); // Skip to era 2
|
||||
}
|
||||
assertEquals(2, bd2.getEra());
|
||||
assertEquals(upperListBefore, bd2.lowerListBuilding);
|
||||
assertNotEquals(upperListBefore, bd2.upperListBuilding);
|
||||
assertEquals(3, bd2.upperListBuilding.size());
|
||||
assertTrue(bd2.upperListBuilding.stream().allMatch(x->x.getEra()==2));
|
||||
assertTrue(bd2.lowerListBuilding.stream().allMatch(x->x.getEra()==1));
|
||||
assertEquals(upperListBefore, bd2.getLowerListBuilding());
|
||||
assertNotEquals(upperListBefore, bd2.getUpperListBuilding());
|
||||
assertEquals(3, bd2.getUpperListBuilding().size());
|
||||
assertTrue(bd2.getUpperListBuilding().stream().allMatch(x->x.getEra()==2));
|
||||
assertTrue(bd2.getLowerListBuilding().stream().allMatch(x->x.getEra()==1));
|
||||
|
||||
// Era 3, nTotem == 2
|
||||
numPlayer = 2;
|
||||
@@ -241,16 +241,16 @@ class BoardTest {
|
||||
for (int i=0;i<3;i++) {
|
||||
bd3.nextRound(); // Skip to era 2
|
||||
}
|
||||
upperListBefore = new ArrayList<>(bd3.upperListBuilding); // We need to take the list of the era 2
|
||||
upperListBefore = new ArrayList<>(bd3.getUpperListBuilding()); // We need to take the list of the era 2
|
||||
for (int i=0;i<3;i++) {
|
||||
bd3.nextRound(); // Skip to era 3
|
||||
}
|
||||
assertEquals(3, bd3.getEra());
|
||||
assertEquals(upperListBefore, bd3.lowerListBuilding);
|
||||
assertNotEquals(upperListBefore, bd3.upperListBuilding);
|
||||
assertEquals(3, bd3.upperListBuilding.size());
|
||||
assertTrue(bd3.upperListBuilding.stream().allMatch(x->x.getEra()==3));
|
||||
assertTrue(bd3.lowerListBuilding.stream().allMatch(x->x.getEra()==2));
|
||||
assertEquals(upperListBefore, bd3.getLowerListBuilding());
|
||||
assertNotEquals(upperListBefore, bd3.getUpperListBuilding());
|
||||
assertEquals(3, bd3.getUpperListBuilding().size());
|
||||
assertTrue(bd3.getUpperListBuilding().stream().allMatch(x->x.getEra()==3));
|
||||
assertTrue(bd3.getLowerListBuilding().stream().allMatch(x->x.getEra()==2));
|
||||
|
||||
|
||||
// Era 3, nTotem == 5
|
||||
@@ -259,16 +259,16 @@ class BoardTest {
|
||||
for (int i=0;i<3;i++) {
|
||||
bd4.nextRound(); // Skip to era 2
|
||||
}
|
||||
upperListBefore = new ArrayList<>(bd4.upperListBuilding); // We need to take the list of the era 2
|
||||
upperListBefore = new ArrayList<>(bd4.getUpperListBuilding()); // We need to take the list of the era 2
|
||||
for (int i=0;i<3;i++) {
|
||||
bd4.nextRound(); // Skip to era 3
|
||||
}
|
||||
assertEquals(3, bd4.getEra());
|
||||
assertEquals(upperListBefore, bd4.lowerListBuilding);
|
||||
assertNotEquals(upperListBefore, bd4.upperListBuilding);
|
||||
assertEquals(5, bd4.upperListBuilding.size());
|
||||
assertTrue(bd4.upperListBuilding.stream().allMatch(x->x.getEra()==3));
|
||||
assertTrue(bd4.lowerListBuilding.stream().allMatch(x->x.getEra()==2));
|
||||
assertEquals(upperListBefore, bd4.getLowerListBuilding());
|
||||
assertNotEquals(upperListBefore, bd4.getUpperListBuilding());
|
||||
assertEquals(5, bd4.getUpperListBuilding().size());
|
||||
assertTrue(bd4.getUpperListBuilding().stream().allMatch(x->x.getEra()==3));
|
||||
assertTrue(bd4.getLowerListBuilding().stream().allMatch(x->x.getEra()==2));
|
||||
|
||||
|
||||
// Era 3, nTotem != 2, 5
|
||||
@@ -277,16 +277,16 @@ class BoardTest {
|
||||
for (int i=0;i<3;i++) {
|
||||
bd5.nextRound(); // Skip to era 2
|
||||
}
|
||||
upperListBefore = new ArrayList<>(bd5.upperListBuilding); // We need to take the list of the era 2
|
||||
upperListBefore = new ArrayList<>(bd5.getUpperListBuilding()); // We need to take the list of the era 2
|
||||
for (int i=0;i<3;i++) {
|
||||
bd5.nextRound(); // Skip to era 3
|
||||
}
|
||||
assertEquals(3, bd5.getEra());
|
||||
assertEquals(upperListBefore, bd5.lowerListBuilding);
|
||||
assertNotEquals(upperListBefore, bd5.upperListBuilding);
|
||||
assertEquals(4, bd5.upperListBuilding.size());
|
||||
assertTrue(bd5.upperListBuilding.stream().allMatch(x->x.getEra()==3));
|
||||
assertTrue(bd5.lowerListBuilding.stream().allMatch(x->x.getEra()==2));
|
||||
assertEquals(upperListBefore, bd5.getLowerListBuilding());
|
||||
assertNotEquals(upperListBefore, bd5.getUpperListBuilding());
|
||||
assertEquals(4, bd5.getUpperListBuilding().size());
|
||||
assertTrue(bd5.getUpperListBuilding().stream().allMatch(x->x.getEra()==3));
|
||||
assertTrue(bd5.getLowerListBuilding().stream().allMatch(x->x.getEra()==2));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1341,8 +1341,8 @@ class GameTest {
|
||||
|
||||
assertTrue(game.disconnectedPlayer(current));
|
||||
|
||||
assertTrue(game.disconnectedPlayers.containsKey(current));
|
||||
assertTrue(game.disconnectedPlayers.get(current));
|
||||
assertTrue(game.getDisconnectedPlayers().containsKey(current));
|
||||
assertTrue(game.getDisconnectedPlayers().get(current));
|
||||
assertNotEquals(current, game.getCurrentState().getCurrentPlayer());
|
||||
}
|
||||
|
||||
@@ -1367,10 +1367,10 @@ class GameTest {
|
||||
Player current = game.getCurrentState().getCurrentPlayer();
|
||||
|
||||
assertTrue(game.disconnectedPlayer(current));
|
||||
assertTrue(game.disconnectedPlayers.containsKey(current));
|
||||
assertTrue(game.getDisconnectedPlayers().containsKey(current));
|
||||
|
||||
assertTrue(game.reconnectPlayer(current));
|
||||
assertFalse(game.disconnectedPlayers.containsKey(current));
|
||||
assertFalse(game.getDisconnectedPlayers().containsKey(current));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1382,11 +1382,11 @@ class GameTest {
|
||||
Player current = game.getCurrentState().getCurrentPlayer();
|
||||
|
||||
assertTrue(game.disconnectedPlayer(current));
|
||||
assertFalse(game.disconnectedPlayers.isEmpty());
|
||||
assertFalse(game.getDisconnectedPlayers().isEmpty());
|
||||
|
||||
game.clearDisconnected();
|
||||
|
||||
assertTrue(game.disconnectedPlayers.isEmpty());
|
||||
assertTrue(game.getDisconnectedPlayers().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user