Skip to content

Commit 2f6c625

Browse files
committed
Merge branch 'master'
2 parents ba5beee + 40a9ef7 commit 2f6c625

File tree

89 files changed

+1026
-1418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1026
-1418
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
2+
* @xeruf @SKoschnike

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ out/
88
!.idea/codeStyles/
99
*.iml
1010

11+
# Artifacts from test runs
1112
logs/
12-
log/
13+
log/
14+
replays/

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,24 @@ The version should always be in sync with the [GUI](https://github.com/CAU-Kiel-
88
- The major version `x` corresponds to the year of the contest and thus only changes once a year
99
- `y` is bumped for any major updates or backwards-incompatible changes
1010

11-
## [21.4.0](https://github.com/CAU-Kiel-Tech-Inf/backend/commits/21.4.0)
11+
## [22.0.0](https://github.com/CAU-Kiel-Tech-Inf/backend/commits/22.0.0)
1212
- Removed PlayerScoreRequest - add up the GameResults instead
1313

14+
## [21.4.0](https://github.com/CAU-Kiel-Tech-Inf/backend/commits/21.4.0) - 2021-05-28
15+
- Enable preparing games without reservations
16+
- Implement generic replay saving & loading
17+
- Create an AdminClient to interface more conveniently with the server
18+
- Distinguish RoomMessages from ProtocolPackets
19+
- The GamePaused message is now actually sent after a Game has been paused
20+
1421
## [21.3.3](https://github.com/CAU-Kiel-Tech-Inf/backend/commits/21.3.3) - 2021-03-01
1522
- Game: Refactor turn advancing logic ([#391](https://github.com/CAU-Kiel-Tech-Inf/backend/pull/391))
1623
- Networking: Improve Exception handling within games and rooms ([#383](https://github.com/CAU-Kiel-Tech-Inf/backend/pull/383))
1724

1825
## [21.3.2](https://github.com/CAU-Kiel-Tech-Inf/backend/commits/21.3.2) - 2021-02-12
1926
### Fixed
2027
- GameState: Round number is now always aligned with turn number (49676b64c)
21-
- TestClient: prevent a race-condition that could occur when getting the results of the first game (4f33fc01f)
28+
- TestClient: Prevent a race-condition that could occur when getting the results of the first game (4f33fc01f)
2229

2330
## [21.3.1](https://github.com/CAU-Kiel-Tech-Inf/backend/commits/21.3.1) - 2021-02-11
2431
### Fixed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
socha.gameName=blokus
22
socha.version.year=21
3-
socha.version.minor=03
4-
socha.version.patch=03
3+
socha.version.minor=04
4+
socha.version.patch=00

player/src/main/sc/player2021/Starter.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@
1717
public class Starter {
1818
private static final Logger logger = LoggerFactory.getLogger(Starter.class);
1919

20-
public Starter(String host, int port, String reservation) {
20+
public Starter(String host, int port, String reservation, String roomId) {
2121
// Strategie zuweisen
2222
IGameHandler logic = new Logic();
2323
PlayerClient client = new PlayerClient(host, port, logic);
2424

2525
// einem Spiel beitreten
26-
if (reservation == null || reservation.isEmpty()) {
27-
client.joinAnyGame();
28-
} else {
26+
if (reservation != null && !reservation.isEmpty()) {
2927
client.joinPreparedGame(reservation);
28+
} else if (roomId != null) {
29+
client.joinGameRoom(roomId);
30+
} else {
31+
client.joinAnyGame();
3032
}
3133
}
3234

@@ -38,6 +40,7 @@ public static void main(String[] args) {
3840
CmdLineParser.Option hostOption = parser.addStringOption('h', "host");
3941
CmdLineParser.Option portOption = parser.addIntegerOption('p', "port");
4042
CmdLineParser.Option reservationOption = parser.addStringOption('r', "reservation");
43+
CmdLineParser.Option roomOption = parser.addStringOption("room");
4144

4245
try {
4346
// Parameter auslesen
@@ -51,11 +54,12 @@ public static void main(String[] args) {
5154
// Parameter laden
5255
String host = (String) parser.getOptionValue(hostOption, "localhost");
5356
int port = (Integer) parser.getOptionValue(portOption, SharedConfiguration.DEFAULT_PORT);
54-
String reservation = (String) parser.getOptionValue(reservationOption, "");
57+
String reservation = (String) parser.getOptionValue(reservationOption);
58+
String room = (String) parser.getOptionValue(roomOption);
5559

5660
// einen neuen client erzeugen
5761
try {
58-
new Starter(host, port, reservation);
62+
new Starter(host, port, reservation, room);
5963
} catch (Exception e) {
6064
logger.error("Beim Starten den Clients ist ein Fehler aufgetreten:", e);
6165
e.printStackTrace();
@@ -66,11 +70,12 @@ public static void main(String[] args) {
6670
private static void showHelp(String errorMsg) {
6771
String jarName = new File(Starter.class.getProtectionDomain().getCodeSource().getLocation().getFile()).getName();
6872
System.out.println("\n" + errorMsg);
69-
System.out.println("\nBitte das Programm mit folgenden Parametern (optional) aufrufen: \n"
73+
System.out.println("\nFolgende Parameter sind erlaubt: \n"
7074
+ "java -jar " + jarName + " [{-h,--host} hostname]\n"
7175
+ " [{-p,--port} port]\n"
72-
+ " [{-r,--reservation} reservierung]");
73-
System.out.println("\nBeispiel: \n"
76+
+ " [{-r,--reservation} reservierung]\n"
77+
+ " [--room raumnummer]\n");
78+
System.out.println("Beispiel: \n"
7479
+ "java -jar " + jarName + " --host 127.0.0.1 --port 10500 --reservation 1234\n");
7580
}
7681

plugin/src/main/sc/plugin2022/Game.kt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ package sc.plugin2022
33
import org.slf4j.LoggerFactory
44
import sc.api.plugins.ITeam
55
import sc.api.plugins.Team
6+
import sc.api.plugins.IMove
67
import sc.api.plugins.exceptions.TooManyPlayersException
78
import sc.framework.plugins.AbstractGame
89
import sc.framework.plugins.ActionTimeout
910
import sc.framework.plugins.Player
1011
import sc.plugin2022.util.Constants
1112
import sc.plugin2022.util.MoveMistake
1213
import sc.plugin2022.util.WinReason
13-
import sc.protocol.room.RoomMessage
1414
import sc.shared.InvalidMoveException
1515
import sc.shared.PlayerScore
1616
import sc.shared.ScoreCause
@@ -24,22 +24,18 @@ class Game(override val currentState: GameState = GameState()): AbstractGame<Pla
2424
private val availableTeams = ArrayDeque<ITeam>().also { it.addAll(Team.values()) }
2525
override fun onPlayerJoined(): Player {
2626
if (availableTeams.isEmpty())
27-
throw TooManyPlayersException()
27+
throw TooManyPlayersException(this)
2828

2929
val player = Player(availableTeams.removeFirst())
3030
players.add(player)
3131
return player
3232
}
3333

34-
override val winners: MutableList<Player>
34+
override val winners: List<Player>
3535
get() {
36-
if (players.first().hasViolated()) {
37-
if (players.last().hasViolated())
38-
return mutableListOf()
39-
return players.subList(1, 2)
40-
}
41-
if (players.last().hasViolated())
42-
return players.subList(0, 1)
36+
val compliant = players.filter { !it.hasViolated() && !it.hasLeft() }
37+
if (compliant.size < players.size)
38+
return compliant
4339

4440
val first = currentState.getPointsForTeam(players.first().team)
4541
val second = currentState.getPointsForTeam(players.last().team)
@@ -126,12 +122,12 @@ class Game(override val currentState: GameState = GameState()): AbstractGame<Pla
126122
ActionTimeout(true, Constants.HARD_TIMEOUT, Constants.SOFT_TIMEOUT)
127123

128124
@Throws(InvalidMoveException::class)
129-
override fun onRoundBasedAction(data: RoomMessage) {
130-
if (data !is Move)
125+
override fun onRoundBasedAction(move: IMove) {
126+
if (move !is Move)
131127
throw InvalidMoveException(MoveMistake.INVALID_FORMAT)
132128

133-
logger.debug("Performing $data")
134-
currentState.performMove(data)
129+
logger.debug("Performing $move")
130+
currentState.performMove(move)
135131
next()
136132
logger.debug("Current State: ${currentState.longString()}")
137133
}

plugin/src/test/sc/plugin2022/GameTest.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ class GameTest: WordSpec({
4040
// hashing it to avoid cloning, since we get the original mutable object
4141
finalState = data.hashCode()
4242
}
43-
44-
override fun onPaused(nextPlayer: Player) {
45-
}
4643
})
4744

4845
"finish without issues".config(invocationTimeout = Constants.GAME_TIMEOUT.milliseconds) {

sdk/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ dependencies {
3636
implementation("xmlpull", "xmlpull", "1.1.3.1")
3737

3838
"testConfigApi"("io.kotest", "kotest-assertions-core")
39-
"testConfigApi"("io.kotest", "kotest-runner-junit5-jvm", "4.4.1")
39+
"testConfigApi"("io.kotest", "kotest-runner-junit5-jvm", "4.4.3")
4040
}

sdk/src/framework/sc/shared/GameResult.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package sc.shared
33
import com.thoughtworks.xstream.annotations.XStreamAlias
44
import com.thoughtworks.xstream.annotations.XStreamImplicit
55
import sc.framework.plugins.Player
6-
import sc.protocol.room.RoomMessage
6+
import sc.protocol.room.ObservableRoomMessage
7+
import sc.protocol.room.RoomOrchestrationMessage
78

89
/**
910
* Das Endergebnis eines Spiels.
@@ -17,7 +18,7 @@ data class GameResult(
1718
val scores: List<PlayerScore>,
1819
@XStreamImplicit(itemFieldName = "winner")
1920
val winners: List<Player>?
20-
): RoomMessage {
21+
): RoomOrchestrationMessage, ObservableRoomMessage {
2122

2223
val isRegular: Boolean
2324
get() = scores.all { it.cause == ScoreCause.REGULAR }

sdk/src/framework/sc/shared/SlotDescriptor.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ import com.thoughtworks.xstream.annotations.XStreamAsAttribute
66
@XStreamAlias(value = "slotDescriptor")
77
data class SlotDescriptor
88
@JvmOverloads constructor(
9-
@XStreamAsAttribute val displayName: String = "Unknown",
10-
@XStreamAsAttribute val canTimeout: Boolean = true)
9+
@XStreamAsAttribute val displayName: String,
10+
@XStreamAsAttribute val canTimeout: Boolean = true,
11+
@XStreamAsAttribute val reserved: Boolean = true,
12+
)

0 commit comments

Comments
 (0)