public CheckMovesResult CheckRule(CheckMovesResult result) { // get players on board var ownFigures = nvp_RuleHelper.GetFiguresOnBoardByColor(result.PlayerColor, result.PlayerFigures, result.DiceValue); ownFigures = ownFigures.Where(x => x.LocalPosition < 40).ToList(); if (ownFigures.Count == 0) { return(_nextRule.CheckRule(result)); } if (ownFigures.Count > 1) { var haveToKill = false; haveToKill |= CheckRuleForFigure(result, ownFigures[0]); haveToKill |= CheckRuleForFigure(result, ownFigures[1]); if (haveToKill) { return(result); } } return(_nextRule.CheckRule(result)); }
public CheckMovesResult CheckRule(CheckMovesResult result) { if (!nvp_RuleHelper.IsLocalPositionAvailable(result.PlayerColor, result.PlayerFigures, 0)) { if (nvp_RuleHelper.CanExitStart(result.PlayerColor, result.PlayerFigures, result.DiceValue)) { var pf = nvp_RuleHelper.GetPlayerFigureFromByLocalPosition(result.PlayerColor, result.PlayerFigures, 0); result.CanMove = true; result.LastActiveRule = "Must Leave Start"; var pm = new PlayerMove { Color = result.PlayerColor, Index = pf.Index, DiceValue = result.DiceValue }; result.PossibleMoves = new List <PlayerMove> { pm }; return(result); } else { result.CanMove = false; result.AdditionalRollGranted = false; result.LastActiveRule = "Must Leave Start"; return(result); } } else { return(_nextRule.CheckRule(result)); } }
public CheckMovesResult CheckRule(CheckMovesResult result) { // no player figure is on the game field which means no player figure has movepoint score between 0 and up to 40 var numberOfFiguresOnBoard = nvp_RuleHelper.CountPlayersOnBoard(result.PlayerColor, result.PlayerFigures); // at least on player figure is in the house var numberOfPlayerInTheHouse = nvp_RuleHelper.CountPlayersInHouse(result.PlayerColor, result.PlayerFigures); // general rule if (numberOfPlayerInTheHouse == 0 || result.DiceValue < 6) { return(_nextRule.CheckRule(result)); } // get figure to move var pf = result.PlayerFigures .Where(x => x.LocalPosition < 0 && x.Color == result.PlayerColor) .OrderBy(x => x.Index) .First(); result.CanMove = true; result.AdditionalRollGranted = true; result.LastActiveRule = "Must leave house"; result.PossibleMoves.Add(new PlayerMove { Color = result.PlayerColor, Index = nvp_RuleHelper.GetNextFigureToLeaveHouse(result.PlayerColor, result.PlayerFigures).Index, DiceValue = 0 }); return(result); }
public CheckMovesResult CheckRule(PlayerColors playerColor, List <PlayerFigure> playerFigures, int diceNumber) { if (nvp_RuleHelper.IsFieldOccupiedByOwnFigure(playerColor, playerFigures, 0)) { if (nvp_RuleHelper.CanExitStart(playerColor, playerFigures, diceNumber)) { var pf = nvp_RuleHelper.GetPlayerFigureOnField(playerColor, playerFigures, 0); var result = new CheckMovesResult(true, false, ""); var pm = new PlayerMove(); pm.Color = playerColor; pm.Index = pf.Index; pm.MovePoints = diceNumber; result.PossibleMoves = new List <PlayerMove>(); result.PossibleMoves.Add(pm); return(result); } else { var result = new CheckMovesResult(false, false, ""); return(result); } } else { return(_nextRule.CheckRule(playerColor, playerFigures, diceNumber)); } }
public CheckMovesResult CheckRule(PlayerColors playerColor, List <PlayerFigure> playerFigures, int diceValue) { CheckMovesResult result = null; // no player figure is on the game field which means no player figure has movepoint score between 0 and up to 40 var numberOfFiguresOnBoard = nvp_RuleHelper.CountPlayersOnBoard(playerColor, playerFigures); // at least on player figure is in the house var numberOfPlayerInTheHouse = nvp_RuleHelper.CountPlayersInHouse(playerColor, playerFigures); // general rule if (numberOfPlayerInTheHouse == 0 || diceValue < 6) { return(_nextRule.CheckRule(playerColor, playerFigures, diceValue)); } result = new CheckMovesResult(true, true, "nvp_Rule_6_all_in_house_class: move out"); // get figure to move var pf = playerFigures.Single(x => x.Index == 0 && x.Color == playerColor); // enlist the move for display result.PossibleMoves = new List <PlayerMove>(); var move = new PlayerMove(); move.Color = playerColor; move.Index = nvp_RuleHelper.GetNextFigureToLeaveHouse(playerColor, playerFigures).Index; move.MovePoints = 0; move.GameBoardLocation = pf.OffSet; result.PossibleMoves.Add(move); return(result); }
public CheckMovesResult CheckRule(CheckMovesResult result) { // get players on board var playerFigures = nvp_RuleHelper.GetFiguresOnBoardByColor(result.PlayerColor, result.PlayerFigures, result.DiceValue); if (playerFigures.Count == 0) { return(_nextRule.CheckRule(result)); } for (int i = 0, n = playerFigures.Count; i < n; i++) { var pf = playerFigures[i]; if (pf.LocalPosition + result.DiceValue < 45) { result.CanMove = true; result.LastActiveRule = "JustMove"; result.PossibleMoves.Add(new PlayerMove { Color = result.PlayerColor, DiceValue = result.DiceValue, Index = pf.Index }); } } result.PossibleMoves = result.PossibleMoves.OrderBy(x => x.Index).ToList(); return(result); }
public CheckMovesResult CheckRule(CheckMovesResult result) { if (result.DiceValue == 6) { result.AdditionalRollGranted = true; } return(_nextRule.CheckRule(result)); }
public CheckMovesResult CheckRule(CheckMovesResult result) { // no player figure is on the game field which means no player figure has movepoint score between 0 and up to 40 var numberOfFiguresOnBoard = nvp_RuleHelper.CountPlayersOnBoard(result.PlayerColor, result.PlayerFigures); // at least on player figure is in the house var numberOfPlayerInTheHouse = nvp_RuleHelper.CountPlayersInHouse(result.PlayerColor, result.PlayerFigures); // general rule if (numberOfFiguresOnBoard > 0 || numberOfPlayerInTheHouse == 0) { return(_nextRule.CheckRule(result)); } _numberOfTries++; if (_numberOfTries >= 3 && result.DiceValue < 6) { // used all free rolls result.LastActiveRule = "nvp_Rule_40_Cant_leave_house_class"; result.CanMove = false; result.AdditionalRollGranted = false; _numberOfTries = 0; return(result); } if (result.DiceValue == 6) { result.LastActiveRule = "nvp_Rule_40_Cant_leave_house_class"; result.CanMove = true; result.AdditionalRollGranted = true; _numberOfTries = 0; return(result); } else { result.CanMove = false; result.AdditionalRollGranted = true; result.LastActiveRule = "nvp_Rule_40_Cant_leave_house_class"; return(result); } }
private ResponseCode Validate(Team team, Point pos) { if (PlayerTurn != team) { return(ResponseCode.WrongTurn); } if (_controller.IsOutOfRange(pos)) { return(ResponseCode.PointOutOfRange); } if (!_rule.CheckRule(TurnNumber, pos)) { return(ResponseCode.RuleViolation); } if (_controller.GetPos(pos) != Team.None) { return(ResponseCode.PointOccupied); } return(ResponseCode.OK); }
public CheckMovesResult CheckRule(PlayerColors playerColor, List <PlayerFigure> playerFigures, int diceNumber) { // no player figure is on the game field which means no player figure has movepoint score between 0 and up to 40 var numberOfFiguresOnBoard = nvp_RuleHelper.CountPlayersOnBoard(playerColor, playerFigures); // at least on player figure is in the house var numberOfPlayerInTheHouse = nvp_RuleHelper.CountPlayersInHouse(playerColor, playerFigures); // general rule if (numberOfFiguresOnBoard > 0 || numberOfPlayerInTheHouse == 0) { return(_nextRule.CheckRule(playerColor, playerFigures, diceNumber)); } CheckMovesResult result = null; _numberOfTries++; if (_numberOfTries >= 3 && diceNumber < 6) { // used all free rolls result = new CheckMovesResult(false, false, "nvp_Rule_5to1_all_in_house_class"); _numberOfTries = 0; return(result); } if (diceNumber == 6) { result = new CheckMovesResult(true, true, "nvp_Rule_5to1_all_in_house_class"); _numberOfTries = 0; return(result); } else { result = new CheckMovesResult(false, true, "nvp_Rule_5to1_all_in_house_class"); return(result); } }