当前位置: 首页>>代码示例>>C#>>正文


C# State.Context类代码示例

本文整理汇总了C#中PoGo.NecroBot.Logic.State.Context的典型用法代码示例。如果您正苦于以下问题:C# Context类的具体用法?C# Context怎么用?C# Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Context类属于PoGo.NecroBot.Logic.State命名空间,在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleEvent

        public void HandleEvent(PokemonCaptureEvent evt, Context ctx)
        {
            Func<ItemId, string> returnRealBallName = a =>
            {
                switch (a)
                {
                    case ItemId.ItemPokeBall:
                        return ctx.Translations.GetTranslation(TranslationString.Pokeball);
                    case ItemId.ItemGreatBall:
                        return ctx.Translations.GetTranslation(TranslationString.GreatPokeball);
                    case ItemId.ItemUltraBall:
                        return ctx.Translations.GetTranslation(TranslationString.UltraPokeball);
                    case ItemId.ItemMasterBall:
                        return ctx.Translations.GetTranslation(TranslationString.MasterPokeball);
                    default:
                        return "Unknown";
                }
            };

            var catchType = evt.CatchType;

            var catchStatus = evt.Attempt > 1
                ? ctx.Translations.GetTranslation(TranslationString.CatchStatusAttempt, evt.Status, evt.Attempt)
                : ctx.Translations.GetTranslation(TranslationString.CatchStatus, evt.Status);

            var familyCandies = evt.FamilyCandies > 0
                ? ctx.Translations.GetTranslation(TranslationString.Candies, evt.FamilyCandies)
                : "";

            Logger.Write(ctx.Translations.GetTranslation(TranslationString.EventPokemonCapture, catchStatus, catchType, evt.Id,
                evt.Level, evt.Cp, evt.MaxCp, evt.Perfection.ToString("0.00"), evt.Probability, evt.Distance.ToString("F2"),
                returnRealBallName(evt.Pokeball), evt.BallAmount, familyCandies), LogLevel.Caught);
        }
开发者ID:Claen,项目名称:NecroBot,代码行数:33,代码来源:ConsoleEventListener.cs

示例2: Execute

        public static void Execute(Context ctx, StateMachine machine)
        {
            if (ctx.LogicSettings.UseLuckyEggsWhileEvolving)
            {
                UseLuckyEgg(ctx.Client, ctx.Inventory, machine);
            }

            var pokemonToEvolveTask = ctx.Inventory.GetPokemonToEvolve(ctx.LogicSettings.PokemonsToEvolve);
            pokemonToEvolveTask.Wait();

            var pokemonToEvolve = pokemonToEvolveTask.Result;
            foreach (var pokemon in pokemonToEvolve)
            {
                var evolveTask = ctx.Client.Inventory.EvolvePokemon(pokemon.Id);
                evolveTask.Wait();

                var evolvePokemonOutProto = evolveTask.Result;

                machine.Fire(new PokemonEvolveEvent
                {
                    Id = pokemon.PokemonId,
                    Exp = evolvePokemonOutProto.ExperienceAwarded,
                    Result = evolvePokemonOutProto.Result
                });

                Thread.Sleep(3000);
            }
        }
开发者ID:Citrusbomb,项目名称:NecroBot,代码行数:28,代码来源:EvolvePokemonTask.cs

示例3: HandleEvent

 public void HandleEvent(PokemonEvolveEvent evt, Context ctx)
 {
     Logger.Write(evt.Result == EvolvePokemonResponse.Types.Result.Success
         ? $"{evt.Id} successfully for {evt.Exp}xp"
         : $"Failed {evt.Id}. EvolvePokemonOutProto.Result was {evt.Result}, stopping evolving {evt.Id}",
         LogLevel.Evolve);
 }
开发者ID:Citrusbomb,项目名称:NecroBot,代码行数:7,代码来源:ConsoleEventListener.cs

