Ejemplo n.º 1
0
        public void StartEnterCode(PokeTradeBot b)
        {
            if (!CreateAssets)
            {
                return;
            }

            try
            {
                var file = GetBlockFileName(b);
                if (CopyImageFile && File.Exists(TradeBlockFile))
                {
                    File.Copy(TradeBlockFile, file);
                }
                else
                {
                    File.WriteAllBytes(file, BlackPixel);
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                LogUtil.LogError(e.Message, nameof(StreamSettings));
            }
        }
Ejemplo n.º 2
0
        private void GenerateBotConnection(PokeTradeBot b, PokeTradeDetail <PK8> detail)
        {
            var file = b.Connection.IP;
            var name = string.Format(TrainerTradeStart, detail.ID, detail.Trainer.TrainerName, (Species)detail.TradeData.Species);

            File.WriteAllText($"{file}.txt", name);
        }
Ejemplo n.º 3
0
        private void GenerateBotConnection(PokeTradeBot b, PokeTradeDetail <PK8> detail)
        {
            var file = b.Config.ConnectionType == ConnectionType.WiFi ? b.Connection.IP : "USB" + b.Connection.UsbPortIndex;
            var name = string.Format(TrainerTradeStart, detail.ID, detail.Trainer.TrainerName, (Species)detail.TradeData.Species);

            File.WriteAllText($"{file}.txt", name);
        }
Ejemplo n.º 4
0
        public void StartTrade(PokeTradeBot b, PokeTradeDetail <PK8> detail, PokeTradeHub <PK8> hub)
        {
            if (!CreateAssets)
            {
                return;
            }

            try
            {
                if (CreateTradeStart)
                {
                    GenerateBotConnection(b, detail);
                }
                if (CreateWaitedTime)
                {
                    GenerateWaitedTime(detail.Time);
                }
                if (CreateEstimatedTime)
                {
                    GenerateEstimatedTime(hub);
                }
                if (CreateUsersInQueue)
                {
                    GenerateUsersInQueue(hub.Queues.Info.Count);
                }
                if (CreateOnDeck)
                {
                    GenerateOnDeck(hub);
                }
                if (CreateOnDeck2)
                {
                    GenerateOnDeck2(hub);
                }
                if (CreateUserList)
                {
                    GenerateUserList(hub);
                }
                if (CreateCompletedTrades)
                {
                    GenerateCompletedTrades(hub.Config.Counts);
                }
                if (CreateTradeStartSprite)
                {
                    GenerateBotSprite(b, detail);
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                LogUtil.LogError(e.Message, nameof(StreamSettings));
            }
        }
Ejemplo n.º 5
0
        private static void GenerateBotSprite(PokeTradeBot b, PokeTradeDetail <PK8> detail)
        {
            var func = CreateSpriteFile;

            if (func == null)
            {
                return;
            }
            var file = b.Connection.IP;
            var pk   = detail.TradeData;

            func.Invoke(pk, $"sprite_{file}.png");
        }
Ejemplo n.º 6
0
        private static void GenerateBotSprite(PokeTradeBot b, PokeTradeDetail <PK8> detail)
        {
            var func = CreateSpriteFile;

            if (func == null)
            {
                return;
            }
            var file = b.Config.ConnectionType == ConnectionType.WiFi ? b.Connection.IP : "USB" + b.Connection.UsbPortIndex;
            var pk   = detail.TradeData;

            func.Invoke(pk, $"sprite_{file}.png");
        }
Ejemplo n.º 7
0
        public void IdleAssets(PokeTradeBot b)
        {
            if (!CreateAssets)
            {
                return;
            }

            try
            {
                var files = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*", SearchOption.TopDirectoryOnly);
                foreach (var file in files)
                {
                    if (file.Contains(b.Config.ConnectionType == ConnectionType.WiFi ? b.Connection.IP : "USB" + b.Connection.UsbPortIndex))
                    {
                        File.Delete(file);
                    }
                }

                if (CreateWaitedTime)
                {
                    File.WriteAllText("waited.txt", "00:00:00");
                }
                if (CreateEstimatedTime)
                {
                    File.WriteAllText("estimatedTime.txt", "Estimated time: 0 minutes");
                    File.WriteAllText("estimatedTimestamp.txt", "");
                }
                if (CreateOnDeck)
                {
                    File.WriteAllText("ondeck.txt", "Waiting...");
                }
                if (CreateOnDeck2)
                {
                    File.WriteAllText("ondeck2.txt", "Queue is empty!");
                }
                if (CreateUserList)
                {
                    File.WriteAllText("users.txt", "None");
                }
                if (CreateUsersInQueue)
                {
                    File.WriteAllText("queuecount.txt", "Users in Queue: 0");
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                LogUtil.LogError(e.Message, nameof(StreamSettings));
            }
        }
Ejemplo n.º 8
0
        public void IdleAssets(PokeTradeBot b)
        {
            if (!CreateAssets)
            {
                return;
            }

            try
            {
                var files = Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*", SearchOption.TopDirectoryOnly);
                foreach (var file in files)
                {
                    if (file.Contains(b.Connection.IP))
                    {
                        File.Delete(file);
                    }
                }

                if (CreateWaitedTime)
                {
                    File.WriteAllText("waited.txt", "00:00:00");
                }
                if (CreateEstimatedTime)
                {
                    File.WriteAllText("estimatedTime.txt", "Estimated time: 0 minutes");
                    File.WriteAllText("estimatedTimestamp.txt", "");
                }
                if (CreateOnDeck)
                {
                    File.WriteAllText("ondeck.txt", "Waiting...");
                }
                if (CreateOnDeck2)
                {
                    File.WriteAllText("ondeck2.txt", "Queue is empty!");
                }
                if (CreateUserList)
                {
                    File.WriteAllText("users.txt", "None");
                }
                if (CreateUsersInQueue)
                {
                    File.WriteAllText("queuecount.txt", "Users in Queue: 0");
                }
            }
            catch (Exception e)
            {
                LogUtil.LogError(e.Message, nameof(StreamSettings));
            }
        }
Ejemplo n.º 9
0
 public void EndEnterCode(PokeTradeBot b)
 {
     try
     {
         var file = GetBlockFileName(b);
         if (File.Exists(file))
         {
             File.Delete(file);
         }
     }
     catch (Exception e)
     {
         LogUtil.LogError(e.Message, nameof(StreamSettings));
     }
 }
Ejemplo n.º 10
0
 public void StartTrade(PokeTradeBot b, PokeTradeDetail <PK8> detail, PokeTradeHub <PK8> hub)
 {
     try
     {
         if (CreateTradeStart)
         {
             GenerateBotConnection(b, detail);
         }
         if (CreateWaitedTime)
         {
             GenerateWaitedTime(detail.Time);
         }
         if (CreateEstimatedTime)
         {
             GenerateEstimatedTime(hub);
         }
         if (CreateUsersInQueue)
         {
             GenerateUsersInQueue(hub.Queues.Info.Count);
         }
         if (CreateOnDeck)
         {
             GenerateOnDeck(hub);
         }
         if (CreateOnDeck2)
         {
             GenerateOnDeck2(hub);
         }
         if (CreateUserList)
         {
             GenerateUserList(hub);
         }
         if (CreateCompletedTrades)
         {
             GenerateCompletedTrades(hub.Config.Counts);
         }
         if (CreateTradeStartSprite)
         {
             GenerateBotSprite(b, detail);
         }
     }
     catch (Exception e)
     {
         LogUtil.LogError(e.Message, nameof(StreamSettings));
     }
 }
Ejemplo n.º 11
0
        public void EndEnterCode(PokeTradeBot b)
        {
            try
            {
                var file = GetBlockFileName(b);
                if (File.Exists(file))
                {
                    File.Delete(file);
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                LogUtil.LogError(e.Message, nameof(StreamSettings));
            }
        }
Ejemplo n.º 12
0
 public void StartEnterCode(PokeTradeBot b)
 {
     try
     {
         var file = GetBlockFileName(b);
         if (CopyImageFile && File.Exists(TradeBlockFile))
         {
             File.Copy(TradeBlockFile, file);
         }
         else
         {
             File.WriteAllBytes(file, BlackPixel);
         }
     }
     catch (Exception e)
     {
         LogUtil.LogError(e.Message, nameof(StreamSettings));
     }
 }
Ejemplo n.º 13
0
        public void CalculateAndNotify(T pkm, PokeTradeDetail <T> detail, SeedCheckSettings settings, PokeTradeBot bot)
        {
            const string msg = "Seed searching implementation not found. " +
                               "Please let the person hosting the bot know that they need to provide the required Z3 files.";

            detail.SendNotification(bot, msg);
        }
Ejemplo n.º 14
0
        public void CalculateAndNotify(T pkm, PokeTradeDetail <T> detail, SeedCheckSettings settings, PokeTradeBot bot)
        {
            var ec        = pkm.EncryptionConstant;
            var pid       = pkm.PID;
            var IVs       = pkm.IVs.Length == 0 ? GetBlankIVTemplate() : PKX.ReorderSpeedLast((int[])pkm.IVs.Clone());
            var name      = SpeciesName.GetSpeciesName(pkm.Species, 2);
            var ot        = pkm.OT_Name;
            var abilityNo = pkm.AbilityNumber;
            var ability   = pkm.Ability;
            var gender    = pkm.GetSaneGender();
            var nature    = pkm.Nature;

            if (settings.ShowAllZ3Results)
            {
                var matches = Z3Search.GetAllSeeds(ec, pid, IVs, name, ot, gender, abilityNo, ability, nature);
                foreach (var match in matches)
                {
                    var lump = new PokeTradeSummary("Calculated Seed:", match);
                    detail.SendNotification(bot, lump);
                }
            }
            else
            {
                var match = Z3Search.GetFirstSeed(ec, pid, IVs, name, ot, gender, abilityNo, ability, nature);
                var lump  = new PokeTradeSummary("Calculated Seed:", match);
                detail.SendNotification(bot, lump);
            }
        }
Ejemplo n.º 15
0
 private string GetBlockFileName(PokeTradeBot b) => string.Format(TradeBlockFormat, b.Connection.IP);
Ejemplo n.º 16
0
        public void CalculateAndNotify(T pkm, PokeTradeDetail <T> detail, SeedCheckSettings settings, PokeTradeBot bot)
        {
            var ec  = pkm.EncryptionConstant;
            var pid = pkm.PID;
            var IVs = pkm.IVs.Length == 0 ? GetBlankIVTemplate() : PKX.ReorderSpeedLast((int[])pkm.IVs.Clone());

            if (settings.ShowAllZ3Results)
            {
                var matches = Z3Search.GetAllSeeds(ec, pid, IVs);
                foreach (var match in matches)
                {
                    var lump = new PokeTradeSummary("Calculated Seed:", match);
                    detail.SendNotification(bot, lump);
                }
            }
            else
            {
                var match = Z3Search.GetFirstSeed(ec, pid, IVs);
                var lump  = new PokeTradeSummary("Calculated Seed:", match);
                detail.SendNotification(bot, lump);
            }
        }
Ejemplo n.º 17
0
 private string GetBlockFileName(PokeTradeBot b) => string.Format(TradeBlockFormat, b.Config.ConnectionType == ConnectionType.WiFi ? b.Connection.IP : "USB" + b.Connection.UsbPortIndex);