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); }
public override bool IncreaseGuildExp(int id, int increaseExp, int[] expTree, out short resultLevel, out int resultExp, out short resultSkillPoint) { resultLevel = 1; resultExp = 0; resultSkillPoint = 0; SQLiteRowsReader reader = ExecuteReader("UPDATE guild SET exp=exp+@increaseExp WHERE id=@id;" + "SELECT level, exp, skillPoint FROM guild WHERE id=@id LIMIT 1;", new SqliteParameter("@increaseExp", increaseExp), new SqliteParameter("@id", id)); if (reader.Read()) { resultLevel = reader.GetInt16("level"); resultExp = reader.GetInt32("exp"); resultSkillPoint = reader.GetInt16("skillPoint"); // Update when guild level is increase if (SocialSystemSetting.CalculateIncreasedGuildExp(expTree, resultLevel, resultExp, resultSkillPoint, out resultLevel, out resultExp, out resultSkillPoint)) { ExecuteNonQuery("UPDATE guild SET level=@level, exp=@exp, skillPoint=@skillPoint WHERE id=@id", new SqliteParameter("@level", resultLevel), new SqliteParameter("@exp", resultExp), new SqliteParameter("@skillPoint", resultSkillPoint), new SqliteParameter("@id", id)); } // Return true if success return(true); } return(false); }
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 override PartyData ReadParty(int id) { PartyData result = null; SQLiteRowsReader reader = ExecuteReader("SELECT * FROM party WHERE id=@id LIMIT 1", new SqliteParameter("@id", id)); if (reader.Read()) { result = new PartyData(id, reader.GetBoolean("shareExp"), reader.GetBoolean("shareItem"), reader.GetString("leaderId")); reader = ExecuteReader("SELECT id, dataId, characterName, level FROM characters WHERE partyId=@id", new SqliteParameter("@id", id)); SocialCharacterData partyMemberData; while (reader.Read()) { // Get some required data, other data will be set at server side partyMemberData = new SocialCharacterData(); partyMemberData.id = reader.GetString("id"); partyMemberData.characterName = reader.GetString("characterName"); partyMemberData.dataId = reader.GetInt32("dataId"); partyMemberData.level = reader.GetInt16("level"); result.AddMember(partyMemberData); } } return(result); }
private bool ReadCharacterItem(SQLiteRowsReader reader, out CharacterItem result, bool resetReader = true) { if (resetReader) { reader.ResetReader(); } if (reader.Read()) { result = new CharacterItem(); result.dataId = reader.GetInt32("dataId"); result.level = reader.GetInt16("level"); result.amount = reader.GetInt16("amount"); result.durability = reader.GetFloat("durability"); 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); }
private bool ReadCharacterSkill(SQLiteRowsReader reader, out CharacterSkill result, bool resetReader = true) { if (resetReader) { reader.ResetReader(); } if (reader.Read()) { result = new CharacterSkill(); result.dataId = reader.GetInt32("dataId"); result.level = reader.GetInt16("level"); return(true); } result = CharacterSkill.Empty; return(false); }
private bool ReadCharacterAttribute(SQLiteRowsReader reader, out CharacterAttribute result, bool resetReader = true) { if (resetReader) { reader.ResetReader(); } if (reader.Read()) { result = new CharacterAttribute(); result.dataId = reader.GetInt32("dataId"); result.amount = reader.GetInt16("amount"); return(true); } result = CharacterAttribute.Empty; return(false); }
public override List <SocialCharacterData> FindCharacters(string characterName) { List <SocialCharacterData> result = new List <SocialCharacterData>(); SQLiteRowsReader reader = ExecuteReader("SELECT id, dataId, characterName, level FROM characters WHERE characterName LIKE @characterName LIMIT 0, 20", new SqliteParameter("@characterName", "%" + characterName + "%")); SocialCharacterData socialCharacterData; while (reader.Read()) { // Get some required data, other data will be set at server side socialCharacterData = new SocialCharacterData(); socialCharacterData.id = reader.GetString("id"); socialCharacterData.characterName = reader.GetString("characterName"); socialCharacterData.dataId = reader.GetInt32("dataId"); socialCharacterData.level = reader.GetInt16("level"); result.Add(socialCharacterData); } return(result); }
private bool ReadCharacterBuff(SQLiteRowsReader reader, out CharacterBuff result, bool resetReader = true) { if (resetReader) { reader.ResetReader(); } if (reader.Read()) { result = new CharacterBuff(); result.type = (BuffType)reader.GetSByte("type"); result.dataId = reader.GetInt32("dataId"); result.level = reader.GetInt16("level"); result.buffRemainsDuration = reader.GetFloat("buffRemainsDuration"); return(true); } result = CharacterBuff.Empty; return(false); }
private bool ReadCharacterSummon(SQLiteRowsReader reader, out CharacterSummon result, bool resetReader = true) { if (resetReader) { reader.ResetReader(); } if (reader.Read()) { result = new CharacterSummon(); result.type = (SummonType)reader.GetSByte("type"); result.dataId = reader.GetInt32("dataId"); result.summonRemainsDuration = reader.GetFloat("summonRemainsDuration"); result.level = reader.GetInt16("level"); result.exp = reader.GetInt32("exp"); result.currentHp = reader.GetInt32("currentHp"); result.currentMp = reader.GetInt32("currentMp"); return(true); } result = CharacterSummon.Empty; return(false); }