public TranslatedWhosOnFirstComponentSolver(BombCommander bombCommander, BombComponent bombComponent) :
        base(bombCommander, bombComponent)
    {
        _component = bombComponent.GetComponent(_componentType);
        _buttons   = (KMSelectable[])_buttonsField.GetValue(_component);
        modInfo    = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} what? [press the button that says \"WHAT?\"] | The phrase must match exactly | Not case sensitive| If the language used asks for pressing a literally blank button, use \"!{0} literally blank\"");

        if (bombCommander != null)
        {
            string language = TranslatedModuleHelper.GetManualCodeAddOn(bombComponent);
            if (language != null)
            {
                modInfo.manualCode = $"Who%E2%80%99s%20on%20First{language}";
            }
            modInfo.moduleDisplayName = $"Who's on First Translated{TranslatedModuleHelper.GetModuleDisplayNameAddon(bombComponent)}";
            bombComponent.StartCoroutine(SetHeaderText());
        }
    }
Ejemplo n.º 2
0
    public NeedyRotaryPhoneComponentSolver(BombCommander bombCommander, MonoBehaviour bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) :
        base(bombCommander, bombComponent, ircConnection, canceller)
    {
        _buttons    = new MonoBehaviour[10];
        _buttons[0] = (MonoBehaviour)_button0Field.GetValue(bombComponent.GetComponent(_componentSolverType));
        _buttons[1] = (MonoBehaviour)_button1Field.GetValue(bombComponent.GetComponent(_componentSolverType));
        _buttons[2] = (MonoBehaviour)_button2Field.GetValue(bombComponent.GetComponent(_componentSolverType));
        _buttons[3] = (MonoBehaviour)_button3Field.GetValue(bombComponent.GetComponent(_componentSolverType));
        _buttons[4] = (MonoBehaviour)_button4Field.GetValue(bombComponent.GetComponent(_componentSolverType));
        _buttons[5] = (MonoBehaviour)_button5Field.GetValue(bombComponent.GetComponent(_componentSolverType));
        _buttons[6] = (MonoBehaviour)_button6Field.GetValue(bombComponent.GetComponent(_componentSolverType));
        _buttons[7] = (MonoBehaviour)_button7Field.GetValue(bombComponent.GetComponent(_componentSolverType));
        _buttons[8] = (MonoBehaviour)_button8Field.GetValue(bombComponent.GetComponent(_componentSolverType));
        _buttons[9] = (MonoBehaviour)_button9Field.GetValue(bombComponent.GetComponent(_componentSolverType));

        helpMessage = "Respond to the phone call with !{0} press 8 4 9.";
        manualCode  = "Rotary%20Phone";
    }
    public TranslatedPasswordComponentSolver(BombCommander bombCommander, BombComponent bombComponent) :
        base(bombCommander, bombComponent)
    {
        _downButtons  = (KMSelectable[])_downButtonField.GetValue(bombComponent.GetComponent(_passwordComponentType));
        _submitButton = (MonoBehaviour)_submitButtonField.GetValue(bombComponent.GetComponent(_passwordComponentType));
        _display      = (TextMesh[])_displayField.GetValue(bombComponent.GetComponent(_passwordComponentType));
        modInfo       = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} cycle 3 [cycle through the letters in column 3] | !{0} cycle 1 3 5 [cycle through the letters in columns 1, 3, and 5] | !{0} world [try to submit a word]");

        if (bombCommander != null)
        {
            string language = TranslatedModuleHelper.GetManualCodeAddOn(bombComponent);
            if (language != null)
            {
                modInfo.manualCode = $"Password{language}";
            }
            modInfo.moduleDisplayName = $"Passwords Translated{TranslatedModuleHelper.GetModuleDisplayNameAddon(bombComponent)}";
            bombComponent.StartCoroutine(SetHeaderText());
        }
    }
Ejemplo n.º 4
0
    private IEnumerator getBomb()
    {
        yield return(null);

        while (currentState == KMGameInfo.State.Gameplay)
        {
            yield return(null);

            if (BombActive)
            {
                BombCommander current = GetHeldBomb();
                if (current != null)
                {
                    currentBomb = current;
                }
            }
        }
        yield break;
    }
