Exemple #1
0
 public void AddMove(Move move)
 {
     IsLastMoveMonomino = move.PieceVariant.Squares.Length == 1;
     Board.PlacePiece(move, CurrentPlayerColor);
     CurrentPlayerHand.Remove(move);
     AllMoves.Add(move);
 }
        public static IEnumerable <string> GetAllInitials()
        {
            var initialMoveList = new List <string>();

            AllMoves.ForEach(move => initialMoveList.Add(move.InitialMove));
            return(initialMoveList);
        }
 public void RecordMoves(IEnumerable <Move> moves)
 {
     foreach (Move move in moves)
     {
         AllMoves.Add(move);
     }
 }
Exemple #4
0
        public void RecordMove(Move move)
        {
            Models.Utils.Log($"{_roundId}|{move.Player.Position}-{move.Player.Name} made a move:{move.Decision.DecisionType}-{move.Decision.ChipsAdded}");
            var decisionPlayer = Players.First(p => p.Equals(move.Player));

            if (move.Decision.DecisionType != DecisionType.Ante)
            {
                decisionPlayer.SetPolled();
            }

            decisionPlayer.ChipsBetByStage[StageEnum] += move.Decision.ChipsAdded;

            MostChipsBetByRound[StageEnum] = Players.Max(p => p.ChipsBetByStage[StageEnum]);

            switch (move.Decision.DecisionType)
            {
            case DecisionType.Raise:
            case DecisionType.Reraise:
                foreach (var player in Players)
                {
                    if (!player.Equals(decisionPlayer))
                    {
                        player.ResetPolled();
                    }
                }
                break;

            case DecisionType.Fold:
                decisionPlayer.Fold();
                break;

            case DecisionType.AllIn:
                decisionPlayer.AllIn();
                break;
            }

            AllMoves.Add(move);

            switch (StageEnum)
            {
            case StageEnum.Preflop:
                PreflopMoves.Add(move);
                break;

            case StageEnum.Flop:
                FlopMoves.Add(move);
                break;

            case StageEnum.Turn:
                TurnMoves.Add(move);
                break;

            case StageEnum.River:
                RiverMoves.Add(move);
                break;

            default:
                throw new InvalidOleVariantTypeException($"Move not accepted in {StageEnum}");
            }
        }
    public void HandleMove(AllMoves action)
    {
        switch (action)
        {
        case AllMoves.DoNothing:
            break;

        case AllMoves.Up:
            Position.x += 1;
            break;

        case AllMoves.Down:
            Position.x -= 1;
            break;

        case AllMoves.Left:
            Position.y -= 1;
            break;

        case AllMoves.Right:
            Position.y += 1;
            break;

        case AllMoves.UpLeft:
            Position.x += 1;
            Position.y -= 1;
            break;

        case AllMoves.UpRight:
            Position.x += 1;
            Position.y += 1;
            break;

        case AllMoves.DownLeft:
            Position.x -= 1;
            Position.y -= 1;
            break;

        case AllMoves.DownRight:
            Position.x -= 1;
            Position.y += 1;
            break;

        case AllMoves.PassTo1:
            GameSimulator.Ball.InPossession = GameSimulator.GetTeam(Team)[0];
            break;

        case AllMoves.PassTo2:
            GameSimulator.Ball.InPossession = GameSimulator.GetTeam(Team)[1];
            break;

        case AllMoves.PassTo3:
            GameSimulator.Ball.InPossession = GameSimulator.GetTeam(Team)[2];
            break;

        default:
            throw new ArgumentOutOfRangeException(nameof(action), action, null);
        }
    }
        public virtual void MoveBack()
        {
            if (AllMoves.Count == 0)
            {
                return;
            }

            var move = AllMoves.Last();

            PreviousPlayer = Players[currentPlayerIndex];
            currentPlayerIndex--;
            if (currentPlayerIndex < 0)
            {
                currentPlayerIndex = Players.Count - 1;
            }


            LastPlayerAction = PlayerAction.Nothing;


            PreviousSelectedPosition = new BoardPosition(move.to_x, move.to_y);
            CurrentSelectedPosition  = new BoardPosition(move.from_x, move.from_y, true);

            BoardKit.SetFigureOnBoard(CurrentSelectedPosition, BoardKit.GetFigureFromBoard(PreviousSelectedPosition));
            BoardKit.GetFigureFromBoard(CurrentSelectedPosition).Steps -= 2;

            var             chessFactory = new ChessItemModelFactory();
            IChessItemModel killed_chess;

            if (move.killed_isnull)
            {
                killed_chess = new NullChessItemModel();
            }
            else
            {
                killed_chess = chessFactory.CreateChessItemModel(new BoardPosition(move.killed_x, move.killed_y), move.killed_type, move.killed_steps, move.killed_side);
            }

            BoardKit.FiguresPlacement[PreviousSelectedPosition.horizontal, PreviousSelectedPosition.vertical] = killed_chess;

            IChessItemModel recoveryItem = null;

            if (!move.killed_isnull)
            {
                recoveryItem = ChessEngineFunctions.GetKilledChessItemFromMove(move, chessGameType);
                BoardKit.FiguresPlacement[move.killed_x, move.killed_y] = recoveryItem;
            }

            AllMoves.RemoveAt(AllMoves.Count - 1);
            LastPlayerAction = PlayerAction.Move;
            CurrentPlayer    = Players[currentPlayerIndex];
            OnChanged(this, new ChessSideArgs(move.side));

            if (!move.killed_isnull)
            {
                OnFigureRecovery(this, new ChessItemArgs(recoveryItem));
            }
        }
