コード例 #1
0
        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;
        }
コード例 #2
0
 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;
 }
コード例 #3
0
 private void CheckGameType(InGamePlayerInfo player)
 {
     if (player.Game.GameMode == "sw")
     {
         _manager.Push(player.User, Achievement.IdLostInStars);
     }
 }
コード例 #4
0
 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));
     }
 }
コード例 #5
0
 public BooleanVoteActivity(InGamePlayerInfo player, BooleanVote vote, bool value)
     : base(player)
 {
     Vote  = vote;
     Value = value;
     Player.EveningVoteActivity = this;
 }
コード例 #6
0
 public VoteActivity(InGamePlayerInfo player, Vote vote, InGamePlayerInfo forWho)
     : base(player)
 {
     Vote           = vote;
     ForWho         = forWho;
     Player.VoteFor = this;
 }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
        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));
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
 public bool IsVotedYes(InGamePlayerInfo voter)
 {
     if (Result.HasValue && Result.Value && DetailedInfo.ContainsKey(voter.User.Id))
     {
         return(DetailedInfo[voter.User.Id].Value);
     }
     return(false);
 }
コード例 #11
0
 public override void ClearActivity(bool cancel, InGamePlayerInfo onlyAgainstTarget = null)
 {
     if (onlyAgainstTarget == null)
     {
         IsCharged = false;
     }
     base.ClearActivity(cancel, onlyAgainstTarget);
 }
コード例 #12
0
 public bool IsVotedForLeader(InGamePlayerInfo voter)
 {
     if (HasOneLeader && DetailedInfo.ContainsKey(voter.User.Id))
     {
         return(DetailedInfo[voter.User.Id].ForWho.User.Id == Leader);
     }
     return(false);
 }
コード例 #13
0
 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;
 }
コード例 #14
0
 public override void ClearActivity(bool cancel, InGamePlayerInfo onlyAgainstTarget = null)
 {
     if (onlyAgainstTarget == null || PlayerToCheck == onlyAgainstTarget)
     {
         PlayerToCheck = null;
         base.ClearActivity(cancel);
     }
 }
コード例 #15
0
 protected virtual void OnCancel(InGamePlayerInfo onlyAgainstTarget)
 {
     if (onlyAgainstTarget == null)
     {
         Canceled?.Invoke(this, EventArgs.Empty);
         IsCanceled = true;
     }
 }
コード例 #16
0
 public override void ClearActivity(bool cancel, InGamePlayerInfo onlyAgainstTarget = null)
 {
     if (onlyAgainstTarget == null || PlayerToInteract == onlyAgainstTarget)
     {
         PlayerToInteract = null;
     }
     base.ClearActivity(cancel, onlyAgainstTarget);
 }
コード例 #17
0
ファイル: Demoman.cs プロジェクト: Desempell/DiscordMafia
 public override void ClearActivity(bool cancel, InGamePlayerInfo onlyAgainstTarget = null)
 {
     if (onlyAgainstTarget == null)
     {
         PlaceToDestroy = null;
     }
     base.ClearActivity(cancel, onlyAgainstTarget);
 }
コード例 #18
0
        /// <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);
        }
コード例 #19
0
 public virtual bool HasActivityAgainst(InGamePlayerInfo target)
 {
     if (this is ITargetedRole directedRole)
     {
         return(target == directedRole.PlayerToInteract);
     }
     return(false);
 }
コード例 #20
0
 public InGamePlayerInfo GetTarget(InGamePlayerInfo voter)
 {
     if (DetailedInfo.ContainsKey(voter.User.Id))
     {
         return(DetailedInfo[voter.User.Id].ForWho);
     }
     return(null);
 }
コード例 #21
0
 public override void ClearActivity(bool cancel, InGamePlayerInfo onlyAgainstTarget = null)
 {
     if (onlyAgainstTarget == null || PlayerToKill == onlyAgainstTarget)
     {
         PlayerToKill = null;
         WasAttacked  = false;
         base.ClearActivity(cancel);
     }
 }
コード例 #22
0
 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);
 }
コード例 #23
0
 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);
     }
 }
コード例 #24
0
 /// <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();
     }
 }
コード例 #25
0
 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;
 }
コード例 #26
0
 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);
     }
 }
コード例 #27
0
 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);
 }
コード例 #28
0
 public void DealCard(List <PokerCard> cards, long blind)
 {
     Status           = SeatStatus.None;
     BetedCoins       = 0;
     InGamePlayerInfo = PlayerInfo;
     handCards        = cards;
     TotalBetedCoins  = blind;
     WinCoins         = 0;
     InGamePlayerInfo.BetCoins(blind);
 }
コード例 #29
0
 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);
         }
     }
 }
コード例 #30
0
 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;
 }