コード例 #1
0
        public void GridPoint_Set_Ownership()
        {
            GridPoint gp     = new GridPoint(1, 1);
            Player    player = new Player();

            gp.SetOwnership(player);
            Assert.IsTrue(gp.Ownership() == player);
        }
コード例 #2
0
ファイル: Classes.cs プロジェクト: kiljoy001/TickTackToe
 public IPlayer CheckPointOwnerShip(GridPoint point)
 {
     if (point != null && BoardLocations.Contains(point))
     {
         GridPoint matchedPoint = BoardLocations.FirstOrDefault(gp => gp.Location.horizontal == point.Location.horizontal && gp.Location.vertical == point.Location.vertical);
         return(matchedPoint.Ownership());
     }
     else
     {
         return(null);
     }
 }
コード例 #3
0
 public void listen()
 {
     while (true)
     {
         string message = playerReader.ReadLine();
         try
         {
             GridPoint incommingPoint = JsonConvert.DeserializeObject <GridPoint>(message);
             game.MakeMove(incommingPoint.Ownership(), incommingPoint);
         }
         catch (ArgumentException ae)
         {
             Log.Error(ae, $"Move invalid! Error Message: {ae.Message}");
         }
         catch (Exception ex)
         {
             Log.Error(ex, $"Error Reading Message! Error Message: {ex.Message}");
         }
     }
 }
コード例 #4
0
ファイル: Classes.cs プロジェクト: kiljoy001/TickTackToe
    public void CommitAndUpdateBoard(IPlayer players)
    {
        List <IGridPoint> moves            = new List <IGridPoint>();
        List <IGridPoint> player1positions = players.PlayerPositions();

        foreach (IGridPoint point in player1positions)
        {
            moves.Add(point);
        }

        foreach (GridPoint point in this.BoardLocations)
        {
            if (moves.Contains(point))
            {
                GridPoint updatePoint = BoardLocations.FirstOrDefault(gp => gp.Location.horizontal == point.Location.horizontal && gp.Location.vertical == point.Location.vertical);
                if (updatePoint != null && updatePoint.Ownership() != point.Ownership())
                {
                    updatePoint.SetOwnership(point.Ownership());
                }
            }
        }
    }