public bool Execute(Pointer pointer, IRunicContext context) { int dir = (int)pointer.direction; if (c == '/') { if (dir % 2 == 0) { int a = 2 - dir; pointer.direction = DirectionHelper.Reflect((Direction)a); } else { int a = 4 - dir; pointer.direction = DirectionHelper.Reflect((Direction)a); } } else { if (dir <= 1) { pointer.direction = DirectionHelper.RotateCCW(pointer.direction); } else { pointer.direction = DirectionHelper.RotateCW(pointer.direction); } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object a = pointer.Pop(); object b = pointer.Pop(); if (a != null && b != null && a is ValueType && b is ValueType && MathHelper.IsInteger((ValueType)a) && MathHelper.IsInteger((ValueType)b)) { int x = (int)MathHelper.GetValue((ValueType)b); int y = (int)MathHelper.GetValue((ValueType)a); char modifier = context.GetModifier(pointer.position.x, pointer.position.y); context.AdvancePointer(pointer, false); if (modifier != '͍') { pointer.Push(pointer.position.x); pointer.Push(pointer.position.y); } if (!context.IsValidPos(x, y)) { pointer.DeductMana(pointer.GetMana()); return(true); } pointer.position = new Vector2Int(x, y); pointer.direction = context.GetModifiedDirection(modifier, pointer.direction); return(false); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object a = pointer.Pop(); object b = pointer.Pop(); if (a is ValueType && b is ValueType) { if (a is Vector3 || b is Vector3) { } else if (a is char || b is char) { double x = MathHelper.GetValue((ValueType)a); double y = MathHelper.GetValue((ValueType)b); pointer.Push(System.Math.Pow(y, x)); } else { double x = Convert.ToDouble(a); double y = Convert.ToDouble(b); pointer.Push(System.Math.Pow(y, x)); } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { char modifier = context.GetModifier(pointer.position.x, pointer.position.y); if (modifier == '̹' || modifier == '͗') { pointer.Push(pointer.GetStacksStackSize()); } else if (modifier == '͍') { object o = pointer.Pop(); if (o is string) { string s = (string)o; pointer.Push(s.Length); } else { pointer.Push(o); } } else { pointer.Push(pointer.GetStackSize()); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object a = pointer.Pop(); object b = pointer.Pop(); bool r; if (a == null && b == null) { r = true; } else if (a == null || b == null) { r = false; } else if (a is ValueType && b is ValueType) { r = MathHelper.NumericRelationship.EqualTo == MathHelper.Compare((ValueType)a, (ValueType)b); } else { r = a.Equals(b); } char modifier = context.GetModifier(pointer.position.x, pointer.position.y); if (modifier == '̸' || modifier == '͍') { r = !r; } pointer.Push(r ? 1 : 0); return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object a = pointer.Pop(); if (a is ValueType) { MathHelper.NumericRelationship r = MathHelper.Compare((ValueType)a, 0); if (r != MathHelper.NumericRelationship.EqualTo) { int b = (int)MathHelper.GetValue((ValueType)a); pointer.SetSkip(System.Math.Max(1, b)); } } else { if (a == null) { pointer.SetSkip(1); } else { pointer.Push(a); } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object o = pointer.Pop(); if (o is ValueType) { char modifier = context.GetModifier(pointer.position.x, pointer.position.y); if (modifier == '͍') { if (o.Equals(0)) { pointer.Push(1); } else { pointer.Push(0); } } else { pointer.Push(o); pointer.Push(-1); mult.Execute(pointer, context); } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object a = pointer.Pop(); object b = pointer.Pop(); if (a != null && b != null) { if (a is ValueType && b is ValueType) { if (MathHelper.IsInteger((ValueType)a) && MathHelper.IsInteger((ValueType)b)) { int c = (int)a + (int)b; pointer.Push(c); } else if (a is Vector3 && b is Vector3) { pointer.Push(((Vector3)a + (Vector3)b)); } else { double c = MathHelper.GetValue((ValueType)a) + MathHelper.GetValue((ValueType)b); pointer.Push(c); } } else if (b is string || a is string) { string s1 = a.ToString(); string s2 = b.ToString(); pointer.Push(s2 + s1); } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { char modifier = context.GetModifier(pointer.position.x, pointer.position.y); if (modifier == '̹' || modifier == '͗') { pointer.RotateStacksStack(rotLeft); } else if (modifier == '͍') { object o = pointer.Pop(); if (o is string) { string s = (string)o; if (rotLeft) { s = s.RotateLeft(); } else { s = s.RotateRight(); } pointer.Push(s); } else { pointer.Push(o); } } else { pointer.RotateStack(rotLeft); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { if (pointer.direction == dir || pointer.direction == DirectionHelper.Reflect(dir)) { pointer.direction = DirectionHelper.Reflect(pointer.direction); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { if (pointer.GetAge() == 0) { pointer.direction = dir; pointer.Merge(new Pointer(10, pointer.direction, Vector2Int.zero)); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object a = pointer.Pop(); object b = pointer.Pop(); Vector3 v1 = getVec3(a); Vector3 v2 = getVec3(b); pointer.Push((v1 - v2).magnitude); return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { pointer.direction = context.GetModifiedDirection(context.GetModifier(pointer.position.x, pointer.position.y), pointer.direction); int j = context.GetDelayAmount(context.GetModifier(pointer.position.x, pointer.position.y)); pointer.SetDelay(j + 1); pointer.SetSkip(j + 1); return(false); }
public bool Execute(Pointer pointer, IRunicContext context) { char modifier = context.GetModifier(pointer.position.x, pointer.position.y); if (modifier == '͍') { object o = pointer.Pop(); if (o is string) { string s = (string)o; int cost = System.Math.Max(s.Length - 10, 1); pointer.DeductMana(cost); List <char> list = (s).ToCharArray().ToList(); list.Sort((x, y) => (int)MathHelper.Compare(x, y)); s = new string(list.ToArray()); pointer.Push(s); } else { pointer.Push(o); } } else { int cost = System.Math.Max(pointer.GetStackSize() - 10, 1); if (pointer.GetMana() <= cost) { return(false); } pointer.DeductMana(cost); List <ValueType> list = new List <ValueType>(); while (pointer.GetStackSize() > 0) { object o = pointer.Pop(); if (o is ValueType) { list.Add((ValueType)o); } else { pointer.Push(o); break; } } list.Sort((x, y) => (int)MathHelper.Compare(y, x)); for (int i = 0; i < list.Count; i++) { pointer.Push(list[i]); } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object a = pointer.Pop(); object b = pointer.Pop(); if (a != null && b != null) { if (a is ValueType && b is ValueType) { if (MathHelper.IsInteger((ValueType)a) && MathHelper.IsInteger((ValueType)b)) { int c = (int)b - (int)a; pointer.Push(c); } else if (a is Vector3 && b is Vector3) { pointer.Push(((Vector3)b - (Vector3)a)); } else { double c = MathHelper.GetValue((ValueType)b) - MathHelper.GetValue((ValueType)a); pointer.Push(c); } } else if (a is ValueType && b is string) { int n = (int)MathHelper.GetValue((ValueType)a); string s = (string)b; if (n > 0) { string second = s.Substring(0, s.Length - n); pointer.Push(second); } else if (n < 0) { n *= -1; string first = s.Substring(0, n); string second = s.Substring(n, s.Length - n); pointer.Push(second); } else { pointer.Push(s); } } else { } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { char modifier = context.GetModifier(pointer.position.x, pointer.position.y); if (modifier == '̹' || modifier == '͗') { pointer.PopDiscardStack(); } else { pointer.Pop(); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { ReadOnlyCollection <Pointer> allpts = context.GetPointers(); IEnumerable <Pointer> pts = allpts.Where(x => x != pointer && x.position.x == pointer.position.x && x.position.y == pointer.position.y); if (pts.Count() == 0) { return(false); } if (pointer.GetStackSize() == 0) { return(false); } object o = pointer.Pop(); if (o is ValueType) { int v = (int)MathHelper.GetValue((ValueType)o); if (context.GetModifier(pointer.position.x, pointer.position.y) == '͍') { foreach (Pointer p in pts) { List <object> stack = new List <object>(); for (; v > 0; v--) { stack.Add(p.Pop()); } stack.Reverse(); PushStack(pointer, stack); } } else { List <object> stack = new List <object>(); for (; v > 0; v--) { stack.Add(pointer.Pop()); } stack.Reverse(); foreach (Pointer p in pts) { PushStack(p, stack); p.SetSkip(1); } } return(true); } return(false); }
public bool Execute(Pointer pointer, IRunicContext context) { var o = pointer.Pop(); if (o is ValueType) { ValueType v = (ValueType)o; if (MathHelper.Compare(pointer.GetMana(), v) >= 0) { return(true); } pointer.Push(o); } return(false); }
public bool Execute(Pointer pointer, IRunicContext context) { object a = pointer.Pop(); object b = pointer.Pop(); if (a != null && b != null) { if (a is ValueType && b is ValueType) { if (MathHelper.IsInteger((ValueType)a) && MathHelper.IsInteger((ValueType)b)) { int c = (int)a * (int)b; pointer.Push(c); } else if (a is Vector3 || b is Vector3) { if (a is Vector3 && b is Vector3) { pointer.Push(Vector3.Cross((Vector3)a, (Vector3)b)); } else if (a is Vector3) { pointer.Push(((Vector3)a) * (float)MathHelper.GetValue((ValueType)b)); } else if (b is Vector3) { pointer.Push(((Vector3)b) * (float)MathHelper.GetValue((ValueType)a)); } } else { double c = MathHelper.GetValue((ValueType)a) * MathHelper.GetValue((ValueType)b); pointer.Push(c); } } else if (b is string && a is ValueType) { StringBuilder sb = new StringBuilder((string)b); int m = (int)MathHelper.GetValue((ValueType)a); for (int i = 1; i < m; i++) { sb.Append((string)b); } pointer.Push(sb.ToString()); } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { char modifier = context.GetModifier(pointer.position.x, pointer.position.y); if (modifier == '͍') { var result = new StringBuilder(); bool cont = false; do { cont = false; if (pointer.GetStackSize() > 0) { object o = pointer.Pop(); if (o is char) { result.Insert(0, o.ToString()); cont = true; } else { pointer.Push(o); } } } while (cont); if (result.Length > 0) { pointer.Push(result.ToString()); } } else { object a = pointer.Pop(); object b = pointer.Pop(); string x = ""; string y = ""; if (a is ValueType || a is string) { x = a.ToString(); } if (b is ValueType || b is string) { y = b.ToString(); } pointer.Push(y + x); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { char modifier = context.GetModifier(pointer.position.x, pointer.position.y); if (modifier == '̹' || modifier == '͗') { pointer.CloneTopSubStack(); } else { object o = pointer.Pop(); pointer.Push(o); pointer.Push(o); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { do { object o = pointer.Pop(); if (o != null) { context.WriteOutputs(o); } } while (dumpStack && pointer.GetStackSize() > 0); if (dumpStack) { pointer.DeductMana(pointer.GetMana()); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object a = pointer.Pop(); object b = pointer.Pop(); if (a is ValueType && b is ValueType) { MathHelper.NumericRelationship q = MathHelper.Compare((ValueType)b, (ValueType)a); bool r = q == MathHelper.NumericRelationship.LessThan; char modifier = context.GetModifier(pointer.position.x, pointer.position.y); if (modifier == '̸' || modifier == '͍') { r = !r; } pointer.Push(r ? 1 : 0); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object o = pointer.Pop(); if (o is string) { if (pointer.GetStackSize() > 0) { object s = pointer.Pop(); if (s is char) { string[] sp = ((string)o).Split((char)s); for (int i = 0; i < sp.Length; i++) { pointer.Push(sp[i]); } return(true); } else { pointer.Push(s); } } char[] c = ((string)o).ToCharArray(); for (int i = 0; i < c.Length; i++) { pointer.Push(c[i]); } } else if (o is Vector3) { Vector3 v = (Vector3)o; pointer.Push(v.x); pointer.Push(v.y); pointer.Push(v.z); } else if (o != null) { pointer.Push(o.ToString()); Execute(pointer, context); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object o = pointer.Pop(); if (o is ValueType) { ValueType v = (ValueType)o; int d = (int)MathHelper.GetValue(v); pointer.PopNewStack(d); if (d > 0) { pointer.DeductMana(1); } } else { pointer.Push(o); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object a = pointer.Pop(); object b = pointer.Pop(); if (a != null && b != null) { if (a is ValueType && b is ValueType) { if (MathHelper.IsInteger((ValueType)a) && MathHelper.IsInteger((ValueType)b)) { int c = (int)MathHelper.GetValue((ValueType)b) % (int)MathHelper.GetValue((ValueType)a); pointer.Push(c); } else { double d = MathHelper.GetValue((ValueType)a); if (MathHelper.Approximately((float)d, 0)) { pointer.DeductMana(pointer.GetMana()); return(true); } double c = MathHelper.GetValue((ValueType)b) % d; pointer.Push(c); } } else if (a is ValueType && b is string) { int c = (int)MathHelper.GetValue((ValueType)a); if (c < 0) { c = ((string)b).Length + c; } pointer.Push(((string)b)[c]); } else { } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { char modifier = context.GetModifier(pointer.position.x, pointer.position.y); if (modifier == '̹' || modifier == '͗') { pointer.SwapStacksStack(); } else if (modifier == '͍') { object o = pointer.Pop(); if (o is string) { string s = (string)o; List <char> list = s.ToCharArray().ToList(); char a = list[list.Count - 1]; list.RemoveAt(list.Count - 1); char b = list[list.Count - 1]; list.RemoveAt(list.Count - 1); list.Add(a); list.Add(b); pointer.Push(new string(list.ToArray())); } else { pointer.Push(o); } } else { if (pointer.GetStackSize() < 2) { return(true); } object a = pointer.Pop(); object b = pointer.Pop(); pointer.Push(a); pointer.Push(b); } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object o = pointer.Pop(); if (o is ValueType) { ValueType v = (ValueType)o; int i = (int)MathHelper.GetValue(v); char c = (char)i; pointer.Push(c); } else if (o is string) { string s = (string)o; if (s.Length == 1) { pointer.Push(s[0]); } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { object o = pointer.Pop(); if (o is ValueType) { pointer.Push(MathHelper.GetValue((ValueType)o)); } else if (o is string) { if (double.TryParse((string)o, out var d)) { pointer.Push(d); } else { pointer.Push(WordDictionary.GetIndex(((string)o).ToLowerInvariant())); } } return(true); }
public bool Execute(Pointer pointer, IRunicContext context) { if (context.GetModifier(pointer.position.x, pointer.position.y) == '͍') { string result = ""; object o = pointer.Pop(); while (o is char && pointer.GetStackSize() > 0) { result += (char)o; o = pointer.Pop(); } if (o is char) { result += (char)o; } else { pointer.Push(o); } result = result.Reverse(); pointer.Push(result); } else { object a = pointer.Pop(); object b = pointer.Pop(); string x = ""; string y = ""; if (a is ValueType || a is string) { x = a.ToString(); } if (b is ValueType || b is string) { y = b.ToString(); } pointer.Push(y + x); } return(true); }