Esempio n. 1
0
        public List <EventDecisionData> FilterToInitialStoryArcEvent(List <EventDecisionData> prevResult, string thisArc)
        {
            List <EventDecisionData> result = prevResult;

            result.RemoveAll(x => x.isStoryArc);

            if (!curPlayerData.IsStoryArcFinished(thisArc))
            {
                result.Add(storyArcEvents.Find(x => x.storyTitle == thisArc).storyEvents[0]);
            }

            return(result);
        }
Esempio n. 2
0
        public List <EventDecisionData> ObtainWeeklyEvents(TerritoryLevel thisLevel, int eventCount, PlayerKingdomData playerData, bool inStory = false)
        {
            List <EventDecisionData> result = new List <EventDecisionData>();

            curPlayerData = playerData;
            List <EventDecisionData> forcedEvent = new List <EventDecisionData>();

            #region DEV DEBUGGING
            if (EnableDebugging)
            {
                if (!KingdomManager.GetInstance.isInStory && !playerData.IsStoryArcFinished(arcForced))
                {
                    // ADD INITIAL EVENT FIRST
                    if (initialEventOnly)
                    {
                        forcedEvent.Add(ForcedInitialStoryEventDataToReturn());
                        result.Add(forcedEvent[forcedEvent.Count - 1]);
                        eventCount -= forcedEvent.Count;
                    }
                    // GET ALL STORY ARC EVENT
                    else if (allStoryArcEvents)
                    {
                        forcedEvent.AddRange(ForcedStoryEventsDataToReturn());
                        result.AddRange(forcedEvent);
                        eventCount -= forcedEvent.Count;
                    }
                }
            }
            #endregion

            if (result.Count >= eventCount)
            {
                return(result);
            }
            else
            {
                // GET TERRITORY
                result.AddRange(GetTerritoryFilteredEvents(thisLevel));

                // Filter by Difficulty
                if (EnableDebugging && forceDifficulty)
                {
                    result = ForceDifficultyFilteredEvent(Difficultyforced, result);
                }
                else
                {
                    result = GetDifficultyRolledEvents(curPlayerData.level, result);
                }

                if (!KingdomManager.GetInstance.isInStory)
                {
                    //Remove other Arcs
                    if (EnableDebugging && forceArc)
                    {
                        result = FilterToInitialStoryArcEvent(result, arcForced);
                    }
                    // FILTER BY STORY
                    if (!initialEventOnly && !inStory)
                    {
                        // CHECK IF RESULT HAS STORIES, REMOVE ALL BUT 1.
                        result = GetTerritoryDifficultyFilteredEvents(result);
                    }
                }
                else
                {
                    List <EventDecisionData> nonStory = new List <EventDecisionData>();
                    nonStory.AddRange(result.FindAll(x => !x.isStoryArc));
                    result = result.FindAll(x => x.isStoryArc && x.storyArc == KingdomManager.GetInstance.currentStory.storyTitle);
                    result.AddRange(nonStory);
                }

                // GET THE TOP 3
                List <EventDecisionData> finalResult = new List <EventDecisionData>();

                List <int> randomEvents = new List <int>();
                // ALWAYS HAVE THE FORCED EVENTS INSIDE THE RESULT.
                if (EnableDebugging)
                {
                    if (forcedEvent.Count > 0)
                    {
                        for (int i = 0; i < result.Count; i++)
                        {
                            if (forcedEvent.Find(x => x.title == result[i].title) != null)
                            {
                                randomEvents.Add(i);
                            }
                        }
                    }
                }
                // Debug.Log("RESULT COUNT: " + result.Count);
                for (int i = 0; i < eventCount; i++)
                {
                    int tmp = UnityEngine.Random.Range(0, result.Count - 1);
                    if (randomEvents.Contains(tmp))
                    {
                        i--;
                    }
                    else
                    {
                        randomEvents.Add(tmp);
                    }
                }

                for (int i = 0; i < randomEvents.Count; i++)
                {
                    finalResult.Add(result[randomEvents[i]]);
                }

                // Debug.Log("Final Result Count: " + finalResult.Count);
                return(finalResult);
            }
        }