Exemplo n.º 1
0
        private void _loadTypeData(JArray monsterList, int monsterIndex,
                                   Bestiary bestiary)
        {
            JObject monster = (JObject)monsterList[monsterIndex];

            if (_isCopyOfOtherMonster(monster))
            {
                bestiary.monster[monsterIndex].IsCopy = true;
                return;
            }
            JToken typeToken = monster["type"];
            var    typeList  = new List <string>();

            if (typeToken.GetType() == typeof(JValue))
            {
                typeList.Add((string)typeToken);
            }
            else if (typeToken.GetType() == typeof(JObject))
            {
                typeList = _parseTypeObjext(typeToken, typeList);
            }
            else
            {
                Console.WriteLine("Unrecognized data type for 'type' " +
                                  "entry: " + typeToken.GetType());
            }
            bestiary.monster[monsterIndex].TypeList = typeList;
        }
Exemplo n.º 2
0
        private void _loadAcData(JArray monsterList, int monsterIndex,
                                 Bestiary bestiary)
        {
            JObject monster = (JObject)monsterList[monsterIndex];

            if (_isCopyOfOtherMonster(monster))
            {
                return;
            }
            JArray acJsonEntry   = (JArray)monster["ac"];
            JToken acJsonElement = acJsonEntry[0];
            Type   eleType       = acJsonElement.GetType();

            if (eleType == typeof(JValue))
            {
                bestiary.monster[monsterIndex].ArmorClass = (int)acJsonElement;
            }
            else if (eleType == typeof(JObject))
            {
                bestiary.monster[monsterIndex].ArmorClass =
                    (int)acJsonElement["ac"];
            }
            else
            {
                Console.WriteLine("Unrecognized data type for 'ac' " +
                                  "entry: " + eleType);
            }
        }
Exemplo n.º 3
0
        } // loadJsonMonsters

        private void _loadCr(JArray monsterList, int monsterIndex,
                             Bestiary bestiary)
        {
            JObject monster = (JObject)monsterList[monsterIndex];
            JToken  crToken = monster["cr"];

            if (crToken is null)
            {
                bestiary.monster[monsterIndex].IsCopy = true;
                return;
            }

            if (crToken.GetType() == typeof(JValue))
            {
                var crStr = (string)crToken;
                bestiary.monster[monsterIndex].ChallengeRating = (string)crToken;
                return;
            }

            if (crToken.GetType() == typeof(JObject))
            {
                crToken = crToken["cr"];
                bestiary.monster[monsterIndex].ChallengeRating = (string)crToken;
                return;
            }

            Console.WriteLine("Can't find the cr for " + monster["name"]);
        }
Exemplo n.º 4
0
 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;
     }
 }
Exemplo n.º 5
0
        private void _loadActionData(JArray monsterList, int monsterIndex,
                                     Bestiary bestiary)
        {
            JObject monster = (JObject)monsterList[monsterIndex];

            if (_isCopyOfOtherMonster(monster))
            {
                return;
            }
            JArray actionList = (JArray)monster["action"];

            if (!(actionList is null))
            {
                _parseActionList(actionList, bestiary, monsterIndex);
            }
        }