コード例 #1
0
        public VaultChest CreateChest(Account acc)
        {
            MySqlCommand cmd = CreateQuery();

            cmd.CommandText =
                @"INSERT INTO vaults(accId, items, itemDatas) VALUES(@accId, '65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535', @itemDatas);
SELECT MAX(chestId) FROM vaults WHERE accId = @accId;UPDATE accounts SET vaultCount=vaultCount+1 WHERE id=@accId;";
            cmd.Parameters.AddWithValue("@accId", acc.AccountId);
            cmd.Parameters.AddWithValue("@itemDatas", ItemDataList.GetJson(new ItemData[12]));
            return(new VaultChest
            {
                ChestId = (int)cmd.ExecuteScalar(),
                _Items = "65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535",
                _Datas = ItemDataList.GetJson(new ItemData[8])
            });
        }
コード例 #2
0
        public Account Register(string uuid, string password, string email, bool isGuest)
        {
            MySqlCommand cmd = CreateQuery();

            cmd.CommandText = "SELECT COUNT(id) FROM accounts WHERE uuid=@uuid;";
            cmd.Parameters.AddWithValue("@uuid", uuid);
            if ((int)(long)cmd.ExecuteScalar() > 0)
            {
                return(null);
            }

            cmd             = CreateQuery();
            cmd.CommandText =
                "INSERT INTO accounts(uuid, password, name, email, guest, maxCharSlot, regTime) VALUES(@uuid, SHA1(@password), @name, @email, @guest, 1, now());";
            cmd.Parameters.AddWithValue("@uuid", uuid);
            cmd.Parameters.AddWithValue("@password", password);
            cmd.Parameters.AddWithValue("@name", names[(uint)uuid.GetHashCode() % names.Length]);
            cmd.Parameters.AddWithValue("@email", email);
            cmd.Parameters.AddWithValue("@guest", isGuest);
            int  v   = cmd.ExecuteNonQuery();
            bool ret = v > 0;

            if (ret)
            {
                cmd             = CreateQuery();
                cmd.CommandText = "SELECT last_insert_id();";
                int accId = Convert.ToInt32(cmd.ExecuteScalar());

                cmd             = CreateQuery();
                cmd.CommandText =
                    "INSERT INTO stats(accId, fame, totalFame, credits, totalCredits, souls, totalSouls) VALUES(@accId, 0, 0, 1000, 1000, 0, 0);";
                cmd.Parameters.AddWithValue("@accId", accId);
                cmd.ExecuteNonQuery();

                cmd             = CreateQuery();
                cmd.CommandText =
                    "INSERT INTO vaults(accId, items, itemDatas) VALUES(@accId, '65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535', @datas);";
                cmd.Parameters.AddWithValue("@accId", accId);
                cmd.Parameters.AddWithValue("@datas", ItemDataList.GetJson(new ItemData[8]));
                cmd.ExecuteNonQuery();
            }
            return(Verify(uuid, password));
        }