Files
Progetto-ingegneria-del-sof…/deliverables/Coverage/htmReport/ns-9/sources/source-1.html
T
2026-06-19 22:57:43 +02:00

250 lines
8.6 KiB
HTML

<!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">
(6/6)
</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">
(22/22)
</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.BuildingCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
&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;
&nbsp;/**
&nbsp; * Represents a Cave Paintings event card.
&nbsp; *
&nbsp; * &lt;p&gt;This class defines the specific behavior of the Cave Paintings event.
&nbsp; */
&nbsp;public class CavePaintings extends EventCard {
&nbsp;
&nbsp; /**
&nbsp; * The minimum number of Artist cards required to avoid the prestige penalty.
&nbsp; * Also, the bottom number on the card.
&nbsp; */
&nbsp; private final int nLower;
&nbsp;
&nbsp; /**
&nbsp; * The amount of Prestige removed if the player has fewer Artist cards than {@code nLower}.
&nbsp; */
&nbsp; private final int nPrestigeRem;
&nbsp;
&nbsp; /**
&nbsp; * The Prestige multiplier applied if the player has at least {@code nLower} Artist cards.
&nbsp; */
&nbsp; private final int nPrestigeMul;
&nbsp;
&nbsp; /**
&nbsp; * Creates a CavePaintings event card with the specified era and effect parameters.
&nbsp; *
&nbsp; * @param Era the era of the event card.
&nbsp; * @param nLower the minimum number of Artist cards required to avoid the prestige penalty.
&nbsp; * @param nPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code nLower}.
&nbsp; * @param nPrestigeMul the Prestige multiplier applied if the player has at least {@code nLower} Artist cards.
&nbsp; */
&nbsp; public CavePaintings(int Era, int nLower, int nPrestigeRem, int nPrestigeMul) {
<b class="fc">&nbsp; super(Era, EventType.CAVE_PAINTINGS);</b>
<b class="fc">&nbsp; this.nLower = nLower;</b>
<b class="fc">&nbsp; this.nPrestigeRem = nPrestigeRem;</b>
<b class="fc">&nbsp; this.nPrestigeMul = nPrestigeMul;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates a CavePaintings event card with the specified image id, era and effect parameters.
&nbsp; *
&nbsp; * @param idIMG the image identifier of the CavePaintings event card.
&nbsp; * @param Era the era of the event card.
&nbsp; * @param nLower the minimum number of Artist cards required to avoid the prestige penalty.
&nbsp; * @param nPrestigeRem the amount of Prestige removed if the player has fewer Artist cards than {@code nLower}.
&nbsp; * @param nPrestigeMul the Prestige multiplier applied if the player has at least {@code nLower} Artist cards.
&nbsp; */
&nbsp; public CavePaintings(String idIMG,int Era, int nLower, int nPrestigeRem, int nPrestigeMul) {
<b class="fc">&nbsp; super(idIMG,Era, EventType.CAVE_PAINTINGS);</b>
<b class="fc">&nbsp; this.nLower = nLower;</b>
<b class="fc">&nbsp; this.nPrestigeRem = nPrestigeRem;</b>
<b class="fc">&nbsp; this.nPrestigeMul = nPrestigeMul;</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Activates the CavePaintings event for the specified list of players.
&nbsp; * For each player, the number of Artist cards is computed together with the number
&nbsp; * of owned building cards having effect id equal to 9.
&nbsp; * The player gains Food equal to the number of such buildings multiplied by the number of Artist cards.
&nbsp; * If the player has fewer Artist cards than {@code nLower}, the player loses {@code nPrestigeRem} Prestige.
&nbsp; * Otherwise, the player gains Prestige equal to {@code nPrestigeMul} multiplied by the number of Artist cards.
&nbsp; *
&nbsp; * @param playerList the list of players affected by the event.
&nbsp; */
&nbsp; @Override
&nbsp; public void activateEvent (ArrayList &lt;Player&gt; playerList){
<b class="fc">&nbsp; for (Player player : playerList){</b>
<b class="fc">&nbsp; int nArtists = player.getNType(CharacterType.ARTIST);</b>
<b class="fc">&nbsp; int nBuildings = 0;</b>
<b class="fc">&nbsp; ArrayList&lt;BuildingCard&gt; buildingCards = player.getBuildingCards();</b>
&nbsp;
<b class="fc">&nbsp; for(BuildingCard card : buildingCards){</b>
<b class="fc">&nbsp; if(card.getEffectId() == 9){</b>
<b class="fc">&nbsp; nBuildings++;</b>
&nbsp; }
&nbsp; }
<b class="fc">&nbsp; player.addFood(nBuildings * nArtists);</b>
<b class="fc">&nbsp; if (nArtists &lt; nLower){</b>
<b class="fc">&nbsp; player.removePrestige(nPrestigeRem);</b>
&nbsp; }
&nbsp; else{
<b class="fc">&nbsp; player.addPrestige(nPrestigeMul * nArtists);</b>
&nbsp; }
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates and returns a copy of this CavePaintings event card.
&nbsp; *
&nbsp; * @return a clone of this CavePaintings event card.
&nbsp; */
&nbsp; @Override
&nbsp; public EventCard clone()
&nbsp; {
<b class="fc">&nbsp; return new CavePaintings(getIdIMG(),getEra(), nLower, nPrestigeRem, nPrestigeMul) ;</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;NOTE: {@code NUpper} is not a real attribute used in calculations (only {@code nLower} is needed),
&nbsp; * however it&#39;s a parameter on the cards&#39; design.
&nbsp; * &lt;/p&gt;
&nbsp; * &lt;p&gt;Includes:
&nbsp; * &lt;li&gt;{@link #nLower}
&nbsp; * &lt;li&gt;{@code NUpper}
&nbsp; * &lt;li&gt;{@link #nPrestigeRem}
&nbsp; * &lt;li&gt;{@link #nPrestigeMul}
&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;CAVE_PAINTINGS&quot;;</b>
&nbsp; }
&nbsp;
&nbsp; @Override
&nbsp; public String toStringBoard() {
<b class="fc">&nbsp; return &quot;\033[38;5;180mCAVE_PAINTINGS 0-&quot; + (nLower-1) + &quot;:&quot; + nPrestigeRem + &quot; &quot; + nLower + &quot;+:&quot; + nPrestigeMul + &quot;\033[0m&quot;;</b>
&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>