Converstaion Data Generator

The idea of this sneaky thing is to create various chains of conversations between entities and such forth. It basically aims to make visual sense of the json structures in the alpha rpg for unity.

by Sam Fereday

HTML

<div id="output"></div>

CSS

body {
  font: 85%/1.4em arial;
}

div {
  box-sizing: border-box;
}

p {
  padding: 0;
  margin: 0;
}

span {
  font-size: 12px;
}

pre {
  word-wrap: break-word;
}

.entity {
  padding: 1em;
  margin-bottom: 1em;
  border: 1px solid #ccc;
}

.top {
  padding-top: 1em;
}

JavaScript

/* Please note that some of the data doesn't completely connect up here visually. For instance, when you've hit select, they will load a separate stream of strings as converstaion that don't require an entity to trigger it since it's already in process. I would suggest have a sub stream within the related entity and show off in a similar fashion as the entity conversation outputs. */
// Some data (straight out of the game)
var anEntity = [{
	"id": "bob",
	"customFlags": [{
		"canSay": {
			"isComplete": ["story1a"]
		},
		"cnvId": "cnv1a"
	}, {
		"canSay": {
			"notComplete": ["quest1a"]
		},
		"cnvId": "cnv2a"
	}, {
		"canSay": {
			"isComplete": ["quest1a"],
			"notComplete": ["quest1b"]
		},
		"cnvId": "cnv3a"
	}]
}, {
	"id": "door1a",
  "customFlags": [
    {
      "canSay": {
        "notComplete": [ "door1aHasKey" ]
      },
      "cnvId": "doorLocked1a"
    },
    {
      "canSay": {
        "isComplete": [ "door1aHasKey" ],
        "notComplete":  ["story1a"]
      },
      "cnvId": "doorUnlock1a"
    },
    {
		  "canSay": {
			  "isComplete": ["door1aHasKey", "story1a"]
		  },
		  "cnvId": "doorUnlocked1a"
	  }
  ]
}, {
	"id": "dog1a",
	"customFlags": [
		{
			"canSay": {},
			"cnvId": "dogDefault"
		}
	]
}, {
	"id": "winry",
	"customFlags": [
		{
			"canSay": {},
			"cnvId": "shopDefault"
		}
	]
}];

var someConversations = [
  {
    "id": "cnv1a",
    "collection": [
      {
        "belongsTo": "triggerNpc",
        "text": "They say war is coming. I fear for our safety..."
      },
      {
        "belongsTo": "player",
        "text": "How can you be so certain?"
      },
      {
        "belongsTo": "triggerNpc",
        "text": "Call it a hunch."
      }
    ]
  },
  {
    "id": "cnv2a",
    "collection": [
      {
        "belongsTo": "triggerNpc",
        "text": "Can you open that door for me?"
      }
    ],
    "options": [
      {
        "text": "Help the guy out?",
        "yes": {
          "text": "Yes",
          "cnvId": "select1a"
  ...