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) {