예제 #1
0
파일: Lima.cs 프로젝트: dwhobrey/BabelTools
        internal static string GetLicensesDetails()
        {
            string s = ""; int count = 0;

            foreach (string lic in ValidLicenses)
            {
                InfoStruct info = new InfoStruct();
                byte[]     p    = System.Text.Encoding.UTF8.GetBytes(lic);
                if (InfoLicense(p, ref info) == 0)
                {
                    string monthName = (new DateTime(2000, 1 + info.month, 1)).ToString("MMM");
                    if (count > 0)
                    {
                        s += "\n";
                    }
                    s += lic + ", " + monthName + " " + info.year;
                    for (int k = 0; k < info.numModules; k++)
                    {
                        s += " " + info.moduleIds[k];
                    }
                    ++count;
                }
            }
            return(s);
        }
예제 #2
0
        //TODO: FUTURE: не закочено. Торренты с одним файлом отличаются структурой.
        public TorrentObject(Dictionary <object, object> dic)
        {
            string infoKey  = "info";
            string filesKey = "files";

            this.Info       = new InfoStruct();
            this.Info.Files = new List <FileStruct>();
            foreach (Dictionary <object, object> fileAsDic in (List <object>)((Dictionary <object, object>)dic[infoKey])[filesKey])
            {
                List <object> pathObject = (List <object>)fileAsDic["path"];
                this.Info.Files.Add(
                    new FileStruct()
                {
                    Length   = (long)fileAsDic["length"],
                    Path     = pathObject,
                    FileName = pathObject.Last().ToString(),
                    FullPath = string.Join("\\", pathObject)
                }
                    );
            }

            /*алгоритм:
             * Запрашиваем в корневом словаре ключ 'info'.
             * Получаем dic.
             * Запрашиваем ключ 'files'.
             + Получаем list.
             + Каждый объект list - файл - словарь (содержащий два ключа 'length' и 'path').
             + 'path' каждого файла - это list.
             + В нем каждый элемент это часть пути (директория) без разделителей.
             + Последний элемент - имя файла.
             + 'length' каждого файла - это 'long' - размер файла.
             */
        }
예제 #3
0
        private void traverseFolder(String path)
        {
            DirectoryInfo info = new DirectoryInfo(path);

            foreach (FileInfo file in info.GetFiles())
            {
                String lowwer = file.FullName.ToLower();
                if (lowwer.EndsWith(".png") || lowwer.EndsWith(".jpg"))
                {
                    string     fileName = System.IO.Path.GetFileName(file.FullName);
                    InfoStruct data     = new InfoStruct();
                    data._name = fileName;
                    resInfo.Add(data);
                }
            }
            initListView();
            if (resInfo.Count > 0)
            {
                listView1.Items[0].Selected = true;
                listView1.Items[0].Focused  = true;
                pictureBox.Enabled          = true;
            }
            else
            {
                pictureBox.Enabled = false;
            }
        }
예제 #4
0
        private static void ContactHosts()
        {
            if ((HostList == null) || (HostList.Count <= 0))
            {
                return;
            }
            foreach (HostInfo info in HostList)
            {
                if (string.IsNullOrEmpty(info.URL) || (info.Func == null))
                {
                    continue;
                }

                MelonDebug.Msg($"ContactURL = {info.URL}");

                string Response = null;
                try { Response = Core.webClient.DownloadString(info.URL); }
                catch (Exception ex)
                {
                    if (!(ex is System.Net.WebException) || ((System.Net.WebException)ex).Response == null)
                    {
                        MelonLogger.Error($"Exception while Contacting RemoteAPI Host ({info.URL}): {ex}");
                        continue;
                    }

                    System.Net.WebException    we       = (System.Net.WebException)ex;
                    System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)we.Response;
                    if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        MelonDebug.Msg($"Game Not Found on RemoteAPI Host ({info.URL})");
                        break;
                    }

                    MelonLogger.Error($"WebException ({Enum.GetName(typeof(System.Net.HttpStatusCode), response.StatusCode)}) while Contacting RemoteAPI Host ({info.URL}): {ex}");
                    continue;
                }

                bool is_response_null = string.IsNullOrEmpty(Response);
                MelonDebug.Msg($"Response = {(is_response_null ? "null" : Response) }");
                if (is_response_null)
                {
                    break;
                }

                InfoStruct returnInfo = info.Func(Response);
                if (returnInfo == null)
                {
                    continue;
                }

                if (returnInfo.ForceDumperVersion != null && SemVersion.Parse(returnInfo.ForceDumperVersion) <= SemVersion.Parse("2022.0.2"))
                {
                    returnInfo.ForceDumperVersion = null;
                }

                Info = returnInfo;
                break;
            }
        }
