From 1888ef13937e972c9712713ce17a4df017a35b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Fri, 11 Apr 2014 12:05:16 +0200 Subject: [PATCH] Compilefehler beseitigt --- inf3.csproj | 4 ++-- src/Parser.cs | 31 +++++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/inf3.csproj b/inf3.csproj index 87944bf..4f81ce7 100644 --- a/inf3.csproj +++ b/inf3.csproj @@ -65,9 +65,9 @@ - - + + \ No newline at end of file diff --git a/src/Parser.cs b/src/Parser.cs index ae99be2..21ed0b7 100644 --- a/src/Parser.cs +++ b/src/Parser.cs @@ -226,10 +226,12 @@ namespace WorldOfPeacecraft Decision d; if (stringValue == "DRAGON") d = Decision.DRAGON; - if (stringValue == "STAGHUNT") + else if (stringValue == "STAGHUNT") d = Decision.STAGHUNT; - if (stringValue == "SKIRMISH") + else if (stringValue == "SKIRMISH") d = Decision.SKIRMISH; + else + throw new ParsingException("Wrong param"); // TODO Better message Opponent o = new Opponent (id, points, total, d); } @@ -243,17 +245,22 @@ namespace WorldOfPeacecraft { int id = challengeBlock.GetIntValue("id"); String type; - switch (challengeBlock.GetStringValue()) + LinkedList value = challengeBlock.GetUnnamedValues(); + // TODO check value size, better name + switch (value.First.Value) { - case "DRAGON": - type = "Dragon"; - break; - case "STAGHUNT": - type = "Staghunt"; - break; - case "SKIRMISCH": - type = "Skirmisch"; - break; + case "DRAGON": + type = "Dragon"; + break; + case "STAGHUNT": + type = "Staghunt"; + break; + case "SKIRMISCH": + type = "Skirmisch"; + break; + default: + throw new ParsingException("Invalid type"); // TODO Better message + break; } bool accepted = challengeBlock.GetBoolValue("accepted"); Challenge c = new Challenge(id, type, accepted);