Ejemplo n.º 5
0
    public TranslatedNeedyVentComponentSolver(BombCommander bombCommander, BombComponent bombComponent) :
        base(bombCommander, bombComponent)
    {
        _yesButton = (MonoBehaviour)_yesButtonField.GetValue(bombComponent.GetComponent(_needyVentComponentSolverType));
        _noButton  = (MonoBehaviour)_noButtonField.GetValue(bombComponent.GetComponent(_needyVentComponentSolverType));
        modInfo    = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} yes, !{0} y [answer yes] | !{0} no, !{0} n [answer no]");

        if (bombCommander != null)
        {
            string language = TranslatedModuleHelper.GetManualCodeAddOn(bombComponent);
            if (language != null)
            {
                modInfo.manualCode = "Venting%20Gas";
            }
            //if (language != null) modInfo.manualCode = $"Venting%20Gas{language}";
            modInfo.moduleDisplayName = $"Needy Vent Gas Translated{TranslatedModuleHelper.GetModuleDisplayNameAddon(bombComponent)}";
            bombComponent.StartCoroutine(SetHeaderText());
        }
    }
Ejemplo n.º 6
0
    public TranslatedMorseCodeComponentSolver(BombCommander bombCommander, BombComponent bombComponent) :
        base(bombCommander, bombComponent)
    {
        _component      = bombComponent.GetComponent(_morseCodeComponentType);
        _upButton       = (MonoBehaviour)_upButtonField.GetValue(_component);
        _downButton     = (MonoBehaviour)_downButtonField.GetValue(_component);
        _transmitButton = (MonoBehaviour)_transmitButtonField.GetValue(_component);
        modInfo         = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} transmit 3.573, !{0} trans 573, !{0} tx 573 [transmit frequency 3.573]");

        if (bombCommander != null)
        {
            string language = TranslatedModuleHelper.GetManualCodeAddOn(bombComponent);
            if (language != null)
            {
                modInfo.manualCode = $"Morse%20Code{language}";
            }
            modInfo.moduleDisplayName = $"Morse Code Translated{TranslatedModuleHelper.GetModuleDisplayNameAddon(bombComponent)}";
            bombComponent.StartCoroutine(SetHeaderText());
        }
    }
    private static ComponentSolver CreateModComponentSolver(BombCommander bombCommander, MonoBehaviour bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller, string moduleType)
    {
        if (ModComponentSolverCreators.ContainsKey(moduleType))
        {
            return(ModComponentSolverCreators[moduleType](bombCommander, bombComponent, ircConnection, canceller));
        }

        Debug.LogFormat("Attempting to find a valid process command method to respond with on component {0}...", moduleType);

        ModComponentSolverDelegate modComponentSolverCreator = GenerateModComponentSolverCreator(bombComponent, moduleType);

        if (modComponentSolverCreator == null)
        {
            throw new NotSupportedException(string.Format("Currently {0} is not supported by 'Twitch Plays' - Could not generate a valid componentsolver for the mod component!", (string)CommonReflectedTypeInfo.ModuleDisplayNameField.Invoke(bombComponent, null)));
        }

        ModComponentSolverCreators[moduleType] = modComponentSolverCreator;

        return(modComponentSolverCreator(bombCommander, bombComponent, ircConnection, canceller));
    }
    public TranslatedButtonComponentSolver(BombCommander bombCommander, BombComponent bombComponent) :
        base(bombCommander, bombComponent)
    {
        _button = (KMSelectable)_buttonField.GetValue(bombComponent.GetComponent(_componentType));
        modInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} tap [tap the button] | !{0} hold [hold the button] | !{0} release 7 [release when the digit shows 7] | (Important - Take note of the strip color on hold, it will change as other translated buttons get held, and the answer retains original color.)");
        Selectable selectable = bombComponent.GetComponent <Selectable>();

        selectable.OnCancel += () => { _selectedField.SetValue(bombComponent.GetComponent(_componentType), false); return(true); };

        if (bombCommander != null)
        {
            string language = TranslatedModuleHelper.GetManualCodeAddOn(bombComponent);
            if (language != null)
            {
                modInfo.manualCode = $"The%20Button{language}";
            }
            modInfo.moduleDisplayName = $"Big Button Translated{TranslatedModuleHelper.GetModuleDisplayNameAddon(bombComponent)}";
            bombComponent.StartCoroutine(SetHeaderText());
        }
    }
