Exemplo n.º 1
0
        public void IsInMonopolyTest()
        {
            Board       board         = new Board();
            List <Land> my3GreenLands = new List <Land>()
            {
                new Land("id1", "Rue de la paix", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board),
                new Land("id2", "2e Rue de la paix", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board),
                new Land("id3", "3e Rue de la paix", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board)
            };

            my3GreenLands.ForEach(land => board.Add(land));

            Land brownLand = new Land("id4", "Une rue marron", Color.Brown, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board);

            board.Add(brownLand);

            Assert.IsFalse(my3GreenLands.Any(land => land.IsInMonopoly));
            //These lands have no owner, so none of these should be in monopoly.

            Player p0 = new Player(0, "p0", 500);
            Player p1 = new Player(1, "p0", 500);


            my3GreenLands.ForEach(land => land.Owner = p1);

            Assert.IsTrue(my3GreenLands.All(land => land.IsInMonopoly));//All green lands should be in monopoly.
            Assert.IsFalse(brownLand.IsInMonopoly);


            my3GreenLands[0].Owner = p0;

            Assert.IsFalse(my3GreenLands.Any(land => land.IsInMonopoly));//One green lands does not belong to p0 so they are not in monopoly.
            Assert.IsFalse(brownLand.IsInMonopoly);
        }
Exemplo n.º 2
0
        public void OwnedPropertiesTest()
        {
            Player p0 = new Player(0, "p0", 500);

            Board       board         = new Board();
            List <Land> my3GreenLands = new List <Land>()
            {
                new Land("id1", "Rue de la paix", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board),
                new Land("id2", "2e Rue de la paix", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board),
                new Land("id3", "3e Rue de la paix", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board)
            };

            my3GreenLands.ForEach(land => board.Add(land));

            Land brownLand = new Land("id4", "Une rue marron", Color.Brown, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board);

            board.Add(brownLand);
            Game.Instance.InitializeBoard(board);


            Assert.AreEqual(0, p0.OwnedProperties.Count);

            my3GreenLands.ForEach(land => land.Owner = p0);
            Assert.AreEqual(3, p0.OwnedProperties.Count);

            brownLand.Owner = p0;
            Assert.AreEqual(4, p0.OwnedProperties.Count);

            brownLand.Owner = null;
            Assert.AreEqual(3, p0.OwnedProperties.Count);
        }
Exemplo n.º 3
0
        public void Put_player_in_board()
        {
            Square square = new Square(position: 0, category: Category.Pop);

            board.Add(A_PLAYER);

            Assert.IsTrue(board.GetPlayersIn(square).Contains(A_PLAYER));
        }
Exemplo n.º 4
0
        public void AcceptSingleFunnelShip()
        {
            board.Add(new PatrolBoat(1, 1));

            var shipsOnBoard = board.GetAll();

            Assert.AreEqual(1, shipsOnBoard.Count);
        }
Exemplo n.º 5
0
        public void RentPriceTest_ColorOwnedBySamePlayerWithoutHouseCostDouble()
        {
            Board board     = new Board();
            Land  landTest1 = new Land("id", "Rue de la paix", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board);

            board.Add(landTest1);
            Land landTest2 = new Land("id2", "Rue 2", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board);

            board.Add(landTest2);
            Player player = new Player(0, "player", 500);

            landTest1.Owner = player;
            landTest2.Owner = player;
            Assert.AreEqual(100, landTest1.RentPrice);
        }
Exemplo n.º 6
0
        public void IsHouseBuildable_FalseWhenNotInMonopoly()
        {
            Board board     = new Board();
            Land  landTest1 = new Land("id1", "Rue de la paix", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board);

            board.Add(landTest1);
            Land landTest2 = new Land("id2", "2e Rue de la paix", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board);

            board.Add(landTest2);
            Player p0 = new Player(0, "p0", 500);

            landTest1.Owner = p0;

            Assert.IsFalse(landTest1.IsHouseBuildable());
        }
