コード例 #1
0
        public PlayerDetails(Player player)
        {
            characterBox.Columns.Add("Name");
            characterBox.Columns.Add("Class/Level");
            characterBox.Columns.Add("DM?");
            characterBox.Columns.Add("Dead?");

            characterBox.Columns[0].Width = 200;
            characterBox.Columns[1].Width = 200;
            characterBox.Columns[2].Width = 50;
            characterBox.Columns[3].Width = 50;

            characterBox.Width = 520;
            characterBox.Height = 490;

            characterBox.ColumnClick += ColumnSort;
            characterBox.DoubleClick += CharacterDoubleClick;
            characterBox.View = View.Details;

            characterBox.Location = new Point(200, 0);

            characterBox.FullRowSelect = true;

            this.Width = 730;
            this.Height = 520;

            this.Name = player.CommunityIds[0];
            this.Text = this.Name;

            cdKeyLabel.Text = "CD Key:";
            cdKeyLabel.Size = cdKeyLabel.PreferredSize;
            cdKeyLabel.Location = new Point(5, 5);
            cdKeyValue.Text = player.CDKey;
            cdKeyValue.Size = cdKeyValue.PreferredSize;
            cdKeyValue.Location = new Point(100, cdKeyLabel.Location.Y);

            firstLoginLabel.Text = "First Login:"******"{0:yyyy/MM/dd}", player.FirstLogin);
            firstLoginValue.Size = firstLoginValue.PreferredSize;
            firstLoginValue.Location = new Point(100, firstLoginLabel.Location.Y);

            lastLoginLabel.Text = "Last Login:"******"{0:yyyy/MM/dd}", player.LastLogin);
            lastLoginValue.Size = lastLoginValue.PreferredSize;
            lastLoginValue.Location = new Point(100, lastLoginLabel.Location.Y);

            if (player.Is18Plus)
            {
                Is18Plus.Text = "Is the age of majority";
            }
            else
            {
                Is18Plus.Text = "Is NOT the age of majority";
                Is18Plus.ForeColor = Color.Red;
                Is18Plus.BackColor = Color.Yellow;
            }
            Is18Plus.Size = Is18Plus.PreferredSize;
            Is18Plus.Location = new Point(5, lastLoginLabel.Location.Y + lastLoginLabel.Height);
            if (player.IsBanned)
            {
                IsBanned.Text = "Has been BANNED";
                IsBanned.ForeColor = Color.Red;
                IsBanned.BackColor = Color.Yellow;
            }
            else
            {
                IsBanned.Text = "Has not been banned.";
            }
            IsBanned.Size = IsBanned.PreferredSize;
            IsBanned.Location = new Point(5, Is18Plus.Location.Y + Is18Plus.Height);
            if (player.IsDM)
            {
                IsDM.Text = "Is a DM";
            }
            else
            {
                IsDM.Text = "Is not a DM";
            }
            IsDM.Size = IsDM.PreferredSize;
            IsDM.Location = new Point(5, IsBanned.Location.Y + IsBanned.Height);

            foreach (Character ownedChar in player.Characters)
            {
                string classLevel = ClassToAbbreviation(ownedChar.Class1) + ownedChar.Level1;
                if (ownedChar.Class2 < 255)
                {
                    classLevel += "/" + ClassToAbbreviation(ownedChar.Class2) + ownedChar.Level2;
                }
                if (ownedChar.Class3 < 255)
                {
                    classLevel += "/" + ClassToAbbreviation(ownedChar.Class3) + ownedChar.Level3;
                }
                string dm = "";
                string dead = ((ownedChar.Status & 0x001) == 0x001) ? "Y" : "";
                characterBox.Items.Add(new ListViewItem(new string[] { ownedChar.Name, classLevel, dm, dead, ownedChar.Id.ToString() }));
            }

            this.Controls.Add(characterBox);
            this.Controls.Add(cdKeyLabel);
            this.Controls.Add(cdKeyValue);
            this.Controls.Add(firstLoginLabel);
            this.Controls.Add(firstLoginValue);
            this.Controls.Add(lastLoginLabel);
            this.Controls.Add(lastLoginValue);
            this.Controls.Add(IsBanned);
            this.Controls.Add(Is18Plus);
            this.Controls.Add(IsDM);
        }
