Exemplo n.º 1
0
        protected void SaveInventory(MySQL_Connection.LogAction dbgCallback = null)
        {
            string query = "UPDATE characters SET " +
                           "mesos = " + Mesos + " ," +
                           "equip_slots = " + MaxSlots[0] + ", " +
                           "use_slots = " + MaxSlots[1] + ", " +
                           "setup_slots = " + MaxSlots[2] + ", " +
                           "etc_slots = " + MaxSlots[3] + ", " +
                           "cash_slots = " + MaxSlots[4] + " " +
                           "WHERE ID = " + CharacterID;

            Connection.RunTransaction(query, dbgCallback);

            Connection.RunTransaction(comm =>
            {
                comm.CommandText = "DELETE FROM teleport_rock_locations WHERE charid = " + CharacterID;
                comm.ExecuteNonQuery();

                var telerockSave = new StringBuilder();
                telerockSave.Append("INSERT INTO teleport_rock_locations VALUES ");
                int idx = 0;
                telerockSave.Append(string.Join(", ", TeleportRockLocations.Select(location => "(" + CharacterID + ", " + (idx++) + ", " + location + ")")));
                comm.CommandText = telerockSave.ToString();
                comm.ExecuteNonQuery();
            }, dbgCallback);


            SplitDBInventory.Save(
                Connection,
                "inventory",
                CharacterID + ", ",
                "charid = " + CharacterID,
                (type, inventory) =>
            {
                switch (type)
                {
                case SplitDBInventory.InventoryType.Eqp:
                    return(Equips.SelectMany(x => x.Where(y => y != null && y.CashId == 0)).Union(Items[0].Where(x => x != null && x.CashId == 0)));

                case SplitDBInventory.InventoryType.Bundle:
                    return(Items[inventory - 1].Where(x => x != null && x.CashId == 0));

                default: throw new Exception();
                }
            },
                dbgCallback
                );
        }