예제 #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="key"></param>
 /// <param name="level">玩家等级</param>
 /// <param name="grid">是哪一个英雄卡牌</param>
 /// <param name="id">卡牌或装备在数据中的id</param>
 /// <param name="type">类型0 卡牌 1-6装备</param>
 /// <returns></returns>
 public bool ChangeDeployment(int userId, string key,int level, int grid, int id, int type,Card c=null)
 {
     Deployment d = new Deployment();
     DeploymentGridModel model;
     switch(grid)
     {
         case 1:
             model=d.grid1;
             break;
         case 2:
             if (level < 20) return false;
             model = d.grid2;
             break;
         case 3:
             if (level < 30) return false;
             model = d.grid3;
             break;
         case 4:
             if (level < 40) return false;
             model = d.grid4;
             break;
         case 5:
             if (level < 45) return false;
             model = d.grid5;
             break;
         default:
             return false;
     }
     switch(type)
     {
         case 0:
             if (c == null) return false;
             if (d.grid1.cardId == id || d.grid2.cardId == id || d.grid3.cardId == id || d.grid4.cardId == id || d.grid5.cardId == id)
                 return false;
             model.cardId = id;
             break;
         case 1:
             model.swordId = id;
             break;
         case 2:
             model.hatId = id;
             break;
         case 3:
             model.clothId=id;
             break;
         case 4:
             model.bookId = id;
             break;
         case 5:
             model.shooeId = id;
             break;
         case 6:
             model.horseId = id;
             break;
     }
     d.Update();
     userDeployments[userId] = d;
     return true;
 }
예제 #2
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public static Card[] GetList(int userId)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select *");
     strSql.Append(" FROM card ");
     strSql.Append(" where user_id=@userId ");
     MySqlParameter[] parameters = {
             new MySqlParameter("@userId", MySqlDbType.Int32)};
     parameters[0].Value = userId;
     DataSet ds = DbHelperMySQL.Query(strSql.ToString(),parameters);
     Card[] cards = new Card[ds.Tables[0].Rows.Count];
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         cards[i] = new Card();
         if (ds.Tables[0].Rows[i]["id"] != null && ds.Tables[0].Rows[i]["id"].ToString() != "")
         {
             cards[i].id = int.Parse(ds.Tables[0].Rows[i]["id"].ToString());
         }
         if (ds.Tables[0].Rows[i]["user_id"] != null && ds.Tables[0].Rows[i]["user_id"].ToString() != "")
         {
             cards[i].user_id = int.Parse(ds.Tables[0].Rows[i]["user_id"].ToString());
         }
         if (ds.Tables[0].Rows[i]["gd_code"] != null && ds.Tables[0].Rows[i]["gd_code"].ToString() != "")
         {
             cards[i].gd_code = int.Parse(ds.Tables[0].Rows[i]["gd_code"].ToString());
         }
         if (ds.Tables[0].Rows[i]["level"] != null && ds.Tables[0].Rows[i]["level"].ToString() != "")
         {
             cards[i].level = int.Parse(ds.Tables[0].Rows[i]["level"].ToString());
         }
         if (ds.Tables[0].Rows[i]["exp"] != null && ds.Tables[0].Rows[i]["exp"].ToString() != "")
         {
             cards[i].exp = int.Parse(ds.Tables[0].Rows[i]["exp"].ToString());
         }
         if (ds.Tables[0].Rows[i]["additional"] != null && ds.Tables[0].Rows[i]["additional"].ToString() != "")
         {
             cards[i].additional = int.Parse(ds.Tables[0].Rows[i]["additional"].ToString());
         }
     }
     return cards;
 }