248 lines
8.6 KiB
HTML
248 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">
|
|
(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>
|