Ejemplo n.º 9
0
    public ListeningComponentSolver(BombCommander bombCommander, BombComponent bombComponent) :
        base(bombCommander, bombComponent)
    {
        Component component = bombComponent.GetComponent("Listening");

        if (component == null)
        {
            throw new NotSupportedException("Could not get Listening Component from bombComponent");
        }

        Type componentType = component.GetType();

        if (componentType == null)
        {
            throw new NotSupportedException("Could not get componentType from Listening Component");
        }

        FieldInfo playField      = componentType.GetField("PlayButton", BindingFlags.Public | BindingFlags.Instance);
        FieldInfo dollarField    = componentType.GetField("DollarButton", BindingFlags.Public | BindingFlags.Instance);
        FieldInfo poundField     = componentType.GetField("PoundButton", BindingFlags.Public | BindingFlags.Instance);
        FieldInfo starField      = componentType.GetField("StarButton", BindingFlags.Public | BindingFlags.Instance);
        FieldInfo ampersandField = componentType.GetField("AmpersandButton", BindingFlags.Public | BindingFlags.Instance);

        if (playField == null || dollarField == null || poundField == null || starField == null || ampersandField == null)
        {
            throw new NotSupportedException("Could not find the KMSelectable fields in component Type");
        }

        _buttons    = new MonoBehaviour[4];
        _play       = (MonoBehaviour)playField.GetValue(component);
        _buttons[0] = (MonoBehaviour)dollarField.GetValue(component);
        _buttons[1] = (MonoBehaviour)poundField.GetValue(component);
        _buttons[2] = (MonoBehaviour)starField.GetValue(component);
        _buttons[3] = (MonoBehaviour)ampersandField.GetValue(component);
        if (_play == null || _buttons.Any(x => x == null))
        {
            throw new NotSupportedException("Component had null KMSelectables.");
        }

        modInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "Listen to the sound with !{0} press play. Enter the response with !{0} press $ & * * #.");
    }
    public ButtonComponentSolver(BombCommander bombCommander, ButtonComponent bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) :
        base(bombCommander, bombComponent, ircConnection, canceller)
    {
        ModuleInformation buttonInfo       = ComponentSolverFactory.GetModuleInfo("ButtonComponentSolver");
        ModuleInformation squarebuttonInfo = ComponentSolverFactory.GetModuleInfo("ButtonV2");

        bombComponent.GetComponent <Selectable>().OnCancel += bombComponent.OnButtonCancel;
        _button = bombComponent.button;
        modInfo = new ModuleInformation
        {
            builtIntoTwitchPlays       = buttonInfo.builtIntoTwitchPlays,
            CameraPinningAlwaysAllowed = buttonInfo.CameraPinningAlwaysAllowed,
            helpText = VanillaRuleModifier.IsSeedVanilla()
                ? buttonInfo.helpText
                : squarebuttonInfo.helpText,
            manualCode        = buttonInfo.manualCode,
            moduleDisplayName = buttonInfo.moduleDisplayName,
            moduleID          = buttonInfo.moduleID,
            moduleScore       = VanillaRuleModifier.IsSeedVanilla()
                ? buttonInfo.moduleScore
                : squarebuttonInfo.moduleScore
        };
    }
