char attItem[MAXITEMLEN], defItem[MAXITEMLEN], bluffItem[MAXITEMLEN];\r
char didYouInstigate[MAXBOOLLEN];\r
char winner[MAXRESULTLEN];\r
+ char uuid[UUIDLEN]; \r
int pointChange;\r
- void *thisInstance;\r
+ void *thisInstance = NULL;\r
\r
ATTACKTYPE attack;\r
ITEMTYPE defence;\r
I can't use the UUID, because python doesn't pass it to me! */\r
me = rand();\r
\r
- // TODO: Get the UUID passed by python\r
- // Currently, just pass an empty string to the initialise function\r
- thisInstance = Initialise( "" );\r
- \r
scanf( "%s", command );\r
\r
while (strcasecmp("BYE",command) != 0) {\r
\r
- if (strcasecmp("ATTACK", command) == 0) {\r
+ if (strcasecmp("HI", command) == 0) {\r
+ scanf( "%s", uuid );\r
+ thisInstance = Initialise( uuid );\r
+ }\r
+ else if (strcasecmp("ATTACK", command) == 0) {\r
scanf( "%s", foeName );\r
+ if( !thisInstance ) break;\r
attack = Attack( thisInstance, foeName );\r
printf("ATTACKING %s %s\n", ITEMNAMES[attack.realAttack], ITEMNAMES[attack.promisedAttack]);\r
\r
} else if (strcasecmp("DEFEND", command) == 0) {\r
scanf( "%s %s", foeName, bluffItem );\r
+ if( !thisInstance ) break;\r
defence = Defend(thisInstance, foeName, stringToItem(bluffItem));\r
printf("DEFENDING %s\n", ITEMNAMES[defence]);\r
\r
} else if (strcasecmp("RESULTS", command) == 0) {\r
/* (foeName, isInstigatedByYou, winner, attItem, defItem, bluffItem, pointDelta) */\r
scanf( "%s %s %s %s %s %s %d", foeName, didYouInstigate, winner, attItem, defItem, bluffItem, &pointChange );\r
+ if( !thisInstance ) break;\r
Results(thisInstance, foeName, (strcasecmp("True",didYouInstigate)==0), stringToResult(winner),\r
stringToItem(attItem), stringToItem(defItem), stringToItem(bluffItem), pointChange);\r
printf("OK\n");\r
scanf( "%s", command );\r
}\r
\r
- Cleanup(thisInstance);\r
+ if( !thisInstance )\r
+ Cleanup(thisInstance);\r
\r
return 0;\r
}\r