Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observation #200

Merged
merged 65 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
c8ded4e
Bump
stephencelis Dec 7, 2023
bf0c97a
wip
stephencelis Dec 7, 2023
84fb895
wip
stephencelis Dec 7, 2023
7a12f8b
wip
stephencelis Dec 8, 2023
e67c0c9
wip
stephencelis Dec 8, 2023
5b24ecf
wip
stephencelis Dec 8, 2023
015932b
wip
stephencelis Dec 8, 2023
57d676d
wip
stephencelis Dec 8, 2023
816d53f
wip
stephencelis Dec 8, 2023
286618f
wip
stephencelis Dec 8, 2023
49df034
wip
stephencelis Dec 8, 2023
0c5270b
wip
stephencelis Dec 8, 2023
852d16c
wip
stephencelis Dec 8, 2023
39c9bb7
wip
stephencelis Dec 8, 2023
19c35f6
wip
stephencelis Dec 8, 2023
fda7be3
wip
stephencelis Dec 8, 2023
3e5a8aa
wip
stephencelis Dec 8, 2023
810fcf3
wip
stephencelis Dec 8, 2023
0932033
wip
stephencelis Dec 8, 2023
4db019c
wip
stephencelis Dec 8, 2023
7b9ae18
wip
stephencelis Dec 8, 2023
70b7e3b
wip
stephencelis Dec 8, 2023
d7da8fc
wip
stephencelis Dec 8, 2023
27e4812
wip
stephencelis Dec 8, 2023
efa9f2b
wip
stephencelis Dec 8, 2023
716bf9c
wip
stephencelis Dec 8, 2023
0aaa62e
wip
stephencelis Dec 8, 2023
7e009ff
wip
stephencelis Dec 8, 2023
de50bc5
wip
stephencelis Dec 8, 2023
319387e
wip
stephencelis Dec 8, 2023
c2f288f
wip
stephencelis Dec 8, 2023
be08617
wip
stephencelis Dec 8, 2023
8abe58f
wip
stephencelis Dec 8, 2023
4a1b154
Merge remote-tracking branch 'origin/main' into observation-beta
stephencelis Dec 8, 2023
f59b3de
wip
stephencelis Dec 8, 2023
e57166f
wip
stephencelis Dec 9, 2023
8a8ff1f
wip
stephencelis Dec 9, 2023
a34be6f
wip
stephencelis Dec 9, 2023
380ce12
wip
stephencelis Dec 9, 2023
eb75020
wip
stephencelis Dec 9, 2023
2fc8dc6
wip
stephencelis Dec 9, 2023
5233f32
wip
stephencelis Dec 9, 2023
cf5f10e
wip
stephencelis Dec 9, 2023
eab3475
wip
stephencelis Dec 9, 2023
2a30738
wip
stephencelis Dec 9, 2023
0740836
wip
stephencelis Dec 9, 2023
db145d3
wip
stephencelis Dec 9, 2023
fa6251d
wip
stephencelis Dec 9, 2023
fd47050
wip
stephencelis Dec 9, 2023
29fae99
Merge branch 'main' into observation-beta
stephencelis Jan 10, 2024
7199286
wip
stephencelis Jan 10, 2024
bc41412
wip
stephencelis Jan 25, 2024
cee0c1c
Merge remote-tracking branch 'origin/main' into observation-beta
stephencelis Jan 25, 2024
098df9f
wip
stephencelis Jan 25, 2024
03716cf
wip
stephencelis Jan 25, 2024
d39632d
Remove firstLaunchOnboarding (#198)
imjn Jan 25, 2024
07e5628
Merge remote-tracking branch 'origin/main' into observation-beta
mbrandonw Apr 7, 2024
beeda8f
use enum reducers
mbrandonw Apr 7, 2024
29d1884
fix some warnings
mbrandonw Apr 7, 2024
b93b94c
udpate last destination reducer
mbrandonw Apr 8, 2024
b9d6bed
ignore some errors
mbrandonw Apr 8, 2024
dae32ea
wip
mbrandonw Apr 9, 2024
ba30ab2
wip
stephencelis Apr 9, 2024
9af2a17
wip
stephencelis Apr 9, 2024
f68c1cd
wip
stephencelis Apr 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
udpate last destination reducer
  • Loading branch information
mbrandonw committed Apr 8, 2024
commit b93b94c1a3b104faaa79f99d50ea1547f2725316
73 changes: 25 additions & 48 deletions Sources/GameCore/GameCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ClientModels
import ComposableArchitecture
import ComposableGameCenter
import CubeCore
import Dependencies
import DictionaryClient
import GameOverFeature
import HapticsCore
Expand All @@ -20,51 +21,26 @@ import UserSettingsClient

@Reducer
public struct Game {
@Reducer
public struct Destination {
@ObservableState
public enum State: Equatable {
case alert(AlertState<Action.Alert>)
case bottomMenu(BottomMenuState<Action.BottomMenu>)
case gameOver(GameOver.State)
case settings(Settings.State = Settings.State())
case upgradeInterstitial(UpgradeInterstitial.State = .init())
@Reducer(state: .equatable)
public enum Destination {
case alert(AlertState<Alert>)
@ReducerCaseEphemeral
case bottomMenu(BottomMenuState<BottomMenu>)
case gameOver(GameOver)
case settings(Settings)
case upgradeInterstitial(UpgradeInterstitial)

@CasePathable
public enum Alert {
case forfeitButtonTapped
}

public enum Action {
case alert(Alert)
case bottomMenu(BottomMenu)
case gameOver(GameOver.Action)
case settings(Settings.Action)
case upgradeInterstitial(UpgradeInterstitial.Action)

@CasePathable
public enum Alert {
case forfeitButtonTapped
}
@CasePathable
public enum BottomMenu: Equatable {
case confirmRemoveCube(LatticePoint)
case endGameButtonTapped
case exitButtonTapped
case forfeitGameButtonTapped
case settingsButtonTapped
}
}

let dismissGame: DismissEffect

public var body: some ReducerOf<Self> {
Scope(state: \.gameOver, action: \.gameOver) {
GameOver()
.dependency(\.dismiss, self.dismissGame)
}
Scope(state: \.settings, action: \.settings) {
Settings()
}
Scope(state: \.upgradeInterstitial, action: \.upgradeInterstitial) {
UpgradeInterstitial()
}
@CasePathable
public enum BottomMenu: Equatable {
case confirmRemoveCube(LatticePoint)
case endGameButtonTapped
case exitButtonTapped
case forfeitGameButtonTapped
case settingsButtonTapped
}
}

Expand Down Expand Up @@ -220,7 +196,8 @@ public struct Game {
}
.filterActionsForYourTurn()
.ifLet(\.$destination, action: \.destination) {
Destination(dismissGame: self.dismiss)
Destination.body
.dependency(\.dismissGame, self.dismiss)
}
.sounds()
}
Expand All @@ -241,7 +218,7 @@ public struct Game {
return .none

case .delayedShowUpgradeInterstitial:
state.destination = .upgradeInterstitial()
state.destination = .upgradeInterstitial(UpgradeInterstitial.State())
return .none

case .destination(.presented(.alert(.forfeitButtonTapped))):
Expand Down Expand Up @@ -301,7 +278,7 @@ public struct Game {
return .none

case .destination(.presented(.bottomMenu(.settingsButtonTapped))):
state.destination = .settings()
state.destination = .settings(Settings.State())
return .none

case let .destination(.presented(.gameOver(.delegate(.startGame(inProgressGame))))):
Expand Down Expand Up @@ -572,7 +549,7 @@ extension TurnBasedMatchData {
}
}

extension BottomMenuState where Action == Game.Destination.Action.BottomMenu {
extension BottomMenuState where Action == Game.Destination.BottomMenu {
public static func removeCube(
index: LatticePoint,
state: Game.State,
Expand Down
15 changes: 15 additions & 0 deletions Sources/GameOverFeature/DismissGame.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import ComposableArchitecture
import Dependencies

private enum DismissGameKey: DependencyKey {
static var liveValue: DismissEffect {
@Dependency(\.dismiss) var dismiss
return dismiss
}
}
extension DependencyValues {
public var dismissGame: DismissEffect {
get { self[DismissGameKey.self] }
set { self[DismissGameKey.self] = newValue }
}
}
10 changes: 5 additions & 5 deletions Sources/GameOverFeature/GameOverView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public struct GameOver {
@Dependency(\.apiClient) var apiClient
@Dependency(\.audioPlayer) var audioPlayer
@Dependency(\.database) var database
@Dependency(\.dismiss) var dismiss
@Dependency(\.dismissGame) var dismissGame
@Dependency(\.fileClient) var fileClient
@Dependency(\.mainRunLoop) var mainRunLoop
@Dependency(\.storeKit.requestReview) var requestReview
Expand All @@ -148,7 +148,7 @@ public struct GameOver {
else {
return .run { send in
try? await self.requestReviewAsync()
await self.dismiss(animation: .default)
await self.dismissGame(animation: .default)
}
}

Expand Down Expand Up @@ -208,14 +208,14 @@ public struct GameOver {
where state.destination.is(\.some.notificationsAuthAlert):
return .run { _ in
try? await self.requestReviewAsync()
await self.dismiss(animation: .default)
await self.dismissGame(animation: .default)
}

case .destination(
.presented(.notificationsAuthAlert(.delegate(.didChooseNotificationSettings)))
):
return .run { _ in
await self.dismiss(animation: .default)
await self.dismissGame(animation: .default)
}

case .destination:
Expand Down Expand Up @@ -276,7 +276,7 @@ public struct GameOver {
return .run { [completedGame = state.completedGame, isDemo = state.isDemo] send in
guard isDemo || completedGame.currentScore > 0
else {
await self.dismiss(animation: .default)
await self.dismissGame(animation: .default)
return
}

Expand Down
Loading