Ejemplo n.º 1
0
        public static void PrintPokemonInfo(ISession session, PokemonData duplicatePokemon)
        {
            var bestPokemonOfType = (session.LogicSettings.PrioritizeIvOverCp
                                        ? session.Inventory.GetHighestPokemonOfTypeByIv(duplicatePokemon)
                                        : session.Inventory.GetHighestPokemonOfTypeByCp(duplicatePokemon)) ??
                                    duplicatePokemon;

            var ev = new TransferPokemonEvent
            {
                Id             = duplicatePokemon.Id,
                PokemonId      = duplicatePokemon.PokemonId,
                Perfection     = PokemonInfo.CalculatePokemonPerfection(duplicatePokemon),
                Cp             = duplicatePokemon.Cp,
                BestCp         = bestPokemonOfType.Cp,
                BestPerfection = PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType),
                Candy          = session.Inventory.GetCandyCount(duplicatePokemon.PokemonId)
            };

            if (session.Inventory.GetCandyFamily(duplicatePokemon.PokemonId) != null)
            {
                ev.FamilyId = session.Inventory.GetCandyFamily(duplicatePokemon.PokemonId).FamilyId;
            }

            session.EventDispatcher.Send(ev);
        }
Ejemplo n.º 2
0
 public void HandleEvent(TransferPokemonEvent evt, ISession session)
 {
     Logger.Write(session.Translation.GetTranslation(TranslationString.EventPokemonTransferred, session.Translation.GetPokemonName(evt.Id), evt.Cp,
                                                     evt.Perfection.ToString("0.00"), evt.BestCp, evt.BestPerfection.ToString("0.00"), evt.FamilyCandies),
                  LogLevel.Transfer, session: session);
     Logger.PushToUi("pm_rem", session, evt.Uid, evt.Family, evt.FamilyCandies);
 }
Ejemplo n.º 3
0
 public void HandleEvent(TransferPokemonEvent evt, ISession session)
 {
     Logger.Write(
         session.Translation.GetTranslation(TranslationString.EventPokemonTransferred, evt.Id, evt.Cp,
                                            evt.Perfection.ToString("0.00"), evt.BestCp, evt.BestPerfection.ToString("0.00"), evt.FamilyCandies),
         LogLevel.Transfer);
 }
Ejemplo n.º 4
0
        public static async Task PrintPokemonInfo(ISession session, PokemonData duplicatePokemon)
        {
            var bestPokemonOfType = (session.LogicSettings.PrioritizeIvOverCp
                                        ? await session.Inventory.GetHighestPokemonOfTypeByIv(duplicatePokemon).ConfigureAwait(false)
                                        : await session.Inventory.GetHighestPokemonOfTypeByCp(duplicatePokemon).ConfigureAwait(false)) ??
                                    duplicatePokemon;

            var ev = new TransferPokemonEvent
            {
                Id             = duplicatePokemon.Id,
                PokemonId      = duplicatePokemon.PokemonId, // session.Translation.GetPokemonTranslation(duplicatePokemon.PokemonId),
                Perfection     = PokemonInfo.CalculatePokemonPerfection(duplicatePokemon),
                Cp             = duplicatePokemon.Cp,
                BestCp         = bestPokemonOfType.Cp,
                BestPerfection = PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType),
                Candy          = await session.Inventory.GetCandyCount(duplicatePokemon.PokemonId).ConfigureAwait(false),
                Level          = PokemonInfo.GetLevel(duplicatePokemon)
            };

            if (await session.Inventory.GetCandyFamily(duplicatePokemon.PokemonId).ConfigureAwait(false) != null)
            {
                ev.FamilyId = (await session.Inventory.GetCandyFamily(duplicatePokemon.PokemonId).ConfigureAwait(false)).FamilyId;
            }

            session.EventDispatcher.Send(ev);
        }
