Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
79e6af4
style(server): reformat Lobby
xeruf Apr 15, 2020
8f991da
refactor(server): hierarchically process Admin requests in Lobby
xeruf Apr 15, 2020
9216213
docs(server): clean up some Javadoc
xeruf Apr 15, 2020
3097d31
refactor(sdk): convert GameResult and PlayerScore to Kotlin
xeruf Apr 16, 2020
2ed06de
refactor(server): turn the Lobby into a GameRoomManager
xeruf Apr 16, 2020
7024add
refactor(server): convert ClientManager to Kotlin
xeruf Apr 16, 2020
3a6104d
style(server): reformat & adjust docs
xeruf Apr 16, 2020
c4d529c
refactor(server): simplify score aggregation in GameRoomManager throu…
xeruf Apr 16, 2020
fe42080
refactor(server): improve relationship of GameRoom and Manager
xeruf Apr 16, 2020
5c4a2cd
fix(server): fix ClientManager closing
xeruf Apr 28, 2020
15a71eb
test(server): use preconfigured XStream
xeruf Apr 28, 2020
c256f26
test(sdk): add PlayerScore tests (#262)
anarchuser Apr 30, 2020
efa8102
refactor(sdk): clean up GameResult
xeruf Apr 30, 2020
8afe4f7
test(sdk): shorten PlayerScore equality tests
xeruf Apr 30, 2020
ab687fc
fix(sdk): turn GameResult into data class
xeruf May 2, 2020
7e89811
fix(server): clean up ClientManager & prevent IndexOutOfBoundsException
xeruf May 3, 2020
769a663
test(server): clean up LobbyTest
xeruf May 3, 2020
056c023
feat(sdk): add proper toString methods for GameResult & its dependencies
xeruf May 3, 2020
a35b583
test(sdk): add GameResult XML tests (#263)
anarchuser May 3, 2020
47b159a
refactor(framework): convert ScoreDefinition to Kotlin
xeruf May 3, 2020
0a4bb3e
refactor(framework): make ScoreDefinition immutable
xeruf May 4, 2020
6508b1a
chore(gradle): separate sdk & plugin buildscripts & update kotest
xeruf May 5, 2020
3908d1b
test(sdk): process PlayerScore XML annotations
xeruf May 5, 2020
61c24df
test(sdk): add PlayerScore toString test in GameResultTest
xeruf May 5, 2020
4807d3c
test(sdk): properly test GameResult XML & equality
xeruf May 5, 2020
56554bb
fix(sdk): treat GameResults with null or empty winners as equal
xeruf May 5, 2020
e7b0847
refactor(sdk): clean up Player
xeruf May 25, 2020
5eaf64e
test(server): add simple GameRoomTest
xeruf Sep 11, 2020
8630863
chore(git): merge branch 'master' into fix/improve-lobby
xeruf Sep 11, 2020
e04df27
test(server): improve TestTeam
xeruf Sep 11, 2020
184213b
test(server): join GameRoom and reservations
xeruf Sep 22, 2020
f8c69b7
refactor(server): replace hardcoded maximum players in GameRoom with …
xeruf Sep 25, 2020
d45d4cd
test(server): disable failing GameResult XML Test
xeruf Sep 25, 2020
4fc1637
test(server): test Game in GameRoom
xeruf Sep 25, 2020
c4ec0f3
refactor(server): factor out GameRoom saveReplay method
xeruf Sep 25, 2020
8c7ff64
fix(server): improve ObservingClient & ControllingClient
xeruf Sep 25, 2020
7e25276
refactor(server): remove superfluous getters from GameRoom
xeruf Sep 25, 2020
e80750a
docs(server): clean up GameRoom documentation
xeruf Sep 25, 2020
62ae74a
test(server): add test for GameRoom.onGameOver
xeruf Sep 25, 2020
1702131
chore(gradle): unify tasks style in buildscripts
xeruf Sep 29, 2020
083c703
chore: merge branch 'master' into fix/improve-lobby
xeruf Sep 22, 2020
b9e5e31
docs(server): clean up game preparation and GameRoomManager
xeruf Sep 22, 2020
273b806
docs(server): simplify network docs
xeruf Sep 29, 2020
8de7a00
refactor(sdk): simplify joinToString iterations
xeruf Sep 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -285,43 +285,6 @@ allprojects {
}
}

project("sdk") {
sourceSets {
main.get().java.srcDirs("src/framework", "src/server-api")
test.get().java.srcDir("src/test")
}

dependencies {
api(kotlin("stdlib"))
api("com.thoughtworks.xstream", "xstream", "1.4.12")
api("jargs", "jargs", "1.0")
api("ch.qos.logback", "logback-classic", "1.2.3")

implementation("org.hamcrest", "hamcrest-core", "2.2")
implementation("net.sf.kxml", "kxml2", "2.3.0")
implementation("xmlpull", "xmlpull", "1.1.3.1")

testImplementation("junit", "junit", "4.13")
testImplementation("io.kotlintest", "kotlintest-runner-junit5", "3.4.2")
}
}

project("plugin") {
sourceSets {
main.get().java.srcDirs("src/client", "src/server", "src/shared")
test.get().java.srcDir("src/test")
}

dependencies {
api(project(":sdk"))

testImplementation("junit", "junit", "4.13")
testImplementation("io.kotlintest", "kotlintest-runner-junit5", "3.4.2")
}

tasks.jar.get().archiveBaseName.set(game)
}

// == Utilities ==

fun InputStream.dump(name: String? = null) {
Expand Down
5 changes: 3 additions & 2 deletions helpers/test-client/src/sc/TestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ protected void onObject(ProtocolMessage message) {
irregularGames++;
StringBuilder log = new StringBuilder("Game {} ended " +
(result.isRegular() ? "regularly -" : "abnormally!") + " Winner: ");
for (Player winner : result.getWinners())
log.append(winner.getDisplayName()).append(", ");
if (result.getWinners() != null)
for (Player winner : result.getWinners())
log.append(winner.getDisplayName()).append(", ");
logger.warn(log.substring(0, log.length() - 2), finishedTests);

finishedTests++;
Expand Down
24 changes: 21 additions & 3 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
tasks.withType<Test> {
useJUnitPlatform()
val game: String by project

sourceSets {
main.get().java.srcDirs("src/client", "src/server", "src/shared")
test.get().java.srcDir("src/test")
}

dependencies {
api(project(":sdk"))

testImplementation("junit", "junit", "4.13")
testImplementation("io.kotest", "kotest-runner-junit5-jvm", "4.0.5")
testImplementation("io.kotest", "kotest-assertions-core", "4.0.5")
testImplementation(kotlin("script-runtime"))
}
}

tasks{
jar {
archiveBaseName.set(game)
}
test {
useJUnitPlatform()
}
}
14 changes: 5 additions & 9 deletions plugin/src/server/sc/plugin2020/GamePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ public class GamePlugin implements IGamePlugin {
public static final String PLUGIN_AUTHOR = "";
public static final String PLUGIN_UUID = "swc_2020_hive";

public static final ScoreDefinition SCORE_DEFINITION;

static {
SCORE_DEFINITION = new ScoreDefinition();
SCORE_DEFINITION.add("Gewinner");
// NOTE: Always write the XML representation of unicode characters, not the character directly, as it confuses the
// parsers which consume the server messages!
SCORE_DEFINITION.add(new ScoreFragment("\u2205 freie Felder", ScoreAggregation.AVERAGE));
}
// NOTE: Always write the XML representation of unicode characters, not the character directly, as it confuses the
// parsers which consume the server messages!
public static final ScoreDefinition SCORE_DEFINITION = new ScoreDefinition(new ScoreFragment[]{
new ScoreFragment("Gewinner"),
new ScoreFragment("\u2205 freie Felder", ScoreAggregation.AVERAGE)});

@Override
public IGameInstance createGame() {
Expand Down
6 changes: 3 additions & 3 deletions plugin/src/server/sc/plugin2021/Game.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class Game(UUID: String = GamePlugin.PLUGIN_UUID): RoundBasedGameInstance<Player
}

override fun getWinners(): MutableList<Player> {
if (players.first().violated) {
if (players.last().violated)
if (players.first().hasViolated()) {
if (players.last().hasViolated())
return mutableListOf()
return players.subList(1, 2)
}
if (players.last().violated)
if (players.last().hasViolated())
return players.subList(0, 1)

val first = gameState.getPointsForPlayer(players.first().color)
Expand Down
8 changes: 4 additions & 4 deletions plugin/src/server/sc/plugin2021/GamePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class GamePlugin: IGamePlugin {
val PLUGIN_AUTHOR = ""
val PLUGIN_UUID = "swc_2021_blokus"

val SCORE_DEFINITION = ScoreDefinition().apply {
add("Gewinner")
add(ScoreFragment("\u2205 Punkte", ScoreAggregation.AVERAGE))
}
val SCORE_DEFINITION = ScoreDefinition(arrayOf(
ScoreFragment("Gewinner"),
ScoreFragment("\u2205 Punkte", ScoreAggregation.AVERAGE)
))
}

override fun createGame(): IGameInstance {
Expand Down
7 changes: 1 addition & 6 deletions plugin/src/shared/sc/plugin2020/Team.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ import sc.api.plugins.ITeam

enum class Team(override val index: Int, val displayName: String): ITeam {
RED(0, "Rot") {
val letter = name.first()

override fun opponent(): Team = BLUE
override fun toString(): String = displayName
},
BLUE(1, "Blau") {
val letter = name.first()

override fun opponent(): Team = RED
override fun toString(): String = displayName
};
override fun toString(): String = displayName
}
6 changes: 3 additions & 3 deletions plugin/src/test/sc/plugin2020/CloneTest.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package sc.plugin2020

import io.kotlintest.matchers.types.shouldNotBeSameInstanceAs
import io.kotlintest.shouldBe
import io.kotlintest.specs.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.types.shouldNotBeSameInstanceAs
import io.kotest.core.spec.style.StringSpec
import sc.framework.plugins.Player

class CloneTest: StringSpec({
Expand Down
9 changes: 5 additions & 4 deletions plugin/src/test/sc/plugin2020/GamePlayTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package sc.plugin2020

import io.kotlintest.matchers.collections.shouldContain
import io.kotlintest.matchers.collections.shouldNotContain
import io.kotlintest.shouldThrow
import io.kotlintest.specs.AnnotationSpec
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.matchers.collections.shouldContain
import io.kotest.matchers.collections.shouldNotContain
import io.kotest.matchers.shouldBe
import io.kotest.core.spec.style.AnnotationSpec
import org.junit.Assert.*
import sc.plugin2020.util.Constants
import sc.plugin2020.util.CubeCoordinates
Expand Down
8 changes: 4 additions & 4 deletions plugin/src/test/sc/plugin2020/GameRuleTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package sc.plugin2020

import io.kotlintest.matchers.collections.shouldHaveSize
import io.kotlintest.shouldBe
import io.kotlintest.shouldNotBe
import io.kotlintest.specs.StringSpec
import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.kotest.core.spec.style.StringSpec
import sc.plugin2020.util.CubeCoordinates
import sc.plugin2020.util.GameRuleLogic
import sc.api.plugins.ITeam
Expand Down
14 changes: 6 additions & 8 deletions plugin/src/test/sc/plugin2020/XMLTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,12 @@ class XMLTest {
val xstream = Configuration.xStream
val xml = xstream.toXML(RoomPacket(roomId, move))
val expect = """
|<room roomId="$roomId">
| <data class="setmove">
| <piece type="ANT">
| <owner class="sc.plugin2020.Team">RED</owner>
| </piece>
| <destination x="1" y="2" z="-3"/>
| </data>
|</room>""".trimMargin()
<room roomId="$roomId">
<data class="setmove">
<piece owner="RED" type="ANT"/>
<destination x="1" y="2" z="-3"/>
</data>
</room>""".trimIndent()
Assert.assertEquals(expect, xml)
}

Expand Down
7 changes: 3 additions & 4 deletions plugin/src/test/sc/plugin2021/BoardTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package sc.plugin2021

import io.kotlintest.matchers.types.shouldNotBeSameInstanceAs

import io.kotlintest.shouldBe
import io.kotlintest.specs.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.types.shouldNotBeSameInstanceAs
import sc.plugin2021.util.Constants

class BoardTest : StringSpec({
Expand Down
8 changes: 3 additions & 5 deletions plugin/src/test/sc/plugin2021/ComparisonTest.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package sc.plugin2021

import io.kotlintest.matchers.types.shouldNotBeSameInstanceAs
import io.kotlintest.shouldBe
import io.kotlintest.shouldNotBe
import io.kotlintest.specs.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.kotest.core.spec.style.StringSpec
import sc.plugin2021.util.Constants

class ComparisonTest: StringSpec({
"Coordinate comparison" {
Coordinates(3, 2) shouldBe Coordinates(3, 2)
Coordinates(3, 2) shouldNotBeSameInstanceAs Coordinates(3, 2)
Coordinates(3, 2) shouldNotBe Coordinates(2, 3)
Coordinates(3, 2) shouldNotBe Board()
}
Expand Down
8 changes: 4 additions & 4 deletions plugin/src/test/sc/plugin2021/GameRuleLogicTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package sc.plugin2021

import io.kotlintest.matchers.collections.shouldContainExactlyInAnyOrder
import io.kotlintest.shouldBe
import io.kotlintest.shouldNotBe
import io.kotlintest.specs.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder
import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.assertThrows
import sc.plugin2021.util.Constants
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/test/sc/plugin2021/GameStateTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sc.plugin2021

import io.kotlintest.shouldBe
import io.kotlintest.specs.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.core.spec.style.StringSpec
import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.assertThrows
import sc.plugin2021.util.Configuration
Expand Down
10 changes: 4 additions & 6 deletions plugin/src/test/sc/plugin2021/GameTest.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package sc.plugin2021

import io.kotlintest.matchers.collections.shouldContainExactly
import io.kotlintest.shouldBe
import io.kotlintest.shouldNotBe
import io.kotlintest.specs.StringSpec
import org.junit.jupiter.api.assertThrows
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.collections.shouldContainExactly
import sc.plugin2020.util.Constants
import sc.plugin2021.util.GameRuleLogic
import sc.shared.InvalidMoveException
import sc.shared.PlayerScore
import sc.shared.ScoreCause

Expand Down
14 changes: 7 additions & 7 deletions plugin/src/test/sc/plugin2021/PieceTest.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package sc.plugin2021

import io.kotlintest.data.forall
import io.kotlintest.matchers.maps.shouldContain
import io.kotlintest.matchers.maps.shouldContainExactly
import io.kotlintest.shouldBe
import io.kotlintest.specs.StringSpec
import io.kotlintest.tables.row
import io.kotest.core.spec.style.StringSpec
import io.kotest.data.forAll
import io.kotest.data.row
import io.kotest.matchers.maps.shouldContain
import io.kotest.matchers.maps.shouldContainExactly
import io.kotest.matchers.shouldBe
import org.opentest4j.AssertionFailedError
import sc.plugin2021.util.*

Expand Down Expand Up @@ -164,7 +164,7 @@ class PieceTest: StringSpec({
piece.coordinates shouldBe coordinates
}
"XML conversion" {
forall(
forAll(
row(Piece(Color.YELLOW, PieceShape.TETRO_O, Rotation.RIGHT, false), """
<piece color="YELLOW" kind="TETRO_O" rotation="RIGHT" isFlipped="false">
<position x="0" y="0"/>
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/test/sc/plugin2021/RotationTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sc.plugin2021

import io.kotlintest.shouldBe
import io.kotlintest.specs.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.core.spec.style.StringSpec

class RotationTest: StringSpec ({
"Rotations can get rotated" {
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/test/sc/plugin2021/helper/MoveParser.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sc.plugin2021.helper

import io.kotlintest.shouldBe
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow
import sc.plugin2021.*
Expand Down
25 changes: 25 additions & 0 deletions sdk/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
sourceSets {
main.get().java.srcDirs("src/framework", "src/server-api")
test.get().java.srcDir("src/test")
}

dependencies {
api(kotlin("stdlib"))
api("com.thoughtworks.xstream", "xstream", "1.4.11.1")
api("jargs", "jargs", "1.0")
api("ch.qos.logback", "logback-classic", "1.2.3")

implementation("org.hamcrest", "hamcrest-core", "2.2")
implementation("net.sf.kxml", "kxml2", "2.3.0")
implementation("xmlpull", "xmlpull", "1.1.3.1")

testImplementation("junit", "junit", "4.13")
testImplementation("io.kotest", "kotest-runner-junit5-jvm", "4.0.5")
testImplementation("io.kotest", "kotest-assertions-core", "4.0.5")
}

tasks{
test {
useJUnitPlatform()
}
}
2 changes: 1 addition & 1 deletion sdk/src/framework/sc/helpers/HelperMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static String getCurrentDateTime() {
public static String generateReplayFilename(String pluginUuid, List<SlotDescriptor> descriptors) {
StringBuilder replayFileName = new StringBuilder("./replays/replay");
replayFileName.append("_");
replayFileName.append(pluginUuid); // something like hui_2018
replayFileName.append(pluginUuid);
for (SlotDescriptor descriptor : descriptors) {
replayFileName.append("_");
replayFileName.append(descriptor.getDisplayName().replace(' ', '_'));
Expand Down
Loading