Ejemplo n.º 1
0
        public async Task LoadData()
        {
            await LoadPlayerData();

            Encounters.Clear();
            var encounters = await App.Database.Encounters.Get <bool>((e) => e.CampaignID == Id, null);

            foreach (var e in encounters)
            {
                Encounters.Add(new EncounterViewModel(e));
            }
        }
Ejemplo n.º 2
0
        private async Task LoadDataAsync()
        {
            IsLoading = true;

            DisplayName = "Lade Daten ...";
            Encounters.Clear();

            await ExtractReportMetaInfoAsync();

            var reportData = await GetReportDataAsync();

            var encounters = await BuildEncounters(reportData);

            Encounters.AddRange(encounters);

            IsLoading = false;
        }
Ejemplo n.º 3
0
        private void CalculateStepCount()
        {
            Encounters.Clear();

            int traverseIndex       = 0;                         // An index to track where we are in the traversal.  i.e., down or up.
            int encounterTableIndex = Const.EncounterStartPoint; // An index to track where we are in the encounter hex table.
            int battleGroupIndex    = 0;                         // An index to track where we are in the battle group
            int stepsSinceLastEnc   = 0;

            // Loop through the users supplied zones + steps
            foreach (StepModel step in Steps.Where(s => s.IsValid))
            {
                if (step.PowerCycle)
                {
                    // User specified this was a power cycle, reset our indexes and continue our loop
                    traverseIndex       = 0;
                    encounterTableIndex = Const.EncounterStartPoint;
                    battleGroupIndex    = 0;
                    stepsSinceLastEnc   = 0;
                    if (!string.IsNullOrWhiteSpace(step.Comments))
                    {
                        Encounters.Add(new EncounterModel(ZoneType.NotApplicable, "(Power Cycle)", null, null, null, step.Comments));
                    }
                    continue;
                }

                int encountersFound = Encounters.Count;
                // Go through every step in our zone
                for (int i = 1; i <= step.Steps; i++)
                {
                    encounterTableIndex = Const.StepCountDirectionPattern[traverseIndex].GetNextIndex(encounterTableIndex);
                    stepsSinceLastEnc++;

                    if (encounterTableIndex == 0)
                    {
                        traverseIndex++;
                        if (traverseIndex > Const.StepCountDirectionPattern.Length - 1)
                        {
                            // Repeat our direction again by resetting to 0
                            traverseIndex = 0;
                        }
                    }

                    // Find the encounter theshhold at this index.  Compare it to the zones threshold
                    if (Const.EncounterTable[encounterTableIndex] < step.Zone.Threshhold)
                    {
                        // Battle!  Find the group
                        Encounters.Add(new EncounterModel(step.Zone.Type, step.Zone.Name, step.Zone.ZoneEncounters[Const.RandomBattleGroup[battleGroupIndex] - 1], Const.RandomBattleGroup[battleGroupIndex], stepsSinceLastEnc, step.Comments));

                        // Move up to the next battle group
                        battleGroupIndex++;
                        if (battleGroupIndex > 255)
                        {
                            battleGroupIndex = 0;
                        }
                        stepsSinceLastEnc = 0;
                    }
                }

                if (encountersFound == Encounters.Count && !string.IsNullOrWhiteSpace(step.Comments))
                {
                    // There are no encounters within this StepModel, but the user provided a comment.  Add this into the result screen (dummy encounter)
                    Encounters.Add(new EncounterModel(step.Zone?.Type ?? ZoneType.NotApplicable, step.ZoneDisplay, null, null, null, step.Comments));
                }
            }

            CurrentDirection = Const.StepCountDirectionPattern[traverseIndex];
            CurrentIndex     = encounterTableIndex.ToString("X");
            CurrentRng       = Const.EncounterTable[encounterTableIndex].ToString("X");
            NextBattleGroup  = Const.RandomBattleGroup[battleGroupIndex];

            // Calculate when the next encounter will occur
            if (FocusedSteps?.Zone != null)
            {
                StepCountPointerDirection direction = CurrentDirection;
                for (int i = 1; i < int.MaxValue; i++)
                {
                    encounterTableIndex = direction.GetNextIndex(encounterTableIndex);

                    if (encounterTableIndex == 0)
                    {
                        traverseIndex++;
                        if (traverseIndex > Const.StepCountDirectionPattern.Length - 1)
                        {
                            // Repeat our direction again by resetting to 0
                            traverseIndex = 0;
                        }
                    }

                    if (Const.EncounterTable[encounterTableIndex] < FocusedSteps.Zone.Threshhold)
                    {
                        // We found the battle
                        StepsTillNextEnc = i;
                        break;
                    }
                }
            }
        }