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         = (short)reader.GetInt32("level");
                    result.AddMember(partyMemberData);
                }
            }
            return(result);
        }
예제 #2
0
        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      = (short)reader.GetInt32("level");
                resultExp        = reader.GetInt32("exp");
                resultSkillPoint = (short)reader.GetInt32("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);
        }
예제 #3
0
        private bool ReadBuilding(SQLiteRowsReader reader, out BuildingSaveData result, bool resetReader = true)
        {
            if (resetReader)
            {
                reader.ResetReader();
            }

            if (reader.Read())
            {
                result              = new BuildingSaveData();
                result.Id           = reader.GetString("id");
                result.ParentId     = reader.GetString("parentId");
                result.EntityId     = reader.GetInt32("entityId");
                result.CurrentHp    = reader.GetInt32("currentHp");
                result.Position     = new Vector3(reader.GetFloat("positionX"), reader.GetFloat("positionY"), reader.GetFloat("positionZ"));
                result.Rotation     = Quaternion.Euler(reader.GetFloat("rotationX"), reader.GetFloat("rotationY"), reader.GetFloat("rotationZ"));
                result.IsLocked     = reader.GetBoolean("isLocked");
                result.LockPassword = reader.GetString("lockPassword");
                result.CreatorId    = reader.GetString("creatorId");
                result.CreatorName  = reader.GetString("creatorName");
                return(true);
            }
            result = new BuildingSaveData();
            return(false);
        }
        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);
        }
예제 #5
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);
        }
        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 = (short)reader.GetInt32("amount");
                return(true);
            }
            result = CharacterAttribute.Empty;
            return(false);
        }
예제 #7
0
        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  = (short)reader.GetInt32("level");
                return(true);
            }
            result = CharacterSkill.Empty;
            return(false);
        }
        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  = (short)reader.GetInt32("level");
                result.buffRemainsDuration = reader.GetFloat("buffRemainsDuration");
                return(true);
            }
            result = CharacterBuff.Empty;
            return(false);
        }
예제 #9
0
        private bool ReadCharacterSkillUsage(SQLiteRowsReader reader, out CharacterSkillUsage result, bool resetReader = true)
        {
            if (resetReader)
            {
                reader.ResetReader();
            }

            if (reader.Read())
            {
                result        = new CharacterSkillUsage();
                result.type   = (SkillUsageType)reader.GetSByte("type");
                result.dataId = reader.GetInt32("dataId");
                result.coolDownRemainsDuration = reader.GetFloat("coolDownRemainsDuration");
                result.isSummoned        = reader.GetBoolean("isSummoned");
                result.currentSummonedHp = reader.GetInt32("currentSummonedHp");
                result.currentSummonedMp = reader.GetInt32("currentSummonedMp");
                return(true);
            }
            result = CharacterSkillUsage.Empty;
            return(false);
        }
        public override int GetGuildGold(int guildId)
        {
            int gold = 0;
            SQLiteRowsReader reader = ExecuteReader("SELECT gold FROM guild WHERE id=@id LIMIT 1",
                                                    new SqliteParameter("@id", guildId));

            if (reader.Read())
            {
                gold = reader.GetInt32("gold");
            }
            return(gold);
        }
예제 #11
0
        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               = (short)reader.GetInt32("level");
                result.amount              = (short)reader.GetInt32("amount");
                result.durability          = reader.GetFloat("durability");
                result.exp                 = reader.GetInt32("exp");
                result.lockRemainsDuration = reader.GetFloat("lockRemainsDuration");
                return(true);
            }
            result = CharacterItem.Empty;
            return(false);
        }
        public override int GetCash(string userId)
        {
            int cash = 0;
            SQLiteRowsReader reader = ExecuteReader("SELECT cash FROM userlogin WHERE id=@id LIMIT 1",
                                                    new SqliteParameter("@id", userId));

            if (reader.Read())
            {
                cash = reader.GetInt32("cash");
            }
            return(cash);
        }
        public override int GetGold(string userId)
        {
            int gold = 0;
            SQLiteRowsReader reader = ExecuteReader("SELECT gold FROM userlogin WHERE id=@id LIMIT 1",
                                                    new SqliteParameter("@id", userId));

            if (reader.Read())
            {
                gold = reader.GetInt32("gold");
            }
            return(gold);
        }
예제 #14
0
        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     = (short)reader.GetInt32("level");
                result.exp       = reader.GetInt32("exp");
                result.currentHp = reader.GetInt32("currentHp");
                result.currentMp = reader.GetInt32("currentMp");
                return(true);
            }
            result = CharacterSummon.Empty;
            return(false);
        }
예제 #15
0
        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");
                result.isSummoned         = reader.GetBoolean("isSummoned");
                result.currentSummonedHp  = reader.GetInt32("currentSummonedHp");
                result.currentSummonedMp  = reader.GetInt32("currentSummonedMp");
                result.currentSummonedExp = reader.GetInt32("currentSummonedExp");
                return(true);
            }
            result = CharacterItem.Empty;
            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");
                result.coolDownRemainsDuration = reader.GetFloat("coolDownRemainsDuration");
                return(true);
            }
            result = CharacterSkill.Empty;
            return(false);
        }
        private bool ReadCharacterQuest(SQLiteRowsReader reader, out CharacterQuest result, bool resetReader = true)
        {
            if (resetReader)
            {
                reader.ResetReader();
            }

            if (reader.Read())
            {
                result                = new CharacterQuest();
                result.dataId         = reader.GetInt32("dataId");
                result.isComplete     = reader.GetBoolean("isComplete");
                result.killedMonsters = ReadKillMonsters(reader.GetString("killedMonsters"));
                return(true);
            }
            result = CharacterQuest.Empty;
            return(false);
        }
        private bool ReadCharacterHotkey(SQLiteRowsReader reader, out CharacterHotkey result, bool resetReader = true)
        {
            if (resetReader)
            {
                reader.ResetReader();
            }

            if (reader.Read())
            {
                result          = new CharacterHotkey();
                result.hotkeyId = reader.GetString("hotkeyId");
                result.type     = (HotkeyType)reader.GetSByte("type");
                result.dataId   = reader.GetInt32("dataId");
                return(true);
            }
            result = CharacterHotkey.Empty;
            return(false);
        }
예제 #19
0
        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);
        }
예제 #20
0
        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.LastUpdate      = (int)(reader.GetDateTime("updateAt").Ticks / System.TimeSpan.TicksPerMillisecond);
                return(true);
            }
            result = null;
            return(false);
        }