예제 #5
0
                internal static bool Contact(string response_str, InfoStruct returninfo)
                {
                    ResponseStruct responseobj = MelonUtils.ParseJSONStringtoStruct <ResponseStruct>(response_str);

                    if (responseobj == null)
                    {
                        return(false);
                    }

                    //returninfo.ForceDumperVersion = responseobj.forceDumperVersion;
                    returninfo.ForceUnhollowerVersion = responseobj.forceUnhollowerVersion;
                    returninfo.ObfuscationRegex       = responseobj.obfuscationRegex;
                    returninfo.MappingURL             = responseobj.mappingURL;
                    returninfo.MappingFileSHA512      = responseobj.mappingFileSHA512;

                    return(true);
                }
예제 #6
0
        private void pictureBox_Click(object sender, EventArgs e)
        {
            int        index = listView1.FocusedItem.Index;
            InfoStruct d     = resInfo[index];

            if (curMode == MODE.MODE_AVATAR)
            {
                d.setAvatarCood(cursorPosition);
                this.listView1.FocusedItem.SubItems[1].Text = d.formatCoordinate();
            }
            else
            {
                d.setSquadCood(cursorPosition);
                this.listView1.FocusedItem.SubItems[2].Text = d.formatCoordinate(true);
            }
            resInfo[index] = d;
        }
예제 #7
0
                internal static InfoStruct Contact(string response_str)
                {
                    ResponseStruct responseobj = MelonUtils.ParseJSONStringtoStruct <ResponseStruct>(response_str);

                    if (responseobj == null)
                    {
                        return(null);
                    }

                    InfoStruct returninfo = new InfoStruct();

                    returninfo.ForceDumperVersion     = responseobj.forceCpp2IlVersion;
                    returninfo.ForceUnhollowerVersion = responseobj.forceUnhollowerVersion;
                    returninfo.ObfuscationRegex       = responseobj.obfuscationRegex;
                    returninfo.MappingURL             = responseobj.mappingUrl;
                    returninfo.MappingFileSHA512      = responseobj.mappingFileSHA512;
                    return(returninfo);
                }
예제 #8
0
        private static void Test1()
        {
            InfoStruct Info = new InfoStruct();

            Info.HardwareNum     = "1.0.0".GetFixLengthChar(16);
            Info.HardwareVersion = "ABC1234567".GetFixLengthChar(16);
            Info.DeviceName      = "Device Name1".GetFixLengthChar(32);
            Info.ModuleID        = 0x10000001;
            Info.SlotNum         = 1;
            Info.SoftwareDate    = "2018/1/22".GetFixLengthChar(16);
            Info.SoftwareVersion = "V1.0.0".GetFixLengthChar(16);

            var b = StructHelper.StuctToByte(Info);

            Console.WriteLine("Struct length:" + b.Length);
            Console.WriteLine("Hex:" + ByteToHexString(b, ' '));
            var s = StructHelper.ByteToStuct <InfoStruct>(b);

            Console.WriteLine("Name:" + s.DeviceName.GetString());
            Console.WriteLine("HardwareVersion:" + s.HardwareVersion.GetString());
        }
