Skip to content

Commit

Permalink
refactor: merge branch next with hui
Browse files Browse the repository at this point in the history
  • Loading branch information
xeruf committed Jun 14, 2024
2 parents 5d337e2 + edd242c commit 1701c7a
Show file tree
Hide file tree
Showing 64 changed files with 2,120 additions and 271 deletions.
2 changes: 2 additions & 0 deletions .dev/scopes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ server
plugin
plugin23
plugin24
plugin25
plugin26
gamerules

sdk
Expand Down
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ The version should always be in sync with the [GUI](https://github.com/software-
and likely contains breaking changes between patches.


### 25.0.0 - 2024
### 25.0.0 - 2024-06

## 2025 Game Mississippi Queen - 2024-06
- Allow other player to move on when one is disqualified

### 24.X - Post-Finale
- Allow one player to move on when other is stuck or finished
(add points depending on speed of reaching goal, do not require passengers?)
### 24 Post-Finale
- Allow one player to move on when other is stuck (now for clarification: crashed) or finished
- Improve XML protocol

### 24.2.5 No points for stuck ship - 2024-03-27
Expand Down
9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
socha.gameName=mississippi
socha.version.year=24
socha.version.minor=02
socha.version.patch=05
socha.gameName=hui
socha.version.year=25
socha.version.minor=00
socha.version.patch=00
socha.version.suffix=alpha1
2 changes: 1 addition & 1 deletion gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
val gameName by extra { property("socha.gameName") as String }
val versions = arrayOf("year", "minor", "patch").map { property("socha.version.$it").toString().toInt() }
val versionObject = KotlinVersion(versions[0], versions[1], versions[2])
version = versionObject.toString()
version = versionObject.toString() + property("socha.version.suffix").toString().takeUnless { it.isBlank() }?.let { "-$it" }.orEmpty()
val year by extra { "20${versionObject.major}" }
val game by extra { "${gameName}_$year" }

Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/kotlin/sc/plugin2023/Board.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package sc.plugin2023
import com.thoughtworks.xstream.annotations.XStreamAlias
import sc.api.plugins.*
import kotlin.random.Random
import sc.plugin2023.util.PluginConstants as Constants
import sc.plugin2023.util.PenguinConstants as Constants

/**
* Klasse welche eine Spielbrett darstellt. Bestehend aus einem
Expand Down
31 changes: 0 additions & 31 deletions plugin/src/main/kotlin/sc/plugin2023/Game.kt

This file was deleted.

20 changes: 10 additions & 10 deletions plugin/src/main/kotlin/sc/plugin2023/GameState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ package sc.plugin2023

import com.thoughtworks.xstream.annotations.XStreamAlias
import com.thoughtworks.xstream.annotations.XStreamAsAttribute
import sc.api.plugins.Coordinates
import sc.api.plugins.ITeam
import sc.api.plugins.Team
import sc.api.plugins.TwoPlayerGameState
import sc.api.plugins.*
import sc.plugin2023.util.PenguinsMoveMistake
import sc.plugin2023.util.PluginConstants
import sc.plugin2023.util.PenguinConstants
import sc.shared.InvalidMoveException
import sc.shared.MoveMistake

Expand Down Expand Up @@ -37,7 +34,7 @@ data class GameState @JvmOverloads constructor(
if(move.from != null) {
if(board[move.from].penguin != currentTeam)
throw InvalidMoveException(MoveMistake.WRONG_COLOR, move)
if(currentPieces.size < PluginConstants.PENGUINS)
if(currentPieces.size < PenguinConstants.PENGUINS)
throw InvalidMoveException(PenguinsMoveMistake.PENGUINS, move)
if(!move.to.minus(move.from).straightHex)
throw InvalidMoveException(MoveMistake.INVALID_MOVE, move)
Expand All @@ -46,7 +43,7 @@ data class GameState @JvmOverloads constructor(
throw InvalidMoveException(MoveMistake.INVALID_MOVE, move)
board[move.from] = null
} else {
if(currentPieces.size >= PluginConstants.PENGUINS)
if(currentPieces.size >= PenguinConstants.PENGUINS)
throw InvalidMoveException(PenguinsMoveMistake.MAX_PENGUINS, move)
if(board[move.to].fish != 1)
throw InvalidMoveException(PenguinsMoveMistake.SINGLE_FISH, move)
Expand All @@ -60,7 +57,7 @@ data class GameState @JvmOverloads constructor(
get() = board.filterValues { it.penguin == currentTeam }

val penguinsPlaced
get() = currentPieces.size == PluginConstants.PENGUINS
get() = currentPieces.size == PenguinConstants.PENGUINS

override fun getSensibleMoves(): List<Move> =
if(penguinsPlaced) {
Expand All @@ -72,12 +69,13 @@ data class GameState @JvmOverloads constructor(
override fun moveIterator(): Iterator<Move> =
getSensibleMoves().iterator()

fun canPlacePenguin(pos: Coordinates) = !penguinsPlaced && board[pos].fish == 1
fun canPlacePenguin(pos: Coordinates) =
!penguinsPlaced && board[pos].fish == 1

fun immovable(team: Team? = null) =
board.getPenguins()
.filter { team == null || it.second == team }
.takeIf { it.size == PluginConstants.PENGUINS * (if(team == null) Team.values().size else 1) }
.takeIf { it.size == PenguinConstants.PENGUINS * (if(team == null) Team.values().size else 1) }
?.all { pair -> pair.first.hexNeighbors.all { board.getOrEmpty(it).fish == 0 } } ?: false

override val isOver: Boolean
Expand All @@ -87,6 +85,8 @@ data class GameState @JvmOverloads constructor(
override fun getPointsForTeam(team: ITeam): IntArray =
intArrayOf(fishes[team.index])

override fun teamStats(team: ITeam) = listOf<Stat>()

override fun clone() = GameState(this)

override fun toString(): String =
Expand Down
14 changes: 0 additions & 14 deletions plugin/src/main/kotlin/sc/plugin2023/XStreamClasses.kt

This file was deleted.

2 changes: 1 addition & 1 deletion plugin/src/main/kotlin/sc/plugin2023/util/Constants.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sc.plugin2023.util

/** Eine Sammlung an verschiedenen Konstanten, die im Spiel verwendet werden. */
object PluginConstants {
object PenguinConstants {
/** Seitenlänge des quadratischen Spielfelds als Anzahl der Felder. */
const val BOARD_SIZE = 8

Expand Down
13 changes: 8 additions & 5 deletions plugin/src/main/kotlin/sc/plugin2023/util/GamePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package sc.plugin2023.util
import sc.api.plugins.IGameInstance
import sc.api.plugins.IGamePlugin
import sc.api.plugins.IGameState
import sc.plugin2023.Game
import sc.framework.plugins.TwoPlayerGame
import sc.plugin2023.GameState
import sc.plugin2023.Move
import sc.shared.ScoreAggregation
import sc.shared.ScoreDefinition
import sc.shared.ScoreFragment
import sc.shared.WinReason

class GamePlugin: IGamePlugin {
class GamePlugin: IGamePlugin<Move> {
companion object {
const val PLUGIN_ID = "swc_2023_penguins"
val scoreDefinition: ScoreDefinition =
Expand All @@ -26,12 +27,14 @@ class GamePlugin: IGamePlugin {
Companion.scoreDefinition

override val turnLimit: Int =
PluginConstants.BOARD_SIZE * PluginConstants.BOARD_SIZE
PenguinConstants.BOARD_SIZE * PenguinConstants.BOARD_SIZE

override val moveClass: Class<Move> = Move::class.java

override fun createGame(): IGameInstance =
Game()
TwoPlayerGame(this, GameState())

override fun createGameFromState(state: IGameState): IGameInstance =
Game(state as GameState)
TwoPlayerGame(this, state as GameState)

}
19 changes: 19 additions & 0 deletions plugin/src/main/kotlin/sc/plugin2023/util/XStreamClasses.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package sc.plugin2023.util

import sc.api.plugins.Coordinates
import sc.networking.XStreamProvider
import sc.plugin2023.Board
import sc.plugin2023.GameState
import sc.plugin2023.Move

class XStreamClasses: XStreamProvider {

override val classesToRegister =
listOf(
Board::class.java,
GameState::class.java,
Move::class.java,
Coordinates::class.java,
)

}
39 changes: 0 additions & 39 deletions plugin/src/main/kotlin/sc/plugin2024/Game.kt

This file was deleted.

Loading

0 comments on commit 1701c7a

Please sign in to comment.