Ejemplo n.º 11
0
    public UnsupportedModComponentSolver(BombCommander bombCommander, BombComponent bombComponent)
        : base(bombCommander, bombComponent)
    {
        bombModule  = bombComponent.GetComponent <KMBombModule>();
        needyModule = bombComponent.GetComponent <KMNeedyModule>();

        modInfo = new ModuleInformation {
            moduleScore = 0, builtIntoTwitchPlays = true, DoesTheRightThing = true, helpText = $"Solve this {(bombModule != null ? "module" : "needy")} with !{{0}} solve", moduleDisplayName = $"Unsupported Twitchplays Module  ({bombComponent.GetModuleDisplayName()})", moduleID = "UnsupportedTwitchPlaysModule"
        };

        UnsupportedModule = true;

        Selectable selectable = bombComponent.GetComponent <Selectable>();

        Selectable[]         selectables       = bombComponent.GetComponentsInChildren <Selectable>();
        HashSet <Selectable> selectableHashSet = new HashSet <Selectable>(selectables)
        {
            selectable
        };

        selectable.OnInteract += () => { ComponentHandle?.CanvasGroupUnsupported?.gameObject.SetActive(false); return(true); };
        selectable.OnDeselect += (x) => { ComponentHandle?.CanvasGroupUnsupported?.gameObject.SetActive(x == null || !selectableHashSet.Contains(x)); };
    }
Ejemplo n.º 12
0
 public NeedyKnobComponentSolver(BombCommander bombCommander, NeedyKnobComponent bombComponent) :
     base(bombCommander, bombComponent)
 {
     _pointingKnob = bombComponent.PointingKnob;
     modInfo       = ComponentSolverFactory.GetModuleInfo("NeedyKnobComponentSolver", "!{0} rotate 3, !{0} turn 3 [rotate the knob 3 quarter-turns]", "Knob");
 }
Ejemplo n.º 13
0
 public CrazyTalkComponentSolver(BombCommander bombCommander, MonoBehaviour bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) :
     base(bombCommander, bombComponent, ircConnection, canceller)
 {
     _toggle     = (MonoBehaviour)_toggleField.GetValue(bombComponent.GetComponent(_componentType));
     helpMessage = "Toggle the switch down and up with !{0} toggle 4 5. The order is down, then up.";
 }
 public LetterKeysComponentSolver(BombCommander bombCommander, BombComponent bombComponent) :
     base(bombCommander, bombComponent)
 {
     _buttons = bombComponent.GetComponent <KMSelectable>().Children;
     modInfo  = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} press b", "Letter%20Keys");
 }
Ejemplo n.º 15
0
 public ProbingComponentSolver(BombCommander bombCommander, BombComponent bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) :
     base(bombCommander, bombComponent, ircConnection, canceller)
 {
     _wires  = (MonoBehaviour[])_wiresField.GetValue(bombComponent.GetComponent(_componentType));
     modInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType());
 }
Ejemplo n.º 16
0
 public CryptographyComponentSolver(BombCommander bombCommander, BombComponent bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) :
     base(bombCommander, bombComponent, ircConnection, canceller)
 {
     _buttons = (KMSelectable[])_keysField.GetValue(bombComponent.GetComponent(_componentType));
     modInfo  = ComponentSolverFactory.GetModuleInfo(GetModuleType());
 }
 public ExtendedPasswordComponentSolver(BombCommander bombCommander, BombComponent bombComponent) :
     base(bombCommander, bombComponent)
 {
     modInfo = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "!{0} cycle 6 [cycle through the letters in column 6] | !{0} lambda [try to submit a word]");
 }
 public RoundKeypadComponentSolver(BombCommander bombCommander, MonoBehaviour bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) :
     base(bombCommander, bombComponent, ircConnection, canceller)
 {
     _buttons    = (Array)_buttonsField.GetValue(bombComponent.GetComponent(_componentType));
     helpMessage = "Solve the module with !{0} press 2 4 6 7 8. Button 1 is the top most botton, and are numbered in clockwise order.";
 }
