From 338c72605088dec9a6209bd47923e35b45d15a38 Mon Sep 17 00:00:00 2001 From: Wafa Sadri Date: Thu, 10 Apr 2014 16:22:01 +0200 Subject: [PATCH 01/19] =?UTF-8?q?Kommentare=20eingef=C3=BCgt,=20f=C3=BCr?= =?UTF-8?q?=20was=20ich=20machen=20werde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Parser.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index 228f633..43ecea6 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -180,6 +180,7 @@ namespace WorldOfPeacecraft string src = mesBlock.GetStringValue ("src"); string txt = mesBlock.GetStringValue ("txt"); //Message m = new Message (srcid, src, txt); + //TODO Herausfinden wie wir das oben lösen } private void ProcessAnswer (Block block) @@ -194,12 +195,17 @@ namespace WorldOfPeacecraft int delay = procBlock.GetIntValue ("delay"); //ProcessOpponent (procBlock.GetBlocks ()); //Result r = new Result(round, running, delay); + //TODO Herausfinden wie wir das oben lösen } - //"round:",INT,"running:",BOOLEAN,"delay:",INT,"begin:opponents:"OPPONENT,OPPONENT","end:opponents", private void ProcessOpponent(Block block) { - //TODO + //TODO -> Wafa + } + + private void ProcessDecision(Block block) + { + //TODO -> Wafa } private void ProcessChallenge (Block block) @@ -217,8 +223,6 @@ namespace WorldOfPeacecraft int y = playerBlock.GetIntValue ("y"); //Player p = new Player(points, id, busy, desc, x, y,); } - //"points:",INT, "id:",INT,"type:Player","busy:"BOOLEAN,"desc:"STRING,"x:",INT,"y:",INT, - private void ProcessYourid (Block yourIdBlock) { @@ -226,14 +230,17 @@ namespace WorldOfPeacecraft string stringValue = unnamedValues.First.Value; int intValue = int.Parse (stringValue); //YourID id = new YourID (intValue); + //TODO Herausfinden wie wir das oben lösen } private void ProcessTime (Block block) { + //TODO -> Wafa } private void ProcessOnline (Block block) { + //TODO -> Wafa } private void ProcessEntities (Block block) From f7e09ccf1a74824d4da5a3aa16e6e5ce373b021b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Thu, 10 Apr 2014 16:30:29 +0200 Subject: [PATCH 02/19] =?UTF-8?q?Kommentare,=20woran=20ich=20gerade=20arbe?= =?UTF-8?q?ite=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Parser.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Parser.cs b/src/Parser.cs index 43ecea6..80aeec2 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -245,10 +245,12 @@ namespace WorldOfPeacecraft private void ProcessEntities (Block block) { + // TODO -> Manu } private void ProcessPlayers (Block block) { + // TODO -> Manu } private void ProcessDragon (Block block) From 883d141d5bddb8d878bbdcfc13fd21a74bd05260 Mon Sep 17 00:00:00 2001 From: Samed Bektas Date: Thu, 10 Apr 2014 17:00:14 +0200 Subject: [PATCH 03/19] Arbeite an der Methode: ProcessCallenge und ProcessDragon --- src/Parser.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Parser.cs b/src/Parser.cs index 80aeec2..7cf581b 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -210,7 +210,7 @@ namespace WorldOfPeacecraft private void ProcessChallenge (Block block) { - + //TODO -> Samed } private void ProcessPlayer (Block playerBlock) @@ -255,6 +255,7 @@ namespace WorldOfPeacecraft private void ProcessDragon (Block block) { + //TODO -> Samed } private Dragon MapDragon (Block dragonBlock) From c96ec4db44ffc55b7d29546710ffe7259ea44e4f Mon Sep 17 00:00:00 2001 From: Samed Bektas Date: Thu, 10 Apr 2014 17:21:05 +0200 Subject: [PATCH 04/19] Methoden ProcessCallenge und ProcessDragon fertiggestellt --- src/Parser.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index 7cf581b..e60ce59 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -208,9 +208,25 @@ namespace WorldOfPeacecraft //TODO -> Wafa } - private void ProcessChallenge (Block block) + private void ProcessChallenge (Block challengeBlock) { //TODO -> Samed + int id = challengeBlock.GetIntValue("id"); + String type; + switch (challengeBlock.GetType().ToString()) + { + case "DRAGON": + type = "Dragon"; + break; + case "STAGHUNT": + type = "Staghunt"; + break; + case "SKIRMISCH": + type = "Skirmisch"; + break; + } + bool accepted = challengeBlock.GetBoolValue("accepted"); + //CHALLENGE: "begin:challenge","id:",INT,"type:",("DRAGON"|"STAGHUNT"|"SKIRMISH"),"accepted:",BOOLEAN,"end:challenge" } private void ProcessPlayer (Block playerBlock) @@ -253,9 +269,15 @@ namespace WorldOfPeacecraft // TODO -> Manu } - private void ProcessDragon (Block block) + private void ProcessDragon (Block dragonBlock) { //TODO -> Samed + int id = dragonBlock.GetIntValue("id"); + bool busy = dragonBlock.GetBoolValue("busy"); + string desc = dragonBlock.GetStringValue("desc"); + int x = dragonBlock.GetIntValue("x"); + int y = dragonBlock.GetIntValue("y"); + //DRAGON: "begin:dragon", "id:",INT,"type:Dragon","busy:"BOOLEAN,"desc:"STRING,"x:",INT,"y:",INT,"end:dragon" } private Dragon MapDragon (Block dragonBlock) From a67d5a4b3df8ffb5fe30e007eaa004fdde99e023 Mon Sep 17 00:00:00 2001 From: Samed Bektas Date: Thu, 10 Apr 2014 18:03:46 +0200 Subject: [PATCH 05/19] Methoden ProcessCallenge und ProcessDragon fertiggestellt v2 --- src/Parser.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Parser.cs b/src/Parser.cs index e60ce59..7b8d830 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -213,7 +213,7 @@ namespace WorldOfPeacecraft //TODO -> Samed int id = challengeBlock.GetIntValue("id"); String type; - switch (challengeBlock.GetType().ToString()) + switch (challengeBlock.GetStringValue()) { case "DRAGON": type = "Dragon"; @@ -226,6 +226,7 @@ namespace WorldOfPeacecraft break; } bool accepted = challengeBlock.GetBoolValue("accepted"); + //Challenge c = new Challenge(id, type, accepted); //CHALLENGE: "begin:challenge","id:",INT,"type:",("DRAGON"|"STAGHUNT"|"SKIRMISH"),"accepted:",BOOLEAN,"end:challenge" } @@ -277,6 +278,7 @@ namespace WorldOfPeacecraft string desc = dragonBlock.GetStringValue("desc"); int x = dragonBlock.GetIntValue("x"); int y = dragonBlock.GetIntValue("y"); + //Dragon d p = new Dragon(id, busy, desc, x, y); //DRAGON: "begin:dragon", "id:",INT,"type:Dragon","busy:"BOOLEAN,"desc:"STRING,"x:",INT,"y:",INT,"end:dragon" } From a316b0072abff8beb0cc8ecc207bb2c6aa7dbf92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Thu, 10 Apr 2014 18:15:01 +0200 Subject: [PATCH 06/19] clear()-methoden im Backend --- src/Backend.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Backend.cs b/src/Backend.cs index cae9716..f78799a 100644 --- a/src/Backend.cs +++ b/src/Backend.cs @@ -41,6 +41,16 @@ namespace Frontend { Players.Remove (player.GetId ()); } + + public void clearPlayers () + { + Players.Clear (); + } + + public void clearDragons () + { + Dragons.Clear (); + } public Player getPlayer (int playerId) { From 2a28de556b997d3203582ad1942a829a953080aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Thu, 10 Apr 2014 21:07:52 +0200 Subject: [PATCH 07/19] ProcessEntities und ProcessPlayers fertiggestellt --- src/Parser.cs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index 7b8d830..e3c903d 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -260,14 +260,31 @@ namespace WorldOfPeacecraft //TODO -> Wafa } - private void ProcessEntities (Block block) + private void ProcessEntities (Block entitiesBlock) { - // TODO -> Manu + backend.clearDragons (); + backend.clearPlayers (); + foreach (Block entityBlock in entitiesBlock) { + switch (entityBlock.GetName()) { + case MessPlayer: + backend.SetPlayer(MapPlayer(entityBlock)); + break; + case MessDragon: + backend.SetDragon(MapDragon(entityBlock)); + break; + default: + ThrowUnknownBlockException(entitiesBlock, entityBlock); + break; + } + } } - private void ProcessPlayers (Block block) + private void ProcessPlayers (Block playersBlock) { - // TODO -> Manu + backend.clearPlayers (); + foreach (Block playerBlock in playersBlock) { + backend.SetPlayer(MapPlayer(playerBlock)); + } } private void ProcessDragon (Block dragonBlock) From 06e0af9ec30143aa038d62c7eb0effa91f932324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Thu, 10 Apr 2014 21:10:24 +0200 Subject: [PATCH 08/19] ProcessDragon ruft nun MapDragon auf --- src/Parser.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index e3c903d..ed1b30b 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -289,14 +289,7 @@ namespace WorldOfPeacecraft private void ProcessDragon (Block dragonBlock) { - //TODO -> Samed - int id = dragonBlock.GetIntValue("id"); - bool busy = dragonBlock.GetBoolValue("busy"); - string desc = dragonBlock.GetStringValue("desc"); - int x = dragonBlock.GetIntValue("x"); - int y = dragonBlock.GetIntValue("y"); - //Dragon d p = new Dragon(id, busy, desc, x, y); - //DRAGON: "begin:dragon", "id:",INT,"type:Dragon","busy:"BOOLEAN,"desc:"STRING,"x:",INT,"y:",INT,"end:dragon" + backend.SetDragon(MapDragon(dragonBlock)); } private Dragon MapDragon (Block dragonBlock) From c6d1303d171c9fa1dcd72b64c406097d218639bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Thu, 10 Apr 2014 21:12:47 +0200 Subject: [PATCH 09/19] ProcessMapcell implementiert --- src/Parser.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Parser.cs b/src/Parser.cs index ed1b30b..5d7da08 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -240,6 +240,11 @@ namespace WorldOfPeacecraft int y = playerBlock.GetIntValue ("y"); //Player p = new Player(points, id, busy, desc, x, y,); } + + private void ProcessMapcell (Block mapcellBlock) + { + backend.getMapObject().SetTile(MapMapcell(mapcellBlock)); + } private void ProcessYourid (Block yourIdBlock) { From 30fe600a822b10c9edf2402c863880ee202ff3f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Thu, 10 Apr 2014 21:14:20 +0200 Subject: [PATCH 10/19] =?UTF-8?q?Ich=20sollte=20mir=20echt=20angew=C3=B6hn?= =?UTF-8?q?en=20auf=20compilefehler=20zu=20checken=20bevor=20ich=20code=20?= =?UTF-8?q?einchecke=20-.-?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Parser.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index 5d7da08..a23dedf 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -269,7 +269,7 @@ namespace WorldOfPeacecraft { backend.clearDragons (); backend.clearPlayers (); - foreach (Block entityBlock in entitiesBlock) { + foreach (Block entityBlock in entitiesBlock.GetBlocks ()) { switch (entityBlock.GetName()) { case MessPlayer: backend.SetPlayer(MapPlayer(entityBlock)); @@ -287,7 +287,7 @@ namespace WorldOfPeacecraft private void ProcessPlayers (Block playersBlock) { backend.clearPlayers (); - foreach (Block playerBlock in playersBlock) { + foreach (Block playerBlock in playersBlock.GetBlocks ()) { backend.SetPlayer(MapPlayer(playerBlock)); } } From d5363bad1d4be5cf7c9802eec5fcc9fdc7c8c32b Mon Sep 17 00:00:00 2001 From: Wafa Sadri Date: Fri, 11 Apr 2014 08:47:22 +0200 Subject: [PATCH 11/19] comments --- src/Parser.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index 80aeec2..0623fd8 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -198,14 +198,20 @@ namespace WorldOfPeacecraft //TODO Herausfinden wie wir das oben lösen } - private void ProcessOpponent(Block block) + private void ProcessOpponent(Block oppBlock) { - //TODO -> Wafa + CheckBlocksSize (oppBlock, 1, 1); + int id = oppBlock.GetIntValue ("id"); + int points = oppBlock.GetIntValue ("points"); + int total = oppBlock.GetIntValue ("total"); + //TYPE decision = ProcessDecision(oppBlock.getBlocks()); } + //"id:"INT,"decision:",DECISION,"points:",INT,"total:",INT," private void ProcessDecision(Block block) { //TODO -> Wafa + //OK das ist hier so'n bissle der gleiche scheiß wie "Answer" wie soll das gehn, ohne Block!? } private void ProcessChallenge (Block block) @@ -237,6 +243,7 @@ namespace WorldOfPeacecraft { //TODO -> Wafa } + //"begin:time",LONG,"end:time" private void ProcessOnline (Block block) { From 8b5316570b5b7e99aa5aaeaa19cf392fd16e5c14 Mon Sep 17 00:00:00 2001 From: Wafa Sadri Date: Fri, 11 Apr 2014 08:51:41 +0200 Subject: [PATCH 12/19] ProcessTime geschrieben --- src/Parser.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index 99c95d9..699dd7c 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -261,11 +261,13 @@ namespace WorldOfPeacecraft //TODO Herausfinden wie wir das oben lösen } - private void ProcessTime (Block block) + private void ProcessTime (Block timeBlock) { - //TODO -> Wafa + LinkedList unnamedValues = timeBlock.GetUnnamedValues (); + string stringValue = unnamedValues.First.Value; + long longValue = long.Parse (stringValue); + //Time t = new Time(longValue); } - //"begin:time",LONG,"end:time" private void ProcessOnline (Block block) { From 2be1340ea0d21fced7eb11446b18171abeae1834 Mon Sep 17 00:00:00 2001 From: Wafa Sadri Date: Fri, 11 Apr 2014 08:54:43 +0200 Subject: [PATCH 13/19] ProcessOnline geschrieben --- src/Parser.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index 699dd7c..9718be4 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -269,9 +269,12 @@ namespace WorldOfPeacecraft //Time t = new Time(longValue); } - private void ProcessOnline (Block block) + private void ProcessOnline (Block onlineBlock) { - //TODO -> Wafa + LinkedList unnamedValues = onlineBlock.GetUnnamedValues (); + string stringValue = unnamedValues.First.Value; + int intValue = int.Parse (stringValue); + //Online o = new Online(intValue); } private void ProcessEntities (Block entitiesBlock) From d91ec3fa6e948c12fcfa59e0709a97e2d03e7f50 Mon Sep 17 00:00:00 2001 From: Wafa Sadri Date: Fri, 11 Apr 2014 08:56:41 +0200 Subject: [PATCH 14/19] comments --- src/Parser.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index 9718be4..972acdf 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -180,7 +180,7 @@ namespace WorldOfPeacecraft string src = mesBlock.GetStringValue ("src"); string txt = mesBlock.GetStringValue ("txt"); //Message m = new Message (srcid, src, txt); - //TODO Herausfinden wie wir das oben lösen + //TODO Herausfinden wie wir das oben lösen (gilt für alle Funktionenstümpfe) } private void ProcessAnswer (Block block) @@ -195,7 +195,6 @@ namespace WorldOfPeacecraft int delay = procBlock.GetIntValue ("delay"); //ProcessOpponent (procBlock.GetBlocks ()); //Result r = new Result(round, running, delay); - //TODO Herausfinden wie wir das oben lösen } private void ProcessOpponent(Block oppBlock) @@ -212,6 +211,7 @@ namespace WorldOfPeacecraft { //TODO -> Wafa //OK das ist hier so'n bissle der gleiche scheiß wie "Answer" wie soll das gehn, ohne Block!? + //Maybe not TODO? } private void ProcessChallenge (Block challengeBlock) From 4b53f153fe1a2491a48f964b12ffb5832709fe11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Fri, 11 Apr 2014 10:12:36 +0200 Subject: [PATCH 15/19] =?UTF-8?q?Fehlerbehandlung=20im=20Parser=20vervolls?= =?UTF-8?q?t=C3=A4ndigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Parser.cs | 57 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/src/Parser.cs b/src/Parser.cs index 972acdf..31aa303 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -56,15 +56,24 @@ namespace WorldOfPeacecraft if (IsCompletePackage ()) { Parse (); } - // TODO Try-catch. IMPORTANT! } } private void Parse () { - String[] aMessage = Enumerable.ToArray (Message); - Block mainBlock = new Block (aMessage, 0, aMessage.Length - 1); - ProcessData (mainBlock); + string[] aMessage = Enumerable.ToArray (Message); + Message.Clear(); + try { + Block mainBlock = new Block (aMessage, 0, aMessage.Length - 1); + ProcessData (mainBlock); + } catch (ParsingException e) { + string errormsg = "Error while parsing message: " + e.Message + "\n"; + errormsg += "Message:"; + foreach (string line in errormsg) { + errormsg += "\n\t" + line; + } + Console.WriteLine(errormsg); + } } private void ProcessData (Block parentBlock) @@ -153,6 +162,9 @@ namespace WorldOfPeacecraft Dragon dragon = MapDragon (block); backend.removeDragon (dragon); break; + default: + ThrowUnknownBlockException(deleteBlock, block); + break; } } @@ -185,6 +197,7 @@ namespace WorldOfPeacecraft private void ProcessAnswer (Block block) { + // TODO } private void ProcessResult (Block procBlock) @@ -359,7 +372,7 @@ namespace WorldOfPeacecraft huntable = true; break; default: - throw new ParsingException("Unknown mapcell-property '" + prop + "'"); + throw new ParsingException("Unknown mapcell property '" + prop + "'"); } } return new Tile(x,y,walkable, wall, forest, huntable, water); @@ -462,22 +475,48 @@ namespace WorldOfPeacecraft public string GetStringValue (string name) { - return Values [name]; + try { + return Values [name]; + } catch (ArgumentOutOfRangeException e) { + throw new ParsingException("The parameter '" + name + "' does not exist in block '" + Name + "'", e); + } } public int GetIntValue (string name) { - return int.Parse (Values [name]); + try { + return int.Parse (Values [name]); + } catch (ArgumentOutOfRangeException e) { + throw new ParsingException("The parameter '" + name + "' does not exist in block '" + Name + "'", e); + } catch (FormatException e) { + throw new ParsingException("The parameter '" + name + "' in block '" + Name + "' is not an integer (it was '" + Values [name] + "')", e); + } catch (OverflowException e) { + throw new ParsingException("The parameter '" + name + "' in blo '" + Name + "' does not fit into an integer (it was '" + Values [name] + "')", e); + } } public long GetLongValue (string name) { - return long.Parse (Values [name]); + try { + return long.Parse (Values [name]); + } catch (ArgumentOutOfRangeException e) { + throw new ParsingException("The parameter '" + name + "' does not exist in block '" + Name + "'", e); + } catch (FormatException e) { + throw new ParsingException("The parameter '" + name + "' in block '" + Name + "' is not a long (it was '" + Values [name] + "')", e); + } catch (OverflowException e) { + throw new ParsingException("The parameter '" + name + "' in blo '" + Name + "' does not fit into a long (it was '" + Values [name] + "')", e); + } } public bool GetBoolValue (string name) { - return bool.Parse (Values [name]); + try { + return bool.Parse (Values [name]); + } catch (ArgumentOutOfRangeException e) { + throw new ParsingException ("The parameter '" + name + "' does not exist in block '" + Name + "'", e); + } catch (FormatException e) { + throw new ParsingException ("The parameter '" + name + "' in block '" + Name + "' is not a bool (it was '" + Values [name] + "')", e); + } } } } From ab10b354b25d6236a6bc050778ba4ec1b32451ee Mon Sep 17 00:00:00 2001 From: Wafa Sadri Date: Fri, 11 Apr 2014 10:27:21 +0200 Subject: [PATCH 16/19] Message Klasse erzeugt und verwendet in Parser.cs --- Message.cs | 12 ++++++++++++ inf3.csproj | 1 + src/Message.cs | 19 +++++++++++++++++++ src/Parser.cs | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 Message.cs create mode 100644 src/Message.cs diff --git a/Message.cs b/Message.cs new file mode 100644 index 0000000..d300666 --- /dev/null +++ b/Message.cs @@ -0,0 +1,12 @@ +using System; + +namespace inf3 +{ + public class Message + { + public Message () + { + } + } +} + diff --git a/inf3.csproj b/inf3.csproj index 271866d..fcdfb7d 100644 --- a/inf3.csproj +++ b/inf3.csproj @@ -56,6 +56,7 @@ + diff --git a/src/Message.cs b/src/Message.cs new file mode 100644 index 0000000..277dc88 --- /dev/null +++ b/src/Message.cs @@ -0,0 +1,19 @@ +using System; + +namespace inf3 +{ + public class Message + { + int sourceID; + string source; + string text; + + public Message (int srcid, string src, string txt) + { + sourceID = srcid; + source = src; + text = txt; + } + } +} + diff --git a/src/Parser.cs b/src/Parser.cs index 972acdf..e25d779 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -179,7 +179,7 @@ namespace WorldOfPeacecraft int srcid = mesBlock.GetIntValue ("srcid"); string src = mesBlock.GetStringValue ("src"); string txt = mesBlock.GetStringValue ("txt"); - //Message m = new Message (srcid, src, txt); + Message m = new Message (srcid, src, txt); //TODO Herausfinden wie wir das oben lösen (gilt für alle Funktionenstümpfe) } From 15181e10216ead25939abf44fbc26740f58b6b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Fri, 11 Apr 2014 10:37:36 +0200 Subject: [PATCH 17/19] Meine Compilefehler sind jetzt raus. Was machen eure? :D --- src/Parser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parser.cs b/src/Parser.cs index 540a095..71fff12 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -69,7 +69,7 @@ namespace WorldOfPeacecraft } catch (ParsingException e) { string errormsg = "Error while parsing message: " + e.Message + "\n"; errormsg += "Message:"; - foreach (string line in errormsg) { + foreach (string line in aMessage) { errormsg += "\n\t" + line; } Console.WriteLine(errormsg); From 9c30e121f362f0df81dd88897929d4df669b88a0 Mon Sep 17 00:00:00 2001 From: Wafa Sadri Date: Fri, 11 Apr 2014 10:48:24 +0200 Subject: [PATCH 18/19] Opponent erzeugt --- Opponent.cs | 19 +++++++++++++++++++ inf3.csproj | 1 + src/Parser.cs | 19 +++++++++++++++---- 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 Opponent.cs diff --git a/Opponent.cs b/Opponent.cs new file mode 100644 index 0000000..89e2eb4 --- /dev/null +++ b/Opponent.cs @@ -0,0 +1,19 @@ +using System; + +namespace inf3 +{ + public class Opponent + { + int points_; + int total_; + enum Decision {DRAGON, STAGHUNT, SKIRMISH}; + Decision d_; + + public Opponent (int points, int total, Decision d) + { + points_ = points; + total_ = total; + d_ = d; + } + } +} \ No newline at end of file diff --git a/inf3.csproj b/inf3.csproj index fcdfb7d..9ed020a 100644 --- a/inf3.csproj +++ b/inf3.csproj @@ -57,6 +57,7 @@ + diff --git a/src/Parser.cs b/src/Parser.cs index 540a095..e0efb1d 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -30,6 +30,8 @@ namespace WorldOfPeacecraft private Regex LastLineRegex; private Backend backend; + enum Decision {DRAGON, STAGHUNT, SKIRMISH}; + public Parser () { ParserThread = new Thread (new ThreadStart (this.RunParser)); @@ -206,19 +208,28 @@ namespace WorldOfPeacecraft int round = procBlock.GetIntValue ("round"); bool running = procBlock.GetBoolValue ("running"); int delay = procBlock.GetIntValue ("delay"); - //ProcessOpponent (procBlock.GetBlocks ()); + LinkedList block = procBlock.GetBlocks (); + ProcessOpponent (block.First.Value); //Result r = new Result(round, running, delay); } private void ProcessOpponent(Block oppBlock) { - CheckBlocksSize (oppBlock, 1, 1); int id = oppBlock.GetIntValue ("id"); int points = oppBlock.GetIntValue ("points"); int total = oppBlock.GetIntValue ("total"); - //TYPE decision = ProcessDecision(oppBlock.getBlocks()); + LinkedList unnamedValue = oppBlock.GetUnnamedValues (); + string stringValue = unnamedValue.First.Value; + Decision d; + if (stringValue == "DRAGON") + d = Decision.DRAGON; + if (stringValue == "STAGHUNT") + d = Decision.STAGHUNT; + if (stringValue == "SKIRMISH") + d = Decision.SKIRMISH; + } - //"id:"INT,"decision:",DECISION,"points:",INT,"total:",INT," + //DRAGON|STAGHUNT|SKIRMISH private void ProcessDecision(Block block) { From 72279dbdcbac96a00b066ea6cd4fdcc90585c1fc Mon Sep 17 00:00:00 2001 From: Wafa Sadri Date: Fri, 11 Apr 2014 11:22:00 +0200 Subject: [PATCH 19/19] =?UTF-8?q?opponent=20aufruf=20hat=20gefehlt=20->=20?= =?UTF-8?q?eingef=C3=BCgt=20+=20ID=20attribut=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inf3.csproj | 2 +- Opponent.cs => src/Opponent.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) rename Opponent.cs => src/Opponent.cs (71%) diff --git a/inf3.csproj b/inf3.csproj index 9ed020a..efa4bc4 100644 --- a/inf3.csproj +++ b/inf3.csproj @@ -57,7 +57,7 @@ - + diff --git a/Opponent.cs b/src/Opponent.cs similarity index 71% rename from Opponent.cs rename to src/Opponent.cs index 89e2eb4..56f1b18 100644 --- a/Opponent.cs +++ b/src/Opponent.cs @@ -4,13 +4,15 @@ namespace inf3 { public class Opponent { + int id_; int points_; int total_; enum Decision {DRAGON, STAGHUNT, SKIRMISH}; Decision d_; - public Opponent (int points, int total, Decision d) + public Opponent (int id, int points, int total, Decision d) { + id_ = id; points_ = points; total_ = total; d_ = d;