From 78d7808fc196de0ef8e405eb5ce777235c673f74 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Mon, 6 Apr 2026 12:49:39 +0200 Subject: [PATCH 1/9] Fix: HuntTest --- src/main/java/it/polimi/ingsw/gc14/Model/Main.java | 2 +- .../gc14/Model/Cards/TribeCards/Events/HuntTest.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Main.java b/src/main/java/it/polimi/ingsw/gc14/Model/Main.java index 606af8f..14d91a0 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Main.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Main.java @@ -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; diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java index 3688573..b1f5d2e 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java @@ -2,6 +2,7 @@ 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.Player; import org.junit.jupiter.api.DisplayName; @@ -65,7 +66,7 @@ class HuntTest { } @Test - @DisplayName("No edge case test") + @DisplayName("p2 has building 7") void activateEvent3() { Player p1 = new Player("Giacomo"); Player p2 = new Player("xiaomi"); @@ -81,6 +82,11 @@ class HuntTest { Hunter hunter3 = new Hunter(1, false); p2.hunters.add(hunter3); + BuildingCard bc = new BuildingCard(7, 1, 5, 5); + p2.addFood(5); + bc.buy(p2); + + h1.activateEvent(players); assertEquals(6, p1.getPrestigeValue()); assertEquals(1, p1.getFoodValue()); From c788bc6a9f2999d31968e3985b9058d667521bc1 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Mon, 6 Apr 2026 12:53:05 +0200 Subject: [PATCH 2/9] Fix: HuntTest --- .../Model/Cards/TribeCards/Events/HuntTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java index b1f5d2e..3cbc8d5 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java @@ -70,8 +70,9 @@ class HuntTest { void activateEvent3() { Player p1 = new Player("Giacomo"); Player p2 = new Player("xiaomi"); + Player p3 = new Player("test"); - ArrayList players = new ArrayList<>(Arrays.asList(p1, p2)); + ArrayList players = new ArrayList<>(Arrays.asList(p1, p2, p3)); Hunt h1 = new Hunt(1, 3); Hunter hunter1 = new Hunter(1, true); @@ -81,16 +82,20 @@ class HuntTest { Hunter hunter3 = new Hunter(1, false); p2.hunters.add(hunter3); - BuildingCard bc = new BuildingCard(7, 1, 5, 5); p2.addFood(5); bc.buy(p2); + Hunter hunter4 = new Hunter(1, false); + p3.hunters.add(hunter4); + h1.activateEvent(players); assertEquals(6, p1.getPrestigeValue()); assertEquals(1, p1.getFoodValue()); - assertEquals(3, p2.getPrestigeValue()); - assertEquals(1, p2.getFoodValue()); + assertEquals(4, p2.getPrestigeValue()); + assertEquals(2, p2.getFoodValue()); + assertEquals(3, p3.getPrestigeValue()); + assertEquals(1, p3.getFoodValue()); } } \ No newline at end of file From a21c6b0eee040f2b8ffc17c89fc0e35b7c6bb055 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Mon, 6 Apr 2026 13:26:54 +0200 Subject: [PATCH 3/9] Fix: HuntTest, CavePaintingsTest --- .../TribeCards/Events/CavePaintingsTest.java | 91 ++++++++++++++++--- .../Cards/TribeCards/Events/HuntTest.java | 17 ++++ 2 files changed, 93 insertions(+), 15 deletions(-) diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java index 2f8656d..95e48b5 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java @@ -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 players = new ArrayList<>(Arrays.asList(p1)); + Player p2 = new Player("Giacomo"); + ArrayList players = new ArrayList<>(Arrays.asList(p1, p2)); CavePaintings cp1 = new CavePaintings(1, 1, 3, 2); + + p2.artists.add(new Artist(1)); 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 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); - new Artist(1).insert(p1); + cp1.activateEvent(players); + assertEquals(-3, p1.getPrestigeValue()); + assertEquals(0, p1.getFoodValue()); - - CavePaintings cp2 = new CavePaintings(1, 1, 3, 2); + p1.artists.add(new Artist(1)); + p1.artists.add(new Artist(1)); 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 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); + p1.artists.add(new Artist(1)); + 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); + p1.artists.add(new Artist(1)); + p1.artists.add(new Artist(1)); + 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()); } } \ No newline at end of file diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java index 3cbc8d5..ff8d912 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java @@ -4,6 +4,8 @@ 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; @@ -98,4 +100,19 @@ class HuntTest { 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.foodToAdd); + assertEquals(3, h2.prestigeMultiplier); + assertEquals(1, h2.getEra()); + assertEquals(EventType.HUNT, h2.getType()); + } } \ No newline at end of file From 6f58b55e5c46fb98d0c274233d04fd1178b5d463 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Mon, 6 Apr 2026 13:55:22 +0200 Subject: [PATCH 4/9] 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 From b63dded777056bd8ef80f0c9e00e5d2ab1bc05d6 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Mon, 6 Apr 2026 21:51:09 +0200 Subject: [PATCH 5/9] Fix: ShamanicRitualTest --- .../TribeCards/Events/SustenanceTest.java | 97 +++++++++++++++++-- 1 file changed, 90 insertions(+), 7 deletions(-) diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java index 970bb11..50c077f 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java @@ -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,86 @@ 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 players = new ArrayList<>(Arrays.asList(p1,p2)); - Sustenance s = new Sustenance(1,1); + + p1.addFood(4); + p1.inventors.add(new Inventor(1, 1)); + p1.shamans.add(new Shaman(1, 5)); + p1.builders.add(new Builder(1, 5, 5)); + p1.artists.add(new Artist(1)); + p1.hunters.add(new Hunter(1, true)); + p1.gatherers.add(new Gatherer(1)); + + p2.addFood(1); + p2.artists.add(new Artist(1)); + p2.hunters.add(new Hunter(1, true)); + + + 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(-2, p2.getPrestigeValue()); + } + + @Test + @DisplayName("Building 1 testing") + void activateEvent2() { + Player p1 = new Player("marco"); + Player p2 = new Player("giacomo"); + ArrayList players = new ArrayList<>(Arrays.asList(p1,p2)); + + p1.addFood(5); + p1.inventors.add(new Inventor(1, 1)); + p1.shamans.add(new Shaman(1, 5)); + p1.builders.add(new Builder(1, 5, 5)); + p1.artists.add(new Artist(1)); + p1.hunters.add(new Hunter(1, true)); + p1.gatherers.add(new Gatherer(1)); + + p2.addFood(2); + p2.artists.add(new Artist(1)); + p2.artists.add(new Artist(1)); + p2.artists.add(new Artist(1)); + + + 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()); } -} \ No newline at end of file + + @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()); + } +} + + + + + From 40933e2e945bd4246cc9e12e5a17cd0756d55919 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Tue, 7 Apr 2026 19:38:19 +0200 Subject: [PATCH 6/9] Changed characters insert for CavePaintingTest, HuntTest, SustenanceTest --- .../TribeCards/Events/CavePaintingsTest.java | 12 +++---- .../Cards/TribeCards/Events/HuntTest.java | 22 ++++-------- .../TribeCards/Events/SustenanceTest.java | 34 +++++++++---------- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java index 95e48b5..f8b1113 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/CavePaintingsTest.java @@ -33,7 +33,7 @@ class CavePaintingsTest { ArrayList players = new ArrayList<>(Arrays.asList(p1, p2)); CavePaintings cp1 = new CavePaintings(1, 1, 3, 2); - p2.artists.add(new Artist(1)); + new Artist(1).insert(p2); cp1.activateEvent(players); assertEquals(-3, p1.getPrestigeValue()); @@ -55,8 +55,8 @@ class CavePaintingsTest { assertEquals(-3, p1.getPrestigeValue()); assertEquals(0, p1.getFoodValue()); - p1.artists.add(new Artist(1)); - p1.artists.add(new Artist(1)); + new Artist(1).insert(p1); + new Artist(1).insert(p1); cp2.activateEvent(players); assertEquals(5, p1.getPrestigeValue()); assertEquals(0, p1.getFoodValue()); @@ -76,7 +76,7 @@ class CavePaintingsTest { BuildingCard bc1 = new BuildingCard(9,1,5,5); p1.addFood(5); bc1.buy(p1); - p1.artists.add(new Artist(1)); + new Artist(1).insert(p1); cp1.activateEvent(players); assertEquals(2, p1.getPrestigeValue()); @@ -86,8 +86,8 @@ class CavePaintingsTest { BuildingCard bc2 = new BuildingCard(9,1,5,5); p1.addFood(5); bc2.buy(p1); - p1.artists.add(new Artist(1)); - p1.artists.add(new Artist(1)); + new Artist(1).insert(p1); + new Artist(1).insert(p1); cp1.activateEvent(players); assertEquals(8, p1.getPrestigeValue()); diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java index ff8d912..3869b08 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java @@ -36,13 +36,9 @@ class HuntTest { ArrayList 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()); @@ -77,19 +73,15 @@ class HuntTest { ArrayList 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); - Hunter hunter3 = new Hunter(1, false); - p2.hunters.add(hunter3); BuildingCard bc = new BuildingCard(7, 1, 5, 5); p2.addFood(5); bc.buy(p2); - Hunter hunter4 = new Hunter(1, false); - p3.hunters.add(hunter4); + new Hunter(1, false).insert(p3); h1.activateEvent(players); diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java index 50c077f..4e3b950 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java @@ -45,16 +45,16 @@ class SustenanceTest { ArrayList players = new ArrayList<>(Arrays.asList(p1,p2)); p1.addFood(4); - p1.inventors.add(new Inventor(1, 1)); - p1.shamans.add(new Shaman(1, 5)); - p1.builders.add(new Builder(1, 5, 5)); - p1.artists.add(new Artist(1)); - p1.hunters.add(new Hunter(1, true)); - p1.gatherers.add(new Gatherer(1)); + 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); - p2.artists.add(new Artist(1)); - p2.hunters.add(new Hunter(1, true)); + new Artist(1).insert(p2); + new Hunter(1, true).insert(p2); Sustenance s = new Sustenance(1,2); @@ -73,17 +73,17 @@ class SustenanceTest { ArrayList players = new ArrayList<>(Arrays.asList(p1,p2)); p1.addFood(5); - p1.inventors.add(new Inventor(1, 1)); - p1.shamans.add(new Shaman(1, 5)); - p1.builders.add(new Builder(1, 5, 5)); - p1.artists.add(new Artist(1)); - p1.hunters.add(new Hunter(1, true)); - p1.gatherers.add(new Gatherer(1)); + 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); - p2.artists.add(new Artist(1)); - p2.artists.add(new Artist(1)); - p2.artists.add(new Artist(1)); + new Artist(1).insert(p2); + new Artist(1).insert(p2); + new Artist(1).insert(p2); Building1 bd1 = new Building1(1, 1, 1, CharacterType.SHAMAN); From 513f9e2d87653667449d034073b2f37ac4bf4dc3 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Tue, 7 Apr 2026 19:44:47 +0200 Subject: [PATCH 7/9] ShamanicRitualTest: test building 6 edge case added SustenanceTest: Testing food debt with 2 characters --- .../TribeCards/Events/ShamanicRitualTest.java | 27 +++++++++++++++++++ .../TribeCards/Events/SustenanceTest.java | 4 ++- 2 files changed, 30 insertions(+), 1 deletion(-) 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 04495c0..dc7d5f2 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 @@ -147,6 +147,7 @@ class ShamanicRitualTest { Player p1 = new Player("Marco"); Player p2 = new Player("Luca"); + ArrayList players = new ArrayList<>(Arrays.asList(p1, p2)); new Shaman(1, 3).insert(p1); @@ -163,6 +164,32 @@ class ShamanicRitualTest { 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 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() { diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java index 4e3b950..e7ea67e 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/SustenanceTest.java @@ -55,6 +55,8 @@ class SustenanceTest { 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); @@ -62,7 +64,7 @@ class SustenanceTest { assertEquals(1, p1.getFoodValue()); assertEquals(0, p2.getFoodValue()); assertEquals(0, p1.getPrestigeValue()); - assertEquals(-2, p2.getPrestigeValue()); + assertEquals(-4, p2.getPrestigeValue()); } @Test From 092b8991cd41d6b9fef12777e3ff8e04feddb760 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Wed, 8 Apr 2026 18:44:28 +0200 Subject: [PATCH 8/9] ShamanicRitual: fixed edge case when everybody has the same icons ShamanicRitualTest: fixed --- .../gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java | 2 +- .../Model/Cards/TribeCards/Events/ShamanicRitualTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java index 00550ca..763e863 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java @@ -68,7 +68,7 @@ public class ShamanicRitual extends EventCard { int minIcon = playerMap.values().stream().mapToInt(Integer::intValue).min().orElse(0); List maxIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == maxIcon).map(Map.Entry::getKey).collect(Collectors.toList()); - List minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).filter(player -> !maxIconsPlayer.contains(player)).collect(Collectors.toList()); + List minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).collect(Collectors.toList()); for (Player player : maxIconsPlayer) { 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 dc7d5f2..6d16b66 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 @@ -65,8 +65,8 @@ class ShamanicRitualTest { ShamanicRitual ritual = new ShamanicRitual(1, 10, 5); ritual.activateEvent(players); - assertEquals(10, p1.getPrestigeValue()); - assertEquals(10, p2.getPrestigeValue()); + assertEquals(5, p1.getPrestigeValue()); + assertEquals(5, p2.getPrestigeValue()); } @Test From e94a9602ab5a17fb5ac2a2c065923882bdb9ef32 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Wed, 8 Apr 2026 19:07:40 +0200 Subject: [PATCH 9/9] Small fix: ShamanicRitual Hunt: changed the food logic HuntTest: test adapted to the new version --- .../Model/Cards/TribeCards/Events/Hunt.java | 18 +++++++++--------- .../TribeCards/Events/ShamanicRitual.java | 2 +- .../Cards/TribeCards/Events/HuntTest.java | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java index 02adfd0..5d9c4f1 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/Hunt.java @@ -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 playerList){ for (Player player : playerList) { - int tmpFoodToAdd = foodToAdd; + int tmpFoodMultiplier = foodMultiplier; int tmpPrestigeMultiplier = prestigeMultiplier; ArrayList 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); } } diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java index 763e863..258dae9 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/ShamanicRitual.java @@ -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 diff --git a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java index 3869b08..4c416a0 100644 --- a/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java +++ b/src/test/java/it/polimi/ingsw/gc14/Model/Cards/TribeCards/Events/HuntTest.java @@ -21,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 @@ -42,7 +42,7 @@ class HuntTest { h1.activateEvent(players); assertEquals(6, p1.getPrestigeValue()); - assertEquals(1, p1.getFoodValue()); + assertEquals(2, p1.getFoodValue()); assertEquals(3, p2.getPrestigeValue()); assertEquals(1, p2.getFoodValue()); } @@ -58,9 +58,9 @@ 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 @@ -86,7 +86,7 @@ class HuntTest { h1.activateEvent(players); assertEquals(6, p1.getPrestigeValue()); - assertEquals(1, p1.getFoodValue()); + assertEquals(2, p1.getFoodValue()); assertEquals(4, p2.getPrestigeValue()); assertEquals(2, p2.getFoodValue()); assertEquals(3, p3.getPrestigeValue()); @@ -102,7 +102,7 @@ class HuntTest { Hunt h1 = new Hunt(era, prestigeMultiplier); Hunt h2 = (Hunt) h1.clone(); - assertEquals(1, h2.foodToAdd); + assertEquals(1, h2.foodMultiplier); assertEquals(3, h2.prestigeMultiplier); assertEquals(1, h2.getEra()); assertEquals(EventType.HUNT, h2.getType());