183 lines
4.8 KiB
HTML
183 lines
4.8 KiB
HTML
|
|
|
|
|
|
<!DOCTYPE html>
|
|
<html id="htmlId">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
|
<title>Coverage Report > AddPlayer</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.Network.NetworkEvents</a>
|
|
</div>
|
|
|
|
<h1>Coverage Summary for Class: AddPlayer (it.polimi.ingsw.gc14.Network.NetworkEvents)</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">AddPlayer</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/4)
|
|
</span>
|
|
</td>
|
|
<td class="coverageStat">
|
|
<span class="percent">
|
|
0%
|
|
</span>
|
|
<span class="absValue">
|
|
(0/2)
|
|
</span>
|
|
</td>
|
|
<td class="coverageStat">
|
|
<span class="percent">
|
|
0%
|
|
</span>
|
|
<span class="absValue">
|
|
(0/13)
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<br/>
|
|
<br/>
|
|
|
|
|
|
<pre>
|
|
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Network.NetworkEvents;
|
|
|
|
import it.polimi.ingsw.gc14.Controller.GameController;
|
|
import it.polimi.ingsw.gc14.ErrorType;
|
|
import it.polimi.ingsw.gc14.Model.MiniModel;
|
|
import it.polimi.ingsw.gc14.Network.EventType;
|
|
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
|
|
|
/**
|
|
* Network event used to register a new player in the lobby.
|
|
*
|
|
* <p>The first player to join also proposes the desired number of players
|
|
* for the match. Subsequent joiners ignore {@code proposedNPlayer} if the
|
|
* game has already been created.
|
|
*/
|
|
public class AddPlayer extends NetworkEvent {
|
|
/** Number of players proposed by this player; used only when creating a new game. */
|
|
private final int proposedNPlayer;
|
|
|
|
/**
|
|
* @return the number of proposed players to add to the match
|
|
*/
|
|
public int getProposedNPlayer() {
|
|
<b class="nc"> return proposedNPlayer;</b>
|
|
}
|
|
|
|
/**
|
|
* Class constructor.
|
|
* Initializes all the attributes.
|
|
* @param username the name of the player requesting the event
|
|
* @param proposedNPlayer the number of proposed players to add to the match
|
|
*/
|
|
public AddPlayer(String username, int proposedNPlayer) {
|
|
<b class="nc"> super(username, EventType.ADD_PLAYER, false, ErrorType.GENERIC_ERROR);</b>
|
|
<b class="nc"> this.proposedNPlayer = proposedNPlayer;</b>
|
|
}
|
|
|
|
/**
|
|
* @param gameController the Game Controller on which to apply the event
|
|
* @return true if the player could be added to the match, false otherwise
|
|
*/
|
|
@Override
|
|
public boolean apply(GameController gameController)
|
|
{
|
|
<b class="nc"> return gameController.addPlayer(username);</b>
|
|
}
|
|
|
|
/**
|
|
* Applies this event to the client-side mini model, updating players,
|
|
* turn order, game state, and slot map.
|
|
*
|
|
* @param miniModel the client-side model to update.
|
|
*/
|
|
@Override
|
|
public void apply(MiniModel miniModel){
|
|
<b class="nc"> synchronized (miniModel) {</b>
|
|
<b class="nc"> if (isError)</b>
|
|
<b class="nc"> return;</b>
|
|
<b class="nc"> miniModel.setPlayers(playerList);</b>
|
|
<b class="nc"> miniModel.setOrderLogicCard(orderLogicCard);</b>
|
|
<b class="nc"> miniModel.setCurrentState(currentState);</b>
|
|
<b class="nc"> miniModel.setSlotPlayerMap(slotPlayerMap);</b>
|
|
<b class="nc"> miniModel.setLastEvent(this);</b>
|
|
<b class="nc"> }</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>
|