Ejemplo n.º 19
0
 public WhosOnFirstComponentSolver(BombCommander bombCommander, WhosOnFirstComponent bombComponent) :
     base(bombCommander, bombComponent)
 {
     _buttons = bombComponent.Buttons;
     modInfo  = ComponentSolverFactory.GetModuleInfo("WhosOnFirstComponentSolver", "!{0} what? [press the button that says \"WHAT?\"] | The phrase must match exactly | Not case sensitive", "Who%E2%80%99s on First");
 }
 public CurriculumComponentSolver(BombCommander bombCommander, BombComponent bombComponent) :
     base(bombCommander, bombComponent)
 {
     _buttons = bombComponent.GetComponent <KMSelectable>().Children;
     modInfo  = ComponentSolverFactory.GetModuleInfo(GetModuleType(), "Cycle the buttons !{0} cycle. Click a button using !{0} click 2. It's possible to add a number of times to click: !{0} click 2 3. Buttons are numbered left to right. Submit your answer with !{0} submit.");
 }
 public VennWireComponentSolver(BombCommander bombCommander, VennWireComponent bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) :
     base(bombCommander, bombComponent, ircConnection, canceller)
 {
     _wires  = bombComponent.ActiveWires;
     modInfo = ComponentSolverFactory.GetModuleInfo("VennWireComponentSolver");
 }
Ejemplo n.º 22
0
 public WireSetComponentSolver(BombCommander bombCommander, WireSetComponent bombComponent) :
     base(bombCommander, bombComponent)
 {
     _wires  = bombComponent.wires;
     modInfo = ComponentSolverFactory.GetModuleInfo("WireSetComponentSolver", "!{0} cut 3 [cut wire 3] | Wires are ordered from top to bottom | Empty spaces are not counted");
 }
