219 lines
6.6 KiB
HTML
219 lines
6.6 KiB
HTML
|
|
|
|
|
|
<!DOCTYPE html>
|
|
<html id="htmlId">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
|
<title>Coverage Report > Order4</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.Orders</a>
|
|
</div>
|
|
|
|
<h1>Coverage Summary for Class: Order4 (it.polimi.ingsw.gc14.Model.Orders)</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">Order4</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">
|
|
(3/3)
|
|
</span>
|
|
</td>
|
|
<td class="coverageStat">
|
|
<span class="percent">
|
|
90%
|
|
</span>
|
|
<span class="absValue">
|
|
(18/20)
|
|
</span>
|
|
</td>
|
|
<td class="coverageStat">
|
|
<span class="percent">
|
|
96.6%
|
|
</span>
|
|
<span class="absValue">
|
|
(28/29)
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<br/>
|
|
<br/>
|
|
|
|
|
|
<pre>
|
|
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Model.Orders;
|
|
|
|
import it.polimi.ingsw.gc14.Model.OrderLogicCard;
|
|
import it.polimi.ingsw.gc14.Model.Player;
|
|
import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
|
|
import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.NoSuchElementException;
|
|
|
|
/**
|
|
* Represents the order logic card used in a four-player game.
|
|
*
|
|
* <p>This class defines the specific turn-order behavior for games with
|
|
* four players.
|
|
*/
|
|
public class Order4 extends OrderLogicCard {
|
|
|
|
/**
|
|
* Creates an Order4 logic card for a four-player game.
|
|
*
|
|
* @param players the list of players associated with this order card.
|
|
* @throws NoSuchElementException if the number of players is not equal to 4.
|
|
*/
|
|
public Order4(ArrayList<Player> players)throws NoSuchElementException {
|
|
<b class="fc"> super(players);</b>
|
|
<b class="fc"> if(players.size()!=4)</b>
|
|
<b class="fc"> throw new NoSuchElementException();</b>
|
|
}
|
|
|
|
/**
|
|
* Applies the effect associated with the specified position index for the given player.
|
|
* <p>If {@code index == 0}, the player gains 2 Food and the building effect is applied.
|
|
* <p>If {@code index == 1}, the player gains 1 Food and the building effect is applied.
|
|
* <p>If {@code index == 2}, no effect is applied.
|
|
* <p>If {@code index == 3}, the player tries to remove 1 Food; if the player cannot pay it,
|
|
* the player loses 2 Prestige.
|
|
*
|
|
* @param player the player to whom the effect is applied.
|
|
* @param index the position index of the effect to apply.
|
|
* @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >= 4}.
|
|
*/
|
|
@Override
|
|
protected void effect(Player player,int index) throws IndexOutOfBoundsException
|
|
{
|
|
<b class="pc"> if(index>=4 || index < 0)</b>
|
|
{
|
|
<b class="fc"> throw new IndexOutOfBoundsException("index out of bounds");</b>
|
|
}
|
|
<b class="fc"> if(index==0)</b>
|
|
{
|
|
<b class="fc"> player.addFood(2);</b>
|
|
<b class="fc"> buildingEffect(player);</b>
|
|
return;
|
|
}
|
|
<b class="fc"> if(index==1)</b>
|
|
{
|
|
<b class="fc"> player.addFood(1);</b>
|
|
<b class="fc"> buildingEffect(player);</b>
|
|
return;
|
|
}
|
|
<b class="fc"> if(index==3){</b>
|
|
<b class="fc"> if(!player.removeFood(1)){</b>
|
|
<b class="fc"> player.removePrestige(2);</b>
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Creates the TURN ORDER box of the TUI.
|
|
* @return the string containing the box
|
|
*/
|
|
@Override
|
|
public String toString()
|
|
{
|
|
|
|
<b class="fc"> var table = new AsciiTable(BorderStyle.ROUNDED, 4);</b>
|
|
<b class="fc"> List<String> stringUp=new ArrayList<>();</b>
|
|
<b class="fc"> for(int i=0;i<4;i++)</b>
|
|
{
|
|
try {
|
|
<b class="fc"> if(playerList.get(i).isPlayed())</b>
|
|
<b class="fc"> stringUp.add("");</b>
|
|
else
|
|
<b class="pc"> stringUp.add(i + ". " + (playerList.get(i).getPlayer().getTotem() != null ? playerList.get(i).getPlayer().getTotem().toString() : playerList.get(i).getPlayer().getUserName()));</b>
|
|
}
|
|
catch (IndexOutOfBoundsException e) {
|
|
<b class="nc"> stringUp.add("");</b>
|
|
}
|
|
}
|
|
<b class="fc"> table.addRow(stringUp);</b>
|
|
|
|
<b class="fc"> List<String> stringList=new ArrayList<>();</b>
|
|
<b class="fc"> stringList.add("+2\uD83C\uDF56");</b>
|
|
<b class="fc"> stringList.add("+1\uD83C\uDF56");</b>
|
|
<b class="fc"> stringList.add("--");</b>
|
|
<b class="fc"> stringList.add("-1\uD83C\uDF56/-2\uD83C\uDFC5");</b>
|
|
<b class="fc"> table.addRow(stringList);</b>
|
|
<b class="fc"> return table.build() + "\n";</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>
|