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; }
protected abstract bool CheckInfo(AbilityInfo info);
protected override bool CheckInfo(AbilityInfo info) { return info.Target != null && info.District != null; }
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); }
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); }
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; }
protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game) { }
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; }
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); } }
protected override bool CheckInfo(AbilityInfo info) { return true; }
protected override bool CheckInfo(AbilityInfo info) { return info.District == null; }
protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game) { game.OnSelect = new StandardSelectStrategy(GetOption(owner), (game1, s, cards) => OnSelect(game1, s, cards, owner)); }
protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game) { owner.Gold += owner.City.Count(c => c.Color == _color); }
protected abstract void UseUnusedAbility(Player owner, AbilityInfo info, Game game);
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()); }
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); }
public void UseAbility(string pid, AbilityInfo ability) { CheckOption(pid, OptionType.UseAbility); var source = ability.Source; var character = GetCharacterInTurn(); var player = PlayerInTurn; if (source == character.Name) { character.UseAbility(player, ability, this); } else { var district = player.Hand.First(d => d.Title == source); //TODO throw hotcit exception? district.UseAbility(player, ability, this); } }