public void Ctor_Player1Raises123_Player1Raise123() { var instruction = new ActionInstruction(PlayerName.player1, GameAction.Raise(123)); var act = instruction.ToString(); var exp = "player1 raise 123"; Assert.AreEqual(exp, act); }
public void Ctor_Player1Call_Player1Call0() { var instruction = new ActionInstruction(PlayerName.player1, GameAction.Call); var act = instruction.ToString(); var exp = "player1 call 0"; Assert.AreEqual(exp, act); }
public void Ctor_Player1Fold_Player1Fold0() { var instruction = new ActionInstruction(PlayerName.player1, GameAction.Fold); var act = instruction.ToString(); var exp = "player1 fold 0"; Assert.AreEqual(exp, act); }
public void Ctor_Player2Check_Playe2Check0() { var instruction = new ActionInstruction(PlayerName.player2, GameAction.Check); var act = instruction.ToString(); var exp = "player2 check 0"; Assert.AreEqual(exp, act); }
public void Act(ActionInstruction instruction) { var action = instruction.Value; if (action.ActionType == GameActionType.call || action.ActionType == GameActionType.raise) { var amountToCall = this[instruction.Name].GetAmountToCall(this[instruction.Name.Other()]); if (amountToCall > 0) { this[instruction.Name].Call(amountToCall); } } this[instruction.Name].Act(action); }
internal static IInstruction Parse(PlayerName name, string[] splitted) { if (splitted.Length != 3) { return(null); } switch (splitted[1].ToUpperInvariant()) { case "STACK": return(StackInstruction.Parse(name, splitted)); case "POST": return(PostInstruction.Parse(name, splitted)); case "HAND": return(HandInstruction.Parse(name, splitted)); case "FOLD": case "CALL": case "CHECK": case "RAISE": return(ActionInstruction.Parse(name, splitted)); case "WINS": return(WinsInstruction.Parse(name, splitted)); } return(null); }
private void SendAction(ActionInstruction action) { this.log.AddAction(action); switch (action.Operation) { case ActionInstruction.OperationTypes.AcceptTrade: { this.GameController.AcceptDirectTradeOffer(this.playerIdsByName[(string)action.Parameters[0]]); break; } case ActionInstruction.OperationTypes.AnswerDirectTradeOffer: { this.GameController.AnswerDirectTradeOffer((ResourceClutch)action.Parameters[0]); break; } case ActionInstruction.OperationTypes.BuyDevelopmentCard: { this.GameController.BuyDevelopmentCard(); break; } case ActionInstruction.OperationTypes.ChooseResourcesToLose: { this.GameController.ChooseResourcesToLose((ResourceClutch)action.Parameters[0]); break; } case ActionInstruction.OperationTypes.ConfirmStart: { this.GameController.ConfirmStart(); break; } case ActionInstruction.OperationTypes.EndOfTurn: { this.GameController.EndTurn(); break; } case ActionInstruction.OperationTypes.MakeDirectTradeOffer: { this.GameController.MakeDirectTradeOffer((ResourceClutch)action.Parameters[0]); break; } case ActionInstruction.OperationTypes.PlaceCity: { this.GameController.PlaceCity((uint)action.Parameters[0]); break; } case ActionInstruction.OperationTypes.PlaceRoadSegment: { this.GameController.PlaceRoadSegment((uint)action.Parameters[0], (uint)action.Parameters[1]); break; } case ActionInstruction.OperationTypes.PlaceRobber: { this.GameController.PlaceRobber((uint)action.Parameters[0]); break; } case ActionInstruction.OperationTypes.PlaceSettlement: { this.GameController.PlaceSettlement((uint)action.Parameters[0]); break; } case ActionInstruction.OperationTypes.PlaceStartingInfrastructure: { this.GameController.PlaceSetupInfrastructure((uint)action.Parameters[0], (uint)action.Parameters[1]); break; } case ActionInstruction.OperationTypes.PlayKnightCard: { this.GameController.PlayKnightCard((uint)action.Parameters[0]); break; } case ActionInstruction.OperationTypes.PlayMonopolyCard: { this.GameController.PlayMonopolyCard((ResourceTypes)action.Parameters[0]); break; } case ActionInstruction.OperationTypes.PlayRoadBuildingCard: { this.GameController.PlayRoadBuildingCard( (uint)action.Parameters[0], (uint)action.Parameters[1], (uint)action.Parameters[2], (uint)action.Parameters[3]); break; } case ActionInstruction.OperationTypes.PlayYearOfPlentyCard: { this.GameController.PlayYearOfPlentyCard((ResourceTypes)action.Parameters[0], (ResourceTypes)action.Parameters[1]); break; } case ActionInstruction.OperationTypes.RequestState: { this.GameController.RequestState(); break; } case ActionInstruction.OperationTypes.QuitGame: { this.GameController.QuitGame(); break; } case ActionInstruction.OperationTypes.SelectResourceFromPlayer: { this.GameController.SelectResourceFromPlayer(this.playerIdsByName[(string)action.Parameters[0]]); break; } default: throw new Exception($"Operation '{action.Operation}' not recognised"); } }
public void AddAction(ActionInstruction action) => this.logEvents.Add(new ActionEvent(action));