Exemple #7
0
 private Move(string name, Type type, MoveCategory category, int attackPower,
              Action <Pokémon, Pokémon> additionalEffects)
 {
     Name        = name;
     AttackType  = type;
     Category    = category;
     AttackPower = attackPower;
     AllMoves.Add(this);
 }
Exemple #8
0
        public void ApplyForcedMove()
        {
            if (!ApplyForcedMoves)
            {
                return;
            }
            var forcedMove = AllMoves.FirstOrDefault(move => move.IsForced());

            forcedMove?.Apply();
        }
        protected virtual void TryMove(bool backInTime = false, bool send_events = true)
        {
            BoardPosition   captureOnTheIsle;
            IChessItemModel killed_chess;
            bool            tryMoveResult = BoardKit.TryMoveChessItem(CurrentPlayer.Side, PreviousSelectedPosition, CurrentSelectedPosition, out captureOnTheIsle, out killed_chess);

            if (tryMoveResult)
            {
                AllMoves.Add(new FigureMove(PreviousSelectedPosition, CurrentSelectedPosition, killed_chess, CurrentPlayer.Side));

                PreviousPlayer = Players[currentPlayerIndex];
                if (++currentPlayerIndex >= Players.Count)
                {
                    currentPlayerIndex = 0;
                }
                CurrentPlayer = Players[currentPlayerIndex];
            }

            //If move is ready
            if (tryMoveResult)
            {
                var prev_item = BoardKit.GetFigureFromBoard(PreviousSelectedPosition);
                var curr_item = BoardKit.GetFigureFromBoard(CurrentSelectedPosition);


                if (!prev_item.IsNullObject && !curr_item.IsNullObject)
                {
                    LastPlayerAction = PlayerAction.Move;
                    if (send_events)
                    {
                        OnChanged_Invoke(PreviousPlayer.Side);
                    }
                }
                else
                {
                    LastPlayerAction = PlayerAction.MoveAndKill;
                    if (send_events)
                    {
                        OnChanged_Invoke(PreviousPlayer.Side);
                    }
                }

                CurrentSelectedPosition  = BoardPosition.None;
                PreviousSelectedPosition = BoardPosition.None;
                if (send_events)
                {
                    CheckForCheckAndMate(send_events);
                }
            }
            else
            {
                CurrentSelectedPosition  = PreviousSelectedPosition;
                PreviousSelectedPosition = BoardPosition.None;
            }
        }
Exemple #10
0
 private static IEnumerable <PBEMove> GetMovesWithoutFlag(PBEMoveFlag flag, PBEMoveEffect?exception = null)
 {
     return(AllMoves.Where(m =>
     {
         PBEMoveData mData = PBEMoveData.Data[m];
         if (!mData.IsMoveUsable())
         {
             return false;
         }
         if (exception.HasValue && mData.Effect == exception.Value)
         {
             return true;
         }
         return !mData.Flags.HasFlag(flag);
     }));
 }