コード例 #2
0
        public static bool GetPlayers()
        {
            currentLoader = new LoadingForm();
            currentLoader.Show();
            currentLoader.status.Text = "Querying players...";
            Application.DoEvents();
            try
            {
                using (MySqlDataReader reader = MySqlHelper.ExecuteReader(ConnectionString, "SELECT * FROM players"))
                {
                    currentLoader.status.Text = "Loading players...";
                    Application.DoEvents();
                    while (reader.Read())
                    {
                        uint databaseRow = 0;
                        string cdKey;
                        string GSID;
                        DateTime firstLogin;
                        DateTime lastLogin;
                        uint logins;
                        bool isDM;
                        bool isBanned;
                        bool is18Plus;
                        bool isMember;
                        try
                        {
                            // First, we gather information about this row.
                            databaseRow = (uint)reader.GetValue(0);
                            cdKey = (string)reader.GetValue(1);
                            GSID = (string)reader.GetValue(2);
                            firstLogin = (DateTime)reader.GetValue(3);
                            lastLogin = (DateTime)reader.GetValue(4);
                            logins = (uint)reader.GetValue(6);
                            isDM = (bool)reader.GetValue(8);
                            isBanned = (bool)reader.GetValue(9);
                            is18Plus = (bool)reader.GetValue(10);
                            isMember = (bool)reader.GetValue(11);
                        }
                        catch
                        {
                            continue;
                        }

                        // Next, we look for if this is a player's duplicate GSID.
                        if (Players.ListByKey.Keys.Contains(cdKey))
                        {
                            // Yes, yes it is.
                            Player modifiedPlayer = Players.ListByKey[cdKey];

                            // We'll want to add to the list of Ids.
                            modifiedPlayer.playerIds.Add(databaseRow);
                            modifiedPlayer.CommunityIds.Add(GSID);

                            // We'll want to note an earlier first login, if this one is earlier
                            // and a later last login, if this one is later.
                            if (modifiedPlayer.FirstLogin > firstLogin)
                            {
                                modifiedPlayer.FirstLogin = firstLogin;
                            }
                            if (modifiedPlayer.LastLogin < lastLogin)
                            {
                                modifiedPlayer.LastLogin = lastLogin;
                            }

                            // Total number of logins is additive.
                            modifiedPlayer.Logins += logins;

                            // And if any of these bools are true, update the list to
                            // reflect as much.
                            if (isDM)
                            {
                                modifiedPlayer.IsDM = true;
                            }
                            if (isBanned)
                            {
                                modifiedPlayer.IsBanned = true;
                            }
                            if (is18Plus)
                            {
                                modifiedPlayer.Is18Plus = true;
                            }
                            if (isMember)
                            {
                                modifiedPlayer.IsMember = true;
                            }

                            // And lastly we need to make sure that the new Id is indexed.
                            Players.ListByPlayerId.Add(databaseRow, modifiedPlayer);
                        }
                        else
                        {
                            // It's a new person! Yaaaaay!
                            Player addedPlayer = new Player()
                            {
                                CDKey = cdKey,
                                DMTime = 0.0f,
                                FirstLogin = firstLogin,
                                LastLogin = lastLogin,
                                Is18Plus = is18Plus,
                                IsBanned = isBanned,
                                IsDM = isDM,
                                IsMember = isMember,
                                Logins = logins
                            };

                            addedPlayer.CommunityIds = new List<string>();
                            addedPlayer.playerIds = new List<uint>();
                            addedPlayer.Characters = new List<Character>();

                            addedPlayer.CommunityIds.Add(GSID);
                            addedPlayer.playerIds.Add(databaseRow);

                            Players.ListByPlayerId.Add(databaseRow, addedPlayer);
                            Players.ListByKey.Add(cdKey, addedPlayer);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return false;
            }
            return true;
        }