It’s time to get into the details what a ruleset looks like. The ruleset is a simple XML file, built in the following way:
First of all, like all XML files, start with an XML declaration:
<?xml version=”1.0″ encoding=”UTF-8″?>
The root object is named “ruleset”, and has the property “name”:
First of all, you may put a “numofplayers” tag. It’s not mandatory (at least for now), but recommended – it helps the engine determine how many AI players to create.
Next comes the zones section. Card zones are a central concept in the Sunflower Engine – The locations of cards are defined by which zone they are in. Zone may or may not be displayed on the screen. The ruleset only determines the identity and behaviour of the zones – their locations and appearence are defined in the table file.
The zones section is made of the “zones” tag, which includes “zone” tags. A zone tag must contain an “id” tag, and may contain a “faceuptype” tag, to create special behaviours for when cards enter that zone – in some zones cards are always face up or face down, in some zones (usually player’s hands) cards that are face up are only visible to a certain player.
Next comes the “variables” tag, where you declare your variables. You do not actually have to declare any variables – if you use an undefined variable, it will be automatically created with a default (null) value. But declaring them can help keep things in order, as well as provide initial values to variables.
The next section is “procedures”. There you may script your own procedures to run from your scripts – for now there is no support for argument passing or returning values, so you’ll have to do those through global variables.
Note that any procedure whose name is “cheat1”, “cheat2”, … , “cheat9” will be called if you press Control+1, Control+2, and so on. This is useful for debugging, or whatever unusual option you want to offer the players.
<action>Gold1 += 1</action>
The final, and most important section, is “phases”. This is where the actual game rules are defined, and will be the topic of the next post.