Beispiel #1
0
        public override GuildData ReadGuild(int id, GuildRoleData[] defaultGuildRoles)
        {
            GuildData        result = null;
            SQLiteRowsReader reader = ExecuteReader("SELECT * FROM guild WHERE id=@id LIMIT 1",
                                                    new SqliteParameter("@id", id));

            if (reader.Read())
            {
                result              = new GuildData(id, reader.GetString("guildName"), reader.GetString("leaderId"), defaultGuildRoles);
                result.level        = reader.GetInt16("level");
                result.exp          = reader.GetInt32("exp");
                result.skillPoint   = reader.GetInt16("skillPoint");
                result.guildMessage = reader.GetString("guildMessage");
                result.gold         = reader.GetInt32("gold");

                reader = ExecuteReader("SELECT * FROM guildrole WHERE guildId=@id",
                                       new SqliteParameter("@id", id));
                byte          guildRole;
                GuildRoleData guildRoleData;
                while (reader.Read())
                {
                    guildRole                        = reader.GetByte("guildRole");
                    guildRoleData                    = new GuildRoleData();
                    guildRoleData.roleName           = reader.GetString("name");
                    guildRoleData.canInvite          = reader.GetBoolean("canInvite");
                    guildRoleData.canKick            = reader.GetBoolean("canKick");
                    guildRoleData.shareExpPercentage = reader.GetByte("shareExpPercentage");
                    result.SetRole(guildRole, guildRoleData);
                }

                reader = ExecuteReader("SELECT id, dataId, characterName, level, guildRole FROM characters WHERE guildId=@id",
                                       new SqliteParameter("@id", id));
                SocialCharacterData guildMemberData;
                while (reader.Read())
                {
                    // Get some required data, other data will be set at server side
                    guildMemberData               = new SocialCharacterData();
                    guildMemberData.id            = reader.GetString("id");
                    guildMemberData.characterName = reader.GetString("characterName");
                    guildMemberData.dataId        = reader.GetInt32("dataId");
                    guildMemberData.level         = reader.GetInt16("level");
                    result.AddMember(guildMemberData, reader.GetByte("guildRole"));
                }

                reader = ExecuteReader("SELECT dataId, level FROM guildskill WHERE guildId=@id",
                                       new SqliteParameter("@id", id));
                while (reader.Read())
                {
                    result.SetSkillLevel(reader.GetInt32("dataId"), reader.GetInt16("level"));
                }
            }
            return(result);
        }
        public List <EquipWeapons> ReadCharacterEquipWeapons(string characterId)
        {
            List <EquipWeapons> result = new List <EquipWeapons>();

            SQLiteRowsReader reader = ExecuteReader("SELECT * FROM characteritem WHERE characterId=@characterId AND (inventoryType=@inventoryType1 OR inventoryType=@inventoryType2) ORDER BY idx ASC",
                                                    new SqliteParameter("@characterId", characterId),
                                                    new SqliteParameter("@inventoryType1", (byte)InventoryType.EquipWeaponRight),
                                                    new SqliteParameter("@inventoryType2", (byte)InventoryType.EquipWeaponLeft));

            CharacterItem tempInventory;
            byte          equipWeaponSet;
            InventoryType inventoryType;

            while (ReadCharacterItem(reader, out tempInventory, false))
            {
                equipWeaponSet = reader.GetByte("idx");
                inventoryType  = (InventoryType)reader.GetSByte("inventoryType");
                // Fill weapon sets if needed
                while (result.Count <= equipWeaponSet)
                {
                    result.Add(new EquipWeapons());
                }
                // Get equip weapon set
                if (inventoryType == InventoryType.EquipWeaponRight)
                {
                    result[equipWeaponSet].rightHand = tempInventory;
                }
                if (inventoryType == InventoryType.EquipWeaponLeft)
                {
                    result[equipWeaponSet].leftHand = tempInventory;
                }
            }
            return(result);
        }
        private bool ReadCharacterItem(SQLiteRowsReader reader, out CharacterItem result, bool resetReader = true)
        {
            if (resetReader)
            {
                reader.ResetReader();
            }

            if (reader.Read())
            {
                result                     = new CharacterItem();
                result.id                  = reader.GetString("id");
                result.dataId              = reader.GetInt32("dataId");
                result.level               = reader.GetInt16("level");
                result.amount              = reader.GetInt16("amount");
                result.equipSlotIndex      = reader.GetByte("equipSlotIndex");
                result.durability          = reader.GetFloat("durability");
                result.exp                 = reader.GetInt32("exp");
                result.lockRemainsDuration = reader.GetFloat("lockRemainsDuration");
                result.ammo                = reader.GetInt16("ammo");
                result.sockets             = ReadSockets(reader.GetString("sockets"));
                return(true);
            }
            result = CharacterItem.Empty;
            return(false);
        }
        private bool ReadCharacter(SQLiteRowsReader reader, out PlayerCharacterData result, bool resetReader = true)
        {
            if (resetReader)
            {
                reader.ResetReader();
            }

            if (reader.Read())
            {
                result                 = new PlayerCharacterData();
                result.Id              = reader.GetString("id");
                result.DataId          = reader.GetInt32("dataId");
                result.EntityId        = reader.GetInt32("entityId");
                result.FactionId       = reader.GetInt32("factionId");
                result.CharacterName   = reader.GetString("characterName");
                result.Level           = reader.GetInt16("level");
                result.Exp             = reader.GetInt32("exp");
                result.CurrentHp       = reader.GetInt32("currentHp");
                result.CurrentMp       = reader.GetInt32("currentMp");
                result.CurrentStamina  = reader.GetInt32("currentStamina");
                result.CurrentFood     = reader.GetInt32("currentFood");
                result.CurrentWater    = reader.GetInt32("currentWater");
                result.EquipWeaponSet  = reader.GetByte("equipWeaponSet");
                result.StatPoint       = reader.GetInt16("statPoint");
                result.SkillPoint      = reader.GetInt16("skillPoint");
                result.Gold            = reader.GetInt32("gold");
                result.PartyId         = reader.GetInt32("partyId");
                result.GuildId         = reader.GetInt32("guildId");
                result.GuildRole       = reader.GetByte("guildRole");
                result.SharedGuildExp  = reader.GetInt32("sharedGuildExp");
                result.CurrentMapName  = reader.GetString("currentMapName");
                result.CurrentPosition = new Vector3(reader.GetFloat("currentPositionX"), reader.GetFloat("currentPositionY"), reader.GetFloat("currentPositionZ"));
                result.RespawnMapName  = reader.GetString("respawnMapName");
                result.RespawnPosition = new Vector3(reader.GetFloat("respawnPositionX"), reader.GetFloat("respawnPositionY"), reader.GetFloat("respawnPositionZ"));
                result.MountDataId     = reader.GetInt32("mountDataId");
                result.LastUpdate      = (int)(reader.GetDateTime("updateAt").Ticks / System.TimeSpan.TicksPerMillisecond);
                return(true);
            }
            result = null;
            return(false);
        }