From 6f58b55e5c46fb98d0c274233d04fd1178b5d463 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Mon, 6 Apr 2026 13:55:22 +0200 Subject: [PATCH] Fix: ShamanicRitualTest --- .../TribeCards/Events/ShamanicRitualTest.java | 125 ++++++++++++++++-- 1 file changed, 115 insertions(+), 10 deletions(-) diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitualTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitualTest.java index 8a3c5fc..04495c0 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitualTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitualTest.java @@ -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,24 +52,98 @@ 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 players = new ArrayList<>(Arrays.asList(p3, p4)); + ArrayList 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(10, p1.getPrestigeValue()); + assertEquals(10, 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 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 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 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"); @@ -74,4 +162,21 @@ class ShamanicRitualTest { assertEquals(20, p1.getPrestigeValue()); assertEquals(-5, p2.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); + + } } \ No newline at end of file