/// <summary> /// Indicates that one or more policies were selected by the client asked to select policies. /// </summary> /// <param name="policies">The selected policies.</param> public async Task PoliciesSelected(IEnumerable <PolicyType> policies) { var myPolicies = policies.ToList(); switch (GameData.MachineState) { case StateMachineState.AwaitingEnactedPolicy: // TODO Validate policy was actually drawn, delivered by correct player if (myPolicies.Count != Constants.ChancellorPolicySelectionCount) { throw new GameStateException("Too many policies selected for the current game state."); } var policy = myPolicies.First(); if (policy == PolicyType.None) { if (!AllowVetoes) { throw new GameStateException("Currently not eligible to veto policies."); } await Director.Broadcast("A veto has been requested."); GameData.MachineState = StateMachineState.AwaitingVetoResponse; await Director.ApproveVeto(GameData.President); return; } foreach (var p in myPolicies) { GameData.DrawnPolicies.Remove(p); } PolicyDeck.Discard(GameData.DrawnPolicies); GameData.DrawnPolicies = null; if (policy == PolicyType.Fascist) { await Director.Broadcast("A fascist policy has been enacted!"); GameData.EnactedFascistPolicyCount++; await DisseminateGameData(); if (InvokeCurrentPresidentialPower()) { return; } } else if (policy == PolicyType.Liberal) { await Director.Broadcast("A liberal policy has been enacted!"); GameData.EnactedLiberalPolicyCount++; } await PrepareNextElection(); break; case StateMachineState.AwaitingPresidentialPolicies: // TODO Validate policy was actually drawn, delivered by correct player // TODO Test me. if (myPolicies.Count != Constants.PresidentialPolicyPassCount) { throw new GameStateException("Too many/few policies selected for the current game state."); } foreach (var p in myPolicies) { GameData.DrawnPolicies.Remove(p); } PolicyDeck.Discard(GameData.DrawnPolicies); GameData.DrawnPolicies = policies.ToList(); await Director.Broadcast("The president has offered policies to the chancellor."); GameData.MachineState = StateMachineState.AwaitingEnactedPolicy; await Director.GetEnactedPolicy(GameData.Chancellor, policies, AllowVetoes); break; default: throw new GameStateException($"{nameof(PoliciesSelected)} called for invalid state {GameData.MachineState}."); } }