Merge pull request #4 from rubenpirreram/JavaDOC-Hunt&ShamanicRitual

JavaDOC-Hunt&ShamanicRitual
This commit is contained in:
rubenpirreram
2026-04-02 17:08:39 +02:00
committed by GitHub
2 changed files with 78 additions and 10 deletions
@@ -1,42 +1,73 @@
package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events; package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard; import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Hunter;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
import java.util.ArrayList; import java.util.ArrayList;
/**
* When activated, gives Food and Prestige Points to every player.
*
* @see EventCard
*/
public class Hunt extends EventCard { public class Hunt extends EventCard {
/** Food points to add during the event. */
int foodToAdd; int foodToAdd;
int prestigeMultiplicator;
public Hunt(int Era, int prestigeMultiplicator) { /** Prestige Points multiplicator used during the event. */
int prestigeMultiplier;
/**
* Creates a new Hunt event card.
*
* @param Era the era of the card
* @param prestigeMultiplier prestige points multiplicator used during the event
*/
public Hunt(int Era, int prestigeMultiplier) {
super(Era, EventType.HUNT); super(Era, EventType.HUNT);
this.foodToAdd = 1; this.foodToAdd = 1;
this.prestigeMultiplicator = prestigeMultiplicator; 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.
*
* Buildings influence:
* Building 7: you take 1 Food and gain 1 additional Prestige Point for each Hunter
*
* @param playerList contains all the players in the game
*/
@Override @Override
public void activateEvent (ArrayList <Player> playerList){ public void activateEvent (ArrayList <Player> playerList){
for (Player player : playerList) { for (Player player : playerList) {
int tmpFoodToAdd = foodToAdd;
int tmpPrestigeMultiplier = prestigeMultiplier;
ArrayList <BuildingCard> buildingList = player.buildingCards; ArrayList <BuildingCard> buildingList = player.buildingCards;
int hunterCounter=player.getNType(CharacterType.HUNTER); int hunterCounter=player.getNType(CharacterType.HUNTER);
for (BuildingCard buildingCard : buildingList) { for (BuildingCard buildingCard : buildingList) {
if (buildingCard.getEffectId() == 7) { if (buildingCard.getEffectId() == 7) {
foodToAdd++; tmpFoodToAdd++;
prestigeMultiplicator++; tmpPrestigeMultiplier++;
} }
} }
player.addFood(foodToAdd); player.addFood(tmpFoodToAdd);
player.addPrestige(prestigeMultiplicator * hunterCounter); player.addPrestige(tmpPrestigeMultiplier * hunterCounter);
} }
} }
/**
* Creates and returns a copy of this Hunt card.
*
* @return a new Hunt card with the same era and prestige multiplicator
*/
@Override @Override
public EventCard clone() { public EventCard clone() {
return new Hunt(getEra(), prestigeMultiplicator); return new Hunt(getEra(), prestigeMultiplier);
} }
} }
@@ -9,9 +9,25 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/**
* When activated, rewards the player with the most shaman icons and penalizes the one with the fewest.
*
* @see EventCard
*/
public class ShamanicRitual extends EventCard { public class ShamanicRitual extends EventCard {
/** Prestige points awarded to the player with the most shaman icons. */
int prestigeToAdd; int prestigeToAdd;
/** Prestige points removed from the player with the fewest shaman icons. */
int prestigeToRemove; int prestigeToRemove;
/**
* Creates a new ShamanicRitual event card.
*
* @param Era the era of the card
* @param prestigeToAdd prestige points awarded to the player with the most icons
* @param prestigeToRemove prestige points removed from the player with the fewest icons
*/
public ShamanicRitual(int Era, int prestigeToAdd, int prestigeToRemove) { public ShamanicRitual(int Era, int prestigeToAdd, int prestigeToRemove) {
super(Era, EventType.SHAMANIC_RITUAL); super(Era, EventType.SHAMANIC_RITUAL);
this.prestigeToAdd = prestigeToAdd; this.prestigeToAdd = prestigeToAdd;
@@ -19,6 +35,20 @@ public class ShamanicRitual extends EventCard {
} }
/**
* Activates the event card "Shamanic Ritual".
* 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.
*
* Buildings influence:
* Building 2: if you have fewer icons than all other players, you don't lose Prestige Points
* Building 5: during the Shamanic Ritual, you gain 3 icons
* Building 6: if you have more icons than any other player, you gain double of Prestige Points
*
* @param playerList contains all the players in the game
*/
@Override @Override
public void activateEvent (ArrayList <Player> playerList){ public void activateEvent (ArrayList <Player> playerList){
Map<Player, Integer> playerMap = new HashMap<>(); Map<Player, Integer> playerMap = new HashMap<>();
@@ -56,6 +86,13 @@ public class ShamanicRitual extends EventCard {
} }
} }
/**
* Creates and returns a copy of this ShamanicRitual card.
*
* @return a new ShamanicRitual card with the same era and prestige values
*/
@Override @Override
public EventCard clone() { public EventCard clone() {
return new ShamanicRitual(getEra(), prestigeToAdd, prestigeToRemove); return new ShamanicRitual(getEra(), prestigeToAdd, prestigeToRemove);