Exemple #11
0
        public void RecordMove(Move move)
        {
            var decisionPlayer = Players.First(p => p.Equals(move.Player));

            if (move.Decision.DecisionType != DecisionType.Ante)
            {
                decisionPlayer.SetPolled();
            }

            decisionPlayer.ChipsBetByStage[StageEnum] += move.Decision.ChipsAdded;

            MostChipsBetByRound[StageEnum] = Players.Max(p => p.ChipsBetByStage[StageEnum]);

            switch (move.Decision.DecisionType)
            {
            case DecisionType.Raise:
            case DecisionType.Reraise:
                foreach (var player in Players)
                {
                    if (!player.Equals(decisionPlayer))
                    {
                        player.ResetPolled();
                    }
                }
                break;

            case DecisionType.Fold:
                decisionPlayer.Fold();
                break;

            case DecisionType.AllIn:
                decisionPlayer.AllIn();
                break;
            }

            AllMoves.Add(move);

            switch (StageEnum)
            {
            case StageEnum.Preflop:
                PreflopMoves.Add(move);
                break;

            case StageEnum.Flop:
                FlopMoves.Add(move);
                break;

            case StageEnum.Turn:
                TurnMoves.Add(move);
                break;

            case StageEnum.River:
                RiverMoves.Add(move);
                break;

            default:
                throw new InvalidOperationException($"Move not accepted in {StageEnum}");
            }

            if (move.Decision.DecisionType == DecisionType.Raise ||
                move.Decision.DecisionType == DecisionType.Reraise)
            {
                if (StageEnum == StageEnum.Preflop)
                {
                    PreflopRaiser = move.Player;
                }
                CurrentRaiser = move.Player;
            }

            int chipsToCall = MostChipsBetByRound[StageEnum] - move.Player.ChipsBetByStage[StageEnum];

            if (move.Decision.DecisionType == DecisionType.AllIn && move.Decision.ChipsAdded > chipsToCall)
            {
                CurrentRaiser = move.Player;
            }

            if (move.Decision.DecisionType != DecisionType.Check && move.Decision.DecisionType != DecisionType.Fold)
            {
                IsRaised = true;
            }
        }
Exemple #12
0
 public void ScheduleTransaction(FootballMatch match, int player, AllMoves move)
 {
 }
Exemple #13
0
 public void DelMove(Move move)
 {
     Board.RemovePiece(move);
     CurrentPlayerHand.Add(move);
     AllMoves.Remove(move);
 }
Exemple #14
0
        protected override void TryMove(bool backInTime = false, bool send_events = true)
        {
            BoardPosition   captureOnTheIsle;
            IChessItemModel killed_chess;

            var  prev_item         = BoardKit.GetFigureFromBoard(PreviousSelectedPosition);
            byte prev_item_type    = prev_item.Type;
            bool prev_item_is_null = prev_item.IsNullObject;
            var  curr_item         = BoardKit.GetFigureFromBoard(CurrentSelectedPosition);
            byte curr_item_type    = curr_item.Type;
            bool curr_item_is_null = curr_item.IsNullObject;

            bool tryMoveResult = BoardKit.TryMoveChessItem(CurrentPlayer.Side, PreviousSelectedPosition, CurrentSelectedPosition, out captureOnTheIsle, out killed_chess);

            if (tryMoveResult)
            {
                AllMoves.Add(new FigureMove(PreviousSelectedPosition, CurrentSelectedPosition, killed_chess, CurrentPlayer.Side));

                PreviousPlayer = Players[currentPlayerIndex];
                if (++currentPlayerIndex >= Players.Count)
                {
                    currentPlayerIndex = 0;
                }
                CurrentPlayer = Players[currentPlayerIndex];
            }

            //If move is ready
            if (tryMoveResult)
            {
                if (!prev_item_is_null && !curr_item_is_null)
                {
                    if (prev_item_type == (byte)ClassicChessItemType.king && curr_item_type == (byte)ClassicChessItemType.rook ||
                        prev_item_type == (byte)ClassicChessItemType.rook && curr_item_type == (byte)ClassicChessItemType.king)
                    {
                        TryMakeCastling(backInTime);
                    }
                    else
                    {
                        LastPlayerAction = PlayerAction.MoveAndKill;
                        if (send_events)
                        {
                            OnChanged_Invoke(PreviousPlayer.Side);
                        }
                    }
                }
                else
                {
                    LastPlayerAction = PlayerAction.Move;
                    if (send_events)
                    {
                        OnChanged_Invoke(PreviousPlayer.Side);
                    }
                }

                CurrentSelectedPosition  = BoardPosition.None;
                PreviousSelectedPosition = BoardPosition.None;
                CheckForCheckAndMate(send_events);
            }
            else
            {
                CurrentSelectedPosition  = PreviousSelectedPosition;
                PreviousSelectedPosition = BoardPosition.None;
            }
        }