@@ -15,14 +15,15 @@ import java.io.IOException
15
15
import java.net.ConnectException
16
16
import kotlin.system.exitProcess
17
17
18
- /* * Abstract client following the SDK.
18
+ /* *
19
+ * Abstract client as specified in the SDK.
19
20
* Contains a LobbyClient as actual client;
20
21
* this class is a plugin specific abstract wrapper.
21
22
*/
22
23
abstract class AbstractClient @Throws(IOException ::class ) constructor(
23
24
host : String ,
24
25
port : Int ,
25
- private val id : PlayerType = PlayerType .PLAYER_ONE
26
+ private val type : PlayerType = PlayerType .PLAYER_ONE
26
27
): ILobbyClientListener {
27
28
28
29
companion object {
@@ -52,19 +53,17 @@ abstract class AbstractClient @Throws(IOException::class) constructor(
52
53
private var error: String? = null
53
54
fun getError () = error
54
55
56
+ /* * Current room of the player. */
55
57
private lateinit var roomID: String
56
58
57
59
/* * The team the client belongs to in order to connect client and player. */
58
- private var team: Team ? = when (id ) {
60
+ private var team: Team ? = when (type ) {
59
61
PlayerType .PLAYER_ONE -> Team .ONE
60
62
PlayerType .PLAYER_TWO -> Team .TWO
61
63
else -> null
62
64
}
63
65
64
- /* * Tell this client to observe the game given by the preparation handler.
65
- *
66
- * @return controllable game
67
- */
66
+ /* * Tell this client to observe the game given by the preparation handler. */
68
67
fun observeGame (handle : PrepareGameProtocolMessage ): IControllableGame =
69
68
client.observe(handle)
70
69
@@ -89,11 +88,15 @@ abstract class AbstractClient @Throws(IOException::class) constructor(
89
88
this .error = error.message
90
89
}
91
90
91
+ /* *
92
+ * Called when game state has been received.
93
+ * Happens after a client made a move.
94
+ */
92
95
override fun onNewState (roomId : String , state : Any ) {
93
96
val gameState = state as GameState
94
97
logger.debug(" $this got a new state $gameState " )
95
98
96
- if (id == PlayerType .OBSERVER ) return
99
+ if (type == PlayerType .OBSERVER ) return
97
100
98
101
handler.onUpdate(gameState)
99
102
if (gameState.orderedColors.isNotEmpty()) {
0 commit comments