Exemplo n.º 1
0
 public bool UseAbility(Player owner, AbilityInfo info, Game game)
 {
     if (Used) return false;
     if (!CheckInfo(info)) throw new HotCitException(ExceptionType.IllegalInput);
     UseUnusedAbility(owner, info, game);
     Used = true;
     return true;
 }
Exemplo n.º 2
0
 public bool UseAbility(Player owner, AbilityInfo info, Game game)
 {
     if (info.Target != null && info.District != null)
     {
         return _destroyAbility.UseAbility(owner, info, game);
     }
     if (info.Target == null && info.District == null)
     {
         return _goldAbility.UseAbility(owner, info, game);
     }
     return false;
 }
Exemplo n.º 3
0
        protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
        {
            var target = game.GetPlayerByUsername(info.Target);

            if (target.IsCharacter(5)) throw new HotCitException(ExceptionType.BadAction, "Cannot destroy bishops districts");

            var district = target.City.FirstOrDefault(d => d.Title == info.District);

            if (district == null) throw new HotCitException(ExceptionType.NotFound, info.District + " not found at " + info.Target);

            owner.Gold -= district.Value - 1;

            target.City.Remove(district);
        }
Exemplo n.º 4
0
 protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
 {
     owner.Gold -= 2;
     for (var i = 0; i < 3; i++)
         owner.Hand.Add(game.TakeDistrict());
 }
Exemplo n.º 5
0
 protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
 {
     var target = game.GetPlayerByCharacter(info.Target);
     if (target == null) return;
     target.RobbedBy(info.Target, owner);
 }
Exemplo n.º 6
0
 public void OnReveal(Player owner, Game game)
 {
     game.King = owner;
 }
Exemplo n.º 7
0
 /****************************************************************************************************/
 /* Public helper methods                                                                            */
 /****************************************************************************************************/
 public void RobbedBy(string character, Player owner)
 {
     _victim = character;
     _thief = owner;
 }
Exemplo n.º 8
0
 public bool OnSelect(Game game, string pid, string[] cards, Player owner)
 {
     owner.Hand.Remove(owner.Hand.First(d => d.Title == cards[0]));
     owner.Gold++;
     return true;
 }
Exemplo n.º 9
0
 protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
 {
     game.OnSelect = new StandardSelectStrategy(GetOption(owner), (game1, s, cards) => OnSelect(game1, s, cards, owner));
 }
Exemplo n.º 10
0
 protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
 {
     owner.Gold += owner.City.Count(c => c.Color == _color);
 }
Exemplo n.º 11
0
 public Option GetOption(Player owner)
 {
     return new Option
     {
         Type = OptionType.Select,
         Amount = 1,
         Message = "Discard one card and recieve one gold",
         Choices = owner.Hand.Select(d => d.Title)
     };
 }
Exemplo n.º 12
0
 protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
 {
     var target = game.Characters.FirstOrDefault(c => c.Name == info.Target);
     if (target == null) throw new HotCitException(ExceptionType.IllegalInput, info.Target + " is not a character in the game");
     target.Dead = true;
 }
Exemplo n.º 13
0
 //TODO delegate?
 /****************************************************************************************************/
 /*  Private and internal helper methods                                                             */
 /****************************************************************************************************/
 internal void SetKing(Player king)
 {
 }
Exemplo n.º 14
0
        public void SwapHand(Player target)
        {
            var temp = Hand;
            Hand.Clear();
            foreach (var d in target.Hand)
                Hand.Add(d);

            target.Hand.Clear();
            foreach (var d in temp)
            {
                target.Hand.Add(d);
            }
        }
Exemplo n.º 15
0
 protected abstract void UseUnusedAbility(Player owner, AbilityInfo info, Game game);
Exemplo n.º 16
0
 protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
 {
     if (info.Target != null) //swap with player
     {
         owner.SwapHand(game.GetPlayerByUsername(info.Target));
     }
     else
     {
         var option = new Option
         {
             Message = "Discard any number of cards and draw an equal number of cards.",
             Choices = owner.Hand.Select(c => c.Title)
         };
         game.OnSelect = new StandardSelectStrategy(option, game.SwapWithPile);
     }
 }
Exemplo n.º 17
0
 public void UseAbility(Player player, AbilityInfo ability, Game game)
 {
     if (Ability == null) throw new HotCitException(ExceptionType.BadAction, Title + " do not have an ability");
     Ability.UseAbility(player, ability, game);
 }
Exemplo n.º 18
0
 protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
 {
 }
Exemplo n.º 19
0
 public void OnReveal(Player owner, Game game)
 {
 }
Exemplo n.º 20
0
 public PlayerResponse(Player player)
 {
     Username = player.Username;
     City = player.City.Select(d => d.Title);
     NumberOfCards = player.Hand.Count;
     Points = player.City.Sum(d => d.Value); //TODO more complex
     Gold = player.Gold;
     Characters = player.Characters.Select(c => c.Name);
 }