Ejemplo n.º 5
0
        public static async Task Execute(ISession session, CancellationToken cancellationToken, List <ulong> pokemonIds)
        {
            using (var blocker = new BlockableScope(session, BotActions.Transfer))
            {
                if (!await blocker.WaitToRun())
                {
                    return;
                }

                var all = session.Inventory.GetPokemons();
                List <PokemonData> pokemonToTransfer = new List <PokemonData>();
                var pokemons = all.OrderBy(x => x.Cp).ThenBy(n => n.StaminaMax);

                foreach (var item in pokemonIds)
                {
                    var pokemon = pokemons.FirstOrDefault(p => p.Id == item);

                    if (pokemon == null)
                    {
                        return;
                    }
                    pokemonToTransfer.Add(pokemon);
                }

                var pokemonSettings = await session.Inventory.GetPokemonSettings();

                var pokemonFamilies = await session.Inventory.GetPokemonFamilies();

                await session.Client.Inventory.TransferPokemons(pokemonIds);

                foreach (var pokemon in pokemonToTransfer)
                {
                    var bestPokemonOfType = (session.LogicSettings.PrioritizeIvOverCp
                                                ? session.Inventory.GetHighestPokemonOfTypeByIv(pokemon)
                                                : session.Inventory.GetHighestPokemonOfTypeByCp(pokemon)) ??
                                            pokemon;

                    // Broadcast event as everyone would benefit
                    var ev = new TransferPokemonEvent
                    {
                        Id             = pokemon.Id,
                        PokemonId      = pokemon.PokemonId,
                        Perfection     = PokemonInfo.CalculatePokemonPerfection(pokemon),
                        Cp             = pokemon.Cp,
                        BestCp         = bestPokemonOfType.Cp,
                        BestPerfection = PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType),
                        Candy          = session.Inventory.GetCandyCount(pokemon.PokemonId)
                    };

                    if (session.Inventory.GetCandyFamily(pokemon.PokemonId) != null)
                    {
                        ev.FamilyId = session.Inventory.GetCandyFamily(pokemon.PokemonId).FamilyId;
                    }

                    session.EventDispatcher.Send(ev);
                }

                await DelayingUtils.DelayAsync(session.LogicSettings.TransferActionDelay, 0, cancellationToken);
            }
        }
Ejemplo n.º 6
0
 internal void OnTransfer(TransferPokemonEvent e)
 {
     this.Remove(e.Id);
     foreach (var item in this.Pokemons.Where(p => p.FamilyId == e.FamilyId))
     {
         item.RaisePropertyChanged("Candy");
     }
 }
Ejemplo n.º 7
0
 internal void OnTransfer(TransferPokemonEvent e)
 {
     this.Remove(e.Id);
     foreach (var item in this.Pokemons)
     {
         if (item.PokemonSettings != null && item.PokemonSettings.FamilyId == e.FamilyId)
         {
             item.Candy = e.FamilyCandies;
         }
     }
 }
Ejemplo n.º 8
0
 private static void HandleEvent(TransferPokemonEvent transferPokemonEvent, ISession session)
 {
     Logger.Write(
         session.Translation.GetTranslation(TranslationString.EventPokemonTransferred,
                                            session.Translation.GetPokemonTranslation(transferPokemonEvent.Id),
                                            transferPokemonEvent.Cp.ToString(),
                                            transferPokemonEvent.Perfection.ToString("0.00"),
                                            transferPokemonEvent.BestCp.ToString(),
                                            transferPokemonEvent.BestPerfection.ToString("0.00"),
                                            transferPokemonEvent.FamilyCandies),
         LogLevel.Transfer);
 }
Ejemplo n.º 9
0
 public void HandleEvent(TransferPokemonEvent transferPokemonEvent, ISession session)
 {
     liveHappening = "transfer";
     PokemonID     = pokemonNameToId[transferPokemonEvent.Id.ToString()];
     PokemonName   = session.Translation.GetPokemonTranslation(transferPokemonEvent.Id);
     Write(
         session.Translation.GetTranslation(TranslationString.EventPokemonTransferred,
                                            session.Translation.GetPokemonTranslation(transferPokemonEvent.Id).PadRight(12, ' '),
                                            transferPokemonEvent.Cp.ToString().PadLeft(4, ' '),
                                            transferPokemonEvent.Perfection.ToString("0.00").PadLeft(6, ' '),
                                            transferPokemonEvent.BestCp.ToString().PadLeft(4, ' '),
                                            transferPokemonEvent.BestPerfection.ToString("0.00").PadLeft(6, ' '),
                                            transferPokemonEvent.FamilyCandies),
         LogLevel.Transfer);
 }
