/* taleSpin 0.9 ...
 */

/* INCLUDES AND DEFINES */

#include ...

/* GLOBAL VARIABLES */

/* these are plot variables */

string theHero, theVillain, theLocation, theTime, theMonster, theGod,
       theQuest, theMoral, theMcGovern, theFoil, theRomanticInterest,
       theRedeamingVirtue, theFatalFlaw, theEvilTwin;


/* these are categories from which we can select fillers */

string time, place, animal, monster, ...;

time =  "a long time ago;once upon a time;...";
place = "Maryland;Baltimore;Ireland;UMBC;...";
animal = "frog;bear;lion;bug;monkey;snake;...";
monster = "dragon;troll;vampire;giant rat;...";
adjective = "big;small;ugly;sad;green;...";
bodyPart = "arm;leg;head;finger;tow;foot;...";
number = "two;three;four;1000;a gazillion;...";
alien = "grey;reptilian;betazoid;...";
object = "rock;dollar;seed;..."


/* FUNCTION PROTOTYPES */
...

main() {
  getInput();
  tellStory();
}


void getInput(void) {
  theHero = askString("Who's the hero of the story? ");
  theVillain = askString("Who is the bad guy? ");
  ...
}


void tellStory (void) {
  switch (randomInteger(1,4)) {
    case 1: tellMyth(); break;
    case 2: tellKidsStory(); break;
    case 3: tellFable(); break;
    /* ... */
    default: Error("Panic - bogus default case selected");
  }
}

void tellMyth(void) {
  /* select some story components */
  theMonster = pick(monster);
  theGod = pick(god);
  theQUest = pick(quest);
  /* generate the story */
  tellMythIntro();
  tellMythBody();
  tellMythEnd();
}

string pick(string phrases) {
  int numberOfPhrases, selected;
  numberOfPhrases = countPhrases(phrases);
  selected = randomInteger(1,numberOfPhrases);
  return(pickNth(selected,phrases));
}

void tellMythBody(void) {
  tellMythBodySentence();
  while(randomChance(.75)) {tellMythBodySentence();}
}

void tellMythBodySentence(void) {
  switch (randomInteger(1,10)) {
  case 1: printf("%s did many things.", theHero); break;
  case 2: printf("%s %s %s.  ", theHero, pick(verb), pick(objects)); break;
  case 3: printf("%s and %s fought.  ", theHero, theVillain); break;
  /* ... */
  case 10: printf("%s turned %s into a %s. ",theVillain,theHero,pick(animal)); 
           break;
  default: Error("Panic - bogus default case selected");
  }
}


