Skip to content

Commit c1d19a3

Browse files
committed
chore(git): merge refactor/convert-generics into master (#268)
2 parents 65d6b5c + 24f1f76 commit c1d19a3

16 files changed

+124
-210
lines changed

server/src/sc/server/gaming/GameRoom.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ private void syncSlot(PlayerSlot slot) throws RescuableClientException {
370370
Player player = getGame().onPlayerJoined(); // make new player in gameState of game
371371
// set attributes for player XXX check whether this is needed for prepared games
372372
player.setDisplayName(slot.getDescriptor().getDisplayName());
373-
player.setShouldBePaused(slot.getDescriptor().isShouldBePaused());
374-
player.setCanTimeout(slot.getDescriptor().isCanTimeout());
373+
player.setShouldBePaused(slot.getDescriptor().getShouldBePaused());
374+
player.setCanTimeout(slot.getDescriptor().getCanTimeout());
375375

376376
if (slot.isEmpty()) // needed for forced step, if client crashes before joining room
377377
{
@@ -652,7 +652,7 @@ public void openSlots(SlotDescriptor[] descriptors)
652652

653653
for (int i = 0; i < descriptors.length; i++) {
654654
this.playerSlots.get(i).setDescriptor(descriptors[i]);
655-
if (descriptors[i].isShouldBePaused()) {
655+
if (descriptors[i].getShouldBePaused()) {
656656
pause(true);
657657
}
658658
}

server/src/sc/server/gaming/PlayerSlot.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public PlayerSlot(GameRoom room) {
1717
throw new IllegalStateException("Room must not be null.");
1818

1919
this.room = room;
20+
descriptor = new SlotDescriptor();
2021
}
2122

2223
public PlayerRole getRole() {
@@ -85,15 +86,12 @@ public String getDisplayName() {
8586
}
8687

8788
public SlotDescriptor getDescriptor() {
88-
if (this.descriptor == null) {
89-
return SlotDescriptor.DEFAULT_DESCRIPTOR;
90-
}
91-
9289
return this.descriptor;
9390
}
9491

9592
public void setDescriptor(SlotDescriptor descriptor) {
96-
this.descriptor = descriptor;
93+
if (descriptor == null) this.descriptor = new SlotDescriptor();
94+
else this.descriptor = descriptor;
9795
}
9896

9997
public IClient getClient() {

socha-sdk/src/framework/sc/shared/DebugHint.java

Lines changed: 0 additions & 74 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
package sc.shared;
1+
package sc.shared
2+
3+
import kotlin.RuntimeException
24

35
/**
46
* This exception is thrown if the server tried to create an invalid game state.
57
* This indicates an error in the server or plugin code. It should never be
68
* thrown on invalid input to the server (i.e. invalid move made).
79
*/
8-
public class InvalidGameStateException extends RuntimeException {
9-
10-
public InvalidGameStateException(String reason) {
11-
super(reason);
12-
}
13-
14-
}
10+
class InvalidGameStateException(reason: String): RuntimeException(reason)

socha-sdk/src/framework/sc/shared/InvalidMoveException.java

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package sc.shared
2+
3+
import sc.api.plugins.IMove
4+
import kotlin.RuntimeException
5+
6+
/** NOTE: It is important to have information about the move in the reason
7+
* because that is the only place where the invalid move is logged */
8+
class InvalidMoveException @JvmOverloads constructor(reason: String, @JvmField val move: IMove? = null):
9+
RuntimeException(reason + move?.let { "; move was $it"}.orEmpty())

socha-sdk/src/framework/sc/shared/ScoreAggregation.java

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package sc.shared
2+
3+
import com.thoughtworks.xstream.annotations.XStreamAlias
4+
5+
@XStreamAlias(value = "scoreAggregation")
6+
enum class ScoreAggregation {
7+
/** All values from all games should be summed up. */
8+
SUM,
9+
10+
/** All values from all games should be averaged. */
11+
AVERAGE
12+
}

socha-sdk/src/framework/sc/shared/ScoreCause.java

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package sc.shared
2+
3+
import com.thoughtworks.xstream.annotations.XStreamAlias
4+
5+
@XStreamAlias(value = "scoreCause")
6+
enum class ScoreCause {
7+
/** The player didn't violate against the rules or left the game early. */
8+
REGULAR,
9+
10+
/** The player left the game early (connection loss). */
11+
LEFT,
12+
13+
/** The player violated against the games rules. */
14+
RULE_VIOLATION,
15+
16+
/** The player took to long to respond to the move request. */
17+
SOFT_TIMEOUT,
18+
19+
/** The player didn't respond to the move request. */
20+
HARD_TIMEOUT,
21+
22+
/** An error occurred during communication. This could indicate a bug in the server's code. */
23+
UNKNOWN
24+
}

0 commit comments

Comments
 (0)