Skip to content

Commit 6955750

Browse files
xerufanarchuser
authored andcommitted
refactor(plugin): fixup documentation & naming
1 parent 75151e7 commit 6955750

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

plugin/src/client/sc/plugin2021/AbstractClient.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import java.io.IOException
1515
import java.net.ConnectException
1616
import kotlin.system.exitProcess
1717

18-
/** Abstract client following the SDK.
18+
/**
19+
* Abstract client as specified in the SDK.
1920
* Contains a LobbyClient as actual client;
2021
* this class is a plugin specific abstract wrapper.
2122
*/
2223
abstract class AbstractClient @Throws(IOException::class) constructor(
2324
host: String,
2425
port: Int,
25-
private val id: PlayerType = PlayerType.PLAYER_ONE
26+
private val type: PlayerType = PlayerType.PLAYER_ONE
2627
): ILobbyClientListener {
2728

2829
companion object {
@@ -52,19 +53,17 @@ abstract class AbstractClient @Throws(IOException::class) constructor(
5253
private var error: String? = null
5354
fun getError() = error
5455

56+
/** Current room of the player. */
5557
private lateinit var roomID: String
5658

5759
/** 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) {
5961
PlayerType.PLAYER_ONE -> Team.ONE
6062
PlayerType.PLAYER_TWO -> Team.TWO
6163
else -> null
6264
}
6365

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. */
6867
fun observeGame(handle: PrepareGameProtocolMessage): IControllableGame =
6968
client.observe(handle)
7069

@@ -89,11 +88,15 @@ abstract class AbstractClient @Throws(IOException::class) constructor(
8988
this.error = error.message
9089
}
9190

91+
/**
92+
* Called when game state has been received.
93+
* Happens after a client made a move.
94+
*/
9295
override fun onNewState(roomId: String, state: Any) {
9396
val gameState = state as GameState
9497
logger.debug("$this got a new state $gameState")
9598

96-
if(id == PlayerType.OBSERVER) return
99+
if(type == PlayerType.OBSERVER) return
97100

98101
handler.onUpdate(gameState)
99102
if (gameState.orderedColors.isNotEmpty()) {

0 commit comments

Comments
 (0)