-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Includes Puzzling Buttons, Traffic Board (ported & modified from mod source) and Nonagon Infinity
- Loading branch information
Showing
5 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
43 changes: 43 additions & 0 deletions
43
TwitchPlaysAssembly/Src/ComponentSolvers/Modded/MaddyMoos/NonagonInfinityComponentSolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
|
||
public class NonagonInfinityComponentSolver : CommandComponentSolver | ||
{ | ||
public NonagonInfinityComponentSolver(TwitchModule module) : | ||
base(module, "NonagonInfinity", "!{0} press <l1> <l2> [Presses the button with label 'l1' then 'l2']") | ||
{ | ||
} | ||
|
||
private IEnumerator Press(CommandParser _) | ||
{ | ||
_.Literal("press"); | ||
_.Regex("([a-z]) ([a-z])", out Match match); | ||
|
||
string l1 = match.Groups[1].Value.ToUpperInvariant(); | ||
string l2 = match.Groups[2].Value.ToUpperInvariant(); | ||
string[] buttonlabels = _component.GetValue<string[]>("buttonlabels"); | ||
if (!buttonlabels.Contains(l1) || !buttonlabels.Contains(l2)) | ||
yield break; | ||
|
||
yield return null; | ||
yield return Click(Array.IndexOf(buttonlabels, l1)); | ||
yield return Click(Array.IndexOf(buttonlabels, l2)); | ||
if (_component.GetValue<string>("input") == _component.GetValue<string>("solve")) | ||
yield return "solve"; | ||
} | ||
|
||
protected override IEnumerator ForcedSolveIEnumerator() | ||
{ | ||
yield return null; | ||
string input = _component.GetValue<string>("input"); | ||
string solve = _component.GetValue<string>("solve"); | ||
string[] buttonlabels = _component.GetValue<string[]>("buttonlabels"); | ||
if (input.Length == 1 && input[0] != solve[0]) | ||
yield break; | ||
for (int i = input.Length; i < 2; i++) | ||
yield return Click(Array.IndexOf(buttonlabels, solve[i].ToString())); | ||
while (!Module.BombComponent.IsSolved) yield return true; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
TwitchPlaysAssembly/Src/ComponentSolvers/Modded/Misc/PuzzlingButtonsComponentSolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Linq; | ||
|
||
public class PuzzlingButtonsComponentSolver : ReflectionComponentSolver | ||
{ | ||
public PuzzlingButtonsComponentSolver(TwitchModule module) : | ||
base(module, "PuzzleMod", "!{0} press <coord1> (coord2)... [Presses the button(s) at the specified coordinate(s)] | Valid coordinates are A1-E5 with letters as column and numbers as row") | ||
{ | ||
} | ||
|
||
public override IEnumerator Respond(string[] split, string command) | ||
{ | ||
if (!command.StartsWith("press ")) yield break; | ||
for (int i = 1; i < split.Length; i++) | ||
{ | ||
if (!coordinates.Contains(split[i])) | ||
yield break; | ||
} | ||
|
||
yield return null; | ||
for (int i = 1; i < split.Length; i++) | ||
yield return Click(Array.IndexOf(coordinates, split[i])); | ||
} | ||
|
||
private readonly string[] coordinates = { "a1", "b1", "c1", "d1", "e1", "a2", "b2", "c2", "d2", "e2", "a3", "b3", "c3", "d3", "e3", "a4", "b4", "c4", "d4", "e4", "a5", "b5", "c5", "d5", "e5" }; | ||
} |
42 changes: 42 additions & 0 deletions
42
TwitchPlaysAssembly/Src/ComponentSolvers/Modded/Misc/TrafficBoardComponentSolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Text.RegularExpressions; | ||
|
||
public class TrafficBoardComponentSolver : ReflectionComponentSolver | ||
{ | ||
public TrafficBoardComponentSolver(TwitchModule module) : | ||
base(module, "trafficBoardScript", "Use '!{0} <sign1> <sign2>' to submit signs (sign1 - top, sign2 - bottom). Possible signs: f - forward, fl - forward/left, fr - forward/right, l - left, lr - left/right, ls - left side (bottom-left arrow), r - right, rs - right side (bottom-right arrow)") | ||
{ | ||
} | ||
|
||
public override IEnumerator Respond(string[] split, string command) | ||
{ | ||
var signRE = string.Join("|", sign_commands); | ||
var match = Regex.Match(command, string.Format("^({0}) ({0})$", signRE)); | ||
if (match.Success) | ||
{ | ||
yield return null; | ||
while (_component.GetValue<int>("selrow") != Array.IndexOf(sign_commands, match.Groups[1].Value)) | ||
yield return Click(0); | ||
while (_component.GetValue<int>("selcolumn") != Array.IndexOf(sign_commands, match.Groups[2].Value)) | ||
yield return Click(1); | ||
yield return Click(2, 0); | ||
} | ||
} | ||
|
||
protected override IEnumerator ForcedSolveIEnumerator() | ||
{ | ||
yield return null; | ||
|
||
while (_component.GetValue<int>("active") == 0) yield return true; | ||
int ansrow = _component.GetValue<int>("ansrow"); | ||
int anscolumn = _component.GetValue<int>("anscolumn"); | ||
while (_component.GetValue<int>("selrow") != ansrow) | ||
yield return Click(0); | ||
while (_component.GetValue<int>("selcolumn") != anscolumn) | ||
yield return Click(1); | ||
yield return Click(2, 0); | ||
} | ||
|
||
private readonly string[] sign_commands = new[] { "f", "fl", "fr", "l", "lr", "ls", "r", "rs" }; | ||
} |