Example #1
0
 public void RecvPokemons(List <EncounterInfo> data)
 {
     data = data.FindNonContains(Encounters.GetAll);
     if (data.Count <= 0)
     {
         return;
     }
     try
     {
         for (var i = 0; i < data.Count; i++)
         {
             var elapsed = (int)(data[i].GetExpiration() - DateTime.Now).TotalMilliseconds;
             if (elapsed > 0)
             {
                 var snc = Encounters.Add(data[i], new TimeSpan(0, 0, 0, 0, elapsed), data[i].UniqueKey());
                 if (snc)
                 {
                     continue;
                 }
             }
             data.RemoveAt(i);
             i--;
         }
         if (data.Count > 0)
         {
             Clients.Group(HubType.Listener.ToString()).NewPokemons(data);
         }
     }
     catch (Exception)
     {
         // ignored
     }
 }
Example #2
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));
            }
        }
Example #3
0
        public Location AddEncounter(int monsterId, int percentage)
        {
            var existing = Encounters.FirstOrDefault(x => x.Id == monsterId);

            if (existing != null)
            {
                existing.Percentage = percentage;
            }
            else
            {
                Encounters.Add(new IdPercentage()
                {
                    Id = monsterId, Percentage = percentage
                });
            }

            return(this);
        }
Example #4
0
 public void AddEncounter(ShadowguardEncounter encounter)
 {
     Encounters.Add(encounter);
 }
Example #5
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;
                    }
                }
            }
        }