示例4: Execute

        public static void Execute(Context ctx, StateMachine machine)
        {
            var duplicatePokemons =
                ctx.Inventory.GetDuplicatePokemonToTransfer(ctx.LogicSettings.KeepPokemonsThatCanEvolve, ctx.LogicSettings.PrioritizeIvOverCp,
                    ctx.LogicSettings.PokemonsNotToTransfer).Result;

            foreach (var duplicatePokemon in duplicatePokemons)
            {
                if (duplicatePokemon.Cp >= ctx.LogicSettings.KeepMinCp ||
                    PokemonInfo.CalculatePokemonPerfection(duplicatePokemon) > ctx.LogicSettings.KeepMinIvPercentage)
                {
                    continue;
                }

                ctx.Client.Inventory.TransferPokemon(duplicatePokemon.Id).Wait();
                ctx.Inventory.DeletePokemonFromInvById(duplicatePokemon.Id);

                var bestPokemonOfType = ctx.LogicSettings.PrioritizeIvOverCp
                    ? ctx.Inventory.GetHighestPokemonOfTypeByIv(duplicatePokemon).Result
                    : ctx.Inventory.GetHighestPokemonOfTypeByCp(duplicatePokemon).Result;

                if (bestPokemonOfType == null)
                    bestPokemonOfType = duplicatePokemon;

                machine.Fire(new TransferPokemonEvent
                {
                    Id = duplicatePokemon.PokemonId,
                    Perfection = PokemonInfo.CalculatePokemonPerfection(duplicatePokemon),
                    Cp = duplicatePokemon.Cp,
                    BestCp = bestPokemonOfType.Cp,
                    BestPerfection = PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType)
                });
            }
        }
开发者ID:Citrusbomb,项目名称:NecroBot,代码行数:34,代码来源:TransferDuplicatePokemonTask.cs

示例5: Execute

        public static async Task Execute(Context ctx, StateMachine machine)
        {
            var highestsPokemonCp = await ctx.Inventory.GetHighestsCp(ctx.LogicSettings.AmountOfPokemonToDisplayOnStart);
            var pokemonPairedWithStatsCp = highestsPokemonCp.Select(pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon))).ToList();

            var highestsPokemonPerfect =
                await ctx.Inventory.GetHighestsPerfect(ctx.LogicSettings.AmountOfPokemonToDisplayOnStart);

            var pokemonPairedWithStatsIv = highestsPokemonPerfect.Select(pokemon => Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon))).ToList();

            machine.Fire(
                new DisplayHighestsPokemonEvent
                {
                    SortedBy = "CP",
                    PokemonList = pokemonPairedWithStatsCp
                });

            await Task.Delay(500);

            machine.Fire(
                new DisplayHighestsPokemonEvent
                {
                    SortedBy = "IV",
                    PokemonList = pokemonPairedWithStatsIv
                });

            await Task.Delay(500);
        }
开发者ID:Crowstrum,项目名称:NecroBot,代码行数:28,代码来源:DisplayPokemonStatsTask.cs

示例6: Execute

        public async Task<IState> Execute(Context ctx, StateMachine machine)
        {
            if (ctx.LogicSettings.AmountOfPokemonToDisplayOnStart > 0)
                await DisplayPokemonStatsTask.Execute(ctx, machine);

            return new FarmState();
        }
开发者ID:Crowstrum,项目名称:NecroBot,代码行数:7,代码来源:InfoState.cs

示例7: Execute

        public static async Task Execute(Context ctx, StateMachine machine)
        {
            var pokemonToEvolveTask = await ctx.Inventory.GetPokemonToEvolve(ctx.LogicSettings.PokemonsToEvolve);
            var pokemonToEvolve = pokemonToEvolveTask.ToList();

            if (pokemonToEvolve.Any())
            {
                if (ctx.LogicSettings.UseLuckyEggsWhileEvolving)
                {
                    if (pokemonToEvolve.Count() >= ctx.LogicSettings.UseLuckyEggsMinPokemonAmount)
                    {
                        await UseLuckyEgg(ctx.Client, ctx.Inventory, machine);
                    }
                    else
                    {
                        // Wait until we have enough pokemon
                        return;
                    }
                }

                foreach (var pokemon in pokemonToEvolve)
                {
                    var evolveResponse = await ctx.Client.Inventory.EvolvePokemon(pokemon.Id);

                    machine.Fire(new PokemonEvolveEvent
                    {
                        Id = pokemon.PokemonId,
                        Exp = evolveResponse.ExperienceAwarded,
                        Result = evolveResponse.Result
                    });

                    await Task.Delay(3000);
                }
            }
        }
开发者ID:Rausu,项目名称:NecroBot,代码行数:35,代码来源:EvolvePokemonTask.cs

