Пример #1
0
        public Guid CreateGame(string gameName, string initiatingPlayerName, string initiatingPlayerEmail, string acceptingPlayerName, string acceptingPlayerEmail)
        {
            var initiatingPlayer = new Player(initiatingPlayerEmail, initiatingPlayerName);
            var acceptingPlayer = new Player(acceptingPlayerEmail, acceptingPlayerName);

            var game = new Game(gameName, initiatingPlayer, acceptingPlayer, PlayerTargetZoneRadius, ShotBlastRadius);
            games.Add(game.Id, game);

            return game.Id;
        }
Пример #2
0
        private Player FindOpponentByPlayerEmail(Game game, string playerEmail)
        {
            if (game.Player1.Email == playerEmail)
            {
                return game.Player2;
            }

            if (game.Player2.Email == playerEmail)
            {
                return game.Player1;
            }

            throw new InvalidOperationException("No such player.");
        }
Пример #3
0
        public static void Main()
        {
            var p1 = new Player("*****@*****.**", "A");
            var p2 = new Player("*****@*****.**", "B");

            const double playerTargetZoneRadius = 2.0;
            const double shotBlastRadius = 1.0;

            var game = new Game("Test", p1, p2, playerTargetZoneRadius, shotBlastRadius);

            p1.UpdateLocation(new GeoCoordinate(0.0, 0.0), playerTargetZoneRadius);
            p2.UpdateLocation(new GeoCoordinate(5.0, 5.0), playerTargetZoneRadius);

            var result = game.TakeShot(p2, p1.Location);
            Console.WriteLine(result);

            result = game.TakeShot(p2, p1.Location);
            Console.WriteLine(result);

            result = game.TakeShot(p1, p1.Location);
            Console.WriteLine(result);

            Console.ReadKey();
        }
Пример #4
0
        private Game CreateGame(out Player player1, out Player player2)
        {
            player1 = new Player("*****@*****.**", "A");
            player2 = new Player("*****@*****.**", "B");

            var game = new Game("Test", player1, player2, playerTargetZoneRadius, shotBlastRadius);

            return game;
        }