예제 #1
0
 public Player(Deck deck, IPlayerAI playerAI, int startingLife = 20, int firstMulligan = 6)
 {
     _LandCountAllowedToPlayEachTurn = 1;
     _NextMulliganCardCount          = firstMulligan;
     Deck = deck ?? throw new ArgumentNullException();
     foreach (var card in Deck.Cards)
     {
         foreach (var ability in card.Abilities)
         {
             ability.Owner = this;
         }
     }
     // 103.3 Each player begins the game with a starting life total of 20.
     StartingLife = startingLife;
     Life         = StartingLife;
     // 103.1 At the start of a game, the player's decks become their libraries.
     Library      = new Library(Deck.Cards);
     Hand         = new Hand();
     Graveyard    = new Graveyard();
     Exile        = new Exile();
     Battlefield  = new Battlefield();
     OutOfTheGame = new OutOfTheGame();
     AI           = playerAI ?? throw new ArgumentNullException();
     AI.Player    = this; // TODO : Can we do without this back reference?
     ManaPool     = new ManaPool();
 }
예제 #2
0
파일: Player.cs 프로젝트: cahurley/codewars
        /// <summary>
        /// Create a player object. This is used during setup.
        /// </summary>
        /// <param name="guid">The unique identifier for this player.</param>
        /// <param name="name">The name of the player.</param>
        /// <param name="school">The school this player is from.</param>
        /// <param name="language">The computer language this A.I. was written in.</param>
        /// <param name="avatar">The avatar of the player.</param>
        /// <param name="limo">The limo for this player.</param>
        /// <param name="spriteColor">The color of this player's sprite.</param>
        /// <param name="ai">The AI for this player.</param>
        public Player(string guid, string name, string school, string language, Image avatar, Limo limo, Color spriteColor, IPlayerAI ai)
        {
            Guid = guid;
            Name = name;
            School = school.Length <= 11 ? school : school.Substring(0, 11);
            Language = language;
            Avatar = avatar;
            Limo = limo;
            passengerDeliveredPoints = 0;
            SpriteColor = spriteColor;
            TransparentSpriteColor = Color.FromArgb(96, spriteColor.R, spriteColor.G, spriteColor.B);
            this.ai = ai;
            IsConnected = true;

            PassengersDelivered = new List<Passenger>();
            PickUp = new List<Passenger>();
            Scoreboard = new List<float>();
        }
예제 #3
0
        public ComputerGamePlayer(IGamePlayerManager manager, IShipPositionGenerator shipPositionGenerator, IGameEvents gameEvents, IPlayerAI playerAI)
            : base(manager)
        {
            _shipPositionGenerator = shipPositionGenerator;

            gameEvents.FireRequested += (player, xCord, yCord) =>
            {
                if (player.Equals(this))
                {
                    return;
                }

                Manager.VerifyOpponentFire(player, xCord, yCord);
            };

            gameEvents.GameSessionStarted += (session) =>
            {
                _nextMoveAvailable = true;
            };

            gameEvents.GameSessionFinished += (session, winner) =>
            {
                _nextMoveAvailable = false;
            };

            gameEvents.RoundFinished += (player, result) =>
            {
                if (_nextMoveAvailable)
                {
                    playerAI.PerformNextAction(Manager);
                }
            };
        }