Beispiel #1
0
        private static bool TryConvertJsonToCsv(JToken rootToken, out string csvContent)
        {
            csvContent = string.Empty;

            RaidConfig raidConfig = rootToken.ToObject <RaidConfig>();

            if (raidConfig.RaidDetails != null)
            {
                foreach (KeyValuePair <string, RoomInfo> roomInfo in raidConfig.RaidDetails.rooms)
                {
                    int missionsCount = roomInfo.Value.missions == null ? 0 : roomInfo.Value.missions.Count;

                    MissionInfo missionInfo = null;

                    if (missionsCount > 0)
                    {
                        missionInfo = new List <MissionInfo>(roomInfo.Value.missions.Values)[0];
                    }

                    csvContent += roomInfo.Key;

                    csvContent += ",";

                    if (missionsCount > 0)
                    {
                        csvContent += TryGetMissionRestriction(missionInfo);
                    }

                    csvContent += ",";

                    if (roomInfo.Value.starting == true)
                    {
                        csvContent += "Start here";
                    }
                    else if (missionsCount == 0)
                    {
                        csvContent += "Empty room";
                    }
                    else if (missionsCount > 1)
                    {
                        csvContent += "ERROR: multimission room";
                    }
                    else if (missionInfo.isBoss == true)
                    {
                        csvContent += "Boss";
                    }

                    csvContent += Environment.NewLine;
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        private static string TryGetMissionRestriction(MissionInfo missionInfo)
        {
            if (missionInfo.filters.filters.allTraits != null)
            {
                string result = string.Empty;

                foreach (string trait in missionInfo.filters.filters.allTraits)
                {
                    if (string.IsNullOrEmpty(result) == false)
                    {
                        result += " and ";
                    }

                    result += trait;
                }

                return(result);
            }

            if (missionInfo.filters.filters.anyTrait != null)
            {
                string result = string.Empty;

                foreach (string trait in missionInfo.filters.filters.anyTrait)
                {
                    if (string.IsNullOrEmpty(result) == false)
                    {
                        result += " or ";
                    }

                    result += trait;
                }

                return(result);
            }

            return("any");
        }