示例8: Execute

        public static async Task Execute(Context ctx, StateMachine machine)
        {
            var highestsPokemonCp = await ctx.Inventory.GetHighestsCp(ctx.LogicSettings.AmountOfPokemonToDisplayOnStart);
            List<Tuple<PokemonData, int, double, double>> pokemonPairedWithStatsCP = new List<Tuple<PokemonData, int, double, double>>();

            foreach (var pokemon in highestsPokemonCp)
                pokemonPairedWithStatsCP.Add(Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon)));

            var highestsPokemonPerfect = await ctx.Inventory.GetHighestsPerfect(ctx.LogicSettings.AmountOfPokemonToDisplayOnStart);

            List<Tuple<PokemonData, int, double, double>> pokemonPairedWithStatsIV = new List<Tuple<PokemonData, int, double, double>>();
            foreach (var pokemon in highestsPokemonPerfect)
                pokemonPairedWithStatsIV.Add(Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon)));

            machine.Fire(
                new DisplayHighestsPokemonEvent
                {
                    SortedBy = "Cp",
                    PokemonList = pokemonPairedWithStatsCP
                });

            await Task.Delay(500);

            machine.Fire(
                    new DisplayHighestsPokemonEvent
                    {
                        SortedBy = "Iv",
                        PokemonList = pokemonPairedWithStatsIV
                    });

            await Task.Delay(500);
        }
开发者ID:Rausu,项目名称:NecroBot,代码行数:32,代码来源:DisplayPokemonStatsTask.cs

示例9: Execute

        public IState Execute(Context ctx, StateMachine machine)
        {
            if (ctx.LogicSettings.EvolveAllPokemonAboveIv || ctx.LogicSettings.EvolveAllPokemonWithEnoughCandy)
            {
                EvolvePokemonTask.Execute(ctx, machine);
            }

            if (ctx.LogicSettings.TransferDuplicatePokemon)
            {
                TransferDuplicatePokemonTask.Execute(ctx, machine);
            }

            RecycleItemsTask.Execute(ctx, machine);

            if (ctx.LogicSettings.UseGpxPathing)
            {
                FarmPokestopsGpxTask.Execute(ctx, machine);
            }
            else
            {
                FarmPokestopsTask.Execute(ctx, machine);
            }

            machine.RequestDelay(10000);

            return this;
        }
开发者ID:Citrusbomb,项目名称:NecroBot,代码行数:27,代码来源:FarmState.cs

示例10: Execute

        public async Task<IState> Execute(Context ctx, StateMachine machine)
        {
            if (ctx.LogicSettings.EvolveAllPokemonAboveIv || ctx.LogicSettings.EvolveAllPokemonWithEnoughCandy)
            {
                await EvolvePokemonTask.Execute(ctx, machine);
            }

            if (ctx.LogicSettings.TransferDuplicatePokemon)
            {
                await TransferDuplicatePokemonTask.Execute(ctx, machine);
            }

            if (ctx.LogicSettings.RenameAboveIv)
            {
                await RenamePokemonTask.Execute(ctx, machine);
            }

            await RecycleItemsTask.Execute(ctx, machine);

            if (ctx.LogicSettings.UseEggIncubators)
            {
                await UseIncubatorsTask.Execute(ctx, machine);
            }

            if (ctx.LogicSettings.UseGpxPathing)
            {
                await FarmPokestopsGpxTask.Execute(ctx, machine);
            }
            else
            {
                await FarmPokestopsTask.Execute(ctx, machine);
            }

            return this;
        }
开发者ID:Crowstrum,项目名称:NecroBot,代码行数:35,代码来源:FarmState.cs

示例11: HandleEvent

 public void HandleEvent(TransferPokemonEvent evt, Context ctx)
 {
     Logger.Write(
         ctx.Translations.GetTranslation(TranslationString.EventPokemonTransferred, evt.Id, evt.Cp,
             evt.Perfection.ToString("0.00"), evt.BestCp, evt.BestPerfection.ToString("0.00"), evt.FamilyCandies),
         LogLevel.Transfer);
 }
开发者ID:Crowstrum,项目名称:NecroBot,代码行数:7,代码来源:ConsoleEventListener.cs

