public async Task Vote([Summary("номер игрока")] InGamePlayerInfo player, [Remainder] string ignored = null) { if (_game.CurrentPlayers.TryGetValue(Context.User.Id, out InGamePlayerInfo currentPlayer)) { if (Context.Channel is IDMChannel) { if (currentPlayer.Role is Elder) { var elder = (currentPlayer.Role as Elder); var playerToKill = player; if (playerToKill != null && elder.PlayerToInteract == null) { try { elder.PlayerToInteract = playerToKill; await ReplyAsync(_game.MessageBuilder.GetText("OK")); _game.CheckNextCheckpoint(); } catch (Exception ex) { _game.MessageBuilder.Text(ex.Message, false).SendPrivate(currentPlayer); } } return; } } else if (_game.CurrentState == GameState.Day) // TODO Изменить проверку { _game.DayVote(currentPlayer, player); _game.CheckNextCheckpoint(); } } await Task.CompletedTask; }
public async Task CheckPlayer([Summary("номер игрока")] InGamePlayerInfo player, [Remainder] string ignored = null) { if (_game.CurrentPlayers.TryGetValue(Context.User.Id, out InGamePlayerInfo currentPlayer)) { if (currentPlayer.Role is Commissioner) { (currentPlayer.Role as Commissioner).PerformNightAction(player); } else if (currentPlayer.Role is Homeless) { (currentPlayer.Role as Homeless).PerformNightAction(player); } else if (currentPlayer.Role is Spy) { (currentPlayer.Role as Spy).PerformNightAction(player); } else if (currentPlayer.Role is Lawyer) { var lawyer = (currentPlayer.Role as Lawyer); if (player != null && lawyer.PlayerToInteract == null) { lawyer.PlayerToInteract = player; _game.NightAction(currentPlayer.Role); _game.MessageBuilder. PrepareTextReplacePlayer("NightAction_Lawyer_ToTeam", currentPlayer, additionalReplaceDictionary: new ReplaceDictionary { ["toCheck"] = lawyer.PlayerToInteract.GetName() }). SendToTeam(Team.Mafia); _game.CheckNextCheckpoint(); } } } await Task.CompletedTask; }
private void CheckGameType(InGamePlayerInfo player) { if (player.Game.GameMode == "sw") { _manager.Push(player.User, Achievement.IdLostInStars); } }
private void AddResult(Dictionary <ulong, TypeReaderValue> results, InGamePlayerInfo player, float score, Game game) { if (player != null && !results.ContainsKey(player.User.Id) && player.IsAlive) { results.Add(player.User.Id, new TypeReaderValue(player, score)); } }
public BooleanVoteActivity(InGamePlayerInfo player, BooleanVote vote, bool value) : base(player) { Vote = vote; Value = value; Player.EveningVoteActivity = this; }
public VoteActivity(InGamePlayerInfo player, Vote vote, InGamePlayerInfo forWho) : base(player) { Vote = vote; ForWho = forWho; Player.VoteFor = this; }
private void CheckPoints(InGamePlayerInfo player) { if (player.DbUser.TotalPoints >= 10000) { _manager.Push(player.User, Achievement.Id10K); } if (player.DbUser.TotalPoints >= 25000) { _manager.Push(player.User, Achievement.Id25K); } if (player.DbUser.TotalPoints >= 50000) { _manager.Push(player.User, Achievement.Id50K); } if (player.DbUser.TotalPoints >= 100000) { _manager.Push(player.User, Achievement.Id100K); } if (player.CurrentGamePoints >= 30) { _manager.Push(player.User, Achievement.IdPointsPerGame); } if (player.CurrentGamePoints <= -30) { _manager.Push(player.User, Achievement.IdPointsPerGameWasted); } }
public string FormatTextReplacePlayer(string messageTemplate, InGamePlayerInfo player, IDictionary <string, object> additionalReplaceDictionary = null) { var replaceDictionary = new Dictionary <string, object> { { "name", FormatName(player) }, { "nameSimple", Encode(player.GetName()) }, { "role", FormatRole(player.StartRole?.GetName(Language)) }, { "role0", FormatRole(player.StartRole?.GetNameCases(Language)[0]) }, { "role1", FormatRole(player.StartRole?.GetNameCases(Language)[1]) }, { "role2", FormatRole(player.StartRole?.GetNameCases(Language)[2]) }, { "role3", FormatRole(player.StartRole?.GetNameCases(Language)[3]) }, { "role4", FormatRole(player.StartRole?.GetNameCases(Language)[4]) }, { "role5", FormatRole(player.StartRole?.GetNameCases(Language)[5]) }, { "currentRole", FormatRole(player.Role?.GetName(Language)) }, { "currentRole0", FormatRole(player.Role?.GetNameCases(Language)[0]) }, { "currentRole1", FormatRole(player.Role?.GetNameCases(Language)[1]) }, { "currentRole2", FormatRole(player.Role?.GetNameCases(Language)[2]) }, { "currentRole3", FormatRole(player.Role?.GetNameCases(Language)[3]) }, { "currentRole4", FormatRole(player.Role?.GetNameCases(Language)[4]) }, { "currentRole5", FormatRole(player.Role?.GetNameCases(Language)[5]) }, }; messageTemplate = GenderRegex.Replace(messageTemplate, player.DbUser.Settings.Gender == DB.User.Gender.Male ? "$1" : "$2"); if (additionalReplaceDictionary != null) { messageTemplate = Format(messageTemplate, additionalReplaceDictionary); } return(Format(messageTemplate, replaceDictionary)); }
/// <summary> /// /// </summary> /// <param name="voter"></param> /// <param name="forWho"></param> /// <exception cref="ArgumentException">Если голосовавший уже голосовал</exception> public void Add(InGamePlayerInfo voter, InGamePlayerInfo forWho) { HasVotes = true; var activity = new VoteActivity(voter, this, forWho); Votes.Add(voter.User.Id, activity); voter.AddActivity(activity); }
public bool IsVotedYes(InGamePlayerInfo voter) { if (Result.HasValue && Result.Value && DetailedInfo.ContainsKey(voter.User.Id)) { return(DetailedInfo[voter.User.Id].Value); } return(false); }
public override void ClearActivity(bool cancel, InGamePlayerInfo onlyAgainstTarget = null) { if (onlyAgainstTarget == null) { IsCharged = false; } base.ClearActivity(cancel, onlyAgainstTarget); }
public bool IsVotedForLeader(InGamePlayerInfo voter) { if (HasOneLeader && DetailedInfo.ContainsKey(voter.User.Id)) { return(DetailedInfo[voter.User.Id].ForWho.User.Id == Leader); } return(false); }
public async Task JustifyPlayer([Summary("номер игрока")] InGamePlayerInfo player, [Remainder] string ignored = null) { if (_game.CurrentPlayers.TryGetValue(Context.User.Id, out InGamePlayerInfo currentPlayer)) { (currentPlayer.Role as Judge).PerformNightAction(player); } await Task.CompletedTask; }
public override void ClearActivity(bool cancel, InGamePlayerInfo onlyAgainstTarget = null) { if (onlyAgainstTarget == null || PlayerToCheck == onlyAgainstTarget) { PlayerToCheck = null; base.ClearActivity(cancel); } }
protected virtual void OnCancel(InGamePlayerInfo onlyAgainstTarget) { if (onlyAgainstTarget == null) { Canceled?.Invoke(this, EventArgs.Empty); IsCanceled = true; } }
public override void ClearActivity(bool cancel, InGamePlayerInfo onlyAgainstTarget = null) { if (onlyAgainstTarget == null || PlayerToInteract == onlyAgainstTarget) { PlayerToInteract = null; } base.ClearActivity(cancel, onlyAgainstTarget); }
public override void ClearActivity(bool cancel, InGamePlayerInfo onlyAgainstTarget = null) { if (onlyAgainstTarget == null) { PlaceToDestroy = null; } base.ClearActivity(cancel, onlyAgainstTarget); }
/// <summary> /// /// </summary> /// <param name="voter"></param> /// <param name="forWho"></param> /// <exception cref="ArgumentException">Если голосовавший уже голосовал</exception> public void Add(InGamePlayerInfo voter, bool value) { HasVotes = true; var activity = new BooleanVoteActivity(voter, this, value); Votes.Add(voter.User.Id, activity); voter.AddActivity(activity); }
public virtual bool HasActivityAgainst(InGamePlayerInfo target) { if (this is ITargetedRole directedRole) { return(target == directedRole.PlayerToInteract); } return(false); }
public InGamePlayerInfo GetTarget(InGamePlayerInfo voter) { if (DetailedInfo.ContainsKey(voter.User.Id)) { return(DetailedInfo[voter.User.Id].ForWho); } return(null); }
public override void ClearActivity(bool cancel, InGamePlayerInfo onlyAgainstTarget = null) { if (onlyAgainstTarget == null || PlayerToKill == onlyAgainstTarget) { PlayerToKill = null; WasAttacked = false; base.ClearActivity(cancel); } }
public MessageBuilder PrepareTextReplacePlayer(string key, InGamePlayerInfo player, string fallbackKey = null) { BuiltMessage += GetTextReplacePlayer(key, player); if (String.IsNullOrEmpty(BuiltMessage) && !String.IsNullOrEmpty(fallbackKey)) { BuiltMessage = GetTextReplacePlayer(fallbackKey, player); } return(this); }
public override void OnDayStart(Game game, InGamePlayerInfo currentPlayer) { this.DecreaseCooldown(); if (!this.IsOnCooldown()) { base.OnDayStart(game, currentPlayer); game.MessageBuilder.Text(this.GetCooldownText(game), false).SendPrivate(currentPlayer); } }
/// <summary> /// /// </summary> /// <param name="voter"></param> public void Remove(InGamePlayerInfo voter) { if (Votes.ContainsKey(voter.User.Id)) { var activity = Votes[voter.User.Id]; Votes.Remove(voter.User.Id); activity.Cancel(); } }
public BooleanVoteActivity(InGamePlayerInfo player, BooleanVote vote, bool value, int weight, EWeightType weightType) : base(player) { Vote = vote; Value = value; Weight = weight; WeightType = weightType; Player.EveningVoteActivity = this; }
public override void NightInfo(Game game, InGamePlayerInfo currentPlayer) { if (AvailableCursesCount > 0) { base.NightInfo(game, currentPlayer); game.GetAlivePlayersMesssage(true, true, currentPlayer, "/curse"); game.messageBuilder.Text($"Осталось проклятий: {AvailableCursesCount}").SendPrivate(currentPlayer); } }
public MessageBuilder PrepareTextReplacePlayer(string key, InGamePlayerInfo player, string fallbackKey = null, IDictionary <string, object> additionalReplaceDictionary = null) { BuiltMessage += GetTextReplacePlayer(key, player, additionalReplaceDictionary: additionalReplaceDictionary); if (String.IsNullOrEmpty(BuiltMessage) && !String.IsNullOrEmpty(fallbackKey)) { BuiltMessage = GetTextReplacePlayer(fallbackKey, player, additionalReplaceDictionary: additionalReplaceDictionary); } return(this); }
public void DealCard(List <PokerCard> cards, long blind) { Status = SeatStatus.None; BetedCoins = 0; InGamePlayerInfo = PlayerInfo; handCards = cards; TotalBetedCoins = blind; WinCoins = 0; InGamePlayerInfo.BetCoins(blind); }
private void CheckWench(InGamePlayerInfo player) { if (player.StartRole is Wench wench) { if (wench.BlockedPlayers.Where(p => p.StartRole.Team == Team.Mafia || p.StartRole.Team == Team.Yakuza).Count() >= 3) { _manager.Push(player.User, Achievement.IdWenchBlock); } } }
public async Task Kill([Summary("номер игрока")] InGamePlayerInfo player, [Remainder] string ignored = null) { if (_game.CurrentPlayers.TryGetValue(Context.User.Id, out InGamePlayerInfo currentPlayer)) { if (currentPlayer.Role is Highlander) { (currentPlayer.Role as Highlander).PerformNightAction(player); return; } if (currentPlayer.Role is Sheriff) { (currentPlayer.Role as Sheriff).PerformNightAction(player); return; } if (currentPlayer.Role is Prosecutor) { (currentPlayer.Role as Prosecutor).PerformNightAction(player); return; } if (currentPlayer.Role is Kamikaze) { (currentPlayer.Role as Kamikaze).PerformNightAction(player); return; } if (currentPlayer.Role is Killer) { var killer = (currentPlayer.Role as Killer); if (player != null && killer.PlayerToInteract == null) { killer.PlayerToInteract = player; _game.NightAction(currentPlayer.Role); _game.MessageBuilder. PrepareTextReplacePlayer("NightAction_Killer_ToTeam", currentPlayer, additionalReplaceDictionary: new ReplaceDictionary { ["toKill"] = killer.PlayerToInteract.GetName() }). SendToTeam(Team.Mafia); _game.CheckNextCheckpoint(); } return; } if (currentPlayer.Role is NeutralKiller) { (currentPlayer.Role as NeutralKiller).PerformNightAction(player); return; } if (currentPlayer.Role is ChuckNorris) { (currentPlayer.Role as ChuckNorris).PerformNightAction(player); return; } _game.NightVote(currentPlayer, player); _game.CheckNextCheckpoint(); } await Task.CompletedTask; }