コード例 #1
0
 private void AwardSolve(string userNickName, int ComponentValue)
 {
     if (OtherModes.ZenModeOn)
     {
         ComponentValue = (int)Math.Ceiling(ComponentValue * 0.20f);
     }
     if (userNickName == null)
     {
         TwitchPlaySettings.AddRewardBonus(ComponentValue);
     }
     else
     {
         string headerText = UnsupportedModule ? modInfo.moduleDisplayName : BombComponent.GetModuleDisplayName();
         IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.AwardSolve, Code, userNickName, ComponentValue, headerText);
         string RecordMessageTone = $"Module ID: {Code} | Player: {userNickName} | Module Name: {headerText} | Value: {ComponentValue}";
         Leaderboard.Instance?.AddSolve(userNickName);
         if (!UserAccess.HasAccess(userNickName, AccessLevel.NoPoints))
         {
             Leaderboard.Instance?.AddScore(userNickName, ComponentValue);
         }
         else
         {
             TwitchPlaySettings.AddRewardBonus(ComponentValue);
         }
         TwitchPlaySettings.AppendToSolveStrikeLog(RecordMessageTone);
         TwitchPlaySettings.AppendToPlayerLog(userNickName);
     }
     if (OtherModes.TimeModeOn)
     {
         float time = OtherModes.GetAdjustedMultiplier() * ComponentValue;
         if (time < TwitchPlaySettings.data.TimeModeMinimumTimeGained)
         {
             BombCommander.timerComponent.TimeRemaining = BombCommander.CurrentTimer + TwitchPlaySettings.data.TimeModeMinimumTimeGained;
             IRCConnection.Instance.SendMessage("Bomb time increased by the minimum {0} seconds!", TwitchPlaySettings.data.TimeModeMinimumTimeGained);
         }
         else
         {
             BombCommander.timerComponent.TimeRemaining = BombCommander.CurrentTimer + time;
             IRCConnection.Instance.SendMessage("Bomb time increased by {0} seconds!", Math.Round(time, 1));
         }
         OtherModes.SetMultiplier(OtherModes.GetMultiplier() + TwitchPlaySettings.data.TimeModeSolveBonus);
     }
 }
コード例 #2
0
    public static void Status(TwitchBomb bomb, string user, bool isWhisper)
    {
        int currentReward = TwitchPlaySettings.GetRewardBonus();

        if (OtherModes.TimeModeOn)
        {
            IRCConnection.SendMessage(string.Format(TwitchPlaySettings.data.BombStatusTimeMode, bomb.GetFullFormattedTime, bomb.GetFullStartingTime,
                                                    OtherModes.GetAdjustedMultiplier(), bomb.BombSolvedModules, bomb.BombSolvableModules, currentReward), user, !isWhisper);
        }
        else if (OtherModes.VSModeOn)
        {
            IRCConnection.SendMessage(string.Format(TwitchPlaySettings.data.BombStatusVsMode, bomb.GetFullFormattedTime,
                                                    bomb.GetFullStartingTime, OtherModes.goodHealth, OtherModes.evilHealth, currentReward), user, !isWhisper);
        }
        else
        {
            IRCConnection.SendMessage(string.Format(TwitchPlaySettings.data.BombStatus, bomb.GetFullFormattedTime, bomb.GetFullStartingTime,
                                                    bomb.StrikeCount, bomb.StrikeLimit, bomb.BombSolvedModules, bomb.BombSolvableModules, currentReward), user, !isWhisper);
        }
    }
コード例 #3
0
 public void UpdateConfidence()
 {
     if (OtherModes.TimeModeOn)
     {
         float timedMultiplier = OtherModes.GetAdjustedMultiplier();
         ConfidencePrefab.color = Color.yellow;
         string conf = "x" + $"{timedMultiplier:0.0}";
         string pts  = "+" + $"{TwitchPlaySettings.GetRewardBonus():0}";
         ConfidencePrefab.text = pts;
         StrikesPrefab.color   = Color.yellow;
         StrikesPrefab.text    = conf;
     }
     else if (OtherModes.ZenModeOn)
     {
         ConfidencePrefab.color = Color.yellow;
         string pts = "+" + $"{TwitchPlaySettings.GetRewardBonus():0}";
         ConfidencePrefab.text = pts;
         StrikesPrefab.color   = Color.red;
         if (_currentBomb != null)
         {
             StrikesPrefab.text = _currentBomb.StrikeCount.ToString();
         }
     }
     else if (OtherModes.VSModeOn)
     {
         int bossHealth = OtherModes.GetEvilHealth();
         int teamHealth = OtherModes.GetGoodHealth();
         StrikesPrefab.color    = Color.cyan;
         ConfidencePrefab.color = Color.red;
         StrikesPrefab.text     = $"{teamHealth} HP";
         ConfidencePrefab.text  = $"{bossHealth} HP";
     }
     else
     {
         ConfidencePrefab.color = Color.yellow;
         string pts = $"+{TwitchPlaySettings.GetRewardBonus():0}";
         ConfidencePrefab.text = pts;
     }
 }
