Advertisement
danfusion

fooQuest.cfc

Nov 11th, 2011
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. component  displayname="Foo Quest" hint="generates semi-random quest text" output="false"
  2. {
  3.     property name="this.travelActions" type="string";
  4.     property name="this.travelTypes" type="string";
  5.     property name="this.modifiers" type="string";
  6.     property name="this.names" type="string";
  7.     property name="this.killActions" type="string";
  8.     property name="this.retrieveActions" type="string";
  9.     property name="this.lootTypes" type="string";
  10.    
  11.     public fooQuest function init(
  12.         required string travelActions,
  13.         required string travelTypes,
  14.         required string modifiers,
  15.         required string names,
  16.         required string killActions,
  17.         required string retrieveActions,
  18.         required string lootTypes ) output="false"
  19.     {
  20.         setTravelActions(arguments.travelActions);
  21.         setTravelTypes(arguments.travelTypes);
  22.         setModifiers(arguments.modifiers);
  23.         setNames(arguments.names);
  24.         setKillActions(arguments.killActions);
  25.         setRetrieveActions(arguments.retrieveActions);
  26.         setLootTypes(arguments.lootTypes);
  27.        
  28.         return this;
  29.     }
  30.    
  31.     public string function getQuestTest()
  32.      displayname="Get Quest Text" description="Returns the quest text" output="false"
  33.     {
  34.         var story = CreateObject("java","java.lang.StringBuffer");
  35.        
  36.         story.append(capitalizeFirst(getRandomFromList(getTravelActions())));
  37.         story.append(" to the ");
  38.         story.append(getRandomFromList(getTravelTypes()));
  39.         story.append(" of the ");
  40.         story.append(getRandomFromList(getModifiers()));
  41.         story.append(" of ");
  42.         story.append(getRandomFromList(getNames()));
  43.         story.append(". ");
  44.         story.append(capitalizeFirst(getRandomFromList(getKillActions())));
  45.         story.append(" the ");
  46.         story.append(getRandomFromList(getModifiers()));
  47.         story.append(" ");
  48.         story.append(getRandomFromList(getNames()));
  49.         story.append(" and ");
  50.         story.append(getRandomFromList(getRetrieveActions()));
  51.         story.append(" the ");
  52.         story.append(getRandomFromList(getLootTypes()));
  53.         story.append(" of ");
  54.         story.append(getRandomFromList(getModifiers()));
  55.         story.append(" +");
  56.         story.append(RandRange(1,10).toString());
  57.         story.append(".");
  58.        
  59.         return story.toString();
  60.     }
  61.    
  62.     private string function getRandomFromList(required string randList) {
  63.         var random = RandRange(1, ListLen(arguments.randList));
  64.        
  65.         return ListGetAt(arguments.randList,random);
  66.     }
  67.    
  68.     private string function capitalizeFirst( required string str ) {
  69.         var strLen = len(arguments.str);
  70.         if (strLen >= 2) {
  71.             return UCASE(Left(arguments.str,1)) & Mid(arguments.str,2,strLen);
  72.         } else {
  73.             return UCASE(arguments.str);
  74.         }
  75.     }
  76.    
  77.     /* -------------- setters / getters  -------------- */
  78.    
  79.     public string function getTravelActions()
  80.     {
  81.         return this.travelActions;
  82.     }
  83.  
  84.     public void function setTravelActions( required string travelActions )
  85.     {
  86.         this.travelActions = arguments.travelActions;
  87.     }
  88.  
  89.     public string function getTravelTypes()
  90.     {
  91.         return this.travelTypes;
  92.     }
  93.  
  94.     public void function setTravelTypes( required string travelTypes )
  95.     {
  96.         this.travelTypes = arguments.travelTypes;
  97.     }
  98.  
  99.     public string function getModifiers()
  100.     {
  101.         return this.modifiers;
  102.     }
  103.  
  104.     public void function setModifiers( required string modifiers )
  105.     {
  106.         this.modifiers = arguments.modifiers;
  107.     }
  108.  
  109.     public string function getNames()
  110.     {
  111.         return this.names;
  112.     }
  113.  
  114.     public void function setNames( required string names )
  115.     {
  116.         this.names = arguments.names;
  117.     }
  118.  
  119.     public string function getKillActions()
  120.     {
  121.         return this.killActions;
  122.     }
  123.  
  124.     public void function setKillActions( required string killActions )
  125.     {
  126.         this.killActions = arguments.killActions;
  127.     }
  128.  
  129.     public string function getRetrieveActions()
  130.     {
  131.         return this.retrieveActions;
  132.     }
  133.  
  134.     public void function setRetrieveActions( required string retrieveActions )
  135.     {
  136.         this.retrieveActions = arguments.retrieveActions;
  137.     }
  138.  
  139.     public string function getLootTypes()
  140.     {
  141.         return this.lootTypes;
  142.     }
  143.  
  144.     public void function setLootTypes( required string lootTypes )
  145.     {
  146.         this.lootTypes = arguments.lootTypes;
  147.     }
  148.  
  149. }
  150.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement