@@ -640,7 +640,7 @@ public class Game implements Serializable {
|
|||||||
{
|
{
|
||||||
currentState.GameStageUpdate(GameStages.OPTIONAL_CARD_EFFECT);
|
currentState.GameStageUpdate(GameStages.OPTIONAL_CARD_EFFECT);
|
||||||
HashMap<Player,Integer> optional=new LinkedHashMap<>();
|
HashMap<Player,Integer> optional=new LinkedHashMap<>();
|
||||||
for (Player p : playersList) {
|
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();
|
||||||
if(tempCount>0)
|
if(tempCount>0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public class Board implements Serializable {
|
|||||||
/** Contains all the building cards of the upper list. When a new era starts, the old era's buildings are moved from the upper to the lower list */
|
/** Contains all the building cards of the upper list. When a new era starts, the old era's buildings are moved from the upper to the lower list */
|
||||||
public List<BuildingCard> lowerListBuilding;
|
public List<BuildingCard> lowerListBuilding;
|
||||||
|
|
||||||
|
|
||||||
|
private final ArrayList<List<BuildingCard>> buildingCardsAllEras;
|
||||||
/** Number of players */
|
/** Number of players */
|
||||||
private int nTotem;
|
private int nTotem;
|
||||||
|
|
||||||
@@ -88,6 +90,7 @@ public class Board implements Serializable {
|
|||||||
tribeDeck=generateTribeDeck(nTotem);
|
tribeDeck=generateTribeDeck(nTotem);
|
||||||
era=1;
|
era=1;
|
||||||
|
|
||||||
|
|
||||||
for(int i=0;i<nTotem+1;i++)
|
for(int i=0;i<nTotem+1;i++)
|
||||||
{
|
{
|
||||||
TribeCard tempCard = tribeDeck.remove();
|
TribeCard tempCard = tribeDeck.remove();
|
||||||
@@ -110,10 +113,44 @@ public class Board implements Serializable {
|
|||||||
|
|
||||||
ArrayList<BuildingCard> buildingDeck = new ArrayList<>(DecksCreator.loadBuildingDeckByEra(1));
|
ArrayList<BuildingCard> buildingDeck = new ArrayList<>(DecksCreator.loadBuildingDeckByEra(1));
|
||||||
Collections.shuffle(buildingDeck);
|
Collections.shuffle(buildingDeck);
|
||||||
|
buildingCardsAllEras= new ArrayList<>();
|
||||||
|
buildingCardsAllEras.add(new ArrayList<>());
|
||||||
|
buildingCardsAllEras.add(new ArrayList<>());
|
||||||
|
buildingCardsAllEras.add(new ArrayList<>());
|
||||||
if(nTotem==2)
|
if(nTotem==2)
|
||||||
|
{
|
||||||
|
buildingCardsAllEras.set(0, new ArrayList<>(buildingDeck.subList(0, 1)));
|
||||||
upperListBuilding = new ArrayList<>(buildingDeck.subList(0,1));
|
upperListBuilding = new ArrayList<>(buildingDeck.subList(0,1));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
buildingCardsAllEras.set(0, new ArrayList<>(buildingDeck.subList(0, 2)));
|
||||||
upperListBuilding = new ArrayList<>(buildingDeck.subList(0,2));
|
upperListBuilding = new ArrayList<>(buildingDeck.subList(0,2));
|
||||||
|
}
|
||||||
|
|
||||||
|
buildingDeck=new ArrayList<>(DecksCreator.loadBuildingDeckByEra(2));
|
||||||
|
Collections.shuffle(buildingDeck);
|
||||||
|
if(nTotem<=3)
|
||||||
|
{
|
||||||
|
buildingCardsAllEras.set(1, new ArrayList<BuildingCard>(buildingDeck.subList(0, 2)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buildingCardsAllEras.set(1, new ArrayList<BuildingCard>(buildingDeck.subList(0, 3)));
|
||||||
|
}
|
||||||
|
buildingDeck=new ArrayList<>(DecksCreator.loadBuildingDeckByEra(3));
|
||||||
|
Collections.shuffle(buildingDeck);
|
||||||
|
if(nTotem==2)
|
||||||
|
{
|
||||||
|
buildingCardsAllEras.set(2, new ArrayList<BuildingCard>(buildingDeck.subList(0, 3)));
|
||||||
|
}else if(nTotem==5)
|
||||||
|
{
|
||||||
|
buildingCardsAllEras.set(2, new ArrayList<BuildingCard>(buildingDeck.subList(0, 5)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
buildingCardsAllEras.set(2, new ArrayList<BuildingCard>(buildingDeck.subList(0, 4)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,27 +267,11 @@ public class Board implements Serializable {
|
|||||||
Collections.shuffle(buildingCards);
|
Collections.shuffle(buildingCards);
|
||||||
if(era==2)
|
if(era==2)
|
||||||
{
|
{
|
||||||
if(nTotem<=3)
|
upperListBuilding.addAll(buildingCardsAllEras.get(1));
|
||||||
{
|
|
||||||
upperListBuilding.addAll(buildingCards.subList(0,2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
upperListBuilding.addAll( buildingCards.subList(0,3));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else // Era 3
|
else
|
||||||
{
|
{
|
||||||
if(nTotem==2)
|
upperListBuilding.addAll(buildingCardsAllEras.get(2));
|
||||||
{
|
|
||||||
upperListBuilding.addAll( buildingCards.subList(0,3));
|
|
||||||
}else if(nTotem==5)
|
|
||||||
{
|
|
||||||
upperListBuilding.addAll( buildingCards.subList(0,5));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
upperListBuilding.addAll(buildingCards.subList(0,4));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class BoardTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("RemgetTribeDeckSizeoving a card from upper row of building cards")
|
@DisplayName("Removing a card from upper row of building cards")
|
||||||
void removeUpperBuildingCard() {
|
void removeUpperBuildingCard() {
|
||||||
Board bd = new Board(3);
|
Board bd = new Board(3);
|
||||||
|
|
||||||
@@ -214,6 +214,8 @@ class BoardTest {
|
|||||||
assertEquals(upperListBefore, bd1.lowerListBuilding);
|
assertEquals(upperListBefore, bd1.lowerListBuilding);
|
||||||
assertNotEquals(upperListBefore, bd1.upperListBuilding);
|
assertNotEquals(upperListBefore, bd1.upperListBuilding);
|
||||||
assertEquals(2, bd1.upperListBuilding.size());
|
assertEquals(2, bd1.upperListBuilding.size());
|
||||||
|
assertTrue(bd1.upperListBuilding.stream().allMatch(x->x.getEra()==2));
|
||||||
|
assertTrue(bd1.lowerListBuilding.stream().allMatch(x->x.getEra()==1));
|
||||||
|
|
||||||
|
|
||||||
// Era 2, nTotem > 3
|
// Era 2, nTotem > 3
|
||||||
@@ -227,7 +229,8 @@ class BoardTest {
|
|||||||
assertEquals(upperListBefore, bd2.lowerListBuilding);
|
assertEquals(upperListBefore, bd2.lowerListBuilding);
|
||||||
assertNotEquals(upperListBefore, bd2.upperListBuilding);
|
assertNotEquals(upperListBefore, bd2.upperListBuilding);
|
||||||
assertEquals(3, bd2.upperListBuilding.size());
|
assertEquals(3, bd2.upperListBuilding.size());
|
||||||
|
assertTrue(bd2.upperListBuilding.stream().allMatch(x->x.getEra()==2));
|
||||||
|
assertTrue(bd2.lowerListBuilding.stream().allMatch(x->x.getEra()==1));
|
||||||
|
|
||||||
// Era 3, nTotem == 2
|
// Era 3, nTotem == 2
|
||||||
numPlayer = 2;
|
numPlayer = 2;
|
||||||
@@ -243,6 +246,8 @@ class BoardTest {
|
|||||||
assertEquals(upperListBefore, bd3.lowerListBuilding);
|
assertEquals(upperListBefore, bd3.lowerListBuilding);
|
||||||
assertNotEquals(upperListBefore, bd3.upperListBuilding);
|
assertNotEquals(upperListBefore, bd3.upperListBuilding);
|
||||||
assertEquals(3, bd3.upperListBuilding.size());
|
assertEquals(3, bd3.upperListBuilding.size());
|
||||||
|
assertTrue(bd3.upperListBuilding.stream().allMatch(x->x.getEra()==3));
|
||||||
|
assertTrue(bd3.lowerListBuilding.stream().allMatch(x->x.getEra()==2));
|
||||||
|
|
||||||
|
|
||||||
// Era 3, nTotem == 5
|
// Era 3, nTotem == 5
|
||||||
@@ -259,6 +264,8 @@ class BoardTest {
|
|||||||
assertEquals(upperListBefore, bd4.lowerListBuilding);
|
assertEquals(upperListBefore, bd4.lowerListBuilding);
|
||||||
assertNotEquals(upperListBefore, bd4.upperListBuilding);
|
assertNotEquals(upperListBefore, bd4.upperListBuilding);
|
||||||
assertEquals(5, bd4.upperListBuilding.size());
|
assertEquals(5, bd4.upperListBuilding.size());
|
||||||
|
assertTrue(bd4.upperListBuilding.stream().allMatch(x->x.getEra()==3));
|
||||||
|
assertTrue(bd4.lowerListBuilding.stream().allMatch(x->x.getEra()==2));
|
||||||
|
|
||||||
|
|
||||||
// Era 3, nTotem != 2, 5
|
// Era 3, nTotem != 2, 5
|
||||||
@@ -275,6 +282,8 @@ class BoardTest {
|
|||||||
assertEquals(upperListBefore, bd5.lowerListBuilding);
|
assertEquals(upperListBefore, bd5.lowerListBuilding);
|
||||||
assertNotEquals(upperListBefore, bd5.upperListBuilding);
|
assertNotEquals(upperListBefore, bd5.upperListBuilding);
|
||||||
assertEquals(4, bd5.upperListBuilding.size());
|
assertEquals(4, bd5.upperListBuilding.size());
|
||||||
|
assertTrue(bd5.upperListBuilding.stream().allMatch(x->x.getEra()==3));
|
||||||
|
assertTrue(bd5.lowerListBuilding.stream().allMatch(x->x.getEra()==2));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user