Ejemplo n.º 23
0
    public IEnumerator RespondToCommand(string userNickName, string message)
    {
        DisableOnStrike      = false;
        Strike               = false;
        StrikeCount          = 0;
        _currentUserNickName = userNickName;

        FloatingHoldable.HoldStateEnum holdState = Holdable.HoldState;

        if (holdState == FloatingHoldable.HoldStateEnum.Held)
        {
        }
        else
        {
            IEnumerator holdCoroutine = HoldableCommander.Hold();
            while (holdCoroutine.MoveNext() && !Strike)
            {
                yield return(holdCoroutine.Current);
            }
        }

        IEnumerator processCommand = RespondToCommandCommon(message);

        if (processCommand == null || !processCommand.MoveNext())
        {
            DebugHelper.Log("Running RespondToCommandInternal()");
            processCommand = RespondToCommandInternal(message);
            bool cancelled  = false;
            bool parseError = false;
            bool cancelling = false;

            if (processCommand == null || !processCommand.MoveNext())
            {
                if (!Strike)
                {
                    SendToChat(null, userNickName, ref parseError);
                }
            }
            else
            {
                processIEnumerators.Push(processCommand);
                processIEnumerators.Push(FirstItem(processCommand.Current));
            }

            do
            {
                try
                {
                    bool result = false;
                    while (!result && !Strike)
                    {
                        if (processIEnumerators.Count > 0)
                        {
                            processCommand = processIEnumerators.Pop();
                            result         = processCommand.MoveNext();
                            if (result)
                            {
                                processIEnumerators.Push(processCommand);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (Strike)
                    {
                        DebugHelper.Log("A strike was caused by the command. Invocation will not continue.");
                    }
                    if (!result || Strike)
                    {
                        break;
                    }
                }
                catch (Exception ex)
                {
                    DebugHelper.LogException(ex, "Error Processing command due to an exception. Invocation will not continue.:");
                    break;
                }

                switch (processCommand.Current)
                {
                case IEnumerator iEnumerator:
                    if (iEnumerator != null)
                    {
                        processIEnumerators.Push(iEnumerator);
                    }
                    continue;

                case KMSelectable kmSelectable when kmSelectable != null:
                    if (heldSelectables.Contains(kmSelectable))
                    {
                        DoInteractionEnd(kmSelectable);
                        heldSelectables.Remove(kmSelectable);
                    }
                    else
                    {
                        DoInteractionStart(kmSelectable);
                        heldSelectables.Add(kmSelectable);
                    }
                    break;

                case KMSelectable[] kmSelectables:
                    foreach (KMSelectable selectable in kmSelectables)
                    {
                        if (selectable != null)
                        {
                            yield return(DoInteractionClick(selectable));

                            if (Strike)
                            {
                                break;
                            }
                        }
                        else
                        {
                            yield return(new WaitForSeconds(0.1f));
                        }
                    }
                    break;

                case Quaternion quaternion:
                    HoldableCommander.RotateByLocalQuaternion(quaternion);
                    break;

                case string currentString when !string.IsNullOrEmpty(currentString):
                    if (currentString.Equals("trycancel", StringComparison.InvariantCultureIgnoreCase) &&
                        CoroutineCanceller.ShouldCancel)
                    {
                        CoroutineCanceller.ResetCancel();
                        cancelled = true;
                    }
                    else if (currentString.ToLowerInvariant().EqualsAny("elevator music", "hold music", "waiting music"))
                    {
                        if (_musicPlayer == null)
                        {
                            _musicPlayer = MusicPlayer.StartRandomMusic();
                        }
                    }
                    else if (currentString.ToLowerInvariant().Equals("cancelled") && cancelling)
                    {
                        CancelBool?.SetValue(CommandComponent, false);
                        CoroutineCanceller.ResetCancel();
                        cancelled = true;
                    }
                    else if (currentString.StartsWith("strikemessage ", StringComparison.InvariantCultureIgnoreCase) &&
                             currentString.Substring(14).Trim() != string.Empty)
                    {
                        StrikeMessage = currentString.Substring(14);
                    }
                    else if (currentString.Equals("strike", StringComparison.InvariantCultureIgnoreCase))
                    {
                        _delegatedStrikeUserNickName = _currentUserNickName;
                    }
                    else if (currentString.Equals("multiple strikes", StringComparison.InvariantCultureIgnoreCase))
                    {
                        DisableOnStrike = true;
                    }
                    else if (currentString.ToLowerInvariant().EqualsAny("detonate", "explode") && BombMessageResponder.BombActive)
                    {
                        BombCommander BombCommander = BombMessageResponder.Instance.BombCommanders[0];
                        AwardStrikes(_currentUserNickName, BombCommander.StrikeLimit - BombCommander.StrikeCount);
                        BombCommander.twitchBombHandle.CauseExplosionByModuleCommand(string.Empty, HoldableCommander.ID);
                        Strike = true;
                    }
                    else if (currentString.ToLowerInvariant().Equals("show front"))
                    {
                        processIEnumerators.Push(HoldableCommander.Hold(true));
                    }
                    else if (currentString.ToLowerInvariant().Equals("show back"))
                    {
                        processIEnumerators.Push(HoldableCommander.Hold(false));
                    }
                    else
                    {
                        SendToChat(currentString, userNickName, ref parseError);
                    }
                    break;

                case string[] currentStrings:
                    if (currentStrings.Length >= 1)
                    {
                        if (currentStrings[0].ToLowerInvariant().EqualsAny("detonate", "explode") && BombMessageResponder.BombActive)
                        {
                            BombCommander BombCommander = BombMessageResponder.Instance.BombCommanders[0];
                            AwardStrikes(_currentUserNickName, BombCommander.StrikeLimit - BombCommander.StrikeCount);
                            switch (currentStrings.Length)
                            {
                            case 2:
                                BombCommander.twitchBombHandle.CauseExplosionByModuleCommand(currentStrings[1], HoldableCommander.ID);
                                break;

                            case 3:
                                BombCommander.twitchBombHandle.CauseExplosionByModuleCommand(currentStrings[1], currentStrings[2]);
                                break;

                            default:
                                BombCommander.twitchBombHandle.CauseExplosionByModuleCommand(string.Empty, HoldableCommander.ID);
                                break;
                            }
                            break;
                        }
                    }
                    break;

                case Dictionary <string, bool> permissions:
                    foreach (KeyValuePair <string, bool> pair in permissions)
                    {
                        if (TwitchPlaySettings.data.ModPermissions.ContainsKey(pair.Key))
                        {
                            continue;
                        }
                        TwitchPlaySettings.data.ModPermissions.Add(pair.Key, pair.Value);
                        TwitchPlaySettings.WriteDataToFile();
                    }
                    break;

                case KMMission mission:
                    MiscellaneousMessageResponder.Instance.RunMission(mission);
                    break;

                case object[] objects:
                    if (objects == null)
                    {
                        break;
                    }
                    switch (objects.Length)
                    {
                    case 3 when objects[0] is string objstr:
                        if (IsAskingPermission(objstr, userNickName, out bool permissionGranted))
                        {
                            if (permissionGranted)
                            {
                                switch (objects[1])
                                {
                                case Action actionTrue:
                                    actionTrue.Invoke();
                                    break;

                                case IEnumerator iEnumerator when iEnumerator != null:
                                    processIEnumerators.Push(iEnumerator);
                                    yield return(null);

                                    continue;
                                }
                            }
                            else
                            {
                                switch (objects[2])
                                {
                                case Action actionFalse:
                                    actionFalse.Invoke();
                                    break;

                                case string objStr2 when !string.IsNullOrEmpty(objStr2):
                                    SendToChat(objStr2, userNickName, ref parseError);
                                    break;

                                case IEnumerator iEnumerator when iEnumerator != null:
                                    processIEnumerators.Push(iEnumerator);
                                    yield return(null);

                                    continue;
                                }
                            }
                        }
                        break;
                    }
                    break;
Ejemplo n.º 24
0
 public KeypadComponentSolver(BombCommander bombCommander, KeypadComponent bombComponent) :
     base(bombCommander, bombComponent)
 {
     _buttons = bombComponent.buttons;
     modInfo  = ComponentSolverFactory.GetModuleInfo("KeypadComponentSolver", "!{0} press 3 1 2 4 | The buttons are 1=TL, 2=TR, 3=BL, 4=BR", "Keypad");
 }
Ejemplo n.º 25
0
 public NeedyDischargeComponentSolver(BombCommander bombCommander, NeedyDischargeComponent bombComponent) :
     base(bombCommander, bombComponent)
 {
     _dischargeButton = bombComponent.DischargeButton;
     modInfo          = ComponentSolverFactory.GetModuleInfo("NeedyDischargeComponentSolver", "!{0} hold 7 [hold the lever for 7 seconds]", "Capacitor Discharge");
 }
 public MemoryComponentSolver(BombCommander bombCommander, MemoryComponent bombComponent) :
     base(bombCommander, bombComponent)
 {
     _buttons = bombComponent.Buttons;
     modInfo  = ComponentSolverFactory.GetModuleInfo("MemoryComponentSolver", "!{0} position 2, !{0} pos 2, !{0} p 2 [2nd position] | !{0} label 3, !{0} lab 3, !{0} l 3 [label 3]");
 }
 public AlphabetComponentSolver(BombCommander bombCommander, BombComponent bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) :
     base(bombCommander, bombComponent, ircConnection, canceller)
 {
     _buttons = bombComponent.GetComponent <KMSelectable>().Children;
     modInfo  = ComponentSolverFactory.GetModuleInfo(GetModuleType());
 }
 public SimonComponentSolver(BombCommander bombCommander, SimonComponent bombComponent) :
     base(bombCommander, bombComponent)
 {
     _buttons = bombComponent.buttons;
     modInfo  = ComponentSolverFactory.GetModuleInfo("SimonComponentSolver", "!{0} press red green blue yellow, !{0} press rgby [press a sequence of colours] | You must include the input from any previous stages");
 }
Ejemplo n.º 29
0
    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;
    }
Ejemplo n.º 30
0
 protected ComponentSolverShim(BombCommander bombCommander, BombComponent bombComponent, string moduleType) : base(bombCommander, bombComponent)
 {
     // Passing null to the BombCommander argument here because _unshimmed is only used to run RespondToCommandInternal(); we don’t want it to award strikes/solves etc. because this object already does that
     _unshimmed = ComponentSolverFactory.CreateDefaultModComponentSolver(null, bombComponent, moduleType, bombComponent.GetModuleDisplayName());
     modInfo    = _unshimmed.modInfo;
 }