382 lines
13 KiB
HTML
382 lines
13 KiB
HTML
|
|
|
|
|
|
<!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/18)
|
|
</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/36)
|
|
</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.CurrentState;
|
|
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 final 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 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>
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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-19 22:53</div>
|
|
</div>
|
|
</body>
|
|
</html>
|