FIx: Fixed Coverage Screenshots And htmlRepot.
This commit is contained in:
@@ -0,0 +1,526 @@
|
||||
|
||||
|
||||
|
||||
<!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">
|
||||
84.5%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(49/58)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
98.1%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(102/104)
|
||||
</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">
|
||||
84.5%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(49/58)
|
||||
</span>
|
||||
</td>
|
||||
<td class="coverageStat">
|
||||
<span class="percent">
|
||||
98.1%
|
||||
</span>
|
||||
<span class="absValue">
|
||||
(103/105)
|
||||
</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 = 10;
|
||||
|
||||
/**
|
||||
* Identifier for the {@code Player} when displaying the game through the GUI.
|
||||
* @see Totems
|
||||
*/
|
||||
private Totems totem;
|
||||
|
||||
/**
|
||||
* Unique string identifier for players; must not be {@code null} and must not
|
||||
* exceed {@link #MAX_USERNAME_LENGTH} 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>
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The current {@link BuildingCard Building Cards} in the player's deck.
|
||||
*/
|
||||
private final ArrayList<BuildingCard> buildingCards;
|
||||
|
||||
/**
|
||||
* The current {@link Artist Artist} cards in the player's deck.
|
||||
*/
|
||||
private final ArrayList<Artist> artists;
|
||||
|
||||
/**
|
||||
* The current {@link Builder Builder} cards in the player's deck.
|
||||
*/
|
||||
private final ArrayList<Builder> builders;
|
||||
|
||||
/**
|
||||
* The current {@link Inventor Inventor} cards in the player's deck.
|
||||
*/
|
||||
private final ArrayList<Inventor> inventors;
|
||||
|
||||
/**
|
||||
* The current {@link Gatherer Gatherer} cards in the player's deck.
|
||||
*/
|
||||
private final ArrayList<Gatherer> gatherers;
|
||||
|
||||
/**
|
||||
* The current {@link Shaman Shaman} cards in the player's deck.
|
||||
*/
|
||||
private final ArrayList<Shaman> shamans;
|
||||
|
||||
/**
|
||||
* The current {@link Hunter Hunter} cards in the player's deck.
|
||||
*/
|
||||
private final 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>
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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>
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks equality between this {@code Player} and another object.
|
||||
* Two players are equal if and only if they share the same {@code userName}.
|
||||
*
|
||||
* @param obj the object to compare with.
|
||||
* @return {@code true} if {@code obj} is a {@code Player} with the same username; {@code false} otherwise.
|
||||
*/
|
||||
@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() {
|
||||
int last;
|
||||
|
||||
<b class="fc"> var table = new AsciiTable(ROUNDED, 1);</b>
|
||||
|
||||
<b class="pc"> String totemStr = (this.totem != null) ? " (" + this.totem + ")" : "";</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="pc"> 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="pc"> 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: \uD83C\uDF56:" + 3*this.gatherers.size());</b>
|
||||
<b class="pc"> 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="pc"> 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="pc"> 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="pc"> (this.buildingCards.stream().mapToInt(BuildingCard::getPrestigeValue).sum() != 0</b>
|
||||
<b class="nc"> ? " \uD83C\uDFC5:" + this.buildingCards.stream().mapToInt(BuildingCard::getPrestigeValue).sum()</b>
|
||||
<b class="fc"> : ""));</b>
|
||||
<b class="pc"> if(!this.buildingCards.isEmpty()){</b>
|
||||
<b class="nc"> table.addRow(this.buildingCards.size() + " Buildings: " + this.buildingCards.stream().map(BuildingCard::toStringPlayer).collect(Collectors.joining(", ")));</b>
|
||||
}
|
||||
|
||||
<b class="fc"> return table.build();</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>
|
||||
Reference in New Issue
Block a user