Exemplo n.º 7
0
    protected void Bt_ok_Click(object sender, EventArgs e)
    {
        string where = " where docID=" + SQLString.GetQuotedString(Request.QueryString["docID"]);
        string    state = ddlState.SelectedValue;
        Hashtable ht    = new Hashtable();

        ht.Add("docState", SQLString.GetQuotedString(state));
        ht.Add("docReason", SQLString.GetQuotedString(txtdocReason.Text));
        Doc dc = new Doc();

        if (dc.Update(ht, where))
        {
            Hashtable board = new Hashtable();
            board.Add("docID", SQLString.GetQuotedString(Request.QueryString["docID"]));
            board.Add("boardState", SQLString.GetQuotedString("未缴费"));
            Board bd = new Board();
            bd.Add(board);

            Response.Write("<script>alert('审核完毕!');window.location='doclist.aspx';</script>");
        }
        else
        {
            Response.Write("<script>alert('审核失败!');window.location='doclist.aspx';</script>");
        }
    }
Exemplo n.º 8
0
    private void TryToDrawOnTheBoard(Touch touch)
    {
        var cellIndex = PickCell(touch.position);

        if (cellIndex.HasValue && !board.IsBorder(cellIndex.Value))
        {
            if (touch.phase == TouchPhase.Began)
            {
                drawingOnTheBoard = true;
            }

            if (drawingOnTheBoard)
            {
                board.Add(new MetaCell
                {
                    Index = cellIndex.Value,
                    Type  = BoardCellType.Alive
                });
            }
        }
        else
        {
            drawingOnTheBoard = false;
        }
    }
Exemplo n.º 9
0
        private void Initialize()
        {
            List <int> possibleNumbers = new List <int>();
            Random     generator       = new Random();

            for (int i = 1; i <= PairCount; i++)
            {
                possibleNumbers.Add(i);
                possibleNumbers.Add(i);
            }

            for (int i = 0; i < Size; i++)
            {
                var row = new ObservableCollection <Box>();
                for (int j = 0; j < Size; j++)
                {
                    int index  = generator.Next(0, possibleNumbers.Count);
                    int cellID = i * Size + j;

                    row.Add(new Box(cellID, possibleNumbers[index]));

                    possibleNumbers.RemoveAt(index);
                }
                Board.Add(row);
            }
        }
Exemplo n.º 10
0
        public void InitializeBoard()
        {
            board = new Board();

            for (int i = 0; i < size; i++)
            {
                List <Gem> rowList = new List <Gem>();
                for (int j = 0; j < size; j++)
                {
                    Rectangle bounds = new Rectangle(playField.X + Gem.size * j, playField.Y + Gem.size * i, Gem.size, Gem.size);
                    Point     index  = new Point(i, j);
                    GemName   tempRand;
                    //Create a gem that does not create a triplet with adjacent gems
                    do
                    {
                        tempRand = (GemName)random.Next(6);
                        if (i < 2 && j < 2)
                        {
                            break;
                        }
                    } while ((j >= 2 && tempRand.Equals(rowList[j - 1].name) && tempRand.Equals(rowList[j - 2].name)) ||
                             (i >= 2 && tempRand.Equals(board[i - 1][j].name) && tempRand.Equals(board[i - 2][j].name)));
                    Gem gem = new Gem(this, tempRand, bounds, index);
                    rowList.Add(gem);
                }
                board.Add(rowList);
            }

            inGame.IsAbleToClick   = true;
            inGame.main.statistics = new Statistics();
        }
Exemplo n.º 11
0
        IGameState Submit(string message)
        {
            var split = message.Split();

            if (split.Length != 2)
            {
                ctx.Send(W("두 주사위의 눈을 곱한 값을 더할지 뺄지 선택하세요. 예시: S -, S +"));
                return(this);
            }
            var initials = split[1];

            if (initials == "+")
            {
                Board.Add(Turn.CurrentPlayer, Turn.Dices[0] * Turn.Dices[1]);
                return(ProceedAndStartTurn());
            }
            else if (initials == "-")
            {
                Board.Add(Turn.CurrentPlayer, -Turn.Dices[0] * Turn.Dices[1]);
                return(ProceedAndStartTurn());
            }
            else
            {
                ctx.Send(W("잘못 입력했습니다. 두 주사위의 눈을 곱한 값을 더할지 뺄지 선택하세요. 예시: S -, S +"));
                return(this);
            }
        }
