Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
Preparing for release
  • Loading branch information
Suprnova authored Oct 26, 2020
1 parent bef7d54 commit aa15330
Showing 1 changed file with 87 additions and 21 deletions.
108 changes: 87 additions & 21 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using static PogCode_Interpreter.Globals;
Expand All @@ -26,6 +27,7 @@ public void PogChamp()

public void PogChamp(string output)
{
bool contains = false;
if (output.Contains('{') && output.Contains('}'))
{
if (output.IndexOf('{') > output.IndexOf('}'))
Expand All @@ -36,22 +38,52 @@ public void PogChamp(string output)
{
string var = output.Remove(output.IndexOf('}'));
var = var.Substring(var.IndexOf('{') + 1);
if (Globals.Variables.ContainsKey(var))
if (Variables.ContainsKey(var) || VariablesInt.ContainsKey(var) || VariablesFloat.ContainsKey(var))
{
contains = true;
}
if (contains)
{
if (Variables[var] == null)
if (Variables.ContainsKey(var))
{
p.ExceptionHandler(9, LineN, Line);
if (Variables[var] == null)
{
p.ExceptionHandler(9, LineN, Line);
}
else
{
output = output.Replace($"{{{var}}}", Variables[var]);
}
}
else
else if (VariablesInt.ContainsKey(var))
{
output = output.Replace($"{{{var}}}", Globals.Variables[var]);
}
if (VariablesInt[var] == null)
{
p.ExceptionHandler(9, LineN, Line);
}
else
{
output = output.Replace($"{{{var}}}", VariablesInt[var]);
}
}
else if (VariablesFloat.ContainsKey(var))
{
if (VariablesFloat[var] == null)
{
p.ExceptionHandler(9, LineN, Line);
}
else
{
output = output.Replace($"{{{var}}}", VariablesFloat[var]);
}
}

}
}
}
try
{
Console.WriteLine(output);
Console.WriteLine(output.Trim());
}
catch
{
Expand All @@ -61,6 +93,7 @@ public void PogChamp(string output)

public void Pog(string output)
{
bool contains = false;
if (output.Contains('{') && output.Contains('}'))
{
if (output.IndexOf('{') > output.IndexOf('}'))
Expand All @@ -71,22 +104,52 @@ public void Pog(string output)
{
string var = output.Remove(output.IndexOf('}'));
var = var.Substring(var.IndexOf('{') + 1);
if (Globals.Variables.ContainsKey(var))
if (Variables.ContainsKey(var) || VariablesInt.ContainsKey(var) || VariablesFloat.ContainsKey(var))
{
if (Variables[var] == null)
contains = true;
}
if (contains)
{
if (Variables.ContainsKey(var))
{
p.ExceptionHandler(9, LineN, Line);
if (Variables[var] == null)
{
p.ExceptionHandler(9, LineN, Line);
}
else
{
output = output.Replace($"{{{var}}}", Variables[var]);
}
}
else
else if (VariablesInt.ContainsKey(var))
{
output = output.Replace($"{{{var}}}", Globals.Variables[var]);
if (VariablesInt[var] == null)
{
p.ExceptionHandler(9, LineN, Line);
}
else
{
output = output.Replace($"{{{var}}}", VariablesInt[var]);
}
}
else if (VariablesFloat.ContainsKey(var))
{
if (VariablesFloat[var] == null)
{
p.ExceptionHandler(9, LineN, Line);
}
else
{
output = output.Replace($"{{{var}}}", VariablesFloat[var]);
}
}

}
}
}
try
{
Console.Write(output);
Console.Write(output.Trim());
}
catch
{
Expand Down Expand Up @@ -341,14 +404,14 @@ private static void Interpreter(string file)
p.ExceptionHandler(3, i, line);
break;
case 2:
parameter = line[line.IndexOf(' ')..line.IndexOf(' ', 1)].Trim();
parameter2 = line.Substring(line.IndexOf(' ', 1)).Trim();
parameter = line[line.IndexOf(' ')..line.IndexOf(' ', line.IndexOf(' ') + 1)].Trim();
parameter2 = line.Substring(line.IndexOf(' ', line.IndexOf(' ') + 1)).Trim();
c.PogU(parameter, parameter2);
break;
case var expression when valueU >= 2:
parameter = line[line.IndexOf(' ')..line.IndexOf(' ', 1)].Trim();
parameter2 = line[line.IndexOf(' ', 1)..line.IndexOf(' ', 2)].Trim();
parameter3 = line.Substring(line.IndexOf(' ', 2)).Trim();
parameter = line[line.IndexOf(' ')..line.IndexOf(' ', line.IndexOf(' ') + 1)].Trim();
parameter2 = line[(line.IndexOf(' ', line.IndexOf(' ') + 1))..line.IndexOf(' ', line.IndexOf(' ', line.IndexOf(' ') + 1) + 1)].Trim();
parameter3 = line.Substring(line.IndexOf(' ', line.IndexOf(' ', line.IndexOf(' ') + 1) + 1)).Trim();
c.PogU(parameter, parameter2, parameter3);
break;
}
Expand All @@ -362,21 +425,24 @@ private static void Interpreter(string file)
p.ExceptionHandler(3, i, line);
break;
case 2:
parameter = line[line.IndexOf(' ')..line.IndexOf(' ', 1)].Trim();
parameter2 = line.Substring(line.IndexOf(' ', 1)).Trim();
parameter = line[line.IndexOf(' ')..line.IndexOf(' ', line.IndexOf(' ') + 1)].Trim();
parameter2 = line.Substring(line.IndexOf(' ', line.IndexOf(' ') + 1)).Trim();
c.WeirdChamp(parameter, parameter2);
break;
case var expression when valueW >= 3:
p.ExceptionHandler(4, i, line);
break;
}
break;
case "PogO":
Debugger.Break();
break;
default:
p.ExceptionHandler(0, i, line);
break;
}
}
Console.WriteLine("Script completed all commands. Press Enter to exit.");
Console.WriteLine("\nScript completed all commands. Press Enter to exit.");
Console.ReadLine();
}

Expand Down

0 comments on commit aa15330

Please sign in to comment.