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; }
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) { 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) { owner.Gold -= 2; for (var i = 0; i < 3; i++) owner.Hand.Add(game.TakeDistrict()); }
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 void OnReveal(Player owner, Game game) { game.King = owner; }
/****************************************************************************************************/ /* Public helper methods */ /****************************************************************************************************/ public void RobbedBy(string character, Player owner) { _victim = character; _thief = owner; }
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; }
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); }
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) }; }
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; }
//TODO delegate? /****************************************************************************************************/ /* Private and internal helper methods */ /****************************************************************************************************/ internal void SetKing(Player king) { }
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); } }
protected abstract void UseUnusedAbility(Player owner, AbilityInfo info, Game game);
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); } }
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); }
protected override void UseUnusedAbility(Player owner, AbilityInfo info, Game game) { }
public void OnReveal(Player owner, Game game) { }
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); }