Parser fix 1/2

This commit is contained in:
Daniel Herrmann
2014-06-05 11:56:34 +02:00
parent 5229f218da
commit d78bec4579
5 changed files with 13 additions and 7 deletions

View File

@@ -57,6 +57,7 @@
<Reference Include="System.Core" /> <Reference Include="System.Core" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="src\EnumGameType.cs" />
<Compile Include="src\GameStrategy.cs" /> <Compile Include="src\GameStrategy.cs" />
<Compile Include="src\IGame.cs" /> <Compile Include="src\IGame.cs" />
<Compile Include="src\Receiver.cs" /> <Compile Include="src\Receiver.cs" />

View File

@@ -5,9 +5,9 @@ namespace WorldOfPeacecraft
public class Challenge public class Challenge
{ {
int id_; int id_;
string type_; GameType type_;
bool accepted_; bool accepted_;
public Challenge (int id, string type, bool accepted) public Challenge (int id, GameType type, bool accepted)
{ {
id_ = id; id_ = id;
type_ = type; type_ = type;

View File

@@ -24,7 +24,7 @@ namespace WorldOfPeacecraft
return cooperate; return cooperate;
} }
public Decision nextMove(Decision opLM) public Decision getNextMove(Decision opLM)
{ {
if (opLM == cooperate && counter == 0) if (opLM == cooperate && counter == 0)
{ {

View File

@@ -267,19 +267,19 @@ namespace WorldOfPeacecraft
private void ProcessChallenge (Block challengeBlock) private void ProcessChallenge (Block challengeBlock)
{ {
int id = challengeBlock.GetIntValue(ValueId); int id = challengeBlock.GetIntValue(ValueId);
String type; GameType type;
LinkedList<string> value = challengeBlock.GetUnnamedValues(); LinkedList<string> value = challengeBlock.GetUnnamedValues();
// TODO check value size, better name // TODO check value size, better name
switch (value.First.Value) switch (value.First.Value)
{ {
case EValueDragon: case EValueDragon:
type = "Dragon"; type = GameType.DRAGON;
break; break;
case EValueStagunt: case EValueStagunt:
type = "Staghunt"; type = GameType.STAGHUNT;
break; break;
case EValueSkirmish: case EValueSkirmish:
type = "Skirmisch"; type = GameType.SKIRMISH;
break; break;
default: default:
throw new ParsingException("Invalid type"); // TODO Better message throw new ParsingException("Invalid type"); // TODO Better message

View File

@@ -18,6 +18,11 @@ namespace WorldOfPeacecraft
return getNextMove(); return getNextMove();
} }
public Decision getNextMove(Decision opLM)
{
return getNextMove();
}
public Decision getNextMove() public Decision getNextMove()
{ {
int randomNumber = random.Next(0, 2); int randomNumber = random.Next(0, 2);