Add: Added Coverage Screenshots And htlmReport.
This commit is contained in:
@@ -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