Add: Added Coverage Screenshots And htlmReport.
This commit is contained in:
@@ -0,0 +1,405 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > DecksCreator</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</a>
|
||||
</div>
|
||||
|
||||
<h1>Coverage Summary for Class: DecksCreator (it.polimi.ingsw.gc14.Model)</h1>
|
||||
|
||||
<table class="coverageStats">
|
||||
|
||||
<tr>
|
||||
<th class="name">Class</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Method, %
|
||||
</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Branch, %
|
||||
</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Line, %
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name">DecksCreator</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">
|
||||
(57/57)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
88.6%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(70/79)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name">DecksCreator$1</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">
|
||||
(1/1)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name">DecksCreator$2</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">
|
||||
(1/1)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name">DecksCreator$BuildingCardDefinition</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name">DecksCreator$TribeCardDefinition</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name"><strong>Total</strong></td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(9/9)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(57/57)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
88.9%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(72/81)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<pre>
|
||||
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Model;
|
||||
|
||||
import com.google.gson.*;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.*;
|
||||
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.Characters.*;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.CavePaintings;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Hunt;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Sustenance;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Utility class responsible for loading and creating decks of cards and slots for the game.
|
||||
* Cards are loaded from JSON resource files and instantiated according to their type and parameters.
|
||||
*/
|
||||
public class DecksCreator {
|
||||
|
||||
private DecksCreator() {}
|
||||
|
||||
/**
|
||||
* Loads the tribe card deck for the specified era from the corresponding JSON resource file.
|
||||
*
|
||||
* @param era the era number (1, 2, or 3).
|
||||
* @return a list of {@link TribeCard} objects for the specified era.
|
||||
* @throws IllegalArgumentException if {@code era} is not 1, 2, or 3.
|
||||
*/
|
||||
public static List<TribeCard> loadTribeDeckByEra(int era) throws IllegalArgumentException
|
||||
{
|
||||
<b class="fc"> return switch (era) {</b>
|
||||
<b class="fc"> case 1 -> loadTribeDeck("/Cards/tribe_era1.json");</b>
|
||||
<b class="fc"> case 2 -> loadTribeDeck("/Cards/tribe_era2.json");</b>
|
||||
<b class="fc"> case 3 -> loadTribeDeck("/Cards/tribe_era3.json");</b>
|
||||
<b class="fc"> default -> throw new IllegalArgumentException();</b>
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a tribe card deck from the specified JSON resource file path.
|
||||
*
|
||||
* @param resourcePath the path to the JSON resource file.
|
||||
* @return a list of {@link TribeCard} objects defined in the resource file.
|
||||
* @throws RuntimeException if the resource file is not found or an error occurs while reading it.
|
||||
*/
|
||||
public static List<TribeCard> loadTribeDeck(String resourcePath) {
|
||||
<b class="fc"> Gson gson = new Gson();</b>
|
||||
<b class="fc"> Type listType = new com.google.gson.reflect.TypeToken<List<TribeCardDefinition>>(){}.getType();</b>
|
||||
|
||||
<b class="fc"> InputStream is = DecksCreator.class.getResourceAsStream(resourcePath);</b>
|
||||
<b class="fc"> if (is == null) {</b>
|
||||
<b class="fc"> throw new RuntimeException("Resource file not found: " + resourcePath);</b>
|
||||
}
|
||||
|
||||
<b class="fc"> try (Reader reader = new InputStreamReader(is)) {</b>
|
||||
<b class="fc"> List<TribeCardDefinition> definitions = gson.fromJson(reader, listType);</b>
|
||||
<b class="fc"> List<TribeCard> cards = new ArrayList<>();</b>
|
||||
<b class="fc"> for (TribeCardDefinition def : definitions) {</b>
|
||||
<b class="fc"> cards.add(createCard(def));</b>
|
||||
}
|
||||
<b class="fc"> return cards;</b>
|
||||
} catch (IOException e) {
|
||||
<b class="nc"> throw new RuntimeException("Error loading deck: " + resourcePath, e);</b>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the building card deck for the specified era, filtering cards from the global building deck.
|
||||
*
|
||||
* @param era the era number (1, 2, or 3).
|
||||
* @return a list of {@link BuildingCard} objects belonging to the specified era.
|
||||
* @throws IllegalArgumentException if {@code era} is not 1, 2, or 3.
|
||||
*/
|
||||
public static List<BuildingCard> loadBuildingDeckByEra(int era) throws IllegalArgumentException
|
||||
{
|
||||
<b class="fc"> if(era<=0 || era>3) throw new IllegalArgumentException();</b>
|
||||
<b class="fc"> return loadBuildingDeck("/Cards/buildingCards.json").stream().filter(x->x.getEra()==era).toList();</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the full building card deck from the specified JSON resource file path.
|
||||
*
|
||||
* @param resourcePath the path to the JSON resource file.
|
||||
* @return a list of {@link BuildingCard} objects defined in the resource file.
|
||||
* @throws RuntimeException if the resource file is not found or an error occurs while reading it.
|
||||
*/
|
||||
public static List<BuildingCard> loadBuildingDeck(String resourcePath) {
|
||||
<b class="fc"> Gson gson = new Gson();</b>
|
||||
<b class="fc"> Type listType = new com.google.gson.reflect.TypeToken<List<BuildingCardDefinition>>(){}.getType();</b>
|
||||
|
||||
<b class="fc"> InputStream is = DecksCreator.class.getResourceAsStream(resourcePath);</b>
|
||||
<b class="fc"> if (is == null) {</b>
|
||||
<b class="fc"> throw new RuntimeException("Resource file not found: " + resourcePath);</b>
|
||||
}
|
||||
|
||||
<b class="fc"> try (Reader reader = new InputStreamReader(is)) {</b>
|
||||
<b class="fc"> List<BuildingCardDefinition> definitions = gson.fromJson(reader, listType);</b>
|
||||
<b class="fc"> List<BuildingCard> cards = new ArrayList<>();</b>
|
||||
<b class="fc"> for (BuildingCardDefinition def : definitions) {</b>
|
||||
<b class="fc"> cards.add(createCard(def));</b>
|
||||
}
|
||||
<b class="fc"> return cards;</b>
|
||||
} catch (IOException e) {
|
||||
<b class="nc"> throw new RuntimeException("Error loading deck: " + resourcePath, e);</b>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns the list of slots used as the game board.
|
||||
* Slots are labeled with the letters A through G.
|
||||
*
|
||||
* @return a list of {@link Slot} objects representing the game board.
|
||||
*/
|
||||
public static List<Slot> loadSlotDeck()
|
||||
{
|
||||
<b class="fc"> List<Slot> slots = new ArrayList<>();</b>
|
||||
<b class="fc"> char[]chars={'A','B','C','D','E','F','G'};</b>
|
||||
<b class="fc"> for(char c : chars)</b>
|
||||
<b class="fc"> slots.add(new Slot(c));</b>
|
||||
<b class="fc"> return slots;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a {@link TribeCard} from the given definition.
|
||||
* Depending on whether the card is an event or a character, the appropriate subclass is created
|
||||
* using the type and parameters specified in the definition.
|
||||
*
|
||||
* @param def the {@link TribeCardDefinition} containing the card's type, era, and parameters.
|
||||
* @return the instantiated {@link TribeCard}.
|
||||
* @throws IllegalArgumentException if the card type is unknown or the parameters are invalid.
|
||||
*/
|
||||
private static TribeCard createCard(TribeCardDefinition def) {
|
||||
<b class="fc"> int era = def.era;</b>
|
||||
<b class="fc"> int[] p = def.params.stream().mapToInt(d -> ((Double) d).intValue()).toArray();</b>
|
||||
<b class="fc"> if(def.isEvent)</b>
|
||||
{
|
||||
<b class="pc"> return switch (def.type) {</b>
|
||||
<b class="fc"> case "Sustenance" -> new Sustenance(def.id,era,p[0]);</b>
|
||||
<b class="fc"> case "Hunt" -> new Hunt(def.id,era,p[0]);</b>
|
||||
<b class="fc"> case "CavePaintings" -> new CavePaintings(def.id,era,p[0],p[1],p[2]);</b>
|
||||
<b class="fc"> case "ShamanicRitual" -> new ShamanicRitual(def.id,era,p[0],p[1]);</b>
|
||||
<b class="nc"> default -> throw new IllegalArgumentException("Unknown event type: " + def.type);</b>
|
||||
};
|
||||
}
|
||||
<b class="pc"> return switch (def.type) {</b>
|
||||
<b class="fc"> case "Hunter" -> p.length == 0</b>
|
||||
<b class="fc"> ? new Hunter(def.id,era, def.armed)</b>
|
||||
<b class="fc"> : new Hunter(def.id,era, def.armed, p[0]);</b>
|
||||
<b class="pc"> case "Builder" -> switch (p.length) {</b>
|
||||
<b class="fc"> case 2 -> new Builder(def.id,era, p[0], p[1]);</b>
|
||||
<b class="fc"> case 3 -> new Builder(def.id,era, p[0], p[1], p[2]);</b>
|
||||
<b class="nc"> default -> throw new IllegalArgumentException("Builder: invalid parameters");</b>
|
||||
};
|
||||
<b class="pc"> case "Gatherer" -> switch (p.length) {</b>
|
||||
<b class="fc"> case 0 -> new Gatherer(def.id,era);</b>
|
||||
<b class="fc"> case 1 -> new Gatherer(def.id,era, p[0]);</b>
|
||||
<b class="nc"> default -> throw new IllegalArgumentException("Gatherer: invalid parameters");</b>
|
||||
};
|
||||
<b class="pc"> case "Artist" -> switch (p.length) {</b>
|
||||
<b class="fc"> case 0 -> new Artist(def.id,era);</b>
|
||||
<b class="fc"> case 1 -> new Artist(def.id,era, p[0]);</b>
|
||||
<b class="nc"> default -> throw new IllegalArgumentException("Artist: invalid parameters");</b>
|
||||
};
|
||||
<b class="pc"> case "Inventor" -> switch (p.length) {</b>
|
||||
<b class="fc"> case 1 -> new Inventor(def.id,era, p[0]);</b>
|
||||
<b class="fc"> case 2 -> new Inventor(def.id,era, p[0], p[1]);</b>
|
||||
<b class="nc"> default -> throw new IllegalArgumentException("Inventor: invalid parameters");</b>
|
||||
};
|
||||
<b class="pc"> case "Shaman" -> switch (p.length) {</b>
|
||||
<b class="fc"> case 1 -> new Shaman(def.id,era, p[0]);</b>
|
||||
<b class="fc"> case 2 -> new Shaman(def.id,era, p[0], p[1]);</b>
|
||||
<b class="nc"> default -> throw new IllegalArgumentException("Shaman: invalid parameters");</b>
|
||||
};
|
||||
<b class="nc"> default -> throw new IllegalArgumentException("Unknown card type: " + def.type);</b>
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a {@link BuildingCard} from the given definition.
|
||||
* The appropriate subclass is selected based on the effect ID specified in the definition.
|
||||
* If no specific subclass matches the effect ID, a base {@link BuildingCard} is created.
|
||||
*
|
||||
* @param def the {@link BuildingCardDefinition} containing the card's effect ID, era, price, prestige value, and parameters.
|
||||
* @return the instantiated {@link BuildingCard}.
|
||||
*/
|
||||
private static BuildingCard createCard(BuildingCardDefinition def) {
|
||||
<b class="pc"> return switch (def.effectId) {</b>
|
||||
<b class="fc"> case 0 -> new Building0(def.id,def.era, def.price, def.prestigeValue);</b>
|
||||
<b class="fc"> case 1 -> new Building1(def.id,def.era, def.price, def.prestigeValue, CharacterType.valueOf(((String) def.params.get(0)).toUpperCase()));</b>
|
||||
<b class="fc"> case 4 -> new Building4(def.id,def.era, def.price, def.prestigeValue);</b>
|
||||
<b class="fc"> case 8 -> new Building8(def.id,def.era, def.price, def.prestigeValue);</b>
|
||||
<b class="fc"> case 10 -> new Building10(def.id,def.era, def.price, def.prestigeValue);</b>
|
||||
<b class="fc"> case 11 -> new Building11(def.id,def.era, def.price, def.prestigeValue, CharacterType.valueOf(((String) def.params.get(0)).toUpperCase()), ((Double) def.params.get(1)).intValue());</b>
|
||||
<b class="fc"> case 13 -> new Building13(def.id,def.era, def.price, def.prestigeValue);</b>
|
||||
<b class="fc"> default -> new BuildingCard(def.id,def.effectId, def.era, def.price, def.prestigeValue);</b>
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal data class representing the raw definition of a tribe card as loaded from a JSON file.
|
||||
* Contains the card identifier, type, era, whether it is armed, whether it is an event card,
|
||||
* and a list of additional parameters.
|
||||
*/
|
||||
private static class TribeCardDefinition {
|
||||
String id;
|
||||
String type;
|
||||
int era;
|
||||
boolean armed;
|
||||
boolean isEvent;
|
||||
List<Object> params; // Object to support mixed boolean and numeric parameters from JSON
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal data class representing the raw definition of a building card as loaded from a JSON file.
|
||||
* Contains the card identifier, effect ID, era, price, prestige value, and a list of additional parameters.
|
||||
*/
|
||||
private static class BuildingCardDefinition {
|
||||
String id;
|
||||
int effectId;
|
||||
int era;
|
||||
int price;
|
||||
int prestigeValue;
|
||||
List<Object> params; // Object to support mixed boolean and numeric parameters from JSON
|
||||
}
|
||||
}
|
||||
</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>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,413 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > MiniModel</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</a>
|
||||
</div>
|
||||
|
||||
<h1>Coverage Summary for Class: MiniModel (it.polimi.ingsw.gc14.Model)</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">MiniModel</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
0%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(0/1)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
0%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(0/21)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
0%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(0/14)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
0%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(0/44)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<pre>
|
||||
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Model;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
import it.polimi.ingsw.gc14.Model.GamePackage.Board;
|
||||
import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
|
||||
import it.polimi.ingsw.gc14.Network.EventType;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Lightweight representation of the game model shared with clients.
|
||||
*
|
||||
* <p>The mini model contains only the information required by the client-side
|
||||
* view and controllers to render the current match state and process incoming
|
||||
* network updates.
|
||||
*/
|
||||
public class MiniModel implements Serializable {
|
||||
|
||||
/** Upper row of tribe cards currently on the board. */
|
||||
public ArrayList<TribeCard> upperListTribeCards;
|
||||
/** Lower row of tribe cards currently on the board. */
|
||||
public ArrayList<TribeCard> lowerListTribeCards;
|
||||
/** Upper row of building cards currently on the board. */
|
||||
public ArrayList<BuildingCard> upperListBuildingCards;
|
||||
/** Lower row of building cards currently on the board. */
|
||||
public ArrayList<BuildingCard> lowerListBuildingCards;
|
||||
/** Usernames of players currently disconnected from the game. */
|
||||
public ArrayList<String> disconnectedPlayers;
|
||||
/** The most recent network event applied to this model. */
|
||||
public NetworkEvent lastEvent;
|
||||
|
||||
/**
|
||||
* Map associating each occupied slot with the corresponding player.
|
||||
*/
|
||||
public Map<Slot, Player> slotPlayerMap;
|
||||
|
||||
/**
|
||||
* Card used to manage the player turn order.
|
||||
*/
|
||||
public OrderLogicCard orderLogicCard;
|
||||
|
||||
/**
|
||||
* Current state of the game.
|
||||
*/
|
||||
public CurrentState currentState;
|
||||
|
||||
/**
|
||||
* Map of players indexed by username.
|
||||
*/
|
||||
public Map<String, Player> players;
|
||||
|
||||
/**
|
||||
* List of totems still available for selection.
|
||||
*/
|
||||
public List<Totems> availableTotems;
|
||||
|
||||
/**
|
||||
* Final standing of the players at the end of the game.
|
||||
*/
|
||||
public List<Player> standingPlayers;
|
||||
|
||||
/**
|
||||
* Constructs an empty mini model.
|
||||
*/
|
||||
<b class="nc"> public MiniModel() {</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a mini model with only the card lists populated.
|
||||
*
|
||||
* @param upperListTribeCards the upper row of tribe cards on the board.
|
||||
* @param lowerListTribeCards the lower row of tribe cards on the board.
|
||||
* @param upperListBuildingCards the upper row of building cards on the board.
|
||||
* @param lowerListBuildingCards the lower row of building cards on the board.
|
||||
*/
|
||||
<b class="nc"> public MiniModel(ArrayList<TribeCard> upperListTribeCards,ArrayList<TribeCard>lowerListTribeCards,ArrayList<BuildingCard> upperListBuildingCards,ArrayList<BuildingCard>lowerListBuildingCards) {</b>
|
||||
<b class="nc"> this.upperListTribeCards = upperListTribeCards;</b>
|
||||
<b class="nc"> this.lowerListTribeCards = lowerListTribeCards;</b>
|
||||
<b class="nc"> this.upperListBuildingCards = upperListBuildingCards;</b>
|
||||
<b class="nc"> this.lowerListBuildingCards = lowerListBuildingCards;</b>
|
||||
<b class="nc"> this.disconnectedPlayers = new ArrayList<>();</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a complete mini model from the current server-side game data.
|
||||
*
|
||||
* @param slotPlayerMap the map associating occupied slots with players.
|
||||
* @param orderLogicCard the card managing player turn order.
|
||||
* @param currentState the current state of the game.
|
||||
* @param players the list of players in the match.
|
||||
* @param availableTotems the list of totems still available for selection.
|
||||
* @param upperListTribeCards the upper row of tribe cards on the board.
|
||||
* @param lowerListTribeCards the lower row of tribe cards on the board.
|
||||
* @param upperListBuildingCards the upper row of building cards on the board.
|
||||
* @param lowerListBuildingCards the lower row of building cards on the board.
|
||||
* @param disconnectedPlayers the list of usernames of currently disconnected players.
|
||||
*/
|
||||
public MiniModel(Map<Slot, Player> slotPlayerMap,
|
||||
OrderLogicCard orderLogicCard,
|
||||
CurrentState currentState,
|
||||
List<Player> players,
|
||||
<b class="nc"> List<Totems> availableTotems,ArrayList<TribeCard> upperListTribeCards,ArrayList<TribeCard>lowerListTribeCards,ArrayList<BuildingCard> upperListBuildingCards,ArrayList<BuildingCard>lowerListBuildingCards, ArrayList<String> disconnectedPlayers) {</b>
|
||||
|
||||
<b class="nc"> this.slotPlayerMap = slotPlayerMap;</b>
|
||||
<b class="nc"> this.orderLogicCard = orderLogicCard;</b>
|
||||
<b class="nc"> this.currentState = currentState;</b>
|
||||
<b class="nc"> this.players = new LinkedHashMap<>();</b>
|
||||
<b class="nc"> this.availableTotems = availableTotems;</b>
|
||||
<b class="nc"> this.standingPlayers = new ArrayList<>();</b>
|
||||
<b class="nc"> this.upperListTribeCards = upperListTribeCards;</b>
|
||||
<b class="nc"> this.lowerListTribeCards = lowerListTribeCards;</b>
|
||||
<b class="nc"> this.upperListBuildingCards = upperListBuildingCards;</b>
|
||||
<b class="nc"> this.lowerListBuildingCards = lowerListBuildingCards;</b>
|
||||
<b class="nc"> this.disconnectedPlayers = disconnectedPlayers;</b>
|
||||
<b class="nc"> setPlayers(players);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last network event applied to the game state.
|
||||
*
|
||||
* @param lastEvent the most recent event received from the server.
|
||||
*/
|
||||
public void setLastEvent(NetworkEvent lastEvent) {
|
||||
<b class="nc"> this.lastEvent = lastEvent;</b>
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the list of totems still available for selection.
|
||||
*
|
||||
* @param availableTotems the available totems.
|
||||
*/
|
||||
public void setAvailableTotems(List<Totems> availableTotems) {
|
||||
<b class="nc"> this.availableTotems = availableTotems;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the map associating occupied slots with players.
|
||||
*
|
||||
* @param slotPlayerMap the slot-player map to assign.
|
||||
*/
|
||||
public void setSlotPlayerMap(Map<Slot, Player> slotPlayerMap) {
|
||||
<b class="nc"> this.slotPlayerMap = slotPlayerMap;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the card used to manage the player turn order.
|
||||
*
|
||||
* @param orderLogicCard the order logic card to assign.
|
||||
*/
|
||||
public void setOrderLogicCard(OrderLogicCard orderLogicCard) {
|
||||
<b class="nc"> this.orderLogicCard = orderLogicCard;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current state of the game.
|
||||
*
|
||||
* @param currentState the current game state.
|
||||
*/
|
||||
public void setCurrentState(CurrentState currentState) {
|
||||
<b class="nc"> this.currentState = currentState;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces or updates the players stored in the mini model.
|
||||
*
|
||||
* <p>Each player is indexed by username.
|
||||
*
|
||||
* @param players the list of players to store.
|
||||
*/
|
||||
public void setPlayers(List<Player> players) {
|
||||
<b class="nc"> for (Player player : players) {</b>
|
||||
<b class="nc"> this.players.put(player.getUserName(), player);</b>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or updates a single player in the mini model.
|
||||
*
|
||||
* @param player the player to store.
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
<b class="nc"> players.put(player.getUserName(), player);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the final standing of the players.
|
||||
*
|
||||
* @param standingPlayers the final ordered list of players.
|
||||
*/
|
||||
public void setStandingPlayers(List<Player> standingPlayers) {
|
||||
<b class="nc"> this.standingPlayers = standingPlayers;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the upper row of tribe cards on the board.
|
||||
*
|
||||
* @param cards the new upper tribe card list.
|
||||
*/
|
||||
public void setUpperListTribeCards(ArrayList<TribeCard> cards) {
|
||||
<b class="nc"> this.upperListTribeCards = cards;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the lower row of tribe cards on the board.
|
||||
*
|
||||
* @param cards the new lower tribe card list.
|
||||
*/
|
||||
public void setLowerListTribeCards(ArrayList<TribeCard> cards) {
|
||||
<b class="nc"> this.lowerListTribeCards = cards;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the upper row of building cards on the board.
|
||||
*
|
||||
* @param cards the new upper building card list.
|
||||
*/
|
||||
public void setUpperListBuildingCards(ArrayList<BuildingCard> cards) {
|
||||
<b class="nc"> this.upperListBuildingCards = cards;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the lower row of building cards on the board.
|
||||
*
|
||||
* @param cards the new lower building card list.
|
||||
*/
|
||||
public void setLowerListBuildingCards(ArrayList<BuildingCard> cards) {
|
||||
<b class="nc"> this.lowerListBuildingCards = cards;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the card at the given position from the upper tribe card list.
|
||||
*
|
||||
* @param pos the zero-based index of the card to remove.
|
||||
*/
|
||||
public void removeUpperTribeCard(int pos) {
|
||||
<b class="nc"> if (upperListTribeCards != null) upperListTribeCards.remove(pos);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the card at the given position from the lower tribe card list.
|
||||
*
|
||||
* @param pos the zero-based index of the card to remove.
|
||||
*/
|
||||
public void removeLowerTribeCard(int pos) {
|
||||
<b class="nc"> if (lowerListTribeCards != null) lowerListTribeCards.remove(pos);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the card at the given position from the upper building card list.
|
||||
*
|
||||
* @param pos the zero-based index of the card to remove.
|
||||
*/
|
||||
public void removeUpperBuildingCard(int pos) {
|
||||
<b class="nc"> if (upperListBuildingCards != null) upperListBuildingCards.remove(pos);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the card at the given position from the lower building card list.
|
||||
*
|
||||
* @param pos the zero-based index of the card to remove.
|
||||
*/
|
||||
public void removeLowerBuildingCard(int pos) {
|
||||
<b class="nc"> if (lowerListBuildingCards != null) lowerListBuildingCards.remove(pos);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the position of the player with the specified username
|
||||
* within the player collection.
|
||||
*
|
||||
* @param username the username of the player to search for.
|
||||
* @return the zero-based position of the player, or {@code -1}
|
||||
* if no matching username is found.
|
||||
*/
|
||||
public int getPositionByUsername(String username) {
|
||||
<b class="nc"> int i = 0;</b>
|
||||
<b class="nc"> for (Player player : players.values()) {</b>
|
||||
<b class="nc"> if (player.getUserName().equals(username)) {</b>
|
||||
<b class="nc"> return i;</b>
|
||||
}
|
||||
<b class="nc"> i++;</b>
|
||||
}
|
||||
<b class="nc"> return -1;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of usernames of currently disconnected players.
|
||||
*
|
||||
* @param disconnectedPlayers the list of disconnected player usernames.
|
||||
*/
|
||||
public void setDisconnectedPlayers (ArrayList<String> disconnectedPlayers){
|
||||
<b class="nc"> this.disconnectedPlayers=disconnectedPlayers;</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,297 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > OrderLogicCard</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</a>
|
||||
</div>
|
||||
|
||||
<h1>Coverage Summary for Class: OrderLogicCard (it.polimi.ingsw.gc14.Model)</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">OrderLogicCard</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(1/1)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
80%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(8/10)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
91.7%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(11/12)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
87.1%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(27/31)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<pre>
|
||||
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Model;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Orders.OrderPlayer;
|
||||
import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
|
||||
import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Abstract base class for all order logic cards.
|
||||
*
|
||||
* <p>An order logic card manages the turn order of the players and defines
|
||||
* the behavior used to update the order during the game.
|
||||
*/
|
||||
public abstract class OrderLogicCard implements Serializable {
|
||||
|
||||
/**
|
||||
* The queue of {@link Player Players} associated with this order logic card.
|
||||
*/
|
||||
private Queue<Player> players;
|
||||
|
||||
/**
|
||||
* The list of {@link OrderPlayer} entries tracking turn order and played status.
|
||||
* Protected so subclasses can read it for display purposes (e.g., {@link #toString()}).
|
||||
*/
|
||||
protected List<OrderPlayer> playerList;
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable view of the player order list.
|
||||
*
|
||||
* @return the list of {@link OrderPlayer} entries in turn order.
|
||||
*/
|
||||
public List<OrderPlayer> getPlayerList() {
|
||||
<b class="nc"> return Collections.unmodifiableList(playerList);</b>
|
||||
}
|
||||
|
||||
/** Total number of players in this game. */
|
||||
protected final int nPlayers;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an order logic card with the specified list of players.
|
||||
*
|
||||
* <p>The input list is shuffled in place to establish a random initial turn order.
|
||||
* This is intentional: the caller's list (typically {@code Game.playersList}) is
|
||||
* reordered so that the game's canonical player sequence reflects the randomised order.
|
||||
*
|
||||
* @param players the list of players associated with this order logic card.
|
||||
* <strong>The list is mutated (shuffled) by this constructor.</strong>
|
||||
*/
|
||||
<b class="fc"> public OrderLogicCard(ArrayList<Player> players) {</b>
|
||||
<b class="fc"> Collections.shuffle(players);</b>
|
||||
<b class="fc"> this.players = new LinkedList<>(players);</b>
|
||||
<b class="fc"> nPlayers = players.size();</b>
|
||||
<b class="fc"> this.playerList = new ArrayList<>(players.stream().map(x -> new OrderPlayer(x, false)).toList());</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the effect associated with the current queue position of the player
|
||||
* and then adds the player to the end of the queue.
|
||||
*
|
||||
* @param player the player to be pushed into the queue.
|
||||
*/
|
||||
public void push(Player player) {
|
||||
<b class="fc"> effect(player, players.size());</b>
|
||||
<b class="fc"> if (players.size() == 0) {</b>
|
||||
<b class="fc"> playerList.clear();</b>
|
||||
}
|
||||
<b class="fc"> playerList.add(new OrderPlayer(player, false));</b>
|
||||
<b class="fc"> players.add(player);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the specified player to the end of the queue without applying effects.
|
||||
*
|
||||
* <p>Any previous occurrence of the player is removed from both the queue
|
||||
* and the order list before the player is added again.
|
||||
*
|
||||
* @param player the player to be pushed into the queue.
|
||||
*/
|
||||
public void pushNoEffect(Player player) {
|
||||
<b class="fc"> players.removeIf(x -> player.getUserName().equals(x.getUserName()));</b>
|
||||
<b class="fc"> playerList.removeIf(x -> player.getUserName().equals(x.getPlayer().getUserName()));</b>
|
||||
<b class="fc"> playerList.add(new OrderPlayer(player, false));</b>
|
||||
<b class="fc"> players.add(player);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes and returns the first player in the queue.
|
||||
*
|
||||
* <p>The first order entry that has not yet been marked as played
|
||||
* is marked as played before removing the player from the queue.
|
||||
*
|
||||
* @return the first player in the queue, or {@code null} if the queue is empty.
|
||||
*/
|
||||
public Player pull() {
|
||||
<b class="fc"> for (OrderPlayer p : playerList) {</b>
|
||||
<b class="fc"> if (!p.isPlayed()) {</b>
|
||||
<b class="fc"> p.markAsPlayed();</b>
|
||||
break;
|
||||
}
|
||||
}
|
||||
<b class="fc"> return players.poll();</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first player in the queue without removing it.
|
||||
*
|
||||
* @return the first player in the queue, or {@code null} if the queue is empty.
|
||||
*/
|
||||
public Player getFirst()
|
||||
{
|
||||
<b class="fc"> return players.peek();</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the effect associated with the specified player and queue position.
|
||||
*
|
||||
* @param player the player to whom the effect is applied.
|
||||
* @param index the queue position index associated with the effect.
|
||||
* @throws IndexOutOfBoundsException if the specified index is not valid.
|
||||
*/
|
||||
protected abstract void effect(Player player, int index) throws IndexOutOfBoundsException;
|
||||
|
||||
/**
|
||||
* Applies the building-related effect to the specified player.
|
||||
* For each building card owned by the player with effect id equal to 3,
|
||||
* the player gains 1 Food.
|
||||
*
|
||||
* @param player the player to whom the building effect is applied.
|
||||
*/
|
||||
protected void buildingEffect(Player player) {
|
||||
<b class="fc"> long count = player.getBuildingCards().stream().filter(x -> x.getEffectId() == 3).count();</b>
|
||||
<b class="fc"> player.addFood((int) count);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given player is currently present in the turn queue.
|
||||
*
|
||||
* @param player the player to look up.
|
||||
* @return {@code true} if the player is in the queue; {@code false} otherwise.
|
||||
*/
|
||||
public boolean containsInQueue(Player player) {
|
||||
<b class="fc"> return players.contains(player);</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given player from both the turn queue and the order list.
|
||||
* No-op if the player is not present.
|
||||
*
|
||||
* @param player the player to remove.
|
||||
*/
|
||||
public void removeFromQueue(Player player) {
|
||||
<b class="nc"> players.removeIf(x -> x.equals(player));</b>
|
||||
<b class="nc"> playerList.removeIf(x -> x.getPlayer().equals(player));</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the position of the player associated with the specified username
|
||||
* within the current order list.
|
||||
*
|
||||
* @param username the username of the player whose position is requested.
|
||||
* @return the player's position, or {@code -1} if no player with the specified
|
||||
* username is present in the order list.
|
||||
* @see Player
|
||||
*/
|
||||
public int getPosition(String username) {
|
||||
<b class="fc"> int pos = 0;</b>
|
||||
<b class="pc"> for (OrderPlayer p : playerList) {</b>
|
||||
<b class="fc"> if (p.getPlayer().getUserName().equals(username))</b>
|
||||
<b class="fc"> return pos;</b>
|
||||
<b class="fc"> pos++;</b>
|
||||
}
|
||||
<b class="nc"> return -1;</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,204 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > PlayableCard</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</a>
|
||||
</div>
|
||||
|
||||
<h1>Coverage Summary for Class: PlayableCard (it.polimi.ingsw.gc14.Model)</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">PlayableCard</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">
|
||||
(14/14)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<pre>
|
||||
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Model;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base class for all playable cards.
|
||||
* A PlayableCard is characterized by an era value.
|
||||
*/
|
||||
public abstract class PlayableCard implements Serializable {
|
||||
|
||||
/**
|
||||
* The image identifier of the playable card.
|
||||
*/
|
||||
private String idIMG;
|
||||
|
||||
/**
|
||||
* Returns the image identifier of this playable card.
|
||||
*
|
||||
* @return the image identifier of this playable card.
|
||||
*/
|
||||
public String getIdIMG() {
|
||||
<b class="fc"> return idIMG;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* The era associated with this playable card.
|
||||
*/
|
||||
private int era;
|
||||
|
||||
/**
|
||||
* Returns the era of this playable card.
|
||||
*
|
||||
* @return the era of this playable card.
|
||||
*/
|
||||
public int getEra(){
|
||||
<b class="fc"> return era;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a playable card with the specified era.
|
||||
*
|
||||
* @param era the era of the playable card.
|
||||
* @throws IllegalArgumentException if {@code era <= 0} or {@code era >= 4}.
|
||||
*/
|
||||
<b class="fc"> public PlayableCard(int era) throws IllegalArgumentException {</b>
|
||||
<b class="fc"> idIMG = "-1";</b>
|
||||
<b class="fc"> if (era > 0 && era < 4) {</b>
|
||||
<b class="fc"> this.era = era;</b>
|
||||
} else {
|
||||
<b class="fc"> throw new IllegalArgumentException();</b>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a playable card with the specified image id and era.
|
||||
*
|
||||
* @param idIMG the image identifier of the playable card.
|
||||
* @param era the era of the playable card.
|
||||
* @throws IllegalArgumentException if {@code era <= 0} or {@code era >= 4}.
|
||||
*/
|
||||
<b class="fc"> public PlayableCard(String idIMG, int era) throws IllegalArgumentException {</b>
|
||||
<b class="fc"> this.idIMG = idIMG;</b>
|
||||
<b class="fc"> if (era > 0 && era < 4) {</b>
|
||||
<b class="fc"> this.era = era;</b>
|
||||
} else {
|
||||
<b class="fc"> throw new IllegalArgumentException();</b>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this playable card.
|
||||
*
|
||||
* @return a string representation of this playable card.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
<b class="fc"> return "";</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a compact string representation used when rendering the board in the TUI.
|
||||
*
|
||||
* @return a compact board representation of this card.
|
||||
*/
|
||||
public String toStringBoard() {
|
||||
<b class="fc"> return ":";</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,503 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > Player</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</a>
|
||||
</div>
|
||||
|
||||
<h1>Coverage Summary for Class: Player (it.polimi.ingsw.gc14.Model)</h1>
|
||||
|
||||
<table class="coverageStats">
|
||||
|
||||
<tr>
|
||||
<th class="name">Class</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Method, %
|
||||
</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Branch, %
|
||||
</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Line, %
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name">Player</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(22/22)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
96.6%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(56/58)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(105/105)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name">Player$1</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">
|
||||
(1/1)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name"><strong>Total</strong></td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(23/23)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
96.6%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(56/58)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(106/106)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<pre>
|
||||
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Model;
|
||||
|
||||
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.Characters.*;
|
||||
import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static it.polimi.ingsw.gc14.View.TUI.BorderStyle.*;
|
||||
|
||||
/**
|
||||
* Default Player class; contains all identifiers and methods needed.
|
||||
*/
|
||||
public class Player implements Serializable {
|
||||
/**
|
||||
* The maximum length allowed for the username string.
|
||||
*/
|
||||
private static final int MAX_USERNAME_LENGTH = 32;
|
||||
|
||||
/**
|
||||
* Identifier for the {@code Player} when displaying the game through the GUI.
|
||||
* @see Totems
|
||||
*/
|
||||
private Totems totem;
|
||||
|
||||
// region Getters
|
||||
/**
|
||||
* Unique string identifier for players; must not be {@code null} and must not
|
||||
* exceed {@link #MAX_VALUE} otherwise an {@link IllegalArgumentException} will be thrown
|
||||
* when the {@link #Player(String) constructor} is called.
|
||||
*/
|
||||
private final String userName;
|
||||
|
||||
/**
|
||||
* Getter for the private attribute {@link #userName}.
|
||||
* @return {@code String} - The UserName
|
||||
*/
|
||||
public String getUserName() {
|
||||
<b class="fc"> return userName;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the totem assigned to this player.
|
||||
*
|
||||
* @return this player's totem.
|
||||
*/
|
||||
public Totems getTotem() {
|
||||
<b class="fc"> return totem;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the total {@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character Character Cards}
|
||||
* the player currently possesses.
|
||||
* @return {@code int} - Total Character Cards.
|
||||
*/
|
||||
public int getTotCharacters() {
|
||||
<b class="fc"> return Arrays.stream(CharacterType.values())</b>
|
||||
<b class="fc"> .mapToInt(this::getNType)</b>
|
||||
<b class="fc"> .sum();</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the total number of cards of the specified {@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType Character Type}.
|
||||
* Character Type must not be {@code null}
|
||||
* @param type the Character Type to be Counted.
|
||||
* @return {@code int} - Total number of cards of given {@code type}.
|
||||
*/
|
||||
public int getNType(CharacterType type) {
|
||||
<b class="pc"> return switch (type) {</b>
|
||||
<b class="fc"> case ARTIST -> artists.size();</b>
|
||||
<b class="fc"> case INVENTOR -> inventors.size();</b>
|
||||
<b class="fc"> case HUNTER -> hunters.size();</b>
|
||||
<b class="fc"> case BUILDER -> builders.size();</b>
|
||||
<b class="fc"> case SHAMAN -> shamans.size();</b>
|
||||
<b class="fc"> case GATHERER -> gatherers.size();</b>
|
||||
};
|
||||
}
|
||||
private ArrayList<BuildingCard> buildingCards;
|
||||
private ArrayList<Artist> artists;
|
||||
private ArrayList<Builder> builders;
|
||||
private ArrayList<Inventor> inventors;
|
||||
private ArrayList<Gatherer> gatherers;
|
||||
private ArrayList<Shaman> shamans;
|
||||
private ArrayList<Hunter> hunters;
|
||||
|
||||
/** @return this player's building cards. */
|
||||
<b class="fc"> public ArrayList<BuildingCard> getBuildingCards() { return buildingCards; }</b>
|
||||
/** @return this player's Artist character cards. */
|
||||
<b class="fc"> public ArrayList<Artist> getArtists() { return artists; }</b>
|
||||
/** @return this player's Builder character cards. */
|
||||
<b class="fc"> public ArrayList<Builder> getBuilders() { return builders; }</b>
|
||||
/** @return this player's Inventor character cards. */
|
||||
<b class="fc"> public ArrayList<Inventor> getInventors() { return inventors; }</b>
|
||||
/** @return this player's Gatherer character cards. */
|
||||
<b class="fc"> public ArrayList<Gatherer> getGatherers() { return gatherers; }</b>
|
||||
/** @return this player's Shaman character cards. */
|
||||
<b class="fc"> public ArrayList<Shaman> getShamans() { return shamans; }</b>
|
||||
/** @return this player's Hunter character cards. */
|
||||
<b class="fc"> public ArrayList<Hunter> getHunters() { return hunters; }</b>
|
||||
|
||||
/**
|
||||
* The current amount of {@code Food} the Player possesses.
|
||||
* Cannot be negative.
|
||||
*/
|
||||
private int foodValue;
|
||||
|
||||
/**
|
||||
* Getter for the private attribute {@link #foodValue}.
|
||||
* @return {@code int} - The amount of Food the player possesses.
|
||||
*/
|
||||
public int getFoodValue() {
|
||||
<b class="fc"> return foodValue;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* The current amount of {@code Prestige} the Player possesses.
|
||||
*/
|
||||
private int prestigeValue;
|
||||
|
||||
/**
|
||||
* Getter for the private attribute {@link #prestigeValue}.
|
||||
* @return {@code int} - The amount of Prestige the Player possesses.
|
||||
*/
|
||||
public int getPrestigeValue() {
|
||||
<b class="fc"> return prestigeValue;</b>
|
||||
}
|
||||
|
||||
// endregion getters
|
||||
|
||||
// region Setters
|
||||
|
||||
/**
|
||||
* Adds {@code value} amount of Food to the Player.
|
||||
* @param value The amount of Food to be added. Should be non-negative.
|
||||
* @see #foodValue
|
||||
*/
|
||||
public void addFood(int value){
|
||||
<b class="fc"> this.foodValue += value;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the totem for this player.
|
||||
*
|
||||
* @param totem the totem to assign.
|
||||
*/
|
||||
public void setTotem(Totems totem) {
|
||||
<b class="fc"> this.totem = totem;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes {@code value} amount of Food from the Player.
|
||||
* {@link #foodValue} cannot go negative: returns {@code false} if
|
||||
* {@code value} exceeds the current food and leaves the value unchanged.
|
||||
*
|
||||
* @param value The amount of Food to be removed. Should be non-negative.
|
||||
* @return {@code true} if the Food is successfully removed, {@code false} otherwise.
|
||||
* @see #foodValue
|
||||
*/
|
||||
public boolean removeFood(int value){
|
||||
<b class="fc"> if(value > this.foodValue){</b>
|
||||
<b class="fc"> return false;</b>
|
||||
}
|
||||
<b class="fc"> this.foodValue -= value;</b>
|
||||
<b class="fc"> return true;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@code value} amount of Prestige to the Player.
|
||||
* @param value The amount of Prestige to be added. Should be non-negative.
|
||||
* @see #prestigeValue
|
||||
*/
|
||||
public void addPrestige(int value){
|
||||
<b class="fc"> this.prestigeValue += value;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes {@code value} amount of Prestige from the Player.
|
||||
* @param value The amount of Prestige to be removed. Should be non-negative.
|
||||
* @see #prestigeValue
|
||||
*/
|
||||
public void removePrestige(int value){
|
||||
<b class="fc"> this.prestigeValue -= value;</b>
|
||||
}
|
||||
|
||||
// endregion setters
|
||||
|
||||
// region Constructors
|
||||
|
||||
/**
|
||||
* Constructor for the class {@code Player}. Each Player is uniquely identified by the {@link #userName}.
|
||||
*
|
||||
* @param userName Unique String identifier for a Player.
|
||||
* @throws IllegalArgumentException when {@code userName} is empty or exceeds {@link #MAX_USERNAME_LENGTH},
|
||||
* with message:
|
||||
* <pre>{@code UserName is empty or exceeds maximum permitted length.}</pre>
|
||||
*
|
||||
* @see #userName
|
||||
* @see #MAX_USERNAME_LENGTH
|
||||
*/
|
||||
<b class="fc"> public Player(String userName) throws IllegalArgumentException {</b>
|
||||
<b class="fc"> if(userName.isEmpty() || userName.length() > MAX_USERNAME_LENGTH) {</b>
|
||||
<b class="fc"> throw new IllegalArgumentException("UserName is empty or exceeds maximum permitted length.");</b>
|
||||
}
|
||||
<b class="fc"> this.userName = userName;</b>
|
||||
|
||||
<b class="fc"> this.inventors = new ArrayList <>();</b>
|
||||
<b class="fc"> this.builders = new ArrayList <>();</b>
|
||||
<b class="fc"> this.gatherers = new ArrayList <>();</b>
|
||||
<b class="fc"> this.shamans = new ArrayList <>();</b>
|
||||
<b class="fc"> this.hunters = new ArrayList <>();</b>
|
||||
<b class="fc"> this.artists = new ArrayList<>();</b>
|
||||
|
||||
<b class="fc"> this.buildingCards = new ArrayList<>();</b>
|
||||
<b class="fc"> this.foodValue = 0;</b>
|
||||
<b class="fc"> this.prestigeValue = 0;</b>
|
||||
<b class="fc"> this.totem = null;</b>
|
||||
}
|
||||
// endregion constructors
|
||||
|
||||
// region Functions
|
||||
|
||||
// TODO
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
<b class="fc"> if (this == obj) return true;</b>
|
||||
<b class="pc"> if (!(obj instanceof Player)) return false;</b>
|
||||
<b class="fc"> return userName.equals(((Player) obj).userName);</b>
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
<b class="fc"> return userName.hashCode();</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the {@code Player}'s attributes for the {@code Board}'s representation.
|
||||
* Uses the {@code UNICODE} border style.
|
||||
* <p><b>Includes:</b>
|
||||
* <li>{@link #foodValue Food}
|
||||
* <li>{@link #prestigeValue Prestige}
|
||||
* <li>{@link #artists Artists}
|
||||
* <li>{@link #builders Builders}
|
||||
* <li>{@link #gatherers Gatherers}
|
||||
* <li>{@link #shamans Shamans}
|
||||
* <li>{@link #inventors Inventors}
|
||||
* <li>{@link #hunters Hunters}
|
||||
* <li>{@link #buildingCards Buildings}
|
||||
* </p>
|
||||
* @return {@code String} - A string representation of the {@code Player}'s attributes.
|
||||
* @see it.polimi.ingsw.gc14.View.TUI.BorderStyle BorderStyle
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
<b class="fc"> int last = -1;</b>
|
||||
|
||||
<b class="fc"> var table = new AsciiTable(ROUNDED, 1);</b>
|
||||
|
||||
<b class="pc"> String totemStr = (this.totem != null) ? " (" + this.totem.toString() + ")" : "";</b>
|
||||
<b class="fc"> table.addHeader(this.getUserName() + totemStr + " | \uD83C\uDF56:" + this.getFoodValue() + " | \uD83C\uDFC5:" + this.getPrestigeValue());</b>
|
||||
<b class="fc"> table.addSeparator();</b>
|
||||
|
||||
<b class="fc"> if(!this.hunters.isEmpty()){</b>
|
||||
<b class="fc"> last = 6;</b>
|
||||
}
|
||||
<b class="fc"> else if(!this.inventors.isEmpty()){</b>
|
||||
<b class="fc"> last = 5;</b>
|
||||
}
|
||||
<b class="fc"> else if(!this.shamans.isEmpty()){</b>
|
||||
<b class="fc"> last = 4;</b>
|
||||
}
|
||||
<b class="fc"> else if(!this.gatherers.isEmpty()){</b>
|
||||
<b class="fc"> last = 3;</b>
|
||||
}
|
||||
<b class="fc"> else if(!this.builders.isEmpty()){</b>
|
||||
<b class="fc"> last = 2;</b>
|
||||
}
|
||||
<b class="fc"> else if(!this.artists.isEmpty()){</b>
|
||||
<b class="fc"> last = 1;</b>
|
||||
}
|
||||
else{
|
||||
<b class="fc"> last = 0;</b>
|
||||
}
|
||||
|
||||
<b class="fc"> if(last == 0){</b>
|
||||
<b class="fc"> table.addSeparator();</b>
|
||||
}
|
||||
<b class="fc"> table.addRow("CHARACTERS");</b>
|
||||
<b class="fc"> if(!this.artists.isEmpty()){</b>
|
||||
<b class="fc"> table.addRow(this.artists.size() + " Artists: \uD83C\uDFA8:" + this.artists.size());</b>
|
||||
<b class="fc"> if(last == 1){</b>
|
||||
<b class="fc"> table.addSeparator();</b>
|
||||
}
|
||||
}
|
||||
|
||||
<b class="fc"> if(!this.builders.isEmpty()){</b>
|
||||
<b class="fc"> table.addRow(this.builders.size() + " Builders: " + "\uD83D\uDD28:" + this.builders.stream().mapToInt(Builder::getReductionValue).sum() + " \uD83C\uDFC5:" + this.builders.stream().mapToInt(Builder::getPrestigeValue).sum());</b>
|
||||
<b class="fc"> if(last == 2){</b>
|
||||
<b class="fc"> table.addSeparator();</b>
|
||||
}
|
||||
}
|
||||
|
||||
<b class="fc"> if(!this.gatherers.isEmpty()){</b>
|
||||
<b class="fc"> table.addRow(this.gatherers.size() + " Gatherers: -\uD83E\uDD57:" + 3*this.gatherers.size());</b>
|
||||
<b class="fc"> if(last == 3){</b>
|
||||
<b class="fc"> table.addSeparator();</b>
|
||||
}
|
||||
}
|
||||
|
||||
<b class="fc"> if(!this.shamans.isEmpty()){</b>
|
||||
<b class="fc"> table.addRow(this.shamans.size() + " Shamans: " + "\uD83C\uDF1F:" + this.shamans.stream().mapToInt(Shaman::getIcon).sum());</b>
|
||||
<b class="fc"> if(last == 4){</b>
|
||||
<b class="fc"> table.addSeparator();</b>
|
||||
}
|
||||
}
|
||||
|
||||
<b class="fc"> if(!this.inventors.isEmpty()){</b>
|
||||
<b class="fc"> table.addRow(this.inventors.size() + " Inventors: " + this.inventors.stream()</b>
|
||||
<b class="fc"> .collect(Collectors.groupingBy(</b>
|
||||
Inventor::getIcon,
|
||||
<b class="fc"> Collectors.counting()</b>
|
||||
))
|
||||
<b class="fc"> .entrySet().stream()</b>
|
||||
<b class="fc"> .sorted(Map.Entry.comparingByKey())</b>
|
||||
<b class="fc"> .map(e -> e.getKey() + ":" + e.getValue())</b>
|
||||
<b class="fc"> .collect(Collectors.joining(", ")));</b>
|
||||
<b class="fc"> if(last == 5){</b>
|
||||
<b class="fc"> table.addSeparator();</b>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
<b class="fc"> if(!this.hunters.isEmpty()){</b>
|
||||
<b class="fc"> table.addRow(this.hunters.size() + " Hunters: \uD83C\uDF56" + this.hunters.stream().filter(Hunter::getIcon).count());</b>
|
||||
<b class="fc"> table.addSeparator();</b>
|
||||
}
|
||||
<b class="fc"> table.addSeparator();</b>
|
||||
<b class="fc"> table.addRow("BUILDING CARDS" +</b>
|
||||
<b class="fc"> (this.buildingCards.stream().mapToInt(BuildingCard::getPrestigeValue).sum() != 0</b>
|
||||
<b class="fc"> ? " 🏅:" + this.buildingCards.stream().mapToInt(BuildingCard::getPrestigeValue).sum()</b>
|
||||
<b class="fc"> : ""));</b>
|
||||
<b class="fc"> if(!this.buildingCards.isEmpty()){</b>
|
||||
<b class="fc"> table.addRow(this.buildingCards.size() + " Buildings: " + this.buildingCards.stream().map(BuildingCard::toStringPlayer).collect(Collectors.joining(", ")));</b>
|
||||
}
|
||||
|
||||
<b class="fc"> return table.build();</b>
|
||||
}
|
||||
// endregion functions
|
||||
}
|
||||
</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,312 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > Slot</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</a>
|
||||
</div>
|
||||
|
||||
<h1>Coverage Summary for Class: Slot (it.polimi.ingsw.gc14.Model)</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">Slot</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(1/1)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
90%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(9/10)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
42.1%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(8/19)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
82.2%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(37/45)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<pre>
|
||||
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Model;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a slot with a specific identifier and associated values
|
||||
* for upper cards, lower cards, food, and minimum number of players.
|
||||
* The slot configuration depends on the specified slot identifier.
|
||||
*/
|
||||
public class Slot implements Serializable {
|
||||
// Getters
|
||||
|
||||
/**
|
||||
* The identifier of this slot.
|
||||
*/
|
||||
private char slotId;
|
||||
|
||||
/**
|
||||
* Returns the identifier of this slot.
|
||||
*
|
||||
* @return the identifier of this slot.
|
||||
*/
|
||||
public char getSlotId() {
|
||||
<b class="fc"> return slotId;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of upper cards associated with this slot.
|
||||
*/
|
||||
private int nUpper;
|
||||
/**
|
||||
* Returns the number of upper cards associated with this slot.
|
||||
*
|
||||
* @return the number of upper cards associated with this slot.
|
||||
*/
|
||||
public int getNUpper(){
|
||||
<b class="fc"> return nUpper;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* The minimum number of players required for this slot.
|
||||
*/
|
||||
private int nMinPlayer;
|
||||
|
||||
/**
|
||||
* Returns the minimum number of players required for this slot.
|
||||
*
|
||||
* @return the minimum number of players required for this slot.
|
||||
*/
|
||||
public int getNMinPlayer()
|
||||
{
|
||||
<b class="fc"> return nMinPlayer;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of lower cards associated with this slot.
|
||||
*/
|
||||
private int nLower;
|
||||
|
||||
/**
|
||||
* Returns the number of lower cards associated with this slot.
|
||||
*
|
||||
* @return the number of lower cards associated with this slot.
|
||||
*/
|
||||
public int getNLower(){
|
||||
<b class="fc"> return nLower;</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* The amount of Food associated with this slot.
|
||||
*/
|
||||
private int food;
|
||||
|
||||
/**
|
||||
* Returns the amount of Food associated with this slot.
|
||||
*
|
||||
* @return the amount of Food associated with this slot.
|
||||
*/
|
||||
public int getFood(){
|
||||
<b class="fc"> return food;</b>
|
||||
}
|
||||
// End getters
|
||||
|
||||
// Constructors
|
||||
|
||||
/**
|
||||
* Creates a slot with the specified identifier.
|
||||
* The slot values for Food, NLower, NUpper, and minimum number of players
|
||||
* are determined by the given slot identifier.
|
||||
*
|
||||
* @param slotId the identifier of the slot.
|
||||
* @throws IllegalArgumentException if the specified slot identifier is not valid.
|
||||
*/
|
||||
public Slot(char slotId) throws IllegalArgumentException
|
||||
<b class="fc"> {</b>
|
||||
<b class="fc"> this.slotId = slotId;</b>
|
||||
<b class="fc"> this.nMinPlayer=0;</b>
|
||||
<b class="fc"> switch(slotId)</b>
|
||||
{
|
||||
case 'A':
|
||||
<b class="fc"> this.food = 3;</b>
|
||||
<b class="fc"> this.nLower = 0;</b>
|
||||
<b class="fc"> this.nUpper = 0;</b>
|
||||
<b class="fc"> this.nMinPlayer=5;</b>
|
||||
break;
|
||||
case 'B':
|
||||
<b class="fc"> this.food = 0;</b>
|
||||
<b class="fc"> this.nLower = 1;</b>
|
||||
<b class="fc"> this.nUpper = 0;</b>
|
||||
break;
|
||||
case 'C':
|
||||
<b class="fc"> this.food = 0;</b>
|
||||
<b class="fc"> this.nLower = 0;</b>
|
||||
<b class="fc"> this.nUpper = 1;</b>
|
||||
break;
|
||||
case 'D':
|
||||
<b class="fc"> this.food = 0;</b>
|
||||
<b class="fc"> this.nLower = 2;</b>
|
||||
<b class="fc"> this.nUpper = 0;</b>
|
||||
<b class="fc"> this.nMinPlayer = 3;</b>
|
||||
break;
|
||||
case 'E':
|
||||
<b class="fc"> this.food = 0;</b>
|
||||
<b class="fc"> this.nLower = 1;</b>
|
||||
<b class="fc"> this.nUpper = 1;</b>
|
||||
break;
|
||||
case 'F':
|
||||
<b class="fc"> this.food = 0;</b>
|
||||
<b class="fc"> this.nLower = 0;</b>
|
||||
<b class="fc"> this.nUpper = 2;</b>
|
||||
break;
|
||||
case 'G':
|
||||
<b class="fc"> this.food = 0;</b>
|
||||
<b class="fc"> this.nLower = 1;</b>
|
||||
<b class="fc"> this.nUpper = 2;</b>
|
||||
<b class="fc"> this.nMinPlayer = 4;</b>
|
||||
break;
|
||||
default:
|
||||
<b class="fc"> throw new IllegalArgumentException();</b>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the string representation of this slot.
|
||||
* The returned string includes the slot identifier, number of upper cards,
|
||||
* number of lower cards, food value, and minimum number of players.
|
||||
*
|
||||
* @return the string representation of this slot.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
<b class="fc"> return ("SlotID: "+this.getSlotId()+"\nNUpper: "+this.getNUpper()+"\nNLower: "+this.getNLower()+"\nFood: "+this.getFood()+"\n");</b>
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a compact string representation of this {@code Slot} for the TUI.
|
||||
* <p>Includes:
|
||||
* <ul>
|
||||
* <li>{@link #slotId}</li>
|
||||
* <li>{@link #nUpper} (shown as ▲ symbols)</li>
|
||||
* <li>{@link #nLower} (shown as ▼ symbols)</li>
|
||||
* <li>{@link #food} (if non-zero)</li>
|
||||
* </ul>
|
||||
* @return a compact TUI string representation of this {@code Slot}.
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
public String toStringTUI()
|
||||
{
|
||||
<b class="nc"> StringBuilder s = new StringBuilder(" ");</b>
|
||||
<b class="nc"> for(int i=0;i<this.getNUpper();i++) s.append("▲");</b>
|
||||
<b class="nc"> for(int i=0;i<this.getNLower();i++) s.append("▼");</b>
|
||||
<b class="nc"> if(getFood()!=0) s.append("+"+getFood()+" \uD83C\uDF56");</b>
|
||||
<b class="nc"> s.append(" ");</b>
|
||||
<b class="nc"> return s.toString();</b>
|
||||
}
|
||||
|
||||
// Functions
|
||||
|
||||
// TODO
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
<b class="pc"> if (this == obj) return true;</b>
|
||||
<b class="nc"> if (!(obj instanceof Slot)) return false;</b>
|
||||
<b class="nc"> return slotId == ((Slot) obj).slotId;</b>
|
||||
}
|
||||
|
||||
// TODO
|
||||
@Override
|
||||
public int hashCode() {
|
||||
<b class="fc"> return Character.hashCode(slotId);</b>
|
||||
}
|
||||
|
||||
// End functions
|
||||
}
|
||||
</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,136 @@
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html id="htmlId">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Coverage Report > Totems</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</a>
|
||||
</div>
|
||||
|
||||
<h1>Coverage Summary for Class: Totems (it.polimi.ingsw.gc14.Model)</h1>
|
||||
|
||||
<table class="coverageStats">
|
||||
<tr>
|
||||
<th class="name">Class</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Class, %
|
||||
</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Method, %
|
||||
</th>
|
||||
<th class="coverageStat
|
||||
">
|
||||
Line, %
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name">Totems</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">
|
||||
(2/2)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
100%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(6/6)
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<pre>
|
||||
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Model;
|
||||
|
||||
/**
|
||||
* Represents the different totem colors available in the game.
|
||||
*/
|
||||
<b class="fc"> public enum Totems {</b>
|
||||
|
||||
/**
|
||||
* Yellow totem.
|
||||
*/
|
||||
<b class="fc"> YELLOW,</b>
|
||||
|
||||
/**
|
||||
* Blue totem.
|
||||
*/
|
||||
<b class="fc"> BLUE,</b>
|
||||
|
||||
/**
|
||||
* Orange totem.
|
||||
*/
|
||||
<b class="fc"> ORANGE,</b>
|
||||
|
||||
/**
|
||||
* White totem.
|
||||
*/
|
||||
<b class="fc"> WHITE,</b>
|
||||
|
||||
/**
|
||||
* Purple totem.
|
||||
*/
|
||||
<b class="fc"> PURPLE</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