예제 #1
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 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;
 }
예제 #2
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 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;
 }
예제 #3
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
        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);
        }
예제 #4
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 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());
 }
예제 #5
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 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);
 }
예제 #6
0
 public void OnReveal(Player owner, Game game)
 {
     game.King = owner;
 }
예제 #7
0
파일: Player.cs 프로젝트: afkpost/HotCit
 /****************************************************************************************************/
 /* Public helper methods                                                                            */
 /****************************************************************************************************/
 public void RobbedBy(string character, Player owner)
 {
     _victim = character;
     _thief = owner;
 }
예제 #8
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 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;
 }
예제 #9
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
 {
     game.OnSelect = new StandardSelectStrategy(GetOption(owner), (game1, s, cards) => OnSelect(game1, s, cards, owner));
 }
예제 #10
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
 {
     owner.Gold += owner.City.Count(c => c.Color == _color);
 }
예제 #11
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 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)
     };
 }
예제 #12
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 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;
 }
예제 #13
0
파일: Game.cs 프로젝트: afkpost/HotCit
 //TODO delegate?
 /****************************************************************************************************/
 /*  Private and internal helper methods                                                             */
 /****************************************************************************************************/
 internal void SetKing(Player king)
 {
 }
예제 #14
0
파일: Player.cs 프로젝트: afkpost/HotCit
        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);
            }
        }
예제 #15
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 protected abstract void UseUnusedAbility(Player owner, AbilityInfo info, Game game);
예제 #16
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 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);
     }
 }
예제 #17
0
파일: Districts.cs 프로젝트: afkpost/HotCit
 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);
 }
예제 #18
0
파일: Abilities.cs 프로젝트: afkpost/HotCit
 protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game)
 {
 }
예제 #19
0
 public void OnReveal(Player owner, Game game)
 {
 }
예제 #20
0
파일: Responses.cs 프로젝트: afkpost/HotCit
 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);
 }