Merge pull request #10 from rubenpirreram/Events-tests
Events-tests and events fix
This commit is contained in:
@@ -13,10 +13,10 @@ import java.util.ArrayList;
|
||||
* @see EventCard
|
||||
*/
|
||||
public class Hunt extends EventCard {
|
||||
/** Food points to add during the event. */
|
||||
int foodToAdd;
|
||||
/** Food points multiplier used during the event. */
|
||||
int foodMultiplier;
|
||||
|
||||
/** Prestige Points multiplicator used during the event. */
|
||||
/** Prestige Points multiplier used during the event. */
|
||||
int prestigeMultiplier;
|
||||
|
||||
/**
|
||||
@@ -27,23 +27,23 @@ public class Hunt extends EventCard {
|
||||
*/
|
||||
public Hunt(int Era, int prestigeMultiplier) {
|
||||
super(Era, EventType.HUNT);
|
||||
this.foodToAdd = 1;
|
||||
this.foodMultiplier = 1;
|
||||
this.prestigeMultiplier = prestigeMultiplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates the event card "Hunt".
|
||||
* Each player takes 1 Food and gains Prestige Points equal to prestigeMultiplier times the number of Hunters in their tribe.
|
||||
* Each player takes 1 Food and gains Prestige Points for each Hunter in their tribe.
|
||||
*
|
||||
* Buildings influence:
|
||||
* Building 7: you take 1 Food and gain 1 additional Prestige Point for each Hunter
|
||||
* Building 7: you take 1 Food and 1 additional Prestige Point for each Hunter
|
||||
*
|
||||
* @param playerList contains all the players in the game
|
||||
*/
|
||||
@Override
|
||||
public void activateEvent (ArrayList <Player> playerList){
|
||||
for (Player player : playerList) {
|
||||
int tmpFoodToAdd = foodToAdd;
|
||||
int tmpFoodMultiplier = foodMultiplier;
|
||||
int tmpPrestigeMultiplier = prestigeMultiplier;
|
||||
|
||||
ArrayList <BuildingCard> buildingList = player.buildingCards;
|
||||
@@ -51,12 +51,12 @@ public class Hunt extends EventCard {
|
||||
|
||||
for (BuildingCard buildingCard : buildingList) {
|
||||
if (buildingCard.getEffectId() == 7) {
|
||||
tmpFoodToAdd++;
|
||||
tmpFoodMultiplier++;
|
||||
tmpPrestigeMultiplier++;
|
||||
}
|
||||
}
|
||||
|
||||
player.addFood(tmpFoodToAdd);
|
||||
player.addFood(tmpFoodMultiplier * hunterCounter);
|
||||
player.addPrestige(tmpPrestigeMultiplier * hunterCounter);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ public class ShamanicRitual extends EventCard {
|
||||
* The player with the most icons gains the Prestige Points indicated.
|
||||
* The player with the fewest icons loses the Prestige Points indicated.
|
||||
* In case of a tie, all player gain or lose the Prestige Points indicated.
|
||||
* If all players have the same amount of icons, they all gains Prestige Points.
|
||||
* If all players have the same amount of icons, they all gain and lose Prestige Points.
|
||||
*
|
||||
* Buildings influence:
|
||||
* Building 2: if you have fewer icons than all other players, you don't lose Prestige Points
|
||||
@@ -68,7 +68,7 @@ public class ShamanicRitual extends EventCard {
|
||||
int minIcon = playerMap.values().stream().mapToInt(Integer::intValue).min().orElse(0);
|
||||
|
||||
List<Player> maxIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == maxIcon).map(Map.Entry::getKey).collect(Collectors.toList());
|
||||
List<Player> minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).filter(player -> !maxIconsPlayer.contains(player)).collect(Collectors.toList());
|
||||
List<Player> minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).collect(Collectors.toList());
|
||||
|
||||
|
||||
for (Player player : maxIconsPlayer) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package it.polimi.ingsw.gc14.Model;
|
||||
|
||||
import it.polimi.ingsw.gc14.Controller.GameController;
|
||||
//import it.polimi.ingsw.gc14.Controller.GameController;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Inventor;
|
||||
|
||||
+76
-15
@@ -1,7 +1,10 @@
|
||||
package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Artist;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -12,36 +15,94 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
class CavePaintingsTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Testing constructor")
|
||||
void testConstructor() {
|
||||
// Gli attributi di CavePainting era e EventType vengono testati in EventCardTest.
|
||||
|
||||
// Gli attributi NLower, NPrestigeRem e NPrestigeMul non possono essere testati singolarmente in quanto non hanno metodi getter
|
||||
// Ne viene testato il corretto funzionamento indirettamente attraverso applyEffect.
|
||||
|
||||
// Come conseguenza finale, non può essere testato il costruttore di CavePainting
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("No edge case test")
|
||||
void activateEvent() {
|
||||
Player p1 = new Player("Marco");
|
||||
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1));
|
||||
Player p2 = new Player("Giacomo");
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2));
|
||||
CavePaintings cp1 = new CavePaintings(1, 1, 3, 2);
|
||||
|
||||
new Artist(1).insert(p2);
|
||||
cp1.activateEvent(players);
|
||||
|
||||
assertEquals(-3, p1.getPrestigeValue());
|
||||
assertEquals(0, p1.getFoodValue());
|
||||
assertEquals(2, p2.getPrestigeValue());
|
||||
assertEquals(0, p2.getFoodValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Multiple activations test")
|
||||
void activateEvent1() {
|
||||
Player p1 = new Player("Marco");
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1));
|
||||
CavePaintings cp1 = new CavePaintings(1, 1, 3, 2);
|
||||
CavePaintings cp2 = new CavePaintings(1, 1, 3, 4);
|
||||
CavePaintings cp3 = new CavePaintings(1, 1, 10, 2);
|
||||
|
||||
cp1.activateEvent(players);
|
||||
assertEquals(-3, p1.getPrestigeValue());
|
||||
assertEquals(0, p1.getFoodValue());
|
||||
|
||||
new Artist(1).insert(p1);
|
||||
|
||||
|
||||
CavePaintings cp2 = new CavePaintings(1, 1, 3, 2);
|
||||
new Artist(1).insert(p1);
|
||||
cp2.activateEvent(players);
|
||||
|
||||
assertEquals(-1, p1.getPrestigeValue());
|
||||
assertEquals(5, p1.getPrestigeValue());
|
||||
assertEquals(0, p1.getFoodValue());
|
||||
|
||||
|
||||
|
||||
new Artist(1).insert(p1);
|
||||
|
||||
|
||||
CavePaintings cp3 = new CavePaintings(1, 1, 3, 5);
|
||||
p1.artists.clear();
|
||||
cp3.activateEvent(players);
|
||||
|
||||
assertEquals(9, p1.getPrestigeValue());
|
||||
assertEquals(-5, p1.getPrestigeValue());
|
||||
assertEquals(0, p1.getFoodValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Building 9 test")
|
||||
void activateEvent2() {
|
||||
Player p1 = new Player("Marco");
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1));
|
||||
CavePaintings cp1 = new CavePaintings(1, 1, 3, 2);
|
||||
BuildingCard bc1 = new BuildingCard(9,1,5,5);
|
||||
p1.addFood(5);
|
||||
bc1.buy(p1);
|
||||
new Artist(1).insert(p1);
|
||||
cp1.activateEvent(players);
|
||||
|
||||
assertEquals(2, p1.getPrestigeValue());
|
||||
assertEquals(1, p1.getFoodValue());
|
||||
|
||||
|
||||
BuildingCard bc2 = new BuildingCard(9,1,5,5);
|
||||
p1.addFood(5);
|
||||
bc2.buy(p1);
|
||||
new Artist(1).insert(p1);
|
||||
new Artist(1).insert(p1);
|
||||
cp1.activateEvent(players);
|
||||
|
||||
assertEquals(8, p1.getPrestigeValue());
|
||||
assertEquals(7, p1.getFoodValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Clone testing")
|
||||
void cloneTest() {
|
||||
int era = 1;
|
||||
|
||||
CavePaintings cv1 = new CavePaintings(era, 1,1,1);
|
||||
CavePaintings cv2 = (CavePaintings) cv1.clone();
|
||||
|
||||
assertEquals(1, cv2.getEra());
|
||||
assertEquals(EventType.CAVE_PAINTINGS, cv2.getType());
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,10 @@ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.Building0;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Hunter;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -18,7 +21,7 @@ class HuntTest {
|
||||
void testConstructor() {
|
||||
// Gli attributi di Hunt era e EventType vengono testati in EventCardTest.
|
||||
|
||||
// Gli attributi foodToAdd e prestigeMultiplier non possono essere testati singolarmente in quanto non hanno metodi getter
|
||||
// Gli attributi foodMultiplier e prestigeMultiplier non possono essere testati singolarmente in quanto non hanno metodi getter
|
||||
// Ne viene testato il corretto funzionamento indirettamente attraverso applyEffect.
|
||||
|
||||
// Come conseguenza finale, non può essere testato il costruttore di Hunt
|
||||
@@ -33,17 +36,13 @@ class HuntTest {
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2));
|
||||
Hunt h1 = new Hunt(1, 3);
|
||||
|
||||
Hunter hunter1 = new Hunter(1, true);
|
||||
Hunter hunter2 = new Hunter(1, false);
|
||||
p1.hunters.add(hunter1);
|
||||
p1.hunters.add(hunter2);
|
||||
|
||||
Hunter hunter3 = new Hunter(1, false);
|
||||
p2.hunters.add(hunter3);
|
||||
new Hunter(1, true).insert(p1);
|
||||
new Hunter(1, false).insert(p1);
|
||||
new Hunter(1, false).insert(p2);
|
||||
|
||||
h1.activateEvent(players);
|
||||
assertEquals(6, p1.getPrestigeValue());
|
||||
assertEquals(1, p1.getFoodValue());
|
||||
assertEquals(2, p1.getFoodValue());
|
||||
assertEquals(3, p2.getPrestigeValue());
|
||||
assertEquals(1, p2.getFoodValue());
|
||||
}
|
||||
@@ -59,32 +58,53 @@ class HuntTest {
|
||||
h1.activateEvent(players);
|
||||
|
||||
assertEquals(0, p1.getPrestigeValue());
|
||||
assertEquals(1, p1.getFoodValue());
|
||||
assertEquals(0, p1.getFoodValue());
|
||||
assertEquals(0, p2.getPrestigeValue());
|
||||
assertEquals(1, p2.getFoodValue());
|
||||
assertEquals(0, p2.getFoodValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("No edge case test")
|
||||
@DisplayName("p2 has building 7")
|
||||
void activateEvent3() {
|
||||
Player p1 = new Player("Giacomo");
|
||||
Player p2 = new Player("xiaomi");
|
||||
Player p3 = new Player("test");
|
||||
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2));
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2, p3));
|
||||
Hunt h1 = new Hunt(1, 3);
|
||||
|
||||
Hunter hunter1 = new Hunter(1, true);
|
||||
Hunter hunter2 = new Hunter(1, false);
|
||||
p1.hunters.add(hunter1);
|
||||
p1.hunters.add(hunter2);
|
||||
new Hunter(1, true).insert(p1);
|
||||
new Hunter(1, false).insert(p1);
|
||||
new Hunter(1, false).insert(p2);
|
||||
|
||||
BuildingCard bc = new BuildingCard(7, 1, 5, 5);
|
||||
p2.addFood(5);
|
||||
bc.buy(p2);
|
||||
|
||||
new Hunter(1, false).insert(p3);
|
||||
|
||||
Hunter hunter3 = new Hunter(1, false);
|
||||
p2.hunters.add(hunter3);
|
||||
|
||||
h1.activateEvent(players);
|
||||
assertEquals(6, p1.getPrestigeValue());
|
||||
assertEquals(1, p1.getFoodValue());
|
||||
assertEquals(3, p2.getPrestigeValue());
|
||||
assertEquals(1, p2.getFoodValue());
|
||||
assertEquals(2, p1.getFoodValue());
|
||||
assertEquals(4, p2.getPrestigeValue());
|
||||
assertEquals(2, p2.getFoodValue());
|
||||
assertEquals(3, p3.getPrestigeValue());
|
||||
assertEquals(1, p3.getFoodValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("clone testing")
|
||||
void cloneTest() {
|
||||
int era = 1;
|
||||
int prestigeMultiplier = 3;
|
||||
|
||||
Hunt h1 = new Hunt(era, prestigeMultiplier);
|
||||
Hunt h2 = (Hunt) h1.clone();
|
||||
|
||||
assertEquals(1, h2.foodMultiplier);
|
||||
assertEquals(3, h2.prestigeMultiplier);
|
||||
assertEquals(1, h2.getEra());
|
||||
assertEquals(EventType.HUNT, h2.getType());
|
||||
}
|
||||
}
|
||||
+142
-10
@@ -3,7 +3,9 @@ package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Shaman;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -21,7 +23,19 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
class ShamanicRitualTest {
|
||||
|
||||
@Test
|
||||
void uniqueWinnerGetsPrestige() {
|
||||
@DisplayName("Testing constructor")
|
||||
void testConstructor() {
|
||||
// Gli attributi di ShamanicRitual era e EventType vengono testati in EventCardTest.
|
||||
|
||||
// Gli attributi prestigeToAdd e prestigeToRemove non possono essere testati singolarmente in quanto non hanno metodi getter
|
||||
// Ne viene testato il corretto funzionamento indirettamente attraverso applyEffect.
|
||||
|
||||
// Come conseguenza finale, non può essere testato il costruttore di ShamanicRitual
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("No edge case test")
|
||||
void applyEvent() {
|
||||
Player p1 = new Player("Marco");
|
||||
Player p2 = new Player("Luca");
|
||||
|
||||
@@ -38,26 +52,101 @@ class ShamanicRitualTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void tiedPlayersNoDoublePrestige() {
|
||||
Player p3 = new Player("Marco");
|
||||
Player p4 = new Player("Luca");
|
||||
@DisplayName("All players have the same icons")
|
||||
void applyEvent2() {
|
||||
Player p1 = new Player("Marco");
|
||||
Player p2 = new Player("Luca");
|
||||
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p3, p4));
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2));
|
||||
|
||||
new Shaman(1, 3).insert(p3);
|
||||
new Shaman(1, 3).insert(p4);
|
||||
new Shaman(1, 3).insert(p1);
|
||||
new Shaman(1, 3).insert(p2);
|
||||
|
||||
ShamanicRitual ritual = new ShamanicRitual(1, 10, 5);
|
||||
ritual.activateEvent(players);
|
||||
|
||||
assertEquals(10, p3.getPrestigeValue());
|
||||
assertEquals(10, p4.getPrestigeValue());
|
||||
assertEquals(5, p1.getPrestigeValue());
|
||||
assertEquals(5, p2.getPrestigeValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void uniqueWinnerWithDoublePrestige() {
|
||||
@DisplayName("Two players have the highest amount of icons")
|
||||
void applyEvent3() {
|
||||
Player p1 = new Player("Marco");
|
||||
Player p2 = new Player("Luca");
|
||||
Player p3 = new Player("Giacomo");
|
||||
|
||||
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2, p3));
|
||||
|
||||
new Shaman(1, 3).insert(p1);
|
||||
new Shaman(1, 3).insert(p2);
|
||||
new Shaman(1, 2).insert(p3);
|
||||
|
||||
|
||||
ShamanicRitual ritual = new ShamanicRitual(1, 10, 5);
|
||||
ritual.activateEvent(players);
|
||||
|
||||
assertEquals(10, p1.getPrestigeValue());
|
||||
assertEquals(10, p2.getPrestigeValue());
|
||||
assertEquals(-5, p3.getPrestigeValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("p3 has building 2")
|
||||
void applyEvent4() {
|
||||
Player p1 = new Player("Marco");
|
||||
Player p2 = new Player("Luca");
|
||||
Player p3 = new Player("Giacomo");
|
||||
|
||||
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2, p3));
|
||||
|
||||
new Shaman(1, 3).insert(p1);
|
||||
new Shaman(1, 3).insert(p2);
|
||||
new Shaman(1, 2).insert(p3);
|
||||
|
||||
BuildingCard bc1 = new BuildingCard(2,1,5,5);
|
||||
p3.addFood(5);
|
||||
bc1.buy(p3);
|
||||
|
||||
ShamanicRitual ritual = new ShamanicRitual(1, 10, 5);
|
||||
ritual.activateEvent(players);
|
||||
|
||||
assertEquals(10, p1.getPrestigeValue());
|
||||
assertEquals(10, p2.getPrestigeValue());
|
||||
assertEquals(0, p3.getPrestigeValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("p1 has building 5")
|
||||
void applyEvent5() {
|
||||
Player p1 = new Player("Marco");
|
||||
Player p2 = new Player("Luca");
|
||||
|
||||
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2));
|
||||
|
||||
new Shaman(1, 2).insert(p1);
|
||||
new Shaman(1, 3).insert(p2);
|
||||
|
||||
BuildingCard bc1 = new BuildingCard(5,1,5,5);
|
||||
p1.addFood(5);
|
||||
bc1.buy(p1);
|
||||
|
||||
ShamanicRitual ritual = new ShamanicRitual(1, 10, 5);
|
||||
ritual.activateEvent(players);
|
||||
|
||||
assertEquals(10, p1.getPrestigeValue());
|
||||
assertEquals(-5, p2.getPrestigeValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("p1 has building 6")
|
||||
void applyEvent6() {
|
||||
Player p1 = new Player("Marco");
|
||||
Player p2 = new Player("Luca");
|
||||
|
||||
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2));
|
||||
|
||||
@@ -74,4 +163,47 @@ class ShamanicRitualTest {
|
||||
assertEquals(20, p1.getPrestigeValue());
|
||||
assertEquals(-5, p2.getPrestigeValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("p1 has building 6 but p2 has same icons")
|
||||
void applyEvent7() {
|
||||
Player p1 = new Player("Marco");
|
||||
Player p2 = new Player("Luca");
|
||||
Player p3 = new Player("Giacomo");
|
||||
|
||||
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1, p2, p3));
|
||||
|
||||
new Shaman(1, 3).insert(p1);
|
||||
new Shaman(1, 3).insert(p2);
|
||||
new Shaman(1, 1).insert(p3);
|
||||
|
||||
BuildingCard b = new BuildingCard(6, 1, 5, 1);
|
||||
p1.addFood(5);
|
||||
b.buy(p1);
|
||||
|
||||
ShamanicRitual ritual = new ShamanicRitual(1, 10, 5);
|
||||
ritual.activateEvent(players);
|
||||
|
||||
assertEquals(10, p1.getPrestigeValue());
|
||||
assertEquals(10, p2.getPrestigeValue());
|
||||
assertEquals(-5, p3.getPrestigeValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Clone testing")
|
||||
void cloneTest() {
|
||||
int era = 1;
|
||||
int prestigeToAdd = 10;
|
||||
int prestigeToRemove = 5;
|
||||
|
||||
ShamanicRitual sr1 = new ShamanicRitual(era, prestigeToAdd,prestigeToRemove);
|
||||
ShamanicRitual sr2 = (ShamanicRitual) sr1.clone();
|
||||
|
||||
assertEquals(1, sr2.getEra());
|
||||
assertEquals(EventType.SHAMANIC_RITUAL, sr2.getType());
|
||||
assertEquals(prestigeToAdd, sr2.prestigeToAdd);
|
||||
assertEquals(prestigeToRemove, sr2.prestigeToRemove);
|
||||
|
||||
}
|
||||
}
|
||||
+92
-7
@@ -1,5 +1,9 @@
|
||||
package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.Building1;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -12,6 +16,17 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class SustenanceTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Testing constructor")
|
||||
void testConstructor() {
|
||||
int era = 1;
|
||||
int prestigeDebt = 5;
|
||||
// Gli attributi di Sustenance era e EventType vengono testati in EventCardTest.
|
||||
|
||||
Sustenance s = new Sustenance(era, prestigeDebt);
|
||||
assertEquals(prestigeDebt, s.getPrestigeDebt());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Exception Test Null List")
|
||||
void test_null() {
|
||||
@@ -22,18 +37,88 @@ class SustenanceTest {
|
||||
});
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Mancano i metodi di play, il player non ha carte e non può giocare al momento
|
||||
@Test
|
||||
@DisplayName("No edge case")
|
||||
void activateEvent() {
|
||||
Player p1 = new Player("p1");
|
||||
Player p2 = new Player("p2");
|
||||
Player p1 = new Player("marco");
|
||||
Player p2 = new Player("giacomo");
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1,p2));
|
||||
Sustenance s = new Sustenance(1,1);
|
||||
|
||||
p1.addFood(4);
|
||||
new Inventor(1, 1).insert(p1);
|
||||
new Shaman(1, 5).insert(p1);
|
||||
new Builder(1, 5, 5).insert(p1);
|
||||
new Artist(1).insert(p1);
|
||||
new Hunter(1, true).insert(p1);
|
||||
new Gatherer(1).insert(p1);
|
||||
|
||||
p2.addFood(1);
|
||||
new Artist(1).insert(p2);
|
||||
new Hunter(1, true).insert(p2);
|
||||
new Hunter(1, true).insert(p2);
|
||||
|
||||
|
||||
|
||||
Sustenance s = new Sustenance(1,2);
|
||||
s.activateEvent(players);
|
||||
assertEquals(0, p1.getFoodValue());
|
||||
assertEquals(1, p1.getFoodValue());
|
||||
assertEquals(0, p2.getFoodValue());
|
||||
assertEquals(0, p1.getPrestigeValue());
|
||||
assertEquals(-4, p2.getPrestigeValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Building 1 testing")
|
||||
void activateEvent2() {
|
||||
Player p1 = new Player("marco");
|
||||
Player p2 = new Player("giacomo");
|
||||
ArrayList<Player> players = new ArrayList<>(Arrays.asList(p1,p2));
|
||||
|
||||
p1.addFood(5);
|
||||
new Inventor(1, 1).insert(p1);
|
||||
new Shaman(1, 5).insert(p1);
|
||||
new Builder(1, 5, 5).insert(p1);
|
||||
new Artist(1).insert(p1);
|
||||
new Hunter(1, true).insert(p1);
|
||||
new Gatherer(1).insert(p1);
|
||||
|
||||
p2.addFood(2);
|
||||
new Artist(1).insert(p2);
|
||||
new Artist(1).insert(p2);
|
||||
new Artist(1).insert(p2);
|
||||
|
||||
|
||||
Building1 bd1 = new Building1(1, 1, 1, CharacterType.SHAMAN);
|
||||
Building1 bd2 = new Building1(1, 1, 1, CharacterType.ARTIST);
|
||||
|
||||
bd1.buy(p1);
|
||||
bd2.buy(p2);
|
||||
|
||||
Sustenance s = new Sustenance(1,2);
|
||||
s.activateEvent(players);
|
||||
assertEquals(2, p1.getFoodValue());
|
||||
assertEquals(1, p2.getFoodValue());
|
||||
assertEquals(0, p1.getPrestigeValue());
|
||||
assertEquals(0, p2.getPrestigeValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Clone testing")
|
||||
void cloneTest() {
|
||||
int era = 1;
|
||||
int prestigeDebt = 5;
|
||||
|
||||
|
||||
Sustenance s1 = new Sustenance(era, prestigeDebt);
|
||||
Sustenance s2 = (Sustenance) s1.clone();
|
||||
|
||||
assertEquals(era, s2.getEra());
|
||||
assertEquals(EventType.SUSTENANCE, s2.getType());
|
||||
assertEquals(prestigeDebt, s2.getPrestigeDebt());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user