コード例 #4
0
    public IEnumerator OnMessageReceived(string userNickName, string userColor, string text)
    {
        string internalCommand;
        Match  match = Regex.Match(text, string.Format("^{0} (.+)", _code), RegexOptions.IgnoreCase);

        if (!match.Success)
        {
            match = Regex.Match(text, string.Format("^{0}(?> (.+))?", _edgeworkCode), RegexOptions.IgnoreCase);
            if (match.Success)
            {
                internalCommand = match.Groups[1].Value;
                if (!string.IsNullOrEmpty(internalCommand))
                {
                    if (!IsAuthorizedDefuser(userNickName))
                    {
                        return(null);
                    }
                    edgeworkText.text = internalCommand;
                }
                IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.BombEdgework, edgeworkText.text);
            }
            return(null);
        }

        internalCommand = match.Groups[1].Value;

        TwitchMessage message = Instantiate <TwitchMessage>(messagePrefab, messageScrollContents.transform, false);

        message.SetMessage(string.IsNullOrEmpty(userColor)
                        ? string.Format("<b>{0}</b>: {1}", userNickName, internalCommand)
                        : string.Format("<b><color={2}>{0}</color></b>: {1}", userNickName, internalCommand, userColor));

        string internalCommandLower = internalCommand.ToLowerInvariant();

        string[] split = internalCommandLower.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);

        //Respond instantly to these commands without dropping "The Bomb", should the command be for "The Other Bomb" and vice versa.
        ICommandResponseNotifier notifier = message;

        if (internalCommandLower.EqualsAny("timestamp", "date"))
        {
            //Some modules depend on the date/time the bomb, and therefore that Module instance has spawned, in the bomb defusers timezone.

            notifier.ProcessResponse(CommandResponse.Start);
            IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.BombTimeStamp, bombCommander.BombTimeStamp);
            notifier.ProcessResponse(CommandResponse.EndNotComplete);
        }
        else if (internalCommandLower.Equals("help"))
        {
            notifier.ProcessResponse(CommandResponse.Start);

            IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.BombHelp);

            notifier.ProcessResponse(CommandResponse.EndNotComplete);
        }
        else if (internalCommandLower.EqualsAny("time", "timer", "clock"))
        {
            notifier.ProcessResponse(CommandResponse.Start);
            IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.BombTimeRemaining, bombCommander.GetFullFormattedTime, bombCommander.GetFullStartingTime);
            notifier.ProcessResponse(CommandResponse.EndNotComplete);
        }
        else if (internalCommandLower.EqualsAny("explode", "detonate", "endzenmode"))
        {
            if (UserAccess.HasAccess(userNickName, AccessLevel.Mod, true) || (OtherModes.ZenModeOn && internalCommandLower.Equals("endzenmode")))
            {
                return(DelayBombExplosionCoroutine(notifier));
            }

            return(null);
        }
        else if (internalCommandLower.Equals("status") || internalCommandLower.Equals("info"))
        {
            int currentReward = TwitchPlaySettings.GetRewardBonus();
            if (OtherModes.TimeModeOn)
            {
                IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.BombStatusTimeMode, bombCommander.GetFullFormattedTime, bombCommander.GetFullStartingTime,
                                                   OtherModes.GetAdjustedMultiplier(), bombCommander.bombSolvedModules, bombCommander.bombSolvableModules, currentReward);
            }
            else if (OtherModes.VSModeOn)
            {
                IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.BombStatusVsMode, bombCommander.GetFullFormattedTime,
                                                   bombCommander.GetFullStartingTime, OtherModes.teamHealth, OtherModes.bossHealth, currentReward);
            }
            else
            {
                IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.BombStatus, bombCommander.GetFullFormattedTime, bombCommander.GetFullStartingTime,
                                                   bombCommander.StrikeCount, bombCommander.StrikeLimit, bombCommander.bombSolvedModules, bombCommander.bombSolvableModules, currentReward);
            }
        }
        else if (split[0].EqualsAny("add", "increase", "change", "subtract", "decrease", "remove", "set"))
        {
            if (UserAccess.HasAccess(userNickName, AccessLevel.Admin, true))
            {
                bool negitive = split[0].EqualsAny("subtract", "decrease", "remove");
                bool direct   = split[0].EqualsAny("set");
                switch (split[1])
                {
                case "time":
                case "t":
                    float time = 0;
                    Dictionary <string, float> timeLengths = new Dictionary <string, float>()
                    {
                        { "ms", 0.001f },
                        { "s", 1 },
                        { "m", 60 },
                        { "h", 3600 },
                        { "d", 86400 },
                        { "w", 604800 },
                        { "y", 31536000 },
                    };

                    foreach (string part in split.Skip(2))
                    {
                        bool valid = false;
                        foreach (string unit in timeLengths.Keys)
                        {
                            if (!part.EndsWith(unit) || !float.TryParse(part.Substring(0, part.Length - unit.Length), out float length))
                            {
                                continue;
                            }
                            time += length * timeLengths[unit];
                            valid = true;
                            break;
                        }

                        if (!valid)
                        {
                            return(null);
                        }
                    }

                    time = (float)Math.Round((decimal)time, 2, MidpointRounding.AwayFromZero);
                    if (!direct && Math.Abs(time) == 0)
                    {
                        break;
                    }
                    if (negitive)
                    {
                        time = -time;
                    }

                    if (direct)
                    {
                        bombCommander.timerComponent.TimeRemaining = time;
                    }
                    else
                    {
                        bombCommander.timerComponent.TimeRemaining = bombCommander.CurrentTimer + time;
                    }

                    if (direct)
                    {
                        IRCConnection.Instance.SendMessage("Set the bomb's timer to {0}.", Math.Abs(time < 0 ? 0 : time).FormatTime());
                    }
                    else
                    {
                        IRCConnection.Instance.SendMessage("{0} {1} {2} the timer.", time > 0 ? "Added" : "Subtracted", Math.Abs(time).FormatTime(), time > 0 ? "to" : "from");
                    }
                    break;

                case "strikes":
                case "strike":
                case "s":
                    if (int.TryParse(split[2], out int strikes) && (strikes != 0 || direct))
                    {
                        if (negitive)
                        {
                            strikes = -strikes;
                        }

                        if (direct && strikes < 0)
                        {
                            strikes = 0;
                        }
                        else if (!direct && (bombCommander.StrikeCount + strikes) < 0)
                        {
                            strikes = -bombCommander.StrikeCount;                                       //Minimum of zero strikes. (Simon says is unsolvable with negative strikes.)
                        }

                        if (direct)
                        {
                            bombCommander.StrikeCount = strikes;
                        }
                        else
                        {
                            bombCommander.StrikeCount += strikes;
                        }

                        if (direct)
                        {
                            IRCConnection.Instance.SendMessage("Set the bomb's strike count to {0} {1}.", Math.Abs(strikes), Math.Abs(strikes) != 1 ? "strikes" : "strike");
                        }
                        else
                        {
                            IRCConnection.Instance.SendMessage("{0} {1} {2} {3} the bomb.", strikes > 0 ? "Added" : "Subtracted", Math.Abs(strikes), Math.Abs(strikes) != 1 ? "strikes" : "strike", strikes > 0 ? "to" : "from");
                        }
                        BombMessageResponder.moduleCameras.UpdateStrikes();
                    }
                    break;

                case "strikelimit":
                case "sl":
                case "maxstrikes":
                case "ms":
                    if (int.TryParse(split[2], out int maxStrikes) && (maxStrikes != 0 || direct))
                    {
                        if (negitive)
                        {
                            maxStrikes = -maxStrikes;
                        }

                        if (direct && maxStrikes < 0)
                        {
                            maxStrikes = 0;
                        }
                        else if (!direct && (bombCommander.StrikeLimit + maxStrikes) < 0)
                        {
                            maxStrikes = -bombCommander.StrikeLimit;
                        }

                        if (direct)
                        {
                            bombCommander.StrikeLimit = maxStrikes;
                        }
                        else
                        {
                            bombCommander.StrikeLimit += maxStrikes;
                        }

                        if (direct)
                        {
                            IRCConnection.Instance.SendMessage("Set the bomb's strike limit to {0} {1}.", Math.Abs(maxStrikes), Math.Abs(maxStrikes) != 1 ? "strikes" : "strike");
                        }
                        else
                        {
                            IRCConnection.Instance.SendMessage("{0} {1} {2} {3} the strike limit.", maxStrikes > 0 ? "Added" : "Subtracted", Math.Abs(maxStrikes), Math.Abs(maxStrikes) > 1 ? "strikes" : "strike", maxStrikes > 0 ? "to" : "from");
                        }
                        BombMessageResponder.moduleCameras.UpdateStrikes();
                        BombMessageResponder.moduleCameras.UpdateStrikeLimit();
                    }
                    break;
                }
            }

            return(null);
        }
        else if (!IsAuthorizedDefuser(userNickName))
        {
            return(null);
        }
        else
        {
            return(RespondToCommandCoroutine(userNickName, internalCommand, message));
        }

        return(null);
    }
