summaryrefslogtreecommitdiff
path: root/sw-engine/src/test
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@gmail.com>2021-03-08 01:31:26 +0100
committerJoffrey Bion <joffrey.bion@gmail.com>2021-03-08 01:31:59 +0100
commit3f8a672dcfefdd9304ba8b489865cb12153a75e3 (patch)
tree3b5e091d37b9f821e189ec26791db7a4eec177b4 /sw-engine/src/test
parentMake SayReady action an object (diff)
downloadseven-wonders-3f8a672dcfefdd9304ba8b489865cb12153a75e3.tar.gz
seven-wonders-3f8a672dcfefdd9304ba8b489865cb12153a75e3.tar.bz2
seven-wonders-3f8a672dcfefdd9304ba8b489865cb12153a75e3.zip
Make turnInfo generic in its action type
Diffstat (limited to 'sw-engine/src/test')
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt12
1 files changed, 6 insertions, 6 deletions
diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt
index 09cdd970..5368fbc0 100644
--- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt
+++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt
@@ -52,7 +52,7 @@ class GameTest {
} while (!game.getCurrentTurnInfo().first().isStartOfAge(age + 1))
}
- private fun PlayerTurnInfo.isStartOfAge(age: Int) = action is TurnAction.WatchScore || currentAge == age
+ private fun PlayerTurnInfo<*>.isStartOfAge(age: Int) = action is TurnAction.WatchScore || currentAge == age
private fun playTurn(nbPlayers: Int, game: Game, ageToCheck: Int) {
val turnInfos = game.getCurrentTurnInfo()
@@ -72,7 +72,7 @@ class GameTest {
assertEquals(expectedMoves, game.getCurrentTurnInfo()[0].table.lastPlayedMoves)
}
- private fun PlayerTurnInfo.firstAvailableMove(): MoveExpectation? = when (val a = action) {
+ private fun PlayerTurnInfo<*>.firstAvailableMove(): MoveExpectation? = when (val a = action) {
is TurnAction.PlayFromHand -> createPlayCardMove(this, a.hand)
is TurnAction.PlayFromDiscarded -> createPlayFreeDiscardedCardMove(this, a.discardedCards)
is TurnAction.PickNeighbourGuild -> createPickGuildMove(this, a.neighbourGuildCards)
@@ -81,7 +81,7 @@ class GameTest {
is TurnAction.WatchScore -> fail("should not have WATCH_SCORE action before end of game")
}
- private fun createPlayCardMove(turnInfo: PlayerTurnInfo, hand: List<HandCard>): MoveExpectation {
+ private fun createPlayCardMove(turnInfo: PlayerTurnInfo<*>, hand: List<HandCard>): MoveExpectation {
val wonderBuildability = turnInfo.wonderBuildability
if (wonderBuildability.isBuildable) {
val transactions = wonderBuildability.transactionsOptions.first()
@@ -95,7 +95,7 @@ class GameTest {
}
}
- private fun createPlayFreeDiscardedCardMove(turn: PlayerTurnInfo, discardedCards: List<HandCard>): MoveExpectation {
+ private fun createPlayFreeDiscardedCardMove(turn: PlayerTurnInfo<*>, discardedCards: List<HandCard>): MoveExpectation {
val card = discardedCards.random()
return MoveExpectation(
turn.playerIndex,
@@ -105,7 +105,7 @@ class GameTest {
}
private fun planMove(
- turnInfo: PlayerTurnInfo,
+ turnInfo: PlayerTurnInfo<*>,
moveType: MoveType,
card: HandCard,
transactions: ResourceTransactions,
@@ -115,7 +115,7 @@ class GameTest {
PlayedMove(turnInfo.playerIndex, moveType, card.toPlayedCard(), transactions),
)
- private fun createPickGuildMove(turnInfo: PlayerTurnInfo, neighbourGuilds: List<HandCard>): MoveExpectation {
+ private fun createPickGuildMove(turnInfo: PlayerTurnInfo<*>, neighbourGuilds: List<HandCard>): MoveExpectation {
// the game should send action WAIT if no guild cards are available around
assertFalse(neighbourGuilds.isEmpty())
val card = neighbourGuilds.first()
bgstack15