Skip to content

Commit f5ce909

Browse files
committed
update
1 parent 317f3bd commit f5ce909

File tree

13 files changed

+95
-107
lines changed

13 files changed

+95
-107
lines changed

Modules/CardLibraryLive/Sources/Modifiers/IgnoreLimitPerTurn.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
@testable import GameCore
99

10-
extension Card.QueueModifier {
11-
static let ignoreLimitPerTurn = Card.QueueModifier(rawValue: "ignoreLimitPerTurn")
10+
extension Card.ModifierName {
11+
static let ignoreLimitPerTurn = Card.ModifierName(rawValue: "ignoreLimitPerTurn")
1212
}
1313

1414
struct IgnoreLimitPerTurn: QueueModifierHandler {
15-
static let id = Card.QueueModifier.ignoreLimitPerTurn
15+
static let name = Card.ModifierName.ignoreLimitPerTurn
1616

1717
static func apply(_ action: GameFeature.Action, state: GameFeature.State) throws(GameFeature.Error) -> [GameFeature.Action] {
1818
guard let playIndex = state.queue.firstIndex(where: {

Modules/CardLibraryLive/Sources/Modifiers/IncrementCardsPerTurn.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
@testable import GameCore
99

10-
extension Card.QueueModifier {
11-
static let incrementCardsPerTurn = Card.QueueModifier(rawValue: "incrementCardsPerTurn")
10+
extension Card.ModifierName {
11+
static let incrementCardsPerTurn = Card.ModifierName(rawValue: "incrementCardsPerTurn")
1212
}
1313

1414
struct IncrementCardsPerTurn: QueueModifierHandler {
15-
static let id = Card.QueueModifier.incrementCardsPerTurn
15+
static let name = Card.ModifierName.incrementCardsPerTurn
1616

1717
static func apply(_ action: GameFeature.Action, state: GameFeature.State) throws(GameFeature.Error) -> [GameFeature.Action] {
1818
guard let amount = action.amount else { fatalError("Missing amount") }

Modules/CardLibraryLive/Sources/Modifiers/IncrementRequiredMisses.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
@testable import GameCore
99

10-
extension Card.QueueModifier {
11-
static let incrementRequiredMisses = Card.QueueModifier(rawValue: "incrementRequiredMisses")
10+
extension Card.ModifierName {
11+
static let incrementRequiredMisses = Card.ModifierName(rawValue: "incrementRequiredMisses")
1212
}
1313

1414
struct IncrementRequiredMisses: QueueModifierHandler {
15-
static let id = Card.QueueModifier.incrementRequiredMisses
15+
static let name = Card.ModifierName.incrementRequiredMisses
1616

1717
static func apply(_ action: GameFeature.Action, state: GameFeature.State) throws(GameFeature.Error) -> [GameFeature.Action] {
1818
guard let amount = action.amount else { fatalError("Missing amount") }

Modules/CardLibraryLive/Tests/SimulationTest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct SimulationTest {
3333
initialState: state,
3434
reducer: GameFeature.reducer,
3535
withDependencies: {
36-
$0.queueModifierClient = .live(handlers: QueueModifiers.allHandlers)
36+
$0 = dependencies
3737
}
3838
)
3939

@@ -55,7 +55,7 @@ struct SimulationTest {
5555
.sink {
5656
print($0)
5757
var nextState = prevState
58-
_ = GameFeature.reducerMechanics(into: &nextState, action: $0, dependencies: dependencies)
58+
_ = GameFeature.reducerMain(into: &nextState, action: $0, dependencies: dependencies)
5959
#expect(nextState == currentState, "Inconsistent state after applying \($0)")
6060
}
6161
.store(in: &cancellables)

Modules/GameCore/Sources/Card.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public struct Card: Equatable, Sendable {
3636
public struct Effect: Equatable, Sendable {
3737
public let trigger: Trigger
3838
public let action: ActionName
39-
public let modifier: QueueModifier?
39+
public let modifier: ModifierName?
4040
public let amount: Int?
4141
public let amountPerTurn: [String: Int]?
4242
public let alias: [String: String]?
@@ -45,7 +45,7 @@ public struct Card: Equatable, Sendable {
4545
public init(
4646
trigger: Trigger,
4747
action: ActionName,
48-
modifier: QueueModifier? = nil,
48+
modifier: ModifierName? = nil,
4949
amount: Int? = nil,
5050
amountPerTurn: [String: Int]? = nil,
5151
alias: [String: String]? = nil,
@@ -214,7 +214,7 @@ public struct Card: Equatable, Sendable {
214214
}
215215
}
216216

217-
public struct QueueModifier: RawRepresentable, Hashable, Sendable {
217+
public struct ModifierName: RawRepresentable, Hashable, Sendable {
218218
public let rawValue: String
219219

220220
public init (rawValue: String) {

Modules/GameCore/Sources/GameFeature.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public enum GameFeature {
6262
var selection: String?
6363
var alias: String?
6464
var playableCards: [String]?
65-
var modifier: Card.QueueModifier?
65+
var modifier: Card.ModifierName?
6666
var children: [Self]?
6767
var selectors: [Card.Selector] = []
6868

@@ -85,9 +85,8 @@ public enum GameFeature {
8585

8686
public static var reducer: Reducer<State, Action> {
8787
combine(
88-
reducerMechanics,
89-
reducerLoop,
90-
reducerAI
88+
reducerMain,
89+
reducerLoop
9190
)
9291
}
9392
}

Modules/GameCore/Sources/QueueModifierClient/QueueModifierClient+Live.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public extension QueueModifierClient {
1515
}
1616

1717
struct QueueModifierRegistry {
18-
let dictionary: [Card.QueueModifier: QueueModifierHandler.Type]
18+
let dictionary: [Card.ModifierName: QueueModifierHandler.Type]
1919

2020
init(handlers: [QueueModifierHandler.Type]) {
21-
var dict: [Card.QueueModifier: QueueModifierHandler.Type] = [:]
21+
var dict: [Card.ModifierName: QueueModifierHandler.Type] = [:]
2222
for type in handlers {
23-
dict[type.id] = type
23+
dict[type.name] = type
2424
}
2525
dictionary = dict
2626
}
@@ -34,7 +34,7 @@ struct QueueModifierRegistry {
3434
}
3535

3636
public protocol QueueModifierHandler {
37-
static var id: Card.QueueModifier { get }
37+
static var name: Card.ModifierName { get }
3838

3939
static func apply(_ action: GameFeature.Action, state: GameFeature.State) throws(GameFeature.Error) -> [GameFeature.Action]
4040
}

0 commit comments

Comments
 (0)