-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
185 lines (177 loc) · 6.15 KB
/
Program.cs
File metadata and controls
185 lines (177 loc) · 6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
using DiscordRPC;
using DiscordRPC.LogTools;
using DiscordRPC.PayLoad;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Xml;
namespace TotalTesting
{
public class Wrapper
{
public enum Opcode
{
menu,
deploy,
prepare,
energy,
qliphoth,
trumpet,
panic,
dead,
endDay,
story,
closing
}
private static GameInfo GI;
//"qwertyuiopasdfghㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ workㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤgayㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤend"
/*static public void Main()
{
GI = new GameInfo();
ConThings client = new ConThings();
foreach(string s in GameInfo.backgrounds.Keys.ToArray())
{
Console.WriteLine(s);
client.SetPrefence(new Activity()
{
assets = new Assets()
{
LargeImage = GI.ProcessURL(s)
},
details = "starting"
});
Console.ReadLine();
}
while (true)
{
s = Console.ReadLine();
Console.WriteLine(s);
}
}/**/
static void Main(string[] args)
{
GI = new GameInfo();
ConThings client = new ConThings();
try
{
GI.previousGrade.Path = args[0];
}catch { }
client.SetPrefence(new Activity()
{
assets = new Assets()
{
LargeImage = "fish"
},
details = "starting",
timeSteps = new TimeSteps(0)
});
string message;
short failCounter = 0;
Timer rpcUpdater = new Timer(new TimerCallback(Execute), client, 8000, 5000);
while (true)
{
message = Console.ReadLine();
if (message == "" || message == null)
{
client.Logger.Warning("recieved empty mess from LC"); failCounter++;
Thread.Sleep(1500);
if (failCounter >= 10) { client.Logger.Error("didnt recieved any valid message for 15 sec, aborting wapper"); break; }
continue;
}
try
{
Decoder(message);
if (GI.changeScene)
{
rpcUpdater.Change(0, 5000);
GI.changeScene = false;
}
}
catch (ArgumentException)
{
client.Logger.Warning("recieved mess dont counts as payload and unvalidable to read");
continue;
}
catch (ObjectDisposedException) { break; }
catch (Exception e)
{
client.Logger.Warning("problem during processing mess from LC: {0}", e.Message);
continue;
}
failCounter = 0;
}
}/**/
static private void Execute(object obj)
{
GI.Update();
if (GI.prevPrefence.Equals(GI.curPrefence)) return;
if (GI.curPrefence == null) return;
((ConThings)obj).SetPrefence(GI.curPrefence);
GI.prevPrefence = GI.curPrefence.Clone();
}
static private void Decoder(string source)
{
string[] arrStr = source.Split('.');
int[] arrInt = new int[arrStr.Length];
for (int i = 0; i < arrStr.Length; i++)
int.TryParse(arrStr[i], out arrInt[i]);
switch ((Opcode)arrInt[0])
{
case Opcode.menu:
GI.Scene = 0;
return;
case Opcode.deploy:
GI.ResetScene();
GI.Scene = 1;
GI.currDay = arrInt[1];
GI.allAgents = arrInt[3];
return;
case Opcode.prepare:
GI.Scene = 2;
GI.maxQliphoth = arrInt[1];
GI.maxEnergy = arrInt[2];
GI.agentsOnMission = arrInt[3];
return;
case Opcode.energy:
GI.currEnergy = arrInt[1];
return;
case Opcode.qliphoth:
GI.currQliphoth = arrInt[1];
GI.qliphothLevel = arrInt[2];
return;
case Opcode.trumpet:
GI.Trumpet = arrStr[1];
return;
case Opcode.panic:
GI.panicAgents += arrInt[1];
return;
case Opcode.dead:
GI.deadAgents++;
return;
case Opcode.endDay:
GI.endOfTheDay = true;
GI.Scene = 4;
GI.previousGrade.grade = arrStr[1];
GI.previousGrade.promoted = arrInt[2];
GI.previousGrade.lobRecieved = arrInt[3];
GI.UpdatePrev();
return;
case Opcode.story:
if (arrInt[1] != 0 || arrStr[1] == "?")
{
GI.storyBG = "AngelaBackground";
GI.cutsceneDay = arrStr[1];
}
else
GI.storyBG = arrStr[1];
GI.Scene = 5;
return;
case Opcode.closing:
throw new ObjectDisposedException("lc");
}
}
}
}