public PlayerViewModel(Player Player)
     : base()
 {
     this.Profile = new ProfileViewModel(Player.Profile);
     this.Color = Player.Color;
     this.Score = Player.Score;
 }
Example #2
0
        public Box( Coordinate SouthWest, Player Owner = null )
        {
            this.SouthWest = SouthWest;
            this.NorthWest = new Coordinate( SouthWest.X, SouthWest.Y + 1 );
            this.SouthEast = new Coordinate(SouthWest.X + 1, SouthWest.Y);
            this.NorthEast = new Coordinate( SouthWest.X + 1, SouthWest.Y + 1 );

            this.North = new Line( NorthWest, NorthEast );
            this.South = new Line( SouthWest, SouthEast );
            this.East = new Line( SouthEast, NorthEast );
            this.West = new Line( SouthWest, NorthWest );

            this.Owner = Owner;
        }
Example #3
0
        public void PlayGame()
        {
            var width = 2;
            var height = 2;
            var expectedBoxes = ( width )*( height );

            Game Game = new Game( width, height );
            var player1 = new Player();
            var player2 = new Player();

            player1.Profile = new Profile();
            player1.Color = Color.Blue.ToArgb();
            player2.Profile = new Profile();
            player2.Color = Color.Red.ToArgb();

            Game.AddPlayer( player1 );
            Game.AddPlayer( player2 );

            Assert.AreEqual(2, Game.Players.Count);

            Assert.AreEqual( 12, Game.TotalTurns );
            Assert.AreEqual( true, Game.GameStartable );
            Assert.AreEqual( false, Game.GameStarted );
            Assert.AreEqual( false, Game.GameFinished );

            Game.AddTurn( new Turn( new Line( new Coordinate( 0, 0 ), new Coordinate( 1, 0 ) ), player1 ) );
            Game.AddTurn( new Turn( new Line( new Coordinate( 0, 0 ), new Coordinate( 0, 1 ) ), player2 ) );
            Game.AddTurn( new Turn( new Line( new Coordinate( 1, 0 ), new Coordinate( 1, 1 ) ), player1 ) );
            Game.AddTurn( new Turn( new Line( new Coordinate( 1, 1 ), new Coordinate( 0, 1 ) ), player2 ) );

            int boxCount = 0;
            foreach(var box in Game.Boxes)
            {
                if(box.Completed())
                {
                    boxCount++;
                }
            }

            Assert.AreEqual( 4, Game.Turns.Count );
            Assert.AreEqual( 1, boxCount );
            Assert.AreEqual( 1, Game.CurrentPlayer );
            Game.AddTurn( new Turn( new Line( new Coordinate( 1, 1 ), new Coordinate( 2, 1 ) ), player2 ) );
            Assert.AreEqual( 0, Game.CurrentPlayer );
        }
Example #4
0
 public Turn(Line Line, Player Player)
     : base()
 {
     this.Line = Line;
     this.Player = Player;
 }
Example #5
0
 public void AddPlayer(Player Player)
 {
     if(!GameStarted && this.Players.Count < this.MaximumPlayers)
     {
         foreach ( var player in this.Players )
         {
             if ( player.Value.Profile.Id.Equals( Player.Profile.Id ) )
             {
                 throw new InvalidAddPlayerException( "Player is already in game!" );
             }
             if ( player.Value.Color.Equals( Player.Color ) )
             {
                 throw new InvalidAddPlayerException( "Please select another color!" );
             }
         }
         this.Players.Add( this.Players.Count, Player );
     }
     else
     {
         throw new InvalidAddPlayerException("Game has already started, or is full.");
     }
 }