forked from anuradhawick/NukeIt-Tanker-Game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameInidiationHandler.cs
55 lines (53 loc) · 1.77 KB
/
GameInidiationHandler.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NukeIt_Tanker.MessageParser
{
class GameInidiationHandler : MessageParser
{
string player_name;
List<int[]> bricks;
List<int[]> stone;
List<int[]> water;
string[] message_components;
string[] temp;
public override bool handleMessageImpl(string message)
{
if (message[0] != 'I')
{
return false;
}
else
{
message_components = message.Split(':');
// Decoding player name
player_name = message_components[1];
// Decoding brick locations
temp = message_components[2].Split(';');
foreach (string s in temp)
{
int[] cordinate = { Int32.Parse(s.Split(',')[0]), Int32.Parse(s.Split(',')[1]) };
bricks.Add(cordinate);
}
// Decoding stone locations
temp = message_components[3].Split(';');
foreach (string s in temp)
{
int[] cordinate = { Int32.Parse(s.Split(',')[0]), Int32.Parse(s.Split(',')[1]) };
stone.Add(cordinate);
}
// Decoding water locations
temp = message_components[4].Split(';');
foreach (string s in temp)
{
int[] cordinate = { Int32.Parse(s.Split(',')[0]), Int32.Parse(s.Split(',')[1]) };
water.Add(cordinate);
}
// Do the required mechanism here
return true;
}
}
}
}