269 lines
9.4 KiB
HTML
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"> package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events;
|
|
|
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
|
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventCard;
|
|
import it.polimi.ingsw.gc14.Model.Player;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* When activated, rewards the player with the most shaman icons and penalizes the one with the fewest.
|
|
*
|
|
* @see EventCard
|
|
*/
|
|
public class ShamanicRitual extends EventCard {
|
|
/** Bonus shaman icons granted per Building 5 owned during this event. */
|
|
private static final int BUILDING5_BONUS_ICONS = 3;
|
|
|
|
/** Prestige points awarded to the player with the most shaman icons. */
|
|
private final int prestigeToAdd;
|
|
|
|
/**
|
|
* Returns the prestige points awarded to the player with the most shaman icons.
|
|
*
|
|
* @return prestige points to award.
|
|
*/
|
|
<b class="fc"> int getPrestigeToAdd() { return prestigeToAdd; }</b>
|
|
|
|
/** Prestige points removed from the player with the fewest shaman icons. */
|
|
private final int prestigeToRemove;
|
|
|
|
/**
|
|
* Returns the prestige points removed from the player with the fewest shaman icons.
|
|
*
|
|
* @return prestige points to remove.
|
|
*/
|
|
<b class="fc"> int getPrestigeToRemove() { return prestigeToRemove; }</b>
|
|
|
|
/**
|
|
* 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) {
|
|
<b class="fc"> super(Era, EventType.SHAMANIC_RITUAL);</b>
|
|
<b class="fc"> this.prestigeToAdd = prestigeToAdd;</b>
|
|
<b class="fc"> this.prestigeToRemove = prestigeToRemove;</b>
|
|
|
|
}
|
|
|
|
/**
|
|
* Creates a new ShamanicRitual event card.
|
|
*
|
|
* @param idIMG the image identifier of the 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(String idIMG,int Era, int prestigeToAdd, int prestigeToRemove) {
|
|
<b class="fc"> super(idIMG,Era, EventType.SHAMANIC_RITUAL);</b>
|
|
<b class="fc"> this.prestigeToAdd = prestigeToAdd;</b>
|
|
<b class="fc"> this.prestigeToRemove = prestigeToRemove;</b>
|
|
|
|
}
|
|
|
|
/**
|
|
* 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 players gain or lose the Prestige Points indicated.
|
|
* If all players have the same amount of icons, they all gain and lose Prestige Points.
|
|
* Buildings influence:
|
|
* Building 2: if you have the lowest number of icons, 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
|
|
public void activateEvent (ArrayList <Player> playerList){
|
|
<b class="fc"> Map<Player, Integer> playerMap = new HashMap<>();</b>
|
|
int tmpIcons;
|
|
int tmpCount;
|
|
|
|
<b class="fc"> for (Player player : playerList) {</b>
|
|
<b class="fc"> tmpIcons = player.getShamans().stream().mapToInt(sh -> sh.getIcon()).sum();</b>
|
|
<b class="fc"> tmpCount = (int) player.getBuildingCards().stream().filter(b -> b.getEffectId() == 5).count();</b>
|
|
<b class="fc"> if (tmpCount >= 1) {</b>
|
|
<b class="fc"> tmpIcons = tmpIcons+(BUILDING5_BONUS_ICONS *tmpCount);</b>
|
|
}
|
|
<b class="fc"> playerMap.put(player, tmpIcons);</b>
|
|
}
|
|
|
|
<b class="fc"> int maxIcon = playerMap.values().stream().mapToInt(Integer::intValue).max().orElse(0);</b>
|
|
<b class="fc"> int minIcon = playerMap.values().stream().mapToInt(Integer::intValue).min().orElse(0);</b>
|
|
|
|
<b class="fc"> List<Player> maxIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == maxIcon).map(Map.Entry::getKey).toList();</b>
|
|
<b class="fc"> List<Player> minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).toList();</b>
|
|
|
|
|
|
<b class="fc"> for (Player player : maxIconsPlayer) {</b>
|
|
<b class="fc"> if (player.getBuildingCards().stream().anyMatch(b -> b.getEffectId() == 6) && maxIconsPlayer.size() == 1) {</b>
|
|
<b class="fc"> player.addPrestige(prestigeToAdd * 2);</b>
|
|
} else {
|
|
<b class="fc"> player.addPrestige(prestigeToAdd);</b>
|
|
}
|
|
}
|
|
|
|
<b class="fc"> for (Player player : minIconsPlayer) {</b>
|
|
<b class="fc"> if (player.getBuildingCards().stream().noneMatch(b -> b.getEffectId() == 2)) {</b>
|
|
<b class="fc"> player.removePrestige(prestigeToRemove);</b>
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Creates and returns a copy of this ShamanicRitual card.
|
|
*
|
|
* @return a new ShamanicRitual card with the same era and prestige values
|
|
*/
|
|
@Override
|
|
public EventCard clone() {
|
|
<b class="fc"> return new ShamanicRitual(getIdIMG(),getEra(), prestigeToAdd, prestigeToRemove);</b>
|
|
}
|
|
|
|
/**
|
|
* Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
|
|
* toString to print a more detailed version.
|
|
* <p>Includes:
|
|
* <li>{@link #prestigeToAdd}
|
|
* <li>{@link #prestigeToRemove}
|
|
* </p>
|
|
* @return {@code String} - a string representation of this {@code TribeCard}.
|
|
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
|
|
* @see it.polimi.ingsw.gc14.Model.Game Game
|
|
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
|
*/
|
|
@Override
|
|
public String toStringPlayer() {
|
|
<b class="fc"> return "SHAMANIC_RITUAL";</b>
|
|
}
|
|
|
|
@Override
|
|
public String toStringBoard() {
|
|
<b class="fc"> return "\033[38;5;180mSHAMANIC_RITUAL \uD83C\uDF1F>:" + prestigeToAdd + " \uD83C\uDF1F<:" + prestigeToRemove + "\033[0m";</b>
|
|
}
|
|
|
|
}
|
|
</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>
|