+
+ char command[MAXCOMMANDLEN];
+ char foeName[MAXFOENAMELEN];
+ char yourItem[MAXITEMLEN], theirItem[MAXITEMLEN], promisedItem[MAXITEMLEN];
+ char didYouInstigate[MAXBOOLLEN], childSpawned[MAXBOOLLEN];
+ int pointChange;
+
+ ATTACKTYPE attack;
+ ITEMTYPE defence;
+
+ scanf( "%s", command );
+
+ while (strcasecmp("BYE",command) != 0) {
+
+ if (strcasecmp("ATTACK", command) == 0) {
+ scanf( "%s", foeName );
+ attack = Attack( foeName );
+ printf("ATTACKING %s %s\n", ITEMNAMES[attack.realAttack], ITEMNAMES[attack.promisedAttack]);
+
+ } else if (strcasecmp("DEFEND", command) == 0) {
+ scanf( "%s %s", foeName, promisedItem );
+ defence = Defend(foeName, stringToItem(promisedItem));
+ printf("DEFENDING %s\n", ITEMNAMES[defence]);
+
+ } else if (strcasecmp("RESULTS", command) == 0) {
+ scanf( "%s %s %s %s %s %d %s", foeName, didYouInstigate, yourItem, theirItem, promisedItem, &pointChange, childSpawned );
+ Results(foeName, (strcasecmp("False",didYouInstigate)==0),
+ stringToItem(yourItem), stringToItem(theirItem), stringToItem(promisedItem));
+ printf("OK\n");
+ }
+
+ // read the next command!
+ scanf( "%s", command );
+ }
+