Files
2026-06-19 22:57:43 +02:00

269 lines
9.4 KiB
HTML

<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > ShamanicRitual</title>
<style type="text/css">
@import "../../css/coverage.css";
@import "../../css/idea.min.css";
</style>
<script type="text/javascript" src="../../js/highlight.min.js"></script>
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>
<body>
<div class="content">
<div class="breadCrumbs">
Current scope: <a href="../../index.html">all classes</a>
<span class="separator">|</span>
<a href="../index.html">it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events</a>
</div>
<h1>Coverage Summary for Class: ShamanicRitual (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
<th class="coverageStat
">
Class, %
</th>
<th class="coverageStat
">
Method, %
</th>
<th class="coverageStat
">
Branch, %
</th>
<th class="coverageStat
">
Line, %
</th>
</tr>
<tr>
<td class="name">ShamanicRitual</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(8/8)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(24/24)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(29/29)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Player;
&nbsp;import java.util.ArrayList;
&nbsp;import java.util.HashMap;
&nbsp;import java.util.List;
&nbsp;import java.util.Map;
&nbsp;
&nbsp;/**
&nbsp; * When activated, rewards the player with the most shaman icons and penalizes the one with the fewest.
&nbsp; *
&nbsp; * @see EventCard
&nbsp; */
&nbsp;public class ShamanicRitual extends EventCard {
&nbsp; /** Bonus shaman icons granted per Building 5 owned during this event. */
&nbsp; private static final int BUILDING5_BONUS_ICONS = 3;
&nbsp;
&nbsp; /** Prestige points awarded to the player with the most shaman icons. */
&nbsp; private final int prestigeToAdd;
&nbsp;
&nbsp; /**
&nbsp; * Returns the prestige points awarded to the player with the most shaman icons.
&nbsp; *
&nbsp; * @return prestige points to award.
&nbsp; */
<b class="fc">&nbsp; int getPrestigeToAdd() { return prestigeToAdd; }</b>
&nbsp;
&nbsp; /** Prestige points removed from the player with the fewest shaman icons. */
&nbsp; private final int prestigeToRemove;
&nbsp;
&nbsp; /**
&nbsp; * Returns the prestige points removed from the player with the fewest shaman icons.
&nbsp; *
&nbsp; * @return prestige points to remove.
&nbsp; */
<b class="fc">&nbsp; int getPrestigeToRemove() { return prestigeToRemove; }</b>
&nbsp;
&nbsp; /**
&nbsp; * Creates a new ShamanicRitual event card.
&nbsp; *
&nbsp; * @param Era the era of the card
&nbsp; * @param prestigeToAdd prestige points awarded to the player with the most icons
&nbsp; * @param prestigeToRemove prestige points removed from the player with the fewest icons
&nbsp; */
&nbsp; public ShamanicRitual(int Era, int prestigeToAdd, int prestigeToRemove) {
<b class="fc">&nbsp; super(Era, EventType.SHAMANIC_RITUAL);</b>
<b class="fc">&nbsp; this.prestigeToAdd = prestigeToAdd;</b>
<b class="fc">&nbsp; this.prestigeToRemove = prestigeToRemove;</b>
&nbsp;
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a new ShamanicRitual event card.
&nbsp; *
&nbsp; * @param idIMG the image identifier of the ShamanicRitual event card.
&nbsp; * @param Era the era of the card.
&nbsp; * @param prestigeToAdd prestige points awarded to the player with the most icons.
&nbsp; * @param prestigeToRemove prestige points removed from the player with the fewest icons.
&nbsp; */
&nbsp; public ShamanicRitual(String idIMG,int Era, int prestigeToAdd, int prestigeToRemove) {
<b class="fc">&nbsp; super(idIMG,Era, EventType.SHAMANIC_RITUAL);</b>
<b class="fc">&nbsp; this.prestigeToAdd = prestigeToAdd;</b>
<b class="fc">&nbsp; this.prestigeToRemove = prestigeToRemove;</b>
&nbsp;
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Activates the event card &quot;Shamanic Ritual&quot;.
&nbsp; * The player with the most icons gains the Prestige Points indicated.
&nbsp; * The player with the fewest icons loses the Prestige Points indicated.
&nbsp; * In case of a tie, all players gain or lose the Prestige Points indicated.
&nbsp; * If all players have the same amount of icons, they all gain and lose Prestige Points.
&nbsp; * Buildings influence:
&nbsp; * Building 2: if you have the lowest number of icons, you don&#39;t lose Prestige Points
&nbsp; * Building 5: during the Shamanic Ritual, you gain 3 icons
&nbsp; * Building 6: if you have more icons than any other player, you gain double of Prestige Points
&nbsp; *
&nbsp; * @param playerList contains all the players in the game
&nbsp; */
&nbsp; @Override
&nbsp; public void activateEvent (ArrayList &lt;Player&gt; playerList){
<b class="fc">&nbsp; Map&lt;Player, Integer&gt; playerMap = new HashMap&lt;&gt;();</b>
&nbsp; int tmpIcons;
&nbsp; int tmpCount;
&nbsp;
<b class="fc">&nbsp; for (Player player : playerList) {</b>
<b class="fc">&nbsp; tmpIcons = player.getShamans().stream().mapToInt(sh -&gt; sh.getIcon()).sum();</b>
<b class="fc">&nbsp; tmpCount = (int) player.getBuildingCards().stream().filter(b -&gt; b.getEffectId() == 5).count();</b>
<b class="fc">&nbsp; if (tmpCount &gt;= 1) {</b>
<b class="fc">&nbsp; tmpIcons = tmpIcons+(BUILDING5_BONUS_ICONS *tmpCount);</b>
&nbsp; }
<b class="fc">&nbsp; playerMap.put(player, tmpIcons);</b>
&nbsp; }
&nbsp;
<b class="fc">&nbsp; int maxIcon = playerMap.values().stream().mapToInt(Integer::intValue).max().orElse(0);</b>
<b class="fc">&nbsp; int minIcon = playerMap.values().stream().mapToInt(Integer::intValue).min().orElse(0);</b>
&nbsp;
<b class="fc">&nbsp; List&lt;Player&gt; maxIconsPlayer = playerMap.entrySet().stream().filter(e -&gt; e.getValue() == maxIcon).map(Map.Entry::getKey).toList();</b>
<b class="fc">&nbsp; List&lt;Player&gt; minIconsPlayer = playerMap.entrySet().stream().filter(e -&gt; e.getValue() == minIcon).map(Map.Entry::getKey).toList();</b>
&nbsp;
&nbsp;
<b class="fc">&nbsp; for (Player player : maxIconsPlayer) {</b>
<b class="fc">&nbsp; if (player.getBuildingCards().stream().anyMatch(b -&gt; b.getEffectId() == 6) &amp;&amp; maxIconsPlayer.size() == 1) {</b>
<b class="fc">&nbsp; player.addPrestige(prestigeToAdd * 2);</b>
&nbsp; } else {
<b class="fc">&nbsp; player.addPrestige(prestigeToAdd);</b>
&nbsp; }
&nbsp; }
&nbsp;
<b class="fc">&nbsp; for (Player player : minIconsPlayer) {</b>
<b class="fc">&nbsp; if (player.getBuildingCards().stream().noneMatch(b -&gt; b.getEffectId() == 2)) {</b>
<b class="fc">&nbsp; player.removePrestige(prestigeToRemove);</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates and returns a copy of this ShamanicRitual card.
&nbsp; *
&nbsp; * @return a new ShamanicRitual card with the same era and prestige values
&nbsp; */
&nbsp; @Override
&nbsp; public EventCard clone() {
<b class="fc">&nbsp; return new ShamanicRitual(getIdIMG(),getEra(), prestigeToAdd, prestigeToRemove);</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}&#39;s
&nbsp; * toString to print a more detailed version.
&nbsp; * &lt;p&gt;Includes:
&nbsp; * &lt;li&gt;{@link #prestigeToAdd}
&nbsp; * &lt;li&gt;{@link #prestigeToRemove}
&nbsp; * &lt;/p&gt;
&nbsp; * @return {@code String} - a string representation of this {@code TribeCard}.
&nbsp; * @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
&nbsp; * @see it.polimi.ingsw.gc14.Model.Game Game
&nbsp; * @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
&nbsp; */
&nbsp; @Override
&nbsp; public String toStringPlayer() {
<b class="fc">&nbsp; return &quot;SHAMANIC_RITUAL&quot;;</b>
&nbsp; }
&nbsp;
&nbsp; @Override
&nbsp; public String toStringBoard() {
<b class="fc">&nbsp; return &quot;\033[38;5;180mSHAMANIC_RITUAL \uD83C\uDF1F&gt;:&quot; + prestigeToAdd + &quot; \uD83C\uDF1F&lt;:&quot; + prestigeToRemove + &quot;\033[0m&quot;;</b>
&nbsp; }
&nbsp;
&nbsp;}
</code>
</pre>
</div>
<script type="text/javascript">
(function() {
var msie = false, msie9 = false;
/*@cc_on
msie = true;
@if (@_jscript_version >= 9)
msie9 = true;
@end
@*/
if (!msie || msie && msie9) {
hljs.highlightAll()
hljs.initLineNumbersOnLoad();
}
})();
</script>
<div class="footer">
<div style="float:right;">generated on 2026-06-19 22:53</div>
</div>
</body>
</html>