I moved to a new URL! Check it out!

Dev Log: RPG and YAML Stuff

Dev Log: RPG and YAML Stuff
With the move to Denver pretty much complete I've gotten back into some sort of groove of working on stuff, but I guess my brain must've been pretty scrambled with this sudden weather change because now I'm taking some time to work on a completely different project again!

This is actually a project I've worked on here and there over the past year, but I think I finally have narrowed down some ideas in my head on more of the finer details and that's inspired me to work on it some more.

Without spoiling too much about it: it is some sort of RPG, and it does have some sort of procedural generation element to it. I've been digging into using YAML for the data since I've been looking for something easy to parse and easy to write out. I think the failings of JSON and XML are that it is a giant pain to write out by hand, so YAML seems to be covering that gap quite well.

Here's an example of some of my YAML data:
name: "Bob"
health: 10
money: 5
drop: [null, null, basicattack]
color: ff0000
- Attack 1
- Attack 1
- [Attack 1, Attack 1, Charge]
- Attack 1
- [Flee, Defend]
- Restart

And to parse it in Otter I'm using a library called YamlDotNet. It makes parsing YAML pretty easy but unfortunately it is lacking in documentation and community.

The parsing code for the above data looks like this:
// An enemy class to match the structure of the YAML
public class Enemy : DataObject {
public static string DataPath = Assets.Data.Enemies;

public int Health { get; set; }
public int Money { get; set; }
public List<string> Drop { get; set; }
public List<object> Combat { get; set; }
public string Color { get; set; }
// A method to load the data from the YAML
enemies = Load<Parsed.Enemy>();
// The method to load the data from YAML
static Dictionary<string, T> Load<T>() where T : Parsed.DataObject {
string dataPath = "";
try {
dataPath = (string)Util.GetFieldValue(typeof(T), "DataPath");
catch {
throw new Exception(string.Format("No data path found on type {0}", typeof(T)));

var dict = DD.Yaml.Deserialize<Dictionary<string, T>>(File.ReadAllText(dataPath));
dict.Each((k, v) => {
v.Id = k;
return dict;
Normally I would be using my Google Spreadsheet tools for data, but unfortunately spreadsheets break down at a certain point. When my data starts to need more than just scalar values in each field spreadsheets become a pain to use. Basically if I want an enemy to have a list of attacks to perform on the player I have to enter that list into a single cell of a spreadsheet which just doesn't look or feel good.

More updates on this and hopefully Super Sky Sisters coming soon!
new comment!

Post your comment!