XMICAE Customizable IF Engine Code
XMICAE is a framework for browser-based IF/RPG narratives.
Status: Alpha
Brought to you by:
homoeoteleuton
XMICAE 0.0.0 readme: This is an unsupported, experimental, release of early XMICAE source. It still needs a few features before becoming production ready: Transition to MySQL prepared statements. Addition of roll features. Configuration section where users can, for instance, toggle viewing trivia. Replace startup scene with XMI files, transition smoothly into gameplay. XMI works via a prompt system; each prompt is an object that stores a variable number of elements (directly inherited from the XML elements in an XML file used with the XMI elements below). Prompts should be extensible indefinitely, meaning that you could load as many files or modify as many elements as desired. Prompts are also based on the action they are associated with, at least if called using the action container element. Special concerns: On Linux, the filesystem is case sensitive. This can really mess up stuff if you're not careful. .htaccess can add headers to files, which, coincidentally, breaks them in PHP. These have mostly been replaced with javascript, but some may remain in PHP because of not being fully awake while working. Setup: There isn't a SQL database install, but you can use the included game.sql to set up your own database. If you're on a limited access database, like I am, for your webhosting, you can simply paste in the load of text at the end of this file. Resume readme. Files and what they do: (I exclude the non-XMICAE files, namely the fonts I include, here). actionoutcome.php: Crucial and utilized. This makes database interactions for states, tokens, and stokens work. attributechecktest.php: Test of attribute checks. Not necessary. attributetypes.php: Configuration file. Will be used once SQL database self-installs, and is used already for a number of functions. caphi.png: high resolution image to signify attribute caps. caplo.png: low resolution image to signify attribute caps. characteradvance.php: Character sheet and upgrade section. Needs upgrade to read from attributetypes.php. characteradvance2.php: Character advance functionality. characteradvancefunctions.php: Handles character advancement functionality. charactersheet.php: Debug tool. Obsolete, though worth looking at since it does what character advance should do after upgrades. config.php: Holds our configuration data, including our password hash and encryption settings. (note, salting comes as part of the code that calls passwords, and is not included here, since we don't have all the data yet). connect.php: Probably the second most complex code here. Handles SQL. Unfinished, needs update to prepared statements. footer.php: Just some HTML formatting stuff. Could have functionality later, but as is it just puts a little bottom element on the screen. functions.php: Holds functions that will be obsolete following connect.php upgrade (sanitizing input, which is a bad way to do what prepared statements do). header.php: Makes the UI magic happen (for the most part). Handles a variety of functionality that is too complex to handle here. help.php: Holds help files. These can be updated as needed, and will likely be replaced with a notification-esque system soon. index.php: Boring main page stuff, redirects to good stuff once people are logged in. login.php: Included as sidebar if the user is not logged in. logout.php: Logs out of the current account. nohi.png: high resolution image to signify being too low on advances to purchase an upgrade. nolo.png: low resolution image to signify being too low on advances to purchase an upgrade. notificationdisplay.php: Functions for notifications. Notifications still need to be implemented into XMI. notificationtest.php: Test file for notifications. objectsinc.php: Contains crucial prompt information for XMI functionality. plushi.png: high resolution image to signify having enough advances to purchase an upgrade. pluslo.png: low resolution image to signify having enough advances to purchase an upgrade. premain.php: Redirects during character creation. register.php: Handles account registration. requirementstest: Test file for requirements. Can be removed. resumegame.php: Has reset function for when you accidentally load a bad XML file. Otherwise obsoleted. roll.php: Holds roll functions. Largely unnecessary, but will allow novices to tweak functionality once rolling is in. roller.php: Entirely to-be-scrapped code for rolling. rolltest.php: Test of roll functionality. Unnecessary. safe.php: Variable management. sidebar.php: Handles navigation sidebar (e.g. access XMI, logout). start1.php: Handles character name setting. start2.php: Workaround for unfinished XMI stuff. Needs to be replaced/merged with start1.php. style.css: CSS stylesheet. Generic medieval theme by default. testblank.xml: entirely blank xml. Only kept in because I've left it in so far. Will be gone in any later release. testxmlprompt1.php: Test for XMI. Unnecessary. testxmlprompt2.php: Text for XMI. Unnecessary. uninitialized.xml: Old XMI file for when people goofed around with XMI. Now error handling prevents this from ever coming up (I hope). weathercore.php: Handles weather system. Configured for Poland near Krakow in June. weathermacrotest.php: Test for weather behaving as it should. weatheroutdoorsphrase.php: Handles actually using the weahter system in certain circumstances. Weather is not currently functional, because it's not necessary/desirable and the calls for it need some work. xmi.php: Mostly used to parse input for XMI as well as load up our files using xmiinclude.php. xmicaetestprep: Cutting-edge tests for prepared statements. Someone with more PHP/MySQL experience may be able to figure out why the things here aren't working, which would be a huge help. xmifunctions.php: The most complex file in here, handles parsing each XMI element. xmiinclude.php: Third most complex file, handles calling xmifunctions.php stuff. xmiold.php: Legacy XMI from before XMI.php and xmiinclude.php were their own separate things. Mostly kept for curiosity. Currently functional XMI tags: Lexicon: [] required input () optional input; these have standard default variables (typically 1 for numbers, = for comparisons, and whatever the XMI parser uses by standard for $varname). Containers: <object>[elements in tags]</object> Objects contain a variety of things, arbitrarily many, and can have a variety of effects. Note that the order in which elements are output is dependent on type, so you may want to use multiple objects for formatting. Display elements: <title><titletext>[text]</titletext>(<titlesize>[size]</titlesize></title> <header><headertext>[text]</headertext>(<headersize>[size]</headersize></title> <hr /> (horizontal rule) <narration>[text]</narration> <trivia>[text]</trivia> Each display element relates to HTML output for the end-user. Action: Actions can contain an arbitrary amount of contained elements. As a result, I just list all the things here. Parent element: <action> </action> Contained elements: <xmidir>(directory)</xmidir> * <xmifile>[file]</xmifile> ** <token>[token]</token> <stoken>[stoken]</stoken> <state>[state](,#,+/=/-)</state> *** <tokendel>[token]</tokendel> <stokendel>[stoken]</stokendel> <statedel>[state]</statedel> <stokenwipe /> * defaults to $defaultxmidirectory in config.php. If you have multiple xmifile elements, they should utilize xmidir elements based on where they are placed in the file (i.e. the top xmifile will use the top xmidir); if they run out of xmidir elements they should use $defaultxmidirectory ** loads [file].xml *** for conditionals, any non +/- functions as =. Requirements: If the required conditions are met, only then will this object be displayed to the user: <adminrequire />* <adminorrequire /> * <tokenrequire>[token]</tokenrequire> * <tokenorrequire>[token]</tokenorrequire> * <stokenrequire>[stoken]</stokenrequire> * <stokenorrequire>[stoken]</stokenrequire> * <staterequire>[state](,#,=/[/]/[=/=],$varname)</staterequire> * ** <stateorrequire>[state](,#,=/[/]/[=/=],$varname)</stateorrequire> * ** * Supports <failtrue /> to be considered a failure. If the tag would normally be self-terminating (< />, simply have a traditional < > </ > pair with <failtrue /> in there somewhere. ** Changing varnames is not supported for XMI; this is intended for when functions are called internally by a XMICAE module (i.e. the roller). Other: <save /> Saves the current location (all loaded XMI prompts) into the database so that the game can be resumed between sessions. Implemented, but loose code: Requirements: <attributerequire>[attribute,skill](,#,=/[/]/[=/=],$varname)</attributerequire> * ** <attributeorrequire>[attribute,skill](,#,=/[/]/[=/=],$varname)</attributeorrequire> * ** Attribute requirements work. I'm not sure how, since NetBeans isn't cooperating and I can't find my attributecheck function. * Supports <failtrue /> to be considered a failure. If the tag would normally be self-terminating (< />, simply have a traditional < > </ > pair with <failtrue /> in there somewhere. ** Changing varnames is not supported for XMI; this is intended for when functions are called internally by a XMICAE module (i.e. the roller). SQL to set up tables: -- -------------------------------------------------------- -- -- Table structure for table `abacus` -- CREATE TABLE IF NOT EXISTS `abacus` ( `id` int(11) NOT NULL AUTO_INCREMENT, `agility` int(2) NOT NULL, `brawn` int(2) NOT NULL, `awareness` int(2) NOT NULL, `cunning` int(2) NOT NULL, `understanding` int(2) NOT NULL, `sympathy` int(2) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; -- -------------------------------------------------------- -- -- Table structure for table `account` -- CREATE TABLE IF NOT EXISTS `account` ( `id` int(11) NOT NULL AUTO_INCREMENT, `admin` bit(1) NOT NULL, `adfree` bit(1) NOT NULL, `trivia` tinyint(1) NOT NULL DEFAULT '1', `doublebreak` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; -- -------------------------------------------------------- -- -- Table structure for table `characterinfo` -- CREATE TABLE IF NOT EXISTS `characterinfo` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30) NOT NULL, `curadva` int(11) NOT NULL, `curtrau` int(2) NOT NULL, `curshoc` int(2) NOT NULL, `curstab` int(2) NOT NULL, `histadva` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; -- -------------------------------------------------------- -- -- Table structure for table `location` -- CREATE TABLE IF NOT EXISTS `location` ( `id` int(11) NOT NULL AUTO_INCREMENT, `serializedprompt` text NOT NULL COMMENT 'note that this should never run into space limitations, but it could.', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; -- -------------------------------------------------------- -- -- Table structure for table `skills` -- CREATE TABLE IF NOT EXISTS `skills` ( `id` int(11) NOT NULL AUTO_INCREMENT, `athletics` int(2) NOT NULL, `closecombat` int(2) NOT NULL, `culture` int(2) NOT NULL, `medical` int(2) NOT NULL, `larceny` int(2) NOT NULL, `rangedcombat` int(2) NOT NULL, `survival` int(2) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; -- -------------------------------------------------------- -- -- Table structure for table `states` -- CREATE TABLE IF NOT EXISTS `states` ( `id` int(11) NOT NULL, `sname` varchar(32) NOT NULL, `count` int(11) NOT NULL, KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `stokens` -- CREATE TABLE IF NOT EXISTS `stokens` ( `id` int(11) NOT NULL, `tname` varchar(32) NOT NULL, KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='This is a storage system for "short term tokens", or "stokens". It can be wiped.'; -- -------------------------------------------------------- -- -- Table structure for table `tokens` -- CREATE TABLE IF NOT EXISTS `tokens` ( `id` int(11) NOT NULL COMMENT 'The owner of the token.', `tname` varchar(32) NOT NULL COMMENT 'Machine name of the token.', KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE IF NOT EXISTS `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(20) NOT NULL, `password` varchar(90) NOT NULL, `email` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;