Exemplo n.º 12
0
        private void AddBoardTile(int row, int i)
        {
            if (i <= m_Bounds.Left)
            {
                m_Bounds.Left     = i - 1;
                BoardTile.XOffset = m_Bounds.Left;
            }

            if (i > m_Bounds.Right)
            {
                m_Bounds.Right = i;
            }

            if (row <= m_Bounds.Top)
            {
                m_Bounds.Top      = row - 1;
                BoardTile.YOffset = m_Bounds.Top;
            }

            if (row > m_Bounds.Bottom)
            {
                m_Bounds.Bottom = row;
            }

            var bt = new BoardTile(this, i, row);

            Board.Add(bt);
            BoardMatrix[i, row] = bt;
        }
Exemplo n.º 13
0
 public Order(string orderName, string orderDescription, int price, string date)
 {
     Title            = orderName;
     OrderDescription = orderDescription;
     Price            = price;
     Date             = date;
     Board.Add(this);
     Id = _vendorCount++;
 }
Exemplo n.º 14
0
 public Jobs(string title, string description, string contact)
 {
     Title       = title;
     Description = description;
     Contact     = contact;
     Index       = Board.Count;
     Id          = ++_jobCount;
     Board.Add(this);
 }
Exemplo n.º 15
0
        public void CreateInPlay(Entity entity, int turn)
        {
            var ce = new CardEntity(entity)
            {
                Turn = turn, Created = true
            };

            Board.Add(ce);
            Log("CreateInPlay", ce);
        }
Exemplo n.º 16
0
        public void AddNewShip_horizental_Success()
        {
            var result = Board.Add(new Coordinate {
                X = 0, Y = 3
            }, new Coordinate {
                X = 0, Y = 5
            });

            Assert.IsTrue(result.Valid);
        }
Exemplo n.º 17
0
 private void InitBoard()
 {
     for (int i = 0; i < RowsCount; i++)
     {
         for (int j = 0; j < ColumnsCount; j++)
         {
             Board.Add(new Cell(false, i, j));
         }
     }
 }
Exemplo n.º 18
0
 public void Reset()
 {
     for (int i = 0; i < Defaults.TileCount; i++)
     {
         Board.Add(new Tile()
         {
             Index = (TileEnum)i
         });
     }
 }
Exemplo n.º 19
0
        public void Update()
        {
            Board.Clear();
            FirstPlayerHands.Hands.Clear();
            SecondPlayerHands.Hands.Clear();

            for (int y = 0; y < this.gameService.GetGame().Board.Height; y++)
            {
                var row = new ObservableCollection <CellViewModel>();
                for (int x = 0; x < this.gameService.GetGame().Board.Width; x++)
                {
                    row.Add(new CellViewModel()
                    {
                        Koma = null, Position = new BoardPosition(x, y), MoveCommands = null
                    });
                }
                Board.Add(row);
            }

            foreach (var koma in this.gameService.GetGame().State.KomaList)
            {
                if (koma.BoardPosition != null)
                {
                    var cell = Board[koma.BoardPosition.Y][koma.BoardPosition.X];
                    cell.Koma = new KomaViewModel()
                    {
                        IsTransformed = koma.IsTransformed,
                        Name          = koma.KomaType.Id,
                        Player        = koma.Player == PlayerType.FirstPlayer ? Player.FirstPlayer : Player.SecondPlayer,
                    };
                }
                else
                {
                    if (koma.Player == PlayerType.FirstPlayer)
                    {
                        FirstPlayerHands.Hands.Add(new HandKomaViewModel()
                        {
                            KomaName = koma.KomaType.Id, KomaType = koma.KomaType, Player = Player.FirstPlayer
                        });
                    }
                    else
                    {
                        SecondPlayerHands.Hands.Add(new HandKomaViewModel()
                        {
                            KomaName = koma.KomaType.Id, KomaType = koma.KomaType, Player = Player.SecondPlayer
                        });
                    }
                }
            }

            FirstPlayerHands.IsCurrentTurn  = this.gameService.GetGame().State.TurnPlayer == PlayerType.FirstPlayer;
            SecondPlayerHands.IsCurrentTurn = this.gameService.GetGame().State.TurnPlayer == PlayerType.SecondPlayer;

            MoveCommand.RaiseCanExecuteChanged();
        }
Exemplo n.º 20
0
 //TODO: Consider this function. should it even be here?=
 public void Initialize()
 {
     _log.Info("Initialising bingo-board with 90 numbers...");
     _board = new BindableCollection <BingoNumber>();
     for (int i = 0; i < _boardSize; i++)
     {
         Board.Add(new BingoNumber(i + 1));
     }
     NotifyOfPropertyChange(() => Board);
     _log.Info("Initialization of board done.");
 }
Exemplo n.º 21
0
        public Dictionary <int, List <string> > CreatingBoard()
        {
            var Width = CreatingWidth();

            for (int i = 0; i <= Width.Count - 1; i++)
            {
                Board.Add(i, new List <string>(Width));
            }

            return(Board);
        }
Exemplo n.º 22
0
        private IList <CellSet> CreateCellSetsIn(Board board, int cellEntries)
        {
            var cellSets = new CellSet[cellEntries];

            for (var i = 0; i < cellEntries; i++)
            {
                var cellSet = new CellSet();
                board.Add(cellSet);
                cellSets[i] = cellSet;
            }
            return(cellSets);
        }
Exemplo n.º 23
0
        private void UpdateWindow()
        {
            Board.Clear();

            for (int i = 0; i < Height; i++)
            {
                for (int j = 0; j < Width; j++)
                {
                    Board.Add(_board.Cells[i, j]);
                }
            }
            Points = _board.Points;
        }
        public void GetNumberOfOwnedRailroadsTest()
        {
            Board    board     = new Board();
            Railroad railroad1 = new Railroad("RAILROAD1", "First Railroad", 50, new int[] { 50, 100, 150, 200 }, board);

            board.Add(railroad1);
            Railroad railroad2 = new Railroad("RAILROAD2", "Second Railroad", 50, new int[] { 50, 100, 150, 200 }, board);

            board.Add(railroad2);
            Railroad railroad3 = new Railroad("RAILROAD3", "Third Railroad", 50, new int[] { 50, 100, 150, 200 }, board);

            board.Add(railroad3);
            Player player = new Player(0, "player", 500);

            Assert.AreEqual(0, Railroad.GetNumberOfOwnedRailroads(player, board));
            railroad1.Owner = player;
            Assert.AreEqual(1, Railroad.GetNumberOfOwnedRailroads(player, board));
            railroad2.Owner = player;
            Assert.AreEqual(2, Railroad.GetNumberOfOwnedRailroads(player, board));
            railroad3.Owner = player;
            Assert.AreEqual(3, Railroad.GetNumberOfOwnedRailroads(player, board));
        }
Exemplo n.º 25
0
    private void TryToDrawOnTheBoard(Touch touch)
    {
        var cellIndex = PickCell(touch.position);

        if (cellIndex.HasValue && !board.IsBorder(cellIndex.Value))
        {
            board.Add(new MetaCell
            {
                Index = cellIndex.Value,
                Type  = BoardCellType.Alive
            });
        }
    }
        public void RentPriceTest()
        {
            Board    board     = new Board();
            Railroad railroad1 = new Railroad("RAILROAD1", "First Railroad", 50, new int[] { 50, 100, 150, 200 }, board);

            board.Add(railroad1);
            Railroad railroad2 = new Railroad("RAILROAD2", "Second Railroad", 50, new int[] { 50, 100, 150, 200 }, board);

            board.Add(railroad2);
            Railroad railroad3 = new Railroad("RAILROAD3", "Third Railroad", 50, new int[] { 50, 100, 150, 200 }, board);

            board.Add(railroad3);
            Player player = new Player(0, "player", 500);

            Assert.AreEqual(0, railroad1.RentPrice);
            railroad1.Owner = player;
            Assert.AreEqual(50, railroad1.RentPrice);
            railroad2.Owner = player;
            Assert.AreEqual(100, railroad1.RentPrice);
            railroad3.Owner = player;
            Assert.AreEqual(150, railroad1.RentPrice);
        }
