Skip to content

Commit e4240d9

Browse files
anarchuserxeruf
authored andcommitted
fix(plugin): revert Color refactoring (#282)
1 parent c1d19a3 commit e4240d9

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

plugin/src/client/sc/plugin2020/AbstractClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void onRoomMessage(String roomId, ProtocolMessage data) {
8181
if(data instanceof MoveRequest) {
8282
this.handler.onRequestAction();
8383
} else if(data instanceof WelcomeMessage) {
84-
this.color = Team.valueOf(((WelcomeMessage)data).getColor());
84+
this.color = Team.valueOf(((WelcomeMessage) data).getColor());
8585
}
8686
this.roomId = roomId;
8787
}

plugin/src/shared/sc/plugin2021/Color.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ import com.thoughtworks.xstream.annotations.XStreamAlias
44

55
@XStreamAlias(value = "color")
66
enum class Color(val team: Team) {
7-
BLUE(Team.ONE),
7+
BLUE (Team.ONE),
88
YELLOW(Team.TWO),
9-
RED(Team.ONE),
10-
GREEN(Team.TWO);
9+
RED (Team.ONE),
10+
GREEN (Team.TWO) { init {
11+
BLUE.next = YELLOW
12+
YELLOW.next = RED
13+
RED.next = GREEN
14+
GREEN.next = BLUE
15+
}};
1116

12-
val next: Color
13-
get() = when (this) {
14-
BLUE -> YELLOW
15-
YELLOW -> RED
16-
RED -> GREEN
17-
GREEN -> BLUE
18-
}
17+
lateinit var next: Color
18+
private set
1919

20-
operator fun unaryPlus(): FieldContent = when (this) {
21-
BLUE -> FieldContent.BLUE
20+
operator fun unaryPlus(): FieldContent = when(this) {
21+
BLUE -> FieldContent.BLUE
2222
YELLOW -> FieldContent.YELLOW
23-
RED -> FieldContent.RED
24-
GREEN -> FieldContent.GREEN
23+
RED -> FieldContent.RED
24+
GREEN -> FieldContent.GREEN
2525
}
2626
}

socha-sdk/src/framework/sc/shared/WelcomeMessage.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ data class WelcomeMessage
1212
private constructor(
1313
@XStreamAsAttribute val color: String
1414
): ProtocolMessage {
15-
constructor(color: ITeam): this(color.toString())
15+
16+
constructor(color: ITeam): this(color.toString().toLowerCase())
1617
}

0 commit comments

Comments
 (0)