private void _parseActionEntries(JArray actionEntryJList, BestiaryMonsterAction monsterActionObj) { foreach (var actionEntryJToken in actionEntryJList) { Type tokenType = actionEntryJToken.GetType(); if (tokenType == typeof(JValue)) { monsterActionObj.ActionEntries.Add( (string)actionEntryJToken); } else if (tokenType == typeof(JObject)) { var actionEntryJObj = (JObject)actionEntryJToken; var actionEntryItemJList = (JArray)actionEntryJObj["items"]; _parseActionSubItems(actionEntryItemJList, monsterActionObj); } else { Console.WriteLine("Unrecognized action entry type: " + tokenType); } } }
private void _parseActionList(JArray actionList, Bestiary bestiary, int monsterIndex) { for (int n = 0; n < actionList.Count; ++n) { var actionJObj = (JObject)actionList[n]; var monsterActionObj = new BestiaryMonsterAction(); monsterActionObj.name = (string)actionJObj["name"]; var actionEntryJList = (JArray)actionJObj["entries"]; _parseActionEntries(actionEntryJList, monsterActionObj); bestiary.monster[monsterIndex].action[n] = monsterActionObj; } }
private void _parseActionSubItems(JArray actionEntryItemJList, BestiaryMonsterAction monsterActionObj) { foreach (JToken actionItemEntry in actionEntryItemJList) { if (actionItemEntry.GetType() != typeof(JObject)) { continue; } var actionItemJObj = (JObject)actionItemEntry; monsterActionObj.ActionEntries.Add( (string)actionItemJObj["entry"]); } }