コード例 #5
0
    private void AwardStrikes(string userNickName, int strikeCount)
    {
        string headerText    = UnsupportedModule ? modInfo.moduleDisplayName : BombComponent.GetModuleDisplayName();
        int    strikePenalty = modInfo.strikePenalty * (TwitchPlaySettings.data.EnableRewardMultipleStrikes ? strikeCount : 1);

        if (OtherModes.ZenModeOn)
        {
            strikePenalty = (int)(strikePenalty * 0.20f);
        }
        IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.AwardStrike, Code, strikeCount == 1 ? "a" : strikeCount.ToString(), strikeCount == 1 ? "" : "s", 0, userNickName, string.IsNullOrEmpty(StrikeMessage) ? "" : " caused by " + StrikeMessage, headerText, strikePenalty);
        if (strikeCount <= 0)
        {
            return;
        }

        string RecordMessageTone = $"Module ID: {Code} | Player: {userNickName} | Module Name: {headerText} | Strike";

        TwitchPlaySettings.AppendToSolveStrikeLog(RecordMessageTone, TwitchPlaySettings.data.EnableRewardMultipleStrikes ? strikeCount : 1);

        int originalReward = TwitchPlaySettings.GetRewardBonus();
        int currentReward  = Convert.ToInt32(originalReward * TwitchPlaySettings.data.AwardDropMultiplierOnStrike);

        TwitchPlaySettings.SetRewardBonus(currentReward);
        if (currentReward != originalReward)
        {
            IRCConnection.Instance.SendMessage($"Reward {(currentReward > 0 ? "reduced" : "increased")} to {currentReward} points.");
        }
        if (OtherModes.TimeModeOn)
        {
            float  originalMultiplier = OtherModes.GetAdjustedMultiplier();
            bool   multiDropped       = OtherModes.DropMultiplier();
            float  multiplier         = OtherModes.GetAdjustedMultiplier();
            string tempMessage;
            if (multiDropped)
            {
                if (Mathf.Abs(originalMultiplier - multiplier) >= 0.1)
                {
                    tempMessage = "Multiplier reduced to " + Math.Round(multiplier, 1) + " and time";
                }
                else
                {
                    tempMessage = "Time";
                }
            }
            else
            {
                tempMessage = $"Multiplier set at {TwitchPlaySettings.data.TimeModeMinMultiplier}, cannot be further reduced.  Time";
            }
            if (BombCommander.CurrentTimer < (TwitchPlaySettings.data.TimeModeMinimumTimeLost / TwitchPlaySettings.data.TimeModeTimerStrikePenalty))
            {
                BombCommander.timerComponent.TimeRemaining = BombCommander.CurrentTimer - TwitchPlaySettings.data.TimeModeMinimumTimeLost;
                tempMessage = tempMessage + $" reduced by {TwitchPlaySettings.data.TimeModeMinimumTimeLost} seconds.";
            }
            else
            {
                float  timeReducer = BombCommander.CurrentTimer * TwitchPlaySettings.data.TimeModeTimerStrikePenalty;
                double easyText    = Math.Round(timeReducer, 1);
                BombCommander.timerComponent.TimeRemaining = BombCommander.CurrentTimer - timeReducer;
                tempMessage = tempMessage + $" reduced by {Math.Round(TwitchPlaySettings.data.TimeModeTimerStrikePenalty * 100, 1)}%. ({easyText} seconds)";
            }
            IRCConnection.Instance.SendMessage(tempMessage);
            BombCommander.StrikeCount = 0;
            BombMessageResponder.moduleCameras.UpdateStrikes();
        }
        if (OtherModes.ZenModeOn)
        {
            BombCommander.StrikeLimit += strikeCount;
        }

        Leaderboard.Instance.AddScore(userNickName, strikePenalty);
        Leaderboard.Instance.AddStrike(userNickName, strikeCount);
        StrikeMessage = string.Empty;
    }