Skip to content

Remove First player setting / green switch when changing round counter #117

@pakirby1

Description

@pakirby1

When the round counter is changed:

  1. for each squad
  2. set first player to false
    1. Redux_SquadView.setFirstPlayer(false)
  3. for each pilot in squad
    1. set the system phase option to false (Redux_PilotCardView.setSystemPhaseState(false))
Redux_SquadView

func setFirstPlayer(_ isFirstPlayer: Bool) {
        // Mutate & Persist
        self.squadData.firstPlayer = isFirstPlayer
        self.updateSquad(squadData: self.squadData)
        
        // Update the local @State
        self.isFirstPlayer = isFirstPlayer
    }
Redux_PilotCardView

func setSystemPhaseState(state: Bool) {
        measure(name: "setSystemPhaseState(state:\(state)") {
            if let data = shipPilot.pilotStateData {
                let name = shipPilot.pilotName
                data.change(update: { psd in
                    
                    print("Redux_PilotCardView.setSystemPhaseState name: \(name) state: \(state)")

                    psd.hasSystemPhaseAction = state
//
                    self.store.send(.squad(action: .updatePilotState(psd, self.shipPilot.pilotState)))

    //                self.store.send(.squad(action: .updatePilotState($0, self.shipPilot.pilotState)))
                    print("Redux_PilotCardView $0.hasSystemPhaseAction = \(String(describing: psd.hasSystemPhaseAction))")
                })
            }
        }
    }
Redux_SquadViewNew

.onChange(of: isFirstPlayer, perform: {
            // Hack because swift thinks I don't want to perform
            // an assignment (=) vs. a boolean check (==)
            let x = $0
            self.squadData.firstPlayer = x
            self.updateSquad(squadData: self.squadData)
        })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions