public Quest GetQuest(string motive, int minimumComplexity) { int failCatch = 0; Subquest root = GetActions(motive); Quest quest = new Quest(root); while (quest.GetDepth() < minimumComplexity || quest.GetDepth() > 20) { if (failCatch > 100) { Debug.Log("Can't find path, breaking out!"); break; } quest = new Quest(GetActions(motive)); failCatch++; } quest.motivation = motive; quest.description = root.actionText; // Will add quest metadata here, such as text, title, etc... return(quest); }
// Gets appropriate actions for the subquest based on motive public Subquest GetActions(string motive) { // Load the lists of available npcs, enemies, locations, and items. locData = new List <LocationData> (gm.locations); npcData = new List <NPCData>(gm.npcs); enemyData = new List <EnemyData>(gm.enemies); itemData = new List <ItemData>(gm.items); SeedData seed; if (motive == "knowledge") { seed = gm.knowledgeSeeds [Random.Range(0, gm.knowledgeSeeds.Length)]; } else if (motive == "comfort") { seed = gm.comfortSeeds [Random.Range(0, gm.comfortSeeds.Length)]; } else if (motive == "justice") { seed = gm.justiceSeeds [Random.Range(0, gm.justiceSeeds.Length)]; } else { throw new System.NotImplementedException(); } List <Action> rootActions = assignActions(new List <string>(seed.actions)); Subquest root = new Subquest(rootActions); // Set the subqest action text root.actionText = seed.description; return(root); }