コード例 #1
0
ファイル: DBBattlePower.cs プロジェクト: wuhuolong/MaxBooks
    public BattlePowerInfo GetItemInfo(uint id)
    {
        string query  = string.Format("SELECT * FROM {0} WHERE {0}.{1}=\"{2}\"", mTableName, "id", id);
        var    reader = DBManager.Instance.ExecuteSqliteQueryToReader(GlobalConfig.DBFile, mTableName, query, (int)DBManager.CommandTag.TAG_3);

        if (reader == null)
        {
            mBattlePowerInfos[id] = null;
            return(null);
        }

        if (!reader.HasRows || !reader.Read())
        {
            mBattlePowerInfos[id] = null;

            reader.Close();
            reader.Dispose();
            return(null);
        }

        BattlePowerInfo info       = new BattlePowerInfo();
        int             suffix_len = "{0}".Length;

        List <string> valStrList = DBTextResource.ParseArrayString(GetReaderString(reader, "val"));

        if (valStrList.Count >= 2)
        {
            uint key = 0;
            uint.TryParse(valStrList[0], out key);
            float val = 0f;
            float.TryParse(valStrList[1], out val);
            info.val = new KeyValuePair <uint, float>(key, val);
        }

        info.show_type = DBTextResource.ParseBT_s(GetReaderString(reader, "show_type"), 0);
        info.desc      = GetReaderString(reader, "desc");
        if (!string.IsNullOrEmpty(info.desc))
        {
            //if(info.desc.Length > suffix_len)
            //    info.name = info.desc.Substring(0, info.desc.Length - suffix_len);
            if (info.desc.Length > suffix_len)
            {
                info.name = info.desc.Replace("{0}", "");
            }
        }

        info.tips_desc          = GetReaderString(reader, "tips_desc");
        info.equip_val          = GetReaderFloat(reader, "equip_val");
        info.equip_strength_val = GetReaderFloat(reader, "equip_strength_val");
        info.equip_baptize_val  = GetReaderFloat(reader, "equip_baptize_val");

        mBattlePowerInfos.Add(id, info);

        reader.Close();
        reader.Dispose();
        return(info);
    }