Opponent erzeugt

This commit is contained in:
Wafa Sadri
2014-04-11 10:48:24 +02:00
parent ab60843c61
commit 9c30e121f3
3 changed files with 35 additions and 4 deletions

19
Opponent.cs Normal file
View File

@@ -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;
}
}
}

View File

@@ -57,6 +57,7 @@
<Compile Include="src\StringUtils.cs" />
<Compile Include="src\ParsingException.cs" />
<Compile Include="src\Message.cs" />
<Compile Include="Opponent.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="src\DefaultGui\" />

View File

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