Ejemplo n.º 1
0
	public void LoadAll () {

		if (diagDefs != null) {
			DialogParser dp = new DialogParser ();
			dp.Start (diagDefs.text);
			Debug.Log("Dialog Definitions successfully Loaded");
		} else {
			Debug.LogError("File not reached: Non existent");
		}

		if (speechDefs != null) {
			SpeechParser sp = new SpeechParser ();
			sp.Start (speechDefs.text);
			Debug.Log("Speech Definitions successfully Loaded");
		} else {
			Debug.LogError("File not reached: Non existent");
		}

		if (questDefs != null) {
			QuestParser qp = new QuestParser ();
			qp.Start (questDefs.text);
			Debug.Log("Quest Definitions successfully Loaded");
		} else {
			Debug.LogError("File not reached: Non existent");
		}
	}
Ejemplo n.º 2
0
    /**
     * For every quest text document, attempt to make it into a quest and save it to the quest table
     * */
    public void MakeQuests()
    {
        questTable      = new Dictionary <int, Quest>();
        activeQuestList = new List <Quest>();
        parser          = new QuestParser();
        foreach (TextAsset questText in questTexts)
        {
            try
            {
                Dictionary <int, Quest> temptable = parser.CreateQuests(questText.text);

                foreach (int val in temptable.Keys)
                {
                    if (questTable.ContainsKey(val))
                    {
                        Debug.Log("Already contains quest ID " + val);
                    }
                    else
                    {
                        questTable.Add(val, temptable[val]);
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e.Message);
                Debug.Log("Unable to read file " + questText.name);
            }
        }
        //Find any quests that start as active
        UpdateActiveQuests();
    }
Ejemplo n.º 3
0
    public void TaskWithInvalidDescriptionTypeThrowsException()
    {
        string testJson = "{\"title\":\"null\", \"tasks\":[{\"description\":null}], \"notes\":[] }";

        Assert.Throws <QuestParseException>(
            () => QuestParser.Parse(testJson)
            );
    }
Ejemplo n.º 4
0
    public void QuestWithoutTitleThrowsException()
    {
        string testJson = "{}";

        Assert.Throws <QuestParseException>(
            () => QuestParser.Parse(testJson)
            );
    }
Ejemplo n.º 5
0
    public void NoteWithInvalidTypeThrowsException()
    {
        string testJson = "{\"title\":\"null\", \"tasks\":[{}], \"notes\":[null] }";

        Assert.Throws <QuestParseException>(
            () => QuestParser.Parse(testJson)
            );
    }
Ejemplo n.º 6
0
    public void QuestWithoutTaskDescriptionThrowsException()
    {
        string testJson = "{\"title\":\"test\", \"tasks\":[{}], \"notes\":[]}";

        Assert.Throws <QuestParseException>(
            () => QuestParser.Parse(testJson)
            );
    }
Ejemplo n.º 7
0
    public void QuestWithoutTasksThrowsException()
    {
        string testJson = "{\"title\":\"test\"}";

        Assert.Throws <QuestParseException>(
            () => QuestParser.Parse(testJson)
            );
    }
Ejemplo n.º 8
0
        public static void Export(List <PackFileEntry> files, MemoryMappedFile memFile)
        {
            if (Hash.CheckHash("ms2-quest-metadata"))
            {
                Console.WriteLine("\rSkipping quest metadata!");
                return;
            }

            // Parse quest metadata
            List <QuestMetadata> entities = QuestParser.Parse(memFile, files);

            QuestParser.Write(entities);
            Hash.WriteHash("ms2-quest-metadata");
        }
Ejemplo n.º 9
0
    public void QuestParseCorrectly()
    {
        string testJson =
            "{\"title\":\"test\", \"tasks\":[{\"description\":\"test\", \"visible\":false}], \"notes\":[\"test1\",\"test2\"] }";


        var expectedQuest = new Quest(
            "test",
            new[] { new QuestTask("test", false) },
            new[] { "test1", "test2" }
            );

        var realQuest = QuestParser.Parse(testJson);

        Assert.AreEqual(expectedQuest, realQuest);
    }
Ejemplo n.º 10
0
 public ImportFactory(CardParser cardParser, DropParser dropParser, ItemParser itemParser,
                      MapMonsterParser mapMonsterParser,
                      MapNpcParser mapNpcParser, MapParser mapParser, MapTypeMapParser mapTypeMapParser,
                      MapTypeParser mapTypeParser, NpcMonsterParser npcMonsterParser,
                      PortalParser portalParser, RespawnMapTypeParser respawnMapTypeParser,
                      ShopItemParser shopItemParser, ShopParser shopParser, SkillParser skillParser, NpcTalkParser npcTalkParser,
                      QuestPrizeParser questPrizeParser, QuestParser questParser, ActParser actParser, ScriptParser scriptParser,
                      IDao <AccountDto, long> accountDao, IDao <I18NQuestDto, int> i18NQuestDao, IDao <I18NSkillDto, int> i18NSkillDao,
                      IDao <I18NNpcMonsterTalkDto, int> i18NNpcMonsterTalkDao,
                      IDao <I18NNpcMonsterDto, int> i18NNpcMonsterDao, IDao <I18NMapPointDataDto, int> i18NMapPointDataDao,
                      IDao <I18NMapIdDataDto, int> i18NMapIdDataDao,
                      IDao <I18NItemDto, int> i18NItemDao, IDao <I18NBCardDto, int> i18NbCardDao,
                      IDao <I18NCardDto, int> i18NCardDao, IDao <I18NActDescDto, int> i18NActDescDao, ILogger logger)
 {
     _actParser             = actParser;
     _questPrizeParser      = questPrizeParser;
     _questParser           = questParser;
     _cardParser            = cardParser;
     _dropParser            = dropParser;
     _itemParser            = itemParser;
     _mapMonsterParser      = mapMonsterParser;
     _mapNpcParser          = mapNpcParser;
     _mapParser             = mapParser;
     _mapTypeMapParser      = mapTypeMapParser;
     _mapTypeParser         = mapTypeParser;
     _npcMonsterParser      = npcMonsterParser;
     _portalParser          = portalParser;
     _respawnMapTypeParser  = respawnMapTypeParser;
     _shopItemParser        = shopItemParser;
     _shopParser            = shopParser;
     _scriptParser          = scriptParser;
     _skillParser           = skillParser;
     _npcTalkParser         = npcTalkParser;
     _accountDao            = accountDao;
     _i18NQuestDao          = i18NQuestDao;
     _i18NSkillDao          = i18NSkillDao;
     _i18NNpcMonsterTalkDao = i18NNpcMonsterTalkDao;
     _i18NNpcMonsterDao     = i18NNpcMonsterDao;
     _i18NMapPointDataDao   = i18NMapPointDataDao;
     _i18NMapIdDataDao      = i18NMapIdDataDao;
     _i18NItemDao           = i18NItemDao;
     _i18NbCardDao          = i18NbCardDao;
     _i18NCardDao           = i18NCardDao;
     _i18NActDescDao        = i18NActDescDao;
     _logger = logger;
 }
Ejemplo n.º 11
0
        private void LoadQuestFiles()
        {
            Log.Info("Loading quest data please wait...");
            if (Directory.Exists(this.Conf.GetQuestFolder()))
            {
                foreach (var file in Directory.GetFiles(this.Conf.GetQuestFolder(), "*.dat"))
                {
                    var questParser = new QuestParser(file);
                    var quest       = questParser.ParseFile();
                    if (!this.GameData.Quests.ContainsKey(quest.Id))
                    {
                        this.GameData.Quests.Add(quest.Id, quest);
                    }
                }
            }

            Log.Info("Loaded " + this.GameData.Quests.Count + " quests");
        }
Ejemplo n.º 12
0
        /// <summary>
        /// extract quest and add description, count, reward item, reward quantity to List<BundleInfoEntry> BundleData
        /// loop if stage exist
        /// </summary>
        /// <param name="questFile"></param>
        private static void getQuestData(string questFile)
        {
            try
            {
                string questFilePath;
                if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
                {
                    questFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, questFile);
                }
                else
                {
                    questFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[questFile], questFile);
                }

                if (questFilePath != null)
                {
                    if (questFilePath.Contains(".uasset") || questFilePath.Contains(".uexp") || questFilePath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(questFilePath.Substring(0, questFilePath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                QuestParser[] questParser = QuestParser.FromJson(JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString());
                                for (int x = 0; x < questParser.Length; x++)
                                {
                                    string oldQuest = string.Empty;
                                    long   oldCount = 0;

                                    for (int p = 0; p < questParser[x].Objectives.Length; p++)
                                    {
                                        long newCount = questParser[x].Objectives[p].Count;
                                        if (questParser[x].ObjectiveCompletionCount > 0)
                                        {
                                            newCount = questParser[x].ObjectiveCompletionCount;
                                        }

                                        //fortbyte check
                                        bool isFortbyte = false;
                                        Parser.Quests.Reward assetTypeToken = null;
                                        if (questParser[x].Rewards != null) //this caused a null exception for some challenges (most of them in the Styles folder)
                                        {
                                            assetTypeToken = questParser[x].Rewards.Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name == "Token").FirstOrDefault();
                                            if (assetTypeToken != null)
                                            {
                                                isFortbyte = assetTypeToken.ItemPrimaryAssetId.PrimaryAssetName == "AthenaFortbyte";
                                            }
                                        }

                                        string newQuest = SearchResource.getTextByKey(questParser[x].Objectives[p].Description.Key, questParser[x].Objectives[p].Description.SourceString);
                                        if (newQuest != oldQuest && newCount != oldCount)
                                        {
                                            if (questParser[x].Rewards != null && !isFortbyte)
                                            {
                                                try
                                                {
                                                    string rewardId       = questParser[x].Rewards.Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest").Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token").FirstOrDefault().ItemPrimaryAssetId.PrimaryAssetName;
                                                    string rewardQuantity = questParser[x].Rewards.Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest").Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token").FirstOrDefault().Quantity.ToString();

                                                    BundleData.Add(new BundleInfoEntry(newQuest, newCount, rewardId, rewardQuantity));
                                                }
                                                catch (NullReferenceException)
                                                {
                                                    if (questParser[x].HiddenRewards != null)
                                                    {
                                                        string rewardId       = questParser[x].HiddenRewards.FirstOrDefault().TemplateId;
                                                        string rewardQuantity = questParser[x].HiddenRewards.FirstOrDefault().Quantity.ToString();

                                                        BundleData.Add(new BundleInfoEntry(newQuest, newCount, rewardId, rewardQuantity));
                                                    }
                                                }

                                                //get stage
                                                for (int k = 0; k < questParser[x].Rewards.Length; k++)
                                                {
                                                    string qAssetType = questParser[x].Rewards[k].ItemPrimaryAssetId.PrimaryAssetType.Name;
                                                    string qAssetName = questParser[x].Rewards[k].ItemPrimaryAssetId.PrimaryAssetName;

                                                    if (qAssetType == "Quest")
                                                    {
                                                        getQuestData(qAssetName);
                                                    }
                                                }
                                            }
                                            else if (isFortbyte && assetTypeToken != null)
                                            {
                                                BundleData.Add(new BundleInfoEntry(newQuest, newCount, assetTypeToken.ItemPrimaryAssetId.PrimaryAssetName, questParser[x].Weight > 0 ? questParser[x].Weight.ToString() : "01"));
                                            }
                                            else
                                            {
                                                BundleData.Add(new BundleInfoEntry(newQuest, newCount, "", ""));
                                            }

                                            oldQuest = newQuest;
                                            oldCount = newCount;
                                        }
                                    }
                                }
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                }
            }
            catch (KeyNotFoundException)
            {
                //do not stop when questFile doesn't exist
                //Console.WriteLine("Can't extract " + questFile);
            }
        }