예제 #9
0
        private void ShowCallout(string title, string content, MapPoint location)
        {
            foreach (var item in MapObj.toolBar.Tools.Children.OfType <ToolItem>())
            {
                if (item.Active == true)
                {
                    return;
                }
            }

            IntPtr windowHandle = Process.GetCurrentProcess().MainWindowHandle;

            InfoStruct info_struct = new InfoStruct(1);

            info_struct.ID = string.Copy(title).ToCharArray();
            Array.Resize(ref info_struct.ID, 64);
            IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(info_struct));

            Marshal.StructureToPtr(info_struct, pnt, false);
            if (windowHandle == IntPtr.Zero || pnt == IntPtr.Zero)
            {
                return;
            }
            SendMessage((int)windowHandle, WM_USER + 58, 8, pnt);
            return;

            var c = new Callout
            {
                CalloutTitle   = title,
                CalloutContent = content
            };
            OverlayItemsControl f = new OverlayItemsControl();

            f.Items.Add(c);

            MapObj.MapView.Overlays.Items.Add(c);
            ViewBase.SetViewOverlayAnchor(c, location);
        }
예제 #10
0
        public override bool Effect(TriggerEvent triggerEvent, Room room, Player player, ref object data, Player target, TriggerStruct trigger_info)
        {
            if (room.SkipGameRule)
            {
                room.SkipGameRule = false;
                return(false);
            }

            // Handle global events
            if (player == null)
            {
                if (triggerEvent == TriggerEvent.GameStart)
                {
                    OnGameStart(room, ref data);
                }

                if (triggerEvent != TriggerEvent.BeforeCardsMove && triggerEvent != TriggerEvent.CardsMoveOneTime)
                {
                    return(false);
                }
            }

            switch (triggerEvent)
            {
            case TriggerEvent.TurnStart:
                OnTurnStart(room, player, ref data);
                break;

            case TriggerEvent.EventPhaseProceeding:
                OnPhaseProceed(room, player, ref data);
                break;

            case TriggerEvent.EventPhaseEnd:
                OnPhaseEnd(room, player, ref data);
                break;

            case TriggerEvent.EventPhaseChanging:
                OnPhaseChanging(room, player, ref data);
                break;

            case TriggerEvent.PreCardUsed:
                OnPreCardUsed(room, player, ref data);
                break;

            case TriggerEvent.CardUsed:
                OnCardUsed(room, player, ref data);
                break;

            case TriggerEvent.CardFinished:
                CardUseStruct use = (CardUseStruct)data;
                //room.ClearCardFlag(use.Card);
                use.Card.ClearFlags();                      //RoomCard会在其移动后自动清除flag
                room.RemoveSubCards(use.Card);

                //以askforcard形式使用的卡牌没有onUse的trigger,但有finish
                if (use.Reason != CardUseStruct.CardUseReason.CARD_USE_REASON_RESPONSE)
                {
                    room.RemoveUseOnFinish();
                }

                if (Engine.GetFunctionCard(use.Card.Name).IsNDTrick())
                {
                    room.RemoveHegNullification(use.Card);
                }

                foreach (Client p in room.Clients)
                {
                    room.DoNotify(p, CommandType.S_COMMAND_NULLIFICATION_ASKED, new List <string> {
                        "."
                    });
                }

                break;

            case TriggerEvent.EventAcquireSkill:
            case TriggerEvent.EventLoseSkill:
                InfoStruct info       = (InfoStruct)data;
                string     skill_name = info.Info;
                Skill      skill      = Engine.GetSkill(skill_name);
                bool       refilter   = skill is FilterSkill;

                if (!refilter && skill is TriggerSkill)
                {
                    TriggerSkill trigger = (TriggerSkill)skill;
                    ViewAsSkill  vsskill = trigger.ViewAsSkill;
                    if (vsskill != null && (vsskill is FilterSkill))
                    {
                        refilter = true;
                    }
                }

                if (refilter)
                {
                    room.FilterCards(player, player.GetCards("he"), triggerEvent == TriggerEvent.EventLoseSkill);
                }

                CheckBigKingdoms(room);
                break;

            case TriggerEvent.PostHpReduced:
                if (player.Hp > 0 || player.HasFlag("Global_Dying"))     // newest GameRule -- a player cannot enter dying when it is dying.
                {
                    break;
                }
                if (data is DamageStruct damage)
                {
                    room.EnterDying(player, damage);
                }
                else
                {
                    room.EnterDying(player, new DamageStruct());
                }

                break;

            case TriggerEvent.AskForPeaches:
                OnAskforPeach(room, player, ref data);
                break;

            case TriggerEvent.AskForPeachesDone:
            {
                if (player.Hp <= 0 && player.Alive)
                {
                    DyingStruct dying = (DyingStruct)data;
                    room.KillPlayer(player, dying.Damage);
                }

                break;
            }

            case TriggerEvent.ConfirmDamage:
            {
                break;
            }

            case TriggerEvent.DamageDone:
            {
                damage = (DamageStruct)data;
                if (damage.From != null && !damage.From.Alive)
                {
                    damage.From = null;
                }
                room.SendDamageLog(damage);

                if (damage.Nature != DamageNature.Normal && player.Chained && !damage.Chain && !damage.ChainStarter)
                {
                    damage.ChainStarter = true;
                }

                data = damage;

                bool reduce = !room.ApplyDamage(player, damage);

                if (reduce)
                {
                    room.RoomThread.Trigger(TriggerEvent.PostHpReduced, room, player, ref data);
                }

                break;
            }

            case TriggerEvent.DamageComplete:
            {
                damage = (DamageStruct)data;
                if (damage.Prevented)
                {
                    return(false);
                }

                /*
                 * if (damage.Nature != DamageNature.Normal && player.Chained)
                 * {
                 *  room.ChainedRemoveOnDamageDone(player, damage);
                 * }
                 */
                if (damage.Nature != DamageNature.Normal && !damage.Chain && damage.ChainStarter)              // iron chain effect
                {
                    List <Player> chained_players = new List <Player>();
                    if (!room.Current.Alive)
                    {
                        chained_players = room.GetOtherPlayers(room.Current);
                    }
                    else
                    {
                        chained_players = room.GetAllPlayers();
                    }
                    chained_players.Remove(damage.To);
                    foreach (Player chained_player in chained_players)
                    {
                        if (chained_player.Chained)
                        {
                            Thread.Sleep(500);
                            LogMessage log = new LogMessage
                            {
                                Type = "#IronChainDamage",
                                From = chained_player.Name
                            };
                            room.SendLog(log);

                            DamageStruct chain_damage = damage;
                            chain_damage.To             = chained_player;
                            chain_damage.Chain          = true;
                            chain_damage.Transfer       = false;
                            chain_damage.TransferReason = null;

                            room.Damage(chain_damage);
                        }
                    }
                }

                foreach (Player p in room.GetAllPlayers())
                {
                    if (p.HasFlag("Global_DFDebut"))
                    {
                        p.SetFlags("-Global_DFDebut");
                        room.RoomThread.Trigger(TriggerEvent.DFDebut, room, p);
                    }
                }
                break;
            }

            case TriggerEvent.CardEffect:
            {
                if (data is CardEffectStruct effect)
                {
                    if (Engine.GetFunctionCard(effect.Card.Name) is DelayedTrick)
                    {
                        CardMoveReason reason = new CardMoveReason(MoveReason.S_REASON_DELAYTRICK_EFFECT,
                                                                   effect.To.Name, effect.Card.Skill, effect.Card.Name)
                        {
                            Card = effect.Card
                        };

                        room.MoveCardTo(effect.Card, effect.To, Place.PlaceTable, reason, true);
                        Thread.Sleep(500);
                    }
                }
                break;
            }

            case TriggerEvent.CardEffected:
            {
                if (data is CardEffectStruct effect)
                {
                    FunctionCard fcard = Engine.GetFunctionCard(effect.Card.Name);
                    if (!(fcard is Slash) && effect.BasicEffect.Nullified)
                    {
                        LogMessage log = new LogMessage
                        {
                            Type = "#Cardnullified",
                            From = effect.To.Name,
                            Arg  = effect.Card.Name
                        };
                        room.SendLog(log);

                        return(true);
                    }
                    else if (fcard.TypeID == CardType.TypeTrick && room.IsCanceled(effect))
                    {
                        effect.To.SetFlags("Global_NonSkillnullify");
                        return(true);
                    }
                    object _effect = effect;
                    room.RoomThread.Trigger(TriggerEvent.CardEffectConfirmed, room, effect.To, ref _effect);

                    if (effect.To.Alive || fcard is Slash)
                    {
                        fcard.OnEffect(room, effect);
                    }
                }

                break;
            }

            case TriggerEvent.SlashEffected:
            {
                SlashEffectStruct effect = (SlashEffectStruct)data;
                if (effect.Nullified)
                {
                    LogMessage log = new LogMessage
                    {
                        Type = "#Cardnullified",
                        From = effect.To.Name,
                        Arg  = effect.Slash.Name
                    };
                    room.SendLog(log);

                    return(true);
                }

                if (effect.Jink_num > 0)
                {
                    room.RoomThread.Trigger(TriggerEvent.SlashProceed, room, effect.From, ref data);
                }
                else
                {
                    room.SlashResult(effect, null);
                }
                break;
            }

            case TriggerEvent.SlashProceed:
            {
                SlashEffectStruct effect  = (SlashEffectStruct)data;
                string            slasher = effect.From.Name;
                if (!effect.To.Alive)
                {
                    break;
                }
                if (effect.Jink_num == 1)
                {
                    CardResponseStruct resp = room.AskForCard(effect.To, Slash.ClassName, Jink.ClassName, string.Format("slash-jink:{0}::{1}", slasher, effect.Slash.Name),
                                                              data, HandlingMethod.MethodUse, null, effect.From, false, false);
                    room.SlashResult(effect, room.IsJinkEffected(effect.To, resp) ? resp.Card : null);
                }
                else
                {
                    WrappedCard jink = new WrappedCard(DummyCard.ClassName);
                    for (int i = effect.Jink_num; i > 0; i--)
                    {
                        string             prompt = string.Format("@multi-jink{0}:{1}::{2}:{3}", i == effect.Jink_num ? "-start" : string.Empty, slasher, i, effect.Slash.Name);
                        CardResponseStruct resp   = room.AskForCard(effect.To, Slash.ClassName, Jink.ClassName, prompt, data, HandlingMethod.MethodUse, null, effect.From, false, false);

                        if (!room.IsJinkEffected(effect.To, resp))
                        {
                            //delete jink;
                            room.SlashResult(effect, null);
                            return(false);
                        }
                        else
                        {
                            jink.AddSubCard(resp.Card);
                        }
                    }
                    room.SlashResult(effect, jink);
                }

                break;
            }

            case TriggerEvent.SlashHit:
            {
                SlashEffectStruct effect = (SlashEffectStruct)data;
                if (effect.Drank > 0)
                {
                    LogMessage log = new LogMessage
                    {
                        Type = "#AnalepticBuff",
                        From = effect.From.Name,
                        To   = new List <string> {
                            effect.To.Name
                        },
                        Arg  = (1 + effect.ExDamage).ToString(),
                        Arg2 = (1 + effect.ExDamage + effect.Drank).ToString()
                    };

                    room.SendLog(log);
                }
                DamageStruct slash_damage = new DamageStruct(effect.Slash, effect.From, effect.To, 1 + effect.ExDamage + effect.Drank, effect.Nature)
                {
                    Drank = effect.Drank > 0
                };
                room.Damage(slash_damage);
                break;
            }

            case TriggerEvent.BeforeGameOverJudge:
            {
                if (!player.General1Showed)
                {
                    room.ShowGeneral(player, true, false, false);
                }
                if (!player.General2Showed)
                {
                    room.ShowGeneral(player, false, false, false);
                }
                break;
            }

            case TriggerEvent.GameOverJudge:
            {
                string winner = GetWinner(room);
                if (!string.IsNullOrEmpty(winner))
                {
                    room.GameOver(winner);
                    return(true);
                }

                break;
            }

            case TriggerEvent.BuryVictim:
            {
                OnBuryVictim(room, player, ref data);
                break;
            }

            case TriggerEvent.StartJudge:
            {
                int         card_id      = room.GetNCards(1)[0];
                JudgeStruct judge_struct = (JudgeStruct)data;
                judge_struct.Card = room.GetCard(card_id);

                LogMessage log = new LogMessage
                {
                    Type     = "$InitialJudge",
                    From     = judge_struct.Who.Name,
                    Card_str = card_id.ToString()
                };
                room.SendLog(log);

                room.MoveCardTo(judge_struct.Card, null, judge_struct.Who, Place.PlaceJudge,
                                new CardMoveReason(MoveReason.S_REASON_JUDGE, judge_struct.Who.Name, null, null, judge_struct.Reason), true);

                Thread.Sleep(500);
                bool effected = judge_struct.Good == Engine.MatchExpPattern(room, judge_struct.Pattern, judge_struct.Who, judge_struct.Card);
                judge_struct.UpdateResult(effected);
                data = judge_struct;
                break;
            }

            case TriggerEvent.JudgeResult:
            {
                JudgeStruct judge = (JudgeStruct)data;
                LogMessage  log   = new LogMessage
                {
                    Type     = "$JudgeResult",
                    From     = player.Name,
                    Card_str = RoomLogic.CardToString(room, judge.Card)
                };
                room.SendLog(log);

                //Thread.Sleep(500);
                if (judge.PlayAnimation)
                {
                    room.SendJudgeResult(judge);
                    Thread.Sleep(800);
                }

                break;
            }

            case TriggerEvent.FinishJudge:
            {
                JudgeStruct judge = (JudgeStruct)data;

                if (room.GetCardPlace(judge.Card.Id) == Place.PlaceJudge)
                {
                    CardMoveReason reason = new CardMoveReason(MoveReason.S_REASON_JUDGEDONE, judge.Who.Name, null, judge.Reason);
                    room.MoveCardTo(judge.Card, judge.Who, null, Place.DiscardPile, reason, true);
                }

                break;
            }

            case TriggerEvent.ChoiceMade:
            {
                foreach (Player p in room.GetAlivePlayers())
                {
                    List <string> flags = new List <string>(p.Flags);
                    foreach (string flag in flags)
                    {
                        if (flag.StartsWith("Global_") && flag.EndsWith("Failed"))
                        {
                            p.SetFlags("-" + flag);
                        }
                    }
                }
                break;
            }

            case TriggerEvent.GeneralShown:
            {
                string winner = GetWinner(room);
                if (!string.IsNullOrEmpty(winner))
                {
                    room.GameOver(winner);         // if all hasShownGenreal, and they are all friend, game over.
                    return(true);
                }
                if (!room.ContainsTag("TheFirstToShowRewarded"))
                {
                    room.SetTag("TheFirstToShowRewarded", true);
                    room.SetPlayerMark(player, "@pioneer", 1);
                    room.AttachSkillToPlayer(player, "pioneer");
                }
                if (player.Alive && player.HasShownAllGenerals())
                {
                    if (player.GetMark("CompanionEffect") > 0)
                    {
                        room.RemovePlayerMark(player, "CompanionEffect");
                        room.DoSuperLightbox(player, string.Empty, "companion");
                        room.SetPlayerMark(player, "@companion", 1);
                        room.AttachSkillToPlayer(player, "companion");
                    }
                    if (player.GetMark("HalfMaxHpLeft") > 0)
                    {
                        room.RemovePlayerMark(player, "HalfMaxHpLeft");
                        room.SetPlayerMark(player, "@megatama", 1);
                        room.AttachSkillToPlayer(player, "megatama");
                    }
                }
                CheckBigKingdoms(room);
                break;
            }

            case TriggerEvent.BeforeCardsMove:
            {
                if (data is CardsMoveOneTimeStruct move)
                {
                    bool should_find_io = false;
                    if (move.To_place == Place.DiscardPile)
                    {
                        if (move.Reason.Reason != MoveReason.S_REASON_USE)
                        {
                            should_find_io = true;         // not use
                        }
                        else if (move.Card_ids.Count > 1)
                        {
                            should_find_io = true;         // use card isn't IO
                        }
                        else
                        {
                            WrappedCard card = room.GetCard(move.Card_ids[0]);
                            if (card.Name == Edict.ClassName && !card.HasFlag("edict_normal_use"))
                            {
                                should_find_io = true;         // use card isn't IO
                            }
                        }
                    }
                    if (should_find_io)
                    {
                        foreach (int id in move.Card_ids)
                        {
                            WrappedCard card = room.GetCard(id);
                            if (card.Name == Edict.ClassName)
                            {
                                room.MoveCardTo(card, null, Place.PlaceTable, true);
                                room.AddToPile(room.Players[0], "#edict", card, false);
                                LogMessage log = new LogMessage
                                {
                                    Type = "#RemoveEdict",
                                    Arg  = Edict.ClassName
                                };
                                room.SendLog(log);
                                room.SetTag("EdictInvoke", true);
                                room.SetTag("EdictCard", card);
                                int i = move.Card_ids.IndexOf(id);
                                move.From_places.RemoveAt(i);
                                move.Open.RemoveAt(i);
                                move.From_pile_names.RemoveAt(i);
                                move.Card_ids.Remove(id);
                                data = move;
                                break;
                            }
                        }
                    }
                }
                break;
            }

            case TriggerEvent.Death:
            {
                OnDeath(room, player, ref data);
                break;
            }

            case TriggerEvent.CardsMoveOneTime:
            {
                if (data is CardsMoveOneTimeStruct move)
                {
                    if (move.From != null && move.From_places.Contains(Place.PlaceEquip))
                    {
                        foreach (int id in move.Card_ids)
                        {
                            WrappedCard card = room.GetCard(id);
                            if (card.Name == JadeSeal.ClassName)
                            {
                                CheckBigKingdoms(room);
                                break;
                            }
                        }
                    }

                    if (move.To != null && move.To_place == Place.PlaceEquip)
                    {
                        foreach (int id in move.Card_ids)
                        {
                            WrappedCard card = room.GetCard(id);
                            if (card.Name == JadeSeal.ClassName)
                            {
                                CheckBigKingdoms(room);
                                break;
                            }
                        }
                    }
                }

                break;
            }

            default:
                break;
            }

            return(false);
        }
예제 #11
0
파일: Lima.cs 프로젝트: dwhobrey/BabelTools
 private static extern int InfoLicense(byte[] p, ref InfoStruct q);
예제 #12
0
        public static async Task <List <InfoStruct> > GetResult(string html)
        {
            return(await Task.Run(() =>
            {
                try
                {
                    var info = new InfoStruct();
                    var doc = new HtmlDocument();
                    doc.LoadHtml(html);

                    try
                    {
                        var instrElem =
                            doc.DocumentNode.Descendants("div")
                            .First(
                                x => x.Attributes.Contains("class") && x.Attributes["class"].Value == "instruction");

                        if (instrElem != null)
                        {
                            var res = instrElem.InnerText;
                            var zas = Regex.Match(res, @"(?<=Спосіб застосування та дози\.\r\n).+(?=\r\n)").Value;
                            info.Zastosuvannya = zas;

                            var pokaz = Regex.Match(res, @"(?<=[(Показання)(Показання для застосування)]\.\r\n).+(?=\r\n)").Value;
                            info.Pokazannya = pokaz;

                            var protu = Regex.Match(res, @"(?<=Протипоказання\.\r\n).+(?=\r\n)").Value;
                            info.Protupokazannya = protu;

                            var farm = Regex.Match(res, @"(?<=Фармакотерапевтична група\.).+(?=\r\n)").Value;
                            info.FarmVlast = farm;

                            var zber = Regex.Match(res, @"(?<=Умови зберігання\.).+(?=\r\n)").Value;
                            info.Zberigannya = zber;
                        }
                    }
                    catch (Exception)
                    {
                        try
                        {
                            var pokaz =
                                doc.DocumentNode.Descendants("span")
                                .First(x => !string.IsNullOrEmpty(x.InnerText) && x.InnerText.Contains("Показання"));

                            if (pokaz != null)
                            {
                                info.Pokazannya = pokaz.ParentNode.NextSibling.InnerText;
                            }
                        }
                        catch (Exception)
                        {
                        }

                        try
                        {
                            var farm =
                                doc.DocumentNode.Descendants("span")
                                .First(
                                    x =>
                                    !string.IsNullOrEmpty(x.InnerText) &&
                                    x.InnerText.Contains("Фармакотерапевтична група"));

                            if (farm != null)
                            {
                                info.FarmVlast = farm.ParentNode.NextSibling.InnerText;
                            }
                        }
                        catch (Exception)
                        {
                        }

                        info.Zberigannya = "Зберігати при температурі не вище 25 °С у недоступному для дітей місці.";
                    }

                    return new List <InfoStruct> {
                        info
                    };
                }
                catch (Exception)
                {
                    return new List <InfoStruct>();
                }
            }));
        }