Exemplo n.º 27
0
        public GameBoard(int boardRows = 10)

        {
            Size = boardRows;
            for (int i = 0; i < boardRows; i++)
            {
                Board.Add(new List <BoardSquareState>());
                for (int j = 0; j < boardRows; j++)
                {
                    Board[i].Add(BoardSquareState.NotUsed);
                }
            }
        }
        //ViewModelの更新(とViewへの通知)
        public void Update(Game game = null)
        {
            if (game == null)
            {
                if (service == null)
                {
                    throw new System.Exception();
                }

                game = service.GetGame();
            }

            //更新
            Board.Clear();
            for (int y = 0; y < game.Board.Height; y++)
            {
                var row = new ObservableCollection <CellViewModel>();
                for (int x = 0; x < game.Board.Width; x++)
                {
                    row.Add(new CellViewModel()
                    {
                        CellType = CellType.NotCell, X = x, Y = y
                    });
                }
                Board.Add(row);
            }

            foreach (var cell in game.Board.GetAllCells())
            {
                if (cell.Stone == null)
                {
                    Board[cell.Position.Y][cell.Position.X].CellType = CellType.Empty;
                }
                else
                {
                    Board[cell.Position.Y][cell.Position.X].CellType  = CellType.PutStone;
                    Board[cell.Position.Y][cell.Position.X].StoneType = cell.Stone;
                }
            }

            foreach (var cell in game.GetCanPutCellsOfCurrentTurn())
            {
                Board[cell.Position.Y][cell.Position.X].CellType = CellType.EmptyAndCanPut;
            }

            CurrentPlayer = game.CurrentTurn;

            //通知
            PutStoneCommand?.RaiseCanExecuteChanged();
            RaisePropertyChanged(null);
        }
Exemplo n.º 29
0
        public void BuildHouseTest()
        {
            Board board    = new Board();
            Land  landTest = new Land("id", "Rue de la paix", Color.Green, 300, new int[] { 50, 100, 140, 250, 300, 450 }, 200, board);

            board.Add(landTest);
            Player p0 = new Player(0, "p0", 500);

            landTest.Owner = p0;

            landTest.BuildHouse();
            Assert.AreEqual(1, landTest.NumberOfHouses);
            Assert.AreEqual(500 - 200, p0.Money);
        }
Exemplo n.º 30
0
 private void createButtons()
 {
     for (int i = 0; i < m_Board.Size; i++)
     {
         for (int j = 0; j < m_Board.Size; j++)
         {
             MyButton button = new MyButton(i, j);
             initButton(button, i, j);
             m_Board.Add(button, i, j);
             this.Controls.Add(button);
             button.Click += buttons_Click;
         }
     }
 }
Exemplo n.º 31
0
    public void BoardSetup(int rows, int columns)
    {
        board = new Board<MatchTile>(rows, columns);
        tileIDsToCheckForMatches = new List<int>();
        tileHolder = new GameObject("TileHolder").transform;
        tileHolder.position = new Vector3(-columns*0.5f+0.5f,rows*0.5f-0.5f,0f);
        gameObjectDict = new Dictionary<int, GameObject>();
        checkedHorizontalTileIDs = new List<int>();
        checkedVerticalTileIDs = new List<int>();
        newDeletedTiles = new List<MatchTile>();
        deletedIdsLastTurn = new List<int>();
        tileBreakAudio = GetComponent<AudioSource>();
        tileBreakAudio.pitch = 0.7f;

        int id = 0;
        for(int y = 0; y < rows; y++) {

            for(int x = 0; x < columns; x++) {
                MatchTile tmpTile = new MatchTile(y,x, id);
                board.Add(tmpTile, y,x);
                board.SetLeftAndUpNeighbors(y,x);
                GameObject toInstantiate = GetValidTileToInstantiate(y,x);
                GameObject instance =
                    (GameObject)Object.Instantiate(toInstantiate, new Vector3 (tileHolder.position.x+x, tileHolder.position.y-y, 0f), Quaternion.identity);
                instance.GetComponent<TileMover>().Row = y;
                instance.GetComponent<TileMover>().Col = x;
                instance.GetComponent<TileMover>().Id = id;
                instance.transform.SetParent(tileHolder);
                MatchTile tile = new MatchTile(instance.GetComponent<TileMover>().tileType, y,x, id);
                board.Add(tile,y,x);
                board.SetLeftAndUpNeighbors(y,x);
                gameObjectDict.Add(id, instance);
                id++;
            }
        }
        isRunning = true;
    }