private bool HandleKey(string[] modulesBefore, string[] modulesAfter, FieldInfo keyTurned, FieldInfo otherKeyTurned, FieldInfo beforeKeyField, MethodInfo onKeyTurn) { if (!GetValue(_activatedField) || GetValue(keyTurned)) { return(false); } KMBombInfo bombInfo = BombComponent.GetComponent <KMBombInfo>(); KMBombModule bombModule = BombComponent.GetComponent <KMBombModule>(); if (TwitchPlaySettings.data.EnforceSolveAllBeforeTurningKeys && modulesAfter.Any(x => bombInfo.GetSolvedModuleNames().Count(x.Equals) != bombInfo.GetSolvableModuleNames().Count(x.Equals))) { bombModule.HandleStrike(); return(false); } beforeKeyField.SetValue(null, TwitchPlaySettings.data.DisableTurnTheKeysSoftLock ? new string[0] : modulesBefore); onKeyTurn.Invoke(BombComponent.GetComponent(_componentType), null); if (GetValue(keyTurned)) { //Check to see if any forbidden modules for this key were solved. if (TwitchPlaySettings.data.DisableTurnTheKeysSoftLock && bombInfo.GetSolvedModuleNames().Any(modulesBefore.Contains)) { bombModule.HandleStrike(); //If so, Award a strike for it. } if (GetValue(otherKeyTurned)) { int modules = bombInfo.GetSolvedModuleNames().Count(x => RightAfterA.Contains(x) || LeftAfterA.Contains(x)); TwitchPlaySettings.AddRewardBonus(2 * modules); IRCConnection.SendMessage("Reward increased by {0} for defusing module !{1} ({2}).", modules * 2, Code, bombModule.ModuleDisplayName); } } return(false); }
public void ProcessResponse(CommandResponse response, int value) { switch (response) { case CommandResponse.Start: StopAllCoroutines(); StartCoroutine(DoBackgroundColorChange(highlightColor)); break; case CommandResponse.EndNotComplete: StopAllCoroutines(); StartCoroutine(DoBackgroundColorChange(normalColor)); break; case CommandResponse.EndComplete: StopAllCoroutines(); StartCoroutine(DoBackgroundColorChange(completeColor)); if (leaderboard != null) { leaderboard.AddSolve(userName, userColor); if (!UserAccess.HasAccess(userName, AccessLevel.NoPoints)) { leaderboard.AddScore(userName, userColor, value); } else { TwitchPlaySettings.AddRewardBonus(value); } } break; case CommandResponse.EndError: StopAllCoroutines(); StartCoroutine(DoBackgroundColorChange(errorColor)); leaderboard?.AddStrike(userName, userColor, TwitchPlaySettings.data.EnableRewardMultipleStrikes ? value : 1); break; case CommandResponse.NoResponse: StopAllCoroutines(); StartCoroutine(DoBackgroundColorChange(ignoreColor)); break; case CommandResponse.EndErrorSubtractScore: if (!UserAccess.HasAccess(userName, AccessLevel.NoPoints)) { leaderboard?.AddScore(userName, userColor, value); } break; default: break; } }
private bool HandleKey(string[] modulesBefore, IEnumerable <string> modulesAfter, FieldInfo keyTurned, FieldInfo otherKeyTurned, FieldInfo beforeKeyField, MethodInfo onKeyTurn, FieldInfo animatorField) { if (!GetValue(ActivatedField) || GetValue(keyTurned)) { return(false); } KMBombInfo bombInfo = Module.BombComponent.GetComponent <KMBombInfo>(); KMBombModule bombModule = Module.BombComponent.GetComponent <KMBombModule>(); KMAudio bombAudio = Module.BombComponent.GetComponent <KMAudio>(); Animator keyAnimator = (Animator)animatorField.GetValue(Module.BombComponent.GetComponent(ComponentType)); if (TwitchPlaySettings.data.EnforceSolveAllBeforeTurningKeys && modulesAfter.Any(x => bombInfo.GetSolvedModuleNames().Count(x.Equals) != bombInfo.GetSolvableModuleNames().Count(x.Equals))) { keyAnimator.SetTrigger("WrongTurn"); bombAudio.PlaySoundAtTransform("WrongKeyTurnFK", Module.transform); bombModule.HandleStrike(); return(false); } beforeKeyField.SetValue(null, TwitchPlaySettings.data.DisableTurnTheKeysSoftLock ? new string[0] : modulesBefore); onKeyTurn.Invoke(Module.BombComponent.GetComponent(ComponentType), null); if (GetValue(keyTurned)) { //Check to see if any forbidden modules for this key were solved. if (TwitchPlaySettings.data.DisableTurnTheKeysSoftLock && bombInfo.GetSolvedModuleNames().Any(modulesBefore.Contains)) { bombModule.HandleStrike(); //If so, Award a strike for it. } if (!GetValue(otherKeyTurned)) { return(false); } int modules = bombInfo.GetSolvedModuleNames().Count(x => RightAfterA.Contains(x) || LeftAfterA.Contains(x)); TwitchPlaySettings.AddRewardBonus((2 * modules * OtherModes.ScoreMultiplier).RoundToInt()); IRCConnection.SendMessage($"Reward increased by {modules * 2} for defusing module !{Code} ({bombModule.ModuleDisplayName})."); } else { keyAnimator.SetTrigger("WrongTurn"); bombAudio.PlaySoundAtTransform("WrongKeyTurnFK", Module.transform); } return(false); }
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); } }
public static void NewBomb(string user, bool isWhisper) { if (!OtherModes.ZenModeOn) { IRCConnection.SendMessage($"Sorry {user}, the newbomb command is only allowed in Zen mode.", user, !isWhisper); return; } if (isWhisper) { IRCConnection.SendMessage($"Sorry {user}, the newbomb command is not allowed in whispers.", user, !isWhisper); return; } Leaderboard.Instance.GetRank(user, out var entry); if (entry.SolveScore < TwitchPlaySettings.data.MinScoreForNewbomb && !UserAccess.HasAccess(user, AccessLevel.Defuser, true)) { IRCConnection.SendMessage($"Sorry {user}, you don’t have enough points to use the newbomb command."); } else { TwitchPlaySettings.AddRewardBonus(-TwitchPlaySettings.GetRewardBonus()); foreach (var bomb in TwitchGame.Instance.Bombs.Where(x => GameRoom.Instance.IsCurrentBomb(x.BombID))) { bomb.Bomb.GetTimer().StopTimer(); } foreach (var module in TwitchGame.Instance.Modules.Where(x => GameRoom.Instance.IsCurrentBomb(x.BombID))) { if (!module.Solved) { module.SolveSilently(); } } } }
private void AwardStrikes(string userNickName, int strikeCount) { BombCommander BombCommander = BombMessageResponder.Instance.BombCommanders[0]; int strikePenalty = -5; strikePenalty = TwitchPlaySettings.data.EnableRewardMultipleStrikes ? (strikeCount * strikePenalty) : (Math.Min(strikePenalty, strikeCount * strikePenalty)); IRCConnection.Instance.SendMessage(TwitchPlaySettings.data.AwardHoldableStrike, HoldableCommander.ID, strikeCount == 1 ? "a" : strikeCount.ToString(), strikeCount == 1 ? "" : "s", strikePenalty, userNickName, string.IsNullOrEmpty(StrikeMessage) ? "" : " caused by " + StrikeMessage); if (strikeCount <= 0) { return; } string RecordMessageTone = $"Holdable ID: {HoldableCommander.ID} | Player: {userNickName} | Strike"; TwitchPlaySettings.AppendToSolveStrikeLog(RecordMessageTone, TwitchPlaySettings.data.EnableRewardMultipleStrikes ? strikeCount : 1); int originalReward = TwitchPlaySettings.GetRewardBonus(); int currentReward = Convert.ToInt32(originalReward * TwitchPlaySettings.data.AwardDropMultiplierOnStrike); TwitchPlaySettings.AddRewardBonus(currentReward - originalReward); if (currentReward != originalReward) { IRCConnection.Instance.SendMessage($"Reward {(currentReward > 0 ? "reduced" : "increased")} to {currentReward} points."); } if (OtherModes.TimeModeOn) { bool multiDropped = OtherModes.DropMultiplier(); float multiplier = OtherModes.GetMultiplier(); string tempMessage; if (multiDropped) { tempMessage = "Multiplier reduced to " + Math.Round(multiplier, 1) + " and 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(); } Leaderboard.Instance?.AddScore(userNickName, strikePenalty); Leaderboard.Instance?.AddStrike(userNickName, strikeCount); StrikeMessage = string.Empty; }