Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
stephtelolahy committed Nov 19, 2023
1 parent c75e980 commit 21d04b2
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
// ActionPutTopDeckToDiscard.swift
// ActionDraw.swift
//
//
// Created by Hugues Telolahy on 18/11/2023.
//

struct ActionPutTopDeckToDiscard: GameActionReducer {
struct ActionDraw: GameActionReducer {
func reduce(state: GameState) throws -> GameState {
var state = state
let card = try state.popDeck()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ private extension GameAction {
case .putBack:
ActionPutBack()

case .putTopDeckToDiscard:
ActionPutTopDeckToDiscard()
case .draw:
ActionDraw()

case let .group(actions):
ActionGroup(children: actions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ private extension CardEffect {
case .putBack:
EffectJust { _ in .putBack }

case .putTopDeckToDiscard:
EffectJust { _ in .putTopDeckToDiscard }
case .draw:
EffectJust { _ in .draw }

case .setTurn:
EffectJust { .setTurn($0.player()) }
Expand Down
2 changes: 1 addition & 1 deletion GameKit/Sources/Game/State/CardEffect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public indirect enum CardEffect: Codable, Equatable {
case putBack

/// Put top deck card to discard
case putTopDeckToDiscard
case draw

/// Set turn
case setTurn
Expand Down
2 changes: 1 addition & 1 deletion GameKit/Sources/Game/State/GameAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public indirect enum GameAction: Action, Codable, Equatable {
case putBack

/// Reveal top deck card and put to discard
case putTopDeckToDiscard
case draw

/// Set turn
case setTurn(String)
Expand Down
8 changes: 4 additions & 4 deletions GameKit/Sources/Inventory/CardList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private extension CardList {
.target(.selectAny)
.on([.playHandicap])
CardEffect.group {
CardEffect.putTopDeckToDiscard
CardEffect.draw
.repeat(.attr(.flippedCards))
CardEffect.luck(
.topDiscard,
Expand All @@ -189,7 +189,7 @@ private extension CardList {

static let barrel = Card(.barrel, prototype: equipement) {
CardEffect.group {
CardEffect.putTopDeckToDiscard
CardEffect.draw
.repeat(.attr(.flippedCards))
CardEffect.luck(
.topDiscard,
Expand All @@ -202,7 +202,7 @@ private extension CardList {

static let dynamite = Card(.dynamite, prototype: equipement) {
CardEffect.group {
CardEffect.putTopDeckToDiscard
CardEffect.draw
.repeat(.attr(.flippedCards))
CardEffect.luck(
.topDiscard,
Expand Down Expand Up @@ -305,7 +305,7 @@ private extension CardList {

static let jourdonnais = Card(.jourdonnais, prototype: pDefault, attributes: [.maxHealth: 4]) {
CardEffect.group {
CardEffect.putTopDeckToDiscard
CardEffect.draw
.repeat(.attr(.flippedCards))
CardEffect.luck(
.topDiscard,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// PutTopDeckToDiscardTests.swift
// DrawTests.swift
//
//
// Created by Hugues Telolahy on 18/11/2023.
Expand All @@ -8,16 +8,16 @@
import Game
import XCTest

final class PutTopDeckToDiscardTests: XCTestCase {
func test_putTopDeckToDiscard_shouldMoveCardFromDeckToDiscard() throws {
final class DrawTests: XCTestCase {
func test_draw_shouldMoveCardFromDeckToDiscard() throws {
// Given
let state = GameState.makeBuilder()
.withDeck(["c2", "c3"])
.withDiscard(["c1"])
.build()

// When
let action = GameAction.putTopDeckToDiscard
let action = GameAction.draw
let result = GameState.reducer(state, action)

// Then
Expand Down
10 changes: 5 additions & 5 deletions GameKit/Tests/InventoryTests/Collectible/BarrelSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class BarrelSpec: QuickSpec {
// Then
expect(result) == [
.playImmediate(.bang, target: "p2", player: "p1"),
.putTopDeckToDiscard,
.draw,
.cancel(.damage(1, player: "p2"))
]
}
Expand Down Expand Up @@ -81,7 +81,7 @@ final class BarrelSpec: QuickSpec {
// Then
expect(result) == [
.playImmediate(.bang, target: "p2", player: "p1"),
.putTopDeckToDiscard,
.draw,
.damage(1, player: "p2")
]
}
Expand Down Expand Up @@ -111,8 +111,8 @@ final class BarrelSpec: QuickSpec {
// Then
expect(result) == [
.playImmediate(.bang, target: "p2", player: "p1"),
.putTopDeckToDiscard,
.putTopDeckToDiscard,
.draw,
.draw,
.cancel(.damage(1, player: "p2"))
]
}
Expand Down Expand Up @@ -142,7 +142,7 @@ final class BarrelSpec: QuickSpec {
// Then
expect(result) == [
.playImmediate(.bang, target: "p2", player: "p1"),
.putTopDeckToDiscard,
.draw,
.cancel(.damage(1, player: "p2"))
]
}
Expand Down
6 changes: 3 additions & 3 deletions GameKit/Tests/InventoryTests/Collectible/DynamiteSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class DynamiteSpec: QuickSpec {

// Then
expect(result) == [.setTurn("p1"),
.putTopDeckToDiscard,
.draw,
.passInPlay(.dynamite, target: "p2", player: "p1"),
.drawDeck(player: "p1"),
.drawDeck(player: "p1")]
Expand All @@ -76,7 +76,7 @@ final class DynamiteSpec: QuickSpec {

// Then
expect(result) == [.setTurn("p1"),
.putTopDeckToDiscard,
.draw,
.damage(3, player: "p1"),
.discardInPlay("dynamite", player: "p1"),
.drawDeck(player: "p1"),
Expand Down Expand Up @@ -112,7 +112,7 @@ final class DynamiteSpec: QuickSpec {

// Then
expect(result) == [.setTurn("p1"),
.putTopDeckToDiscard,
.draw,
.damage(3, player: "p1"),
.eliminate(player: "p1"),
.discardInPlay(.jail, player: "p1"),
Expand Down
4 changes: 2 additions & 2 deletions GameKit/Tests/InventoryTests/Collectible/JailSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class JailSpec: QuickSpec {

// Then
expect(result) == [.setTurn("p1"),
.putTopDeckToDiscard,
.draw,
.discardInPlay(.jail, player: "p1"),
.drawDeck(player: "p1"),
.drawDeck(player: "p1")]
Expand All @@ -86,7 +86,7 @@ final class JailSpec: QuickSpec {

// Then
expect(result) == [.setTurn("p1"),
.putTopDeckToDiscard,
.draw,
.cancel(.effect(.repeat(.attr(.startTurnCards), effect: .drawDeck), ctx: EffectContext(actor: "p1", card: .drawOnSetTurn, event: .setTurn("p1")))),
.discardInPlay(.jail, player: "p1"),
.setTurn("p2")]
Expand Down
2 changes: 1 addition & 1 deletion GameKit/Tests/InventoryTests/Figures/JourdonnaisSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class JourdonnaisSpec: QuickSpec {
// Then
expect(result) == [
.playImmediate(.bang, target: "p2", player: "p1"),
.putTopDeckToDiscard,
.draw,
.cancel(.damage(1, player: "p2"))
]
}
Expand Down

0 comments on commit 21d04b2

Please sign in to comment.