예제 #1
0
        //private List<string> getPieces(Symbol sym)
        //{
        //    List<string> ps = new List<string>();
        //    for(int i = 0; i < board.allPositions().Count; i++)
        //    {
        //        Tile t = board.getTile(board.allPositions()[i]);
        //        if (t.cond.Symbol == sym) ps.Add(t.pos);
        //    }
        //    return ps;
        //}
        //private bool availPieces(Symbol sym)
        //{
        //    List<string> list = getPieces(sym);
        //    bool isNotAvailable = false;
        //    foreach (string str in list)
        //    {
        //        isNotAvailable = isInMillPos(str, player);
        //        if (!isNotAvailable) return false;
        //    }
        //    return true;
        //}
        public void Shoot(IPlayer player, IReferee referee, string position)
        {
            if (referee.canShoot(player, position))
            {
                if (referee.isValidDestroy(player, position))

                {
                    if (!referee.isAvailablePieces(player))
                    {
                        if (referee.isInMillPos(position, player))
                        {
                            Console.WriteLine("You can't shoot a piece in a mill. There are still available pieces to shoot");
                            Thread.Sleep(1500);
                            flag = true;
                        }
                    }
                    else
                    {
                        board.updateTile(new Tile(position, new Piece(Symbol.BL, position)));
                        cowBox.placeCow(switchPlayer(player.symbol));
                        flag = false;
                    }
                }
                else
                {
                    Console.WriteLine("You can't remove your own player or shoot a blank spot!!!");
                    flag = true;
                    Thread.Sleep(1500);
                }
            }
        }