Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
stephtelolahy committed Jan 6, 2025
1 parent 6c6ae41 commit b3869dc
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1620"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SettingsData"
BuildableName = "SettingsData"
BlueprintName = "SettingsData"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SettingsData"
BuildableName = "SettingsData"
BlueprintName = "SettingsData"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
35 changes: 0 additions & 35 deletions WildWestOnline/Core/Game/Sources/Reducer/GameReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ public func gameReducer(
return .none
}

return .group([
try prepareReducer(state: &state, action: action),
try updateReducer(state: &state, action: action),
try triggerEffectsReducer(state: &state, action: action),
try playAIMoveReducer(state: &state, action: action)
])
}

private func prepareReducer(
state: inout GameState,
action: GameAction
) throws -> Effect {
guard !state.isOver else {
fatalError("Unexpected game is over")
}
Expand All @@ -44,13 +32,6 @@ private func prepareReducer(
state.active.removeValue(forKey: action.payload.target)
}

return .none
}

private func updateReducer(
state: inout GameState,
action: GameAction
) throws -> Effect {
if action.payload.selectors.isNotEmpty {
if state.pendingChoice != nil {
fatalError("Unexpected waiting user choice")
Expand All @@ -67,19 +48,3 @@ private func updateReducer(

return .none
}

private func triggerEffectsReducer(
state: inout GameState,
action: GameAction
) throws -> Effect {
// TODO: triggered effects
.none
}

private func playAIMoveReducer(
state: inout GameState,
action: GameAction
) throws -> Effect {
// TODO: AI moves
.none
}
4 changes: 1 addition & 3 deletions WildWestOnline/Core/Game/Tests/CreateGameStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import Redux
import GameCore

typealias GameStore = Store<GameState, Void>

@MainActor func createGameStore(initialState: GameState) -> GameStore {
@MainActor func createGameStore(initialState: GameState) -> Store<GameState, Void> {
.init(
initialState: initialState,
reducer: gameReducer,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// CreateGameStoreWithSideEffects.swift
// WildWestOnline
//
// Created by Hugues Stephano TELOLAHY on 06/01/2025.
//

import Redux
import GameCore

@MainActor func createGameStoreWithSideEffects(initialState: GameState) -> Store<GameState, Void> {
.init(
initialState: initialState,
reducer: gameReducer,
dependencies: ()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Serialization
import SettingsCore

public class SettingsRepository: SettingsService {
public class SettingsRepository {
public init() {}

@UserDefaultsStored("settings.playersCount", defaultValue: 5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct StoreProjectionTest {
)

let connector = SearchView.Connector()
let sut: SearchView.ViewModel = await store.projection(deriveState: connector.deriveState)
let sut = await store.projection(deriveState: connector.deriveState)

// When
await sut.dispatch(AppAction.fetchRecent)
Expand All @@ -42,9 +42,8 @@ private struct SearchView: View {
struct State: Equatable {
let items: [String]
}

typealias ViewModel = Store<State, Void>
@ObservedObject var store: ViewModel

@ObservedObject var store: Store<State, Void>
@SwiftUI.State var query: String = ""

var body: some View {
Expand Down

0 comments on commit b3869dc

Please sign in to comment.