示例12: Main

        private static void Main()
        {
            Logger.SetLogger(new ConsoleLogger(LogLevel.Info));

            var machine = new StateMachine();
            var stats = new Statistics();
            stats.DirtyEvent += () => Console.Title = stats.ToString();

            var aggregator = new StatisticsAggregator(stats);
            var listener = new ConsoleEventListener();

            machine.EventListener += listener.Listen;
            machine.EventListener += aggregator.Listen;

            machine.SetFailureState(new LoginState());

            SettingsUtil.Load();

            var context = new Context(new ClientSettings(), new LogicSettings());
            context.Client.Login.GoogleDeviceCodeEvent += LoginWithGoogle;

            machine.AsyncStart(new VersionCheckState(), context);

            Console.ReadLine();
        }
开发者ID:Citrusbomb,项目名称:NecroBot,代码行数:25,代码来源:Program.cs

示例13: Main

        private static void Main(string[] args)
        {
            var subPath = "";
            if (args.Length > 0)
                subPath = Path.DirectorySeparatorChar + args[0];

            Logger.SetLogger(new ConsoleLogger(LogLevel.Info), subPath);

            GlobalSettings settings = GlobalSettings.Load(subPath);

            var machine = new StateMachine();
            var stats = new Statistics();
            stats.DirtyEvent += () => Console.Title = stats.ToString();

            var aggregator = new StatisticsAggregator(stats);
            var listener = new ConsoleEventListener();
            var websocket = new WebSocketInterface(settings.WebSocketPort);

            machine.EventListener += listener.Listen;
            machine.EventListener += aggregator.Listen;
            machine.EventListener += websocket.Listen;

            machine.SetFailureState(new LoginState());

            var context = new Context(new ClientSettings(settings), new LogicSettings(settings));

            context.Navigation.UpdatePositionEvent += (lat, lng) => machine.Fire(new UpdatePositionEvent { Latitude = lat, Longitude = lng });

            context.Client.Login.GoogleDeviceCodeEvent += LoginWithGoogle;

            machine.AsyncStart(new VersionCheckState(), context);

            Console.ReadLine();
        }
开发者ID:yanwuv4yue,项目名称:NecroBot,代码行数:34,代码来源:Program.cs

示例14: Execute

        public async Task<IState> Execute(Context ctx, StateMachine machine)
        {
            if(ctx.LogicSettings.AmountOfPokemonToDisplayOnStart > 0)
                await LogBestPokemonTask.Execute(ctx,machine);

            return new PositionCheckState();
        }
开发者ID:Claen,项目名称:NecroBot,代码行数:7,代码来源:InfoState.cs

示例15: Execute

        public static async Task Execute(Context ctx, StateMachine machine)
        {
            var pokemons = await ctx.Inventory.GetPokemons();

            foreach (var pokemon in pokemons)
            {
                var perfection = Math.Round(PokemonInfo.CalculatePokemonPerfection(pokemon));
                var pokemonName = pokemon.PokemonId.ToString();
                if (pokemonName.Length > 10 - perfection.ToString().Length)
                {
                    pokemonName = pokemonName.Substring(0, 10 - perfection.ToString().Length);
                }
                var newNickname = $"{pokemonName}_{perfection}";

                if (perfection > ctx.LogicSettings.KeepMinIvPercentage && newNickname != pokemon.Nickname && ctx.LogicSettings.RenameAboveIv)
                {
                    var result = await ctx.Client.Inventory.NicknamePokemon(pokemon.Id, newNickname);

                    machine.Fire(new NoticeEvent
                    {
                        Message = $"Pokemon {pokemon.PokemonId} ({pokemon.Id}) renamed from {pokemon.Nickname} to {newNickname}."
                    });
                }
                else if (newNickname == pokemon.Nickname && !ctx.LogicSettings.RenameAboveIv)
                {
                    var result = await ctx.Client.Inventory.NicknamePokemon(pokemon.Id, pokemon.PokemonId.ToString());

                    machine.Fire(new NoticeEvent
                    {
                        Message = $"Pokemon {pokemon.PokemonId} ({pokemon.Id}) renamed from {pokemon.Nickname} to {pokemon.PokemonId}."
                    });
                }
            }

        }
开发者ID:Claen,项目名称:NecroBot,代码行数:35,代码来源:RenamePokemonTask.cs


注:本文中的PoGo.NecroBot.Logic.State.Context类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。