Skip to content

Commit

Permalink
fix(plugin): revert Color refactoring (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
anarchuser authored and xeruf committed Sep 9, 2020
1 parent 89ae8b7 commit 040b96b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion plugin/src/client/sc/plugin2020/AbstractClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void onRoomMessage(String roomId, ProtocolMessage data) {
if(data instanceof MoveRequest) {
this.handler.onRequestAction();
} else if(data instanceof WelcomeMessage) {
this.color = Team.valueOf(((WelcomeMessage)data).getColor());
this.color = Team.valueOf(((WelcomeMessage) data).getColor());
}
this.roomId = roomId;
}
Expand Down
28 changes: 14 additions & 14 deletions plugin/src/shared/sc/plugin2021/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import com.thoughtworks.xstream.annotations.XStreamAlias

@XStreamAlias(value = "color")
enum class Color(val team: Team) {
BLUE(Team.ONE),
BLUE (Team.ONE),
YELLOW(Team.TWO),
RED(Team.ONE),
GREEN(Team.TWO);
RED (Team.ONE),
GREEN (Team.TWO) { init {
BLUE.next = YELLOW
YELLOW.next = RED
RED.next = GREEN
GREEN.next = BLUE
}};

val next: Color
get() = when (this) {
BLUE -> YELLOW
YELLOW -> RED
RED -> GREEN
GREEN -> BLUE
}
lateinit var next: Color
private set

operator fun unaryPlus(): FieldContent = when (this) {
BLUE -> FieldContent.BLUE
operator fun unaryPlus(): FieldContent = when(this) {
BLUE -> FieldContent.BLUE
YELLOW -> FieldContent.YELLOW
RED -> FieldContent.RED
GREEN -> FieldContent.GREEN
RED -> FieldContent.RED
GREEN -> FieldContent.GREEN
}
}
3 changes: 2 additions & 1 deletion socha-sdk/src/framework/sc/shared/WelcomeMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ data class WelcomeMessage
private constructor(
@XStreamAsAttribute val color: String
): ProtocolMessage {
constructor(color: ITeam): this(color.toString())

constructor(color: ITeam): this(color.toString().toLowerCase())
}

0 comments on commit 040b96b

Please sign in to comment.