Created
April 7, 2011 18:16
-
-
Save triptych/908359 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This xml file allows you to essentially create a web service through YQL for game levels | |
| See this blog post: | |
| http://andrewwooldridge.com/blog/2011/04/07/creating-your-own-yql-webservice-with-no-server/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> | |
| <meta> | |
| <sampleQuery>select * from xpl where basexp="100" and numlevels="5" and startlevel="2"</sampleQuery> | |
| <author>Andrew Wooldridge</author> | |
| <description>Returns a list of levels and their required experience points. Suitable for RPGs or other games.</description> | |
| </meta> | |
| <bindings> | |
| <select itemPath="" produces="XML"> | |
| <inputs> | |
| <key id="basexp" type="xs:string" paramType="variable" required="true" /> | |
| <key id="numlevels" type="xs:string" paramType="variable" required="true"/> | |
| <key id="startlevel" type="xs:string" paramType="variable" required="false"/> | |
| </inputs> | |
| <execute><![CDATA[ | |
| var retobj; | |
| var tempXP; | |
| var levels = <levels></levels>; | |
| basexp = parseInt(basexp); | |
| numlevels = parseInt(numlevels); | |
| startlevel = parseInt(startlevel); | |
| if(!startlevel){ | |
| startlevel = 1; | |
| } | |
| iterationIndex = (numlevels -1) + startlevel; //where to start | |
| y.log("numlevels = "+ numlevels); | |
| y.log("startlevel = "+ startlevel); | |
| y.log("iterationIndex = " + iterationIndex); | |
| for(var level = startlevel; level <= iterationIndex; level++){ | |
| tempXP = basexp*(level*(level - 1)/2); | |
| levels.level += <level><value>{level}</value><experience>{tempXP}</experience></level> | |
| } | |
| //levels.level += <level>3</level>; | |
| response.object = levels; | |
| ]]></execute> | |
| </select> | |
| </bindings> | |
| </table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment