Add: Added Coverage Screenshots And htlmReport.
This commit is contained in:
@@ -0,0 +1,247 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > CavePaintings</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: CavePaintings (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">CavePaintings</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">
|
||||
(5/5)
|
||||
</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">
|
||||
(21/21)
|
||||
</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.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
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.Characters.Artist;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Represents a Cave Paintings event card.
|
||||
*
|
||||
* <p>This class defines the specific behavior of the Cave Paintings event.
|
||||
*/
|
||||
public class CavePaintings extends EventCard {
|
||||
|
||||
/**
|
||||
* The minimum number of Artist cards required to avoid the prestige penalty.
|
||||
* Also, the bottom number on the card.
|
||||
*/
|
||||
private int nLower;
|
||||
|
||||
/**
|
||||
* The amount of Prestige removed if the player has fewer Artist cards than {@code nLower}.
|
||||
*/
|
||||
private int nPrestigeRem; // NPrestigeLower
|
||||
|
||||
/**
|
||||
* The Prestige multiplier applied if the player has at least {@code nLower} Artist cards.
|
||||
*/
|
||||
private int nPrestigeMul; // NPrestigeUpper
|
||||
|
||||
/**
|
||||
* Creates a CavePaintings event card with the specified era and effect parameters.
|
||||
*
|
||||
* @param Era the era of the event card.
|
||||
* @param nLower the minimum number of Artist cards required to avoid the prestige penalty.
|
||||
* @param nPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code nLower}.
|
||||
* @param nPrestigeMul the Prestige multiplier applied if the player has at least {@code nLower} Artist cards.
|
||||
*/
|
||||
public CavePaintings(int Era, int nLower, int nPrestigeRem, int nPrestigeMul) {
|
||||
<b class="fc"> super(Era, EventType.CAVE_PAINTINGS);</b>
|
||||
<b class="fc"> this.nLower = nLower;</b>
|
||||
<b class="fc"> this.nPrestigeRem = nPrestigeRem;</b>
|
||||
<b class="fc"> this.nPrestigeMul = nPrestigeMul;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a CavePaintings event card with the specified image id, era and effect parameters.
|
||||
*
|
||||
* @param idIMG the image identifier of the CavePaintings event card.
|
||||
* @param Era the era of the event card.
|
||||
* @param nLower the minimum number of Artist cards required to avoid the prestige penalty.
|
||||
* @param nPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code nLower}.
|
||||
* @param nPrestigeMul the Prestige multiplier applied if the player has at least {@code nLower} Artist cards.
|
||||
*/
|
||||
public CavePaintings(String idIMG,int Era, int nLower, int nPrestigeRem, int nPrestigeMul) {
|
||||
<b class="fc"> super(idIMG,Era, EventType.CAVE_PAINTINGS);</b>
|
||||
<b class="fc"> this.nLower = nLower;</b>
|
||||
<b class="fc"> this.nPrestigeRem = nPrestigeRem;</b>
|
||||
<b class="fc"> this.nPrestigeMul = nPrestigeMul;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates the CavePaintings event for the specified list of players.
|
||||
* For each player, the number of Artist cards is computed together with the number
|
||||
* of owned building cards having effect id equal to 9.
|
||||
* The player gains Food equal to the number of such buildings multiplied by the number of Artist cards.
|
||||
* If the player has fewer Artist cards than {@code nLower}, the player loses {@code nPrestigeRem} Prestige.
|
||||
* Otherwise, the player gains Prestige equal to {@code nPrestigeMul} multiplied by the number of Artist cards.
|
||||
*
|
||||
* @param playerList the list of players affected by the event.
|
||||
*/
|
||||
@Override
|
||||
public void activateEvent (ArrayList <Player> playerList){
|
||||
<b class="fc"> for (Player player : playerList){</b>
|
||||
<b class="fc"> int nArtists = player.getNType(CharacterType.ARTIST);</b>
|
||||
<b class="fc"> int nBuildings = 0;</b>
|
||||
<b class="fc"> ArrayList<BuildingCard> buildingCards = player.getBuildingCards();</b>
|
||||
|
||||
<b class="fc"> for(BuildingCard card : buildingCards){</b>
|
||||
<b class="fc"> if(card.getEffectId() == 9){</b>
|
||||
<b class="fc"> nBuildings++;</b>
|
||||
}
|
||||
}
|
||||
<b class="fc"> player.addFood(nBuildings * nArtists);</b>
|
||||
<b class="fc"> if (nArtists < nLower){</b>
|
||||
<b class="fc"> player.removePrestige(nPrestigeRem);</b>
|
||||
}
|
||||
else{
|
||||
<b class="fc"> player.addPrestige(nPrestigeMul * nArtists);</b>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a copy of this CavePaintings event card.
|
||||
*
|
||||
* @return a clone of this CavePaintings event card.
|
||||
*/
|
||||
@Override
|
||||
public EventCard clone()
|
||||
{
|
||||
<b class="fc"> return new CavePaintings(getIdIMG(),getEra(), nLower, nPrestigeRem, nPrestigeMul) ;</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>NOTE: {@code NUpper} is not a real attribute used in calculations (only {@code nLower} is needed),
|
||||
* however it's a parameter on the cards' design.
|
||||
* </p>
|
||||
* <p>Includes:
|
||||
* <li>{@link #nLower}
|
||||
* <li>{@code NUpper}
|
||||
* <li>{@link #nPrestigeRem}
|
||||
* <li>{@link #nPrestigeMul}
|
||||
* </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 toStringBoard() {
|
||||
<b class="fc"> return super.toStringBoard()+" 0-"+(nLower-1)+":"+nPrestigeRem+" "+nLower+"+:"+nPrestigeMul;</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-14 21:53</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,219 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > Hunt</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: Hunt (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">Hunt</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">
|
||||
(6/6)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(6/6)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(18/18)
|
||||
</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.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||
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;
|
||||
|
||||
/**
|
||||
* When activated, gives Food and Prestige Points to every player.
|
||||
*
|
||||
* @see EventCard
|
||||
*/
|
||||
public class Hunt extends EventCard {
|
||||
/** Base food units granted per Hunter. Always 1; increased by Building 7. */
|
||||
private static final int BASE_FOOD_PER_HUNTER = 1;
|
||||
|
||||
/** Prestige Points multiplier used during the event. */
|
||||
private int prestigeMultiplier;
|
||||
|
||||
<b class="fc"> int getPrestigeMultiplier() { return prestigeMultiplier; }</b>
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
<b class="fc"> super(Era, EventType.HUNT);</b>
|
||||
<b class="fc"> this.prestigeMultiplier = prestigeMultiplier;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Hunt event card.
|
||||
*
|
||||
* @param idIMG the image identifier of the Hunt event card.
|
||||
* @param Era the era of the card.
|
||||
* @param prestigeMultiplier the prestige points multiplier used during the event.
|
||||
*/
|
||||
public Hunt(String idIMG, int Era, int prestigeMultiplier) {
|
||||
<b class="fc"> super(idIMG, Era, EventType.HUNT);</b>
|
||||
<b class="fc"> this.prestigeMultiplier = prestigeMultiplier;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates the event card "Hunt".
|
||||
* Each player gains Food and Prestige Points for each Hunter in their tribe,
|
||||
* multiplied by the respective multipliers (base food per hunter is 1).
|
||||
* Buildings influence:
|
||||
* Building 7: adds 1 to both the food and prestige multiplier for each copy owned.
|
||||
*
|
||||
* @param playerList the list of all players in the game.
|
||||
*/
|
||||
@Override
|
||||
public void activateEvent (ArrayList <Player> playerList){
|
||||
<b class="fc"> for (Player player : playerList) {</b>
|
||||
<b class="fc"> int tmpFoodMultiplier = BASE_FOOD_PER_HUNTER;</b>
|
||||
<b class="fc"> int tmpPrestigeMultiplier = prestigeMultiplier;</b>
|
||||
|
||||
<b class="fc"> ArrayList <BuildingCard> buildingList = player.getBuildingCards();</b>
|
||||
<b class="fc"> int hunterCounter=player.getNType(CharacterType.HUNTER);</b>
|
||||
|
||||
<b class="fc"> for (BuildingCard buildingCard : buildingList) {</b>
|
||||
<b class="fc"> if (buildingCard.getEffectId() == 7) {</b>
|
||||
<b class="fc"> tmpFoodMultiplier++;</b>
|
||||
<b class="fc"> tmpPrestigeMultiplier++;</b>
|
||||
}
|
||||
}
|
||||
|
||||
<b class="fc"> player.addFood(tmpFoodMultiplier * hunterCounter);</b>
|
||||
<b class="fc"> player.addPrestige(tmpPrestigeMultiplier * hunterCounter);</b>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a copy of this Hunt card.
|
||||
*
|
||||
* @return a new Hunt card with the same era and prestige multiplier
|
||||
*/
|
||||
@Override
|
||||
public EventCard clone() {
|
||||
<b class="fc"> return new Hunt(getIdIMG(),getEra(), prestigeMultiplier);</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 #prestigeMultiplier}
|
||||
* </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 toStringBoard() {
|
||||
<b class="fc"> return super.toStringBoard()+" 1\uD83C\uDF56+"+prestigeMultiplier+"\uD83C\uDFC5"+"×\uD83C\uDFF9";</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-14 21:53</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,256 @@
|
||||
|
||||
|
||||
|
||||
<!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">
|
||||
(7/7)
|
||||
</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">
|
||||
(30/30)
|
||||
</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;
|
||||
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 {
|
||||
/** 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 int prestigeToAdd;
|
||||
|
||||
// TODO
|
||||
<b class="fc"> int getPrestigeToAdd() { return prestigeToAdd; }</b>
|
||||
|
||||
/** Prestige points removed from the player with the fewest shaman icons. */
|
||||
private int prestigeToRemove;
|
||||
|
||||
// TODO
|
||||
<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>
|
||||
<b class="fc"> int tmpIcons = 0;</b>
|
||||
<b class="fc"> int tmpCount = 0;</b>
|
||||
|
||||
<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).collect(Collectors.toList());</b>
|
||||
<b class="fc"> List<Player> minIconsPlayer = playerMap.entrySet().stream().filter(e -> e.getValue() == minIcon).map(Map.Entry::getKey).collect(Collectors.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().anyMatch(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 toStringBoard() {
|
||||
<b class="fc"> return super.toStringBoard()+" \uD83C\uDF1F>:"+prestigeToAdd+" \uD83C\uDF1F<:"+prestigeToRemove;</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-14 21:53</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,242 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > Sustenance</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: Sustenance (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">Sustenance</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">
|
||||
(6/6)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(10/10)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(22/22)
|
||||
</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.Building.Effects.Building1;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Represents a Sustenance event card.
|
||||
*
|
||||
* <p>This class defines the specific behavior of the Sustenance event.
|
||||
*/
|
||||
public class Sustenance extends EventCard {
|
||||
|
||||
/** Food units covered by each Gatherer during the Sustenance event. */
|
||||
private static final int FOOD_PER_GATHERER = 3;
|
||||
|
||||
/**
|
||||
* The prestige penalty multiplier applied for each unpaid Food unit.
|
||||
*/
|
||||
private int prestigeDebt;
|
||||
|
||||
/**
|
||||
* Returns the prestige penalty multiplier associated with this Sustenance event.
|
||||
*
|
||||
* @return the prestige penalty multiplier associated with this Sustenance event.
|
||||
*/
|
||||
public int getPrestigeDebt() {
|
||||
<b class="fc"> return prestigeDebt;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Sustenance event card with the specified era and prestige debt value.
|
||||
*
|
||||
* @param Era the era of the event card.
|
||||
* @param prestigeDebt the prestige penalty multiplier for unpaid Food units.
|
||||
*/
|
||||
public Sustenance(int Era, int prestigeDebt) {
|
||||
<b class="fc"> super(Era, EventType.SUSTENANCE);</b>
|
||||
<b class="fc"> this.prestigeDebt = prestigeDebt;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Sustenance event card with the specified image id, era and prestige debt value.
|
||||
*
|
||||
* @param idIMG the image identifier of the Sustenance event card.
|
||||
* @param Era the era of the event card.
|
||||
* @param prestigeDebt the prestige penalty multiplier for unpaid Food units.
|
||||
*/
|
||||
public Sustenance(String idIMG,int Era, int prestigeDebt) {
|
||||
<b class="fc"> super(idIMG,Era, EventType.SUSTENANCE);</b>
|
||||
<b class="fc"> this.prestigeDebt = prestigeDebt;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates the Sustenance event for the specified list of players.
|
||||
* For each player, the required Food is computed from the total number of characters,
|
||||
* reduced by the contribution of Gatherers and by any applicable character discounts
|
||||
* granted by owned building cards with effect id equal to 1.
|
||||
* If the resulting Food debt is positive, the player must pay it with available Food.
|
||||
* If the player does not have enough Food, all remaining Food is removed and the player
|
||||
* loses Prestige equal to the unpaid Food debt multiplied by {@code prestigeDebt}.
|
||||
* <b>This event is intended to be executed last among event effects.</b>
|
||||
*
|
||||
* @param playerList the list of players affected by the event.
|
||||
*/
|
||||
@Override
|
||||
public void activateEvent (ArrayList <Player> playerList) {
|
||||
<b class="fc"> for(Player player : playerList){</b>
|
||||
<b class="fc"> int nChar = player.getTotCharacters();</b>
|
||||
<b class="fc"> int nGatherers = player.getNType(CharacterType.GATHERER);</b>
|
||||
|
||||
<b class="fc"> int nCharDiscount = 0;</b>
|
||||
<b class="fc"> for(BuildingCard b : player.getBuildingCards()){</b>
|
||||
<b class="fc"> if(b.getEffectId() == 1){</b>
|
||||
<b class="fc"> CharacterType c = ((Building1)b).getIcon();</b>
|
||||
<b class="fc"> nCharDiscount += player.getNType(c);</b>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
<b class="fc"> int foodDebt = nChar - (FOOD_PER_GATHERER * nGatherers + nCharDiscount);</b>
|
||||
|
||||
<b class="fc"> if(foodDebt <= 0){</b>
|
||||
continue;
|
||||
}
|
||||
<b class="fc"> if(player.getFoodValue() >= foodDebt){</b>
|
||||
<b class="fc"> player.removeFood(foodDebt);</b>
|
||||
}
|
||||
else{
|
||||
<b class="fc"> foodDebt -= player.getFoodValue();</b>
|
||||
<b class="fc"> player.removeFood(player.getFoodValue()); // player.getFoodValue() == 0</b>
|
||||
<b class="fc"> player.removePrestige(foodDebt * prestigeDebt);</b>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a copy of this Sustenance event card.
|
||||
*
|
||||
* @return a clone of this Sustenance event card.
|
||||
*/
|
||||
@Override
|
||||
public EventCard clone() {
|
||||
<b class="fc"> return new Sustenance(getIdIMG(),getEra(), prestigeDebt);</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 #prestigeDebt}
|
||||
* </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 toStringBoard() {
|
||||
<b class="fc"> return super.toStringBoard()+" -1\uD83C\uDF56/-"+prestigeDebt+"\uD83C\uDFC5";</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-14 21:53</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user