Ejemplo n.º 10
0
 private static void HandleEvent(TransferPokemonEvent transferPokemonEvent, ISession session)
 {
     Logger.Write(
         session.Translation.GetTranslation(TranslationString.EventPokemonTransferred,
                                            session.Translation.GetPokemonTranslation(transferPokemonEvent.PokemonId).PadRight(12, ' '),
                                            transferPokemonEvent.Cp.ToString("0").PadLeft(4, ' '),
                                            transferPokemonEvent.Perfection.ToString("0.00").PadLeft(6, ' '),
                                            transferPokemonEvent.BestCp.ToString("0").PadLeft(4, ' '),
                                            transferPokemonEvent.BestPerfection.ToString("0.00").PadLeft(6, ' '),
                                            transferPokemonEvent.Candy.ToString("0").PadLeft(4, ' '),
                                            transferPokemonEvent.Level.ToString("0.0").PadLeft(4, ' ')
                                            ),
         LogLevel.Transfer
         );
 }
Ejemplo n.º 11
0
 private static void HandleEvent(TransferPokemonEvent transferPokemonEvent, ISession session)
 {
     if (session.LogicSettings.NotificationConfig.EnablePushBulletNotification && transferPokemonEvent.Slashed)
     {
         PushNotificationClient.SendNotification(session, $"Transferred Slashed Pokemon", $"{session.Translation.GetPokemonTranslation(transferPokemonEvent.PokemonId)}\n" +
                                                 $"Lvl: {transferPokemonEvent.Level}\n" +
                                                 $"CP:  {transferPokemonEvent.Cp}/{transferPokemonEvent.BestCp}\n" +
                                                 $"IV:  {transferPokemonEvent.Perfection.ToString("0.00")}\n", true).ConfigureAwait(false);
     }
     Logger.Write(
         session.Translation.GetTranslation(TranslationString.EventPokemonTransferred,
                                            session.Translation.GetPokemonTranslation(transferPokemonEvent.PokemonId).PadRight(12, ' '),
                                            transferPokemonEvent.Cp.ToString("0").PadLeft(4, ' '),
                                            transferPokemonEvent.Perfection.ToString("0.00").PadLeft(6, ' '),
                                            transferPokemonEvent.BestCp.ToString("0").PadLeft(4, ' '),
                                            transferPokemonEvent.BestPerfection.ToString("0.00").PadLeft(6, ' '),
                                            transferPokemonEvent.Candy.ToString("0").PadLeft(4, ' '),
                                            transferPokemonEvent.Level.ToString("0.0").PadLeft(4, ' '),
                                            transferPokemonEvent.Slashed.ToString().PadLeft(5, ' ')
                                            ),
         LogLevel.Transfer
         );
 }
Ejemplo n.º 12
0
 public void HandleEvent(TransferPokemonEvent evt, ISession session)
 {
     _stats.TotalPokemonsTransfered++;
     _stats.Dirty(session.Inventory);
     _stats.CheckLevelUp(session);
 }
Ejemplo n.º 13
0
 public void OnBotEvent(TransferPokemonEvent transferedPkm)
 {
     this.datacontext.PokemonList.OnTransfer(transferedPkm);
 }
Ejemplo n.º 14
0
 public void HandleEvent(TransferPokemonEvent evt, ISession session)
 {
     _stats.TotalPokemonTransferred++;
     _stats.Dirty(session.Inventory, session);
 }
Ejemplo n.º 15
0
 public void HandleEvent(TransferPokemonEvent evt, ISession session)
 {
     session.Stats.TotalPokemonsTransfered++;
     session.Stats.RefreshStatAndCheckLevelup(session);
 }