Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- component displayname="Foo Quest" hint="generates semi-random quest text" output="false"
- {
- property name="this.travelActions" type="string";
- property name="this.travelTypes" type="string";
- property name="this.modifiers" type="string";
- property name="this.names" type="string";
- property name="this.killActions" type="string";
- property name="this.retrieveActions" type="string";
- property name="this.lootTypes" type="string";
- public fooQuest function init(
- required string travelActions,
- required string travelTypes,
- required string modifiers,
- required string names,
- required string killActions,
- required string retrieveActions,
- required string lootTypes ) output="false"
- {
- setTravelActions(arguments.travelActions);
- setTravelTypes(arguments.travelTypes);
- setModifiers(arguments.modifiers);
- setNames(arguments.names);
- setKillActions(arguments.killActions);
- setRetrieveActions(arguments.retrieveActions);
- setLootTypes(arguments.lootTypes);
- return this;
- }
- public string function getQuestTest()
- displayname="Get Quest Text" description="Returns the quest text" output="false"
- {
- var story = CreateObject("java","java.lang.StringBuffer");
- story.append(capitalizeFirst(getRandomFromList(getTravelActions())));
- story.append(" to the ");
- story.append(getRandomFromList(getTravelTypes()));
- story.append(" of the ");
- story.append(getRandomFromList(getModifiers()));
- story.append(" of ");
- story.append(getRandomFromList(getNames()));
- story.append(". ");
- story.append(capitalizeFirst(getRandomFromList(getKillActions())));
- story.append(" the ");
- story.append(getRandomFromList(getModifiers()));
- story.append(" ");
- story.append(getRandomFromList(getNames()));
- story.append(" and ");
- story.append(getRandomFromList(getRetrieveActions()));
- story.append(" the ");
- story.append(getRandomFromList(getLootTypes()));
- story.append(" of ");
- story.append(getRandomFromList(getModifiers()));
- story.append(" +");
- story.append(RandRange(1,10).toString());
- story.append(".");
- return story.toString();
- }
- private string function getRandomFromList(required string randList) {
- var random = RandRange(1, ListLen(arguments.randList));
- return ListGetAt(arguments.randList,random);
- }
- private string function capitalizeFirst( required string str ) {
- var strLen = len(arguments.str);
- if (strLen >= 2) {
- return UCASE(Left(arguments.str,1)) & Mid(arguments.str,2,strLen);
- } else {
- return UCASE(arguments.str);
- }
- }
- /* -------------- setters / getters -------------- */
- public string function getTravelActions()
- {
- return this.travelActions;
- }
- public void function setTravelActions( required string travelActions )
- {
- this.travelActions = arguments.travelActions;
- }
- public string function getTravelTypes()
- {
- return this.travelTypes;
- }
- public void function setTravelTypes( required string travelTypes )
- {
- this.travelTypes = arguments.travelTypes;
- }
- public string function getModifiers()
- {
- return this.modifiers;
- }
- public void function setModifiers( required string modifiers )
- {
- this.modifiers = arguments.modifiers;
- }
- public string function getNames()
- {
- return this.names;
- }
- public void function setNames( required string names )
- {
- this.names = arguments.names;
- }
- public string function getKillActions()
- {
- return this.killActions;
- }
- public void function setKillActions( required string killActions )
- {
- this.killActions = arguments.killActions;
- }
- public string function getRetrieveActions()
- {
- return this.retrieveActions;
- }
- public void function setRetrieveActions( required string retrieveActions )
- {
- this.retrieveActions = arguments.retrieveActions;
- }
- public string function getLootTypes()
- {
- return this.lootTypes;
- }
- public void function setLootTypes( required string lootTypes )
- {
- this.lootTypes = arguments.lootTypes;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement