コード例 #1
0
        private void ReadDeck(string deck)
        {
            var lines = File.ReadAllLines(deck);

            foreach (string nonTrimmerLine in lines)
            {
                string line = nonTrimmerLine.Trim();
                if (line.Equals(string.Empty))
                {
                    continue;
                }

                if (line.StartsWith("#"))
                {
                    if (line.Contains("main"))
                    {
                        DeckList.Items.Add("--Main--");
                    }
                    if (line.Contains("extra"))
                    {
                        DeckList.Items.Add("--Extra--");
                    }
                    continue;
                }
                if (line.StartsWith("!"))
                {
                    DeckList.Items.Add("--Side--");
                    continue;
                }

                CardInfos card = LauncherHelper.CardManager.FromId(Int32.Parse(line));
                if (card == null)
                {
                    continue;
                }
                if (CardList.ContainsKey(card.Name))
                {
                    CardList[card.Name].Amount++;
                }
                else
                {
                    CardList.Add(card.Name, (CardInfos)card.Clone());
                    DeckList.Items.Add(card.Name);
                    CardList[card.Name].Amount++;
                }
            }
        }
コード例 #2
0
        public void ReadReplay(string fileName)
        {
            try
            {
                YGOPro_Launcher.ReplayReader.YgoReplay replay = new YGOPro_Launcher.ReplayReader.YgoReplay();
                if (!replay.FromFile(fileName))
                {
                    ReplayInfo.Text = "Error opening replay.";
                    return;
                }

                string hostname   = ExtractName(replay.ReadString(40));
                string clientname = ExtractName(replay.ReadString(40));

                string player3 = "";
                string player4 = "";
                if (replay.Tag)
                {
                    player3 = ExtractName(replay.ReadString(40));
                    player4 = ExtractName(replay.ReadString(40));
                }

                int startlp   = 0;
                int starthand = 0;
                int drawcount = 0;
                if (!replay.Tag)
                {
                    startlp   = replay.DataReader.ReadInt32();
                    starthand = replay.DataReader.ReadInt32();
                    drawcount = replay.DataReader.ReadInt32();
                }

                int opt = replay.DataReader.ReadInt32();
                if (replay.Tag)
                {
                    VSText.Text = hostname + ", " + clientname + " vs " + player3 + ", " + player4;
                }
                else
                {
                    VSText.Text = hostname + " vs " + clientname;
                }

                ReplayInfo.Text += Environment.NewLine;
                ReplayInfo.Text  = "Replay Type: " + (replay.Tag ? "Tag" : "Single");
                if (!replay.Tag)
                {
                    ReplayInfo.Text += Environment.NewLine;
                    ReplayInfo.Text += "StartLP: " + startlp;
                    ReplayInfo.Text += Environment.NewLine;
                    ReplayInfo.Text += "StartHand: " + starthand;
                    ReplayInfo.Text += Environment.NewLine;
                    ReplayInfo.Text += "DrawCount: " + drawcount;
                    ReplayInfo.Text += Environment.NewLine;
                }

                if (!replay.Tag)
                {
                    bool     playerfound = false;
                    string[] players     = null;
                    if (!replay.Tag)
                    {
                        players = new string[] { hostname, clientname }
                    }
                    ;
                    else
                    {
                        players = new string[] { hostname, clientname, player3, player4 }
                    };

                    foreach (string player in players)
                    {
                        List <string> cardnumbers = new List <string>();
                        cardnumbers.Add("#main");
                        int count = replay.DataReader.ReadInt32();
                        for (int i = 0; i < count; ++i)
                        {
                            cardnumbers.Add(replay.DataReader.ReadInt32().ToString());
                        }

                        count = replay.DataReader.ReadInt32();
                        cardnumbers.Add("#extra");
                        for (int i = 0; i < count; ++i)
                        {
                            cardnumbers.Add(replay.DataReader.ReadInt32().ToString());
                        }
                        if (player == Program.UserInfo.Username)
                        {
                            playerfound = true;
                            DeckList.Items.Clear();
                            CardList.Clear();
                            foreach (string cardnumber in cardnumbers)
                            {
                                if (cardnumber.StartsWith("#"))
                                {
                                    if (cardnumber.Contains("main"))
                                    {
                                        DeckList.Items.Add("--Main--");
                                    }
                                    if (cardnumber.Contains("extra"))
                                    {
                                        DeckList.Items.Add("--Extra--");
                                    }
                                    continue;
                                }
                                CardInfos card = LauncherHelper.CardManager.FromId(Int32.Parse(cardnumber));
                                if (card == null)
                                {
                                    continue;
                                }
                                if (CardList.ContainsKey(card.Name))
                                {
                                    CardList[card.Name].Amount++;
                                }
                                else
                                {
                                    CardList.Add(card.Name, (CardInfos)card.Clone());
                                    DeckList.Items.Add(card.Name);
                                    CardList[card.Name].Amount++;
                                }
                            }
                        }
                    }

                    if (!playerfound)
                    {
                        CardList.Clear();
                        DeckList.Items.Clear();
                    }
                }
                else
                {
                    CardList.Clear();
                    DeckList.Items.Clear();
                }
            }
            catch
            {
                DeckList.Items.Clear();
                CardList.Clear();
                ReplayInfo.Text = "Error reading replay.";
            }
        }