update
This commit is contained in:
parent
885b4bbb50
commit
9d81c8b703
@ -18,16 +18,15 @@ func (this *apiComp) ActivateCheck(session comm.IUserSession, req *pb.AtlasActiv
|
|||||||
|
|
||||||
// 激活图鉴信息
|
// 激活图鉴信息
|
||||||
func (this *apiComp) Activate(session comm.IUserSession, req *pb.AtlasActivateReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) Activate(session comm.IUserSession, req *pb.AtlasActivateReq) (errdata *pb.ErrorData) {
|
||||||
if code = this.ActivateCheck(session, req); code != pb.ErrorCode_Success {
|
if errdata = this.ActivateCheck(session, req); errdata != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
atlasConf, err := this.module.configure.GetPandoAtlasConf(req.Id)
|
atlasConf, err := this.module.configure.GetPandoAtlasConf(req.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_ConfigNoFound // 返回错误码
|
errdata = &pb.ErrorData{
|
||||||
data = &pb.ErrorData{
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
Title: pb.GetErrorCodeMsg(code),
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
Message: err.Error(),
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -45,9 +44,15 @@ func (this *apiComp) Activate(session comm.IUserSession, req *pb.AtlasActivateRe
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
code = pb.ErrorCode_MartialhallAtlasError
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_MartialhallAtlasError,
|
||||||
|
Title: pb.ErrorCode_MartialhallAtlasError.ToString(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
code = pb.ErrorCode_SmithyNoFoundAtlas
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_SmithyNoFoundAtlas,
|
||||||
|
Title: pb.ErrorCode_SmithyNoFoundAtlas.ToString(),
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,17 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.AtlasAwardReq) (er
|
|||||||
res = append(res, conf.ItemId...)
|
res = append(res, conf.ItemId...)
|
||||||
}
|
}
|
||||||
if len(res) == 0 { // 没有奖励可领取
|
if len(res) == 0 { // 没有奖励可领取
|
||||||
code = pb.ErrorCode_MartialhallAtlasNoReward
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_MartialhallAtlasNoReward,
|
||||||
|
Title: pb.ErrorCode_MartialhallAtlasNoReward.ToString(),
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success {
|
if errdata = this.module.DispenseRes(session, res, true); errdata != nil {
|
||||||
buff, _ := json.Marshal(res)
|
buff, _ := json.Marshal(res)
|
||||||
data = &pb.ErrorData{Title: "图鉴奖励领取失败!", Datastring: string(buff)}
|
//data = &pb.ErrorData{Title: "图鉴奖励领取失败!", Datastring: string(buff)}
|
||||||
|
errdata.Title = "图鉴奖励领取失败!"
|
||||||
|
errdata.Datastring = string(buff)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,10 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.AtlasGetListReq)
|
|||||||
|
|
||||||
list, err := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId())
|
list, err := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), "getlist", &pb.AtlasGetListResp{
|
session.SendMsg(string(this.module.GetType()), "getlist", &pb.AtlasGetListResp{
|
||||||
|
@ -27,25 +27,27 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
|
|
||||||
)
|
)
|
||||||
update = make(map[string]interface{})
|
update = make(map[string]interface{})
|
||||||
if code = this.BuyOrSellCheck(session, req); code != pb.ErrorCode_Success {
|
if errdata = this.BuyOrSellCheck(session, req); errdata != nil {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
caravan, _ := this.module.modelCaravan.getCaravanList(session.GetUserId())
|
caravan, _ := this.module.modelCaravan.getCaravanList(session.GetUserId())
|
||||||
|
|
||||||
cityInfo, ok = caravan.City[req.City]
|
if cityInfo, ok = caravan.City[req.City]; !ok {
|
||||||
if !ok {
|
errdata = &pb.ErrorData{
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c, err := this.module.configure.GetCaravanLv(caravan.Lv)
|
c, err := this.module.configure.GetCaravanLv(caravan.Lv)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
upperLimit = c.Bagtagnum // 获取单个格子堆叠数
|
upperLimit = c.Bagtagnum // 获取单个格子堆叠数
|
||||||
} else {
|
} else {
|
||||||
data = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Title: pb.GetErrorCodeMsg(code),
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
}
|
}
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +58,10 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
// 校验背包数据够不够
|
// 校验背包数据够不够
|
||||||
caravan.Items[k].Count -= v
|
caravan.Items[k].Count -= v
|
||||||
if caravan.Items[k].Count < 0 {
|
if caravan.Items[k].Count < 0 {
|
||||||
code = pb.ErrorCode_TrollItemNoEnough // 道具数量不足
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_TrollItemNoEnough, // 道具数量不足
|
||||||
|
Title: pb.ErrorCode_TrollItemNoEnough.ToString(),
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
items := caravan.Items[k]
|
items := caravan.Items[k]
|
||||||
@ -69,11 +74,11 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
price = cityConf.Specialnum * price / 1000
|
price = cityConf.Specialnum * price / 1000
|
||||||
bFound = true
|
bFound = true
|
||||||
} else {
|
} else {
|
||||||
data = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Title: pb.GetErrorCodeMsg(code),
|
Code: pb.ErrorCode_TrollItemNoEnough, // 道具数量不足
|
||||||
|
Title: pb.ErrorCode_TrollItemNoEnough.ToString(),
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
}
|
}
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@ -87,9 +92,9 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
code = pb.ErrorCode_DataNotFound
|
errdata = &pb.ErrorData{
|
||||||
data = &pb.ErrorData{
|
Code: pb.ErrorCode_ConfigNoFound, // 道具数量不足
|
||||||
Title: pb.GetErrorCodeMsg(code),
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +102,10 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
addScore += price * v // 卖出收益
|
addScore += price * v // 卖出收益
|
||||||
}
|
}
|
||||||
if this.module.ArrayBag(caravan, upperLimit) { // 背包满了
|
if this.module.ArrayBag(caravan, upperLimit) { // 背包满了
|
||||||
code = pb.ErrorCode_TrollMaxItemCount
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_TrollMaxItemCount, // 道具数量不足
|
||||||
|
Title: pb.ErrorCode_TrollMaxItemCount.ToString(),
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 统计 收益
|
// 统计 收益
|
||||||
@ -112,19 +120,25 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
update["lv"] = curLv
|
update["lv"] = curLv
|
||||||
update["baglimit"] = c.Bagtop
|
update["baglimit"] = c.Bagtop
|
||||||
} else {
|
} else {
|
||||||
data = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Title: pb.GetErrorCodeMsg(code),
|
Code: pb.ErrorCode_ConfigNoFound, // 道具数量不足
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
}
|
}
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
caravan.Lv = curLv
|
caravan.Lv = curLv
|
||||||
}
|
}
|
||||||
if len(lvReward) > 0 {
|
if len(lvReward) > 0 {
|
||||||
if reward := this.module.DispenseRes(session, lvReward, true); reward != pb.ErrorCode_Success {
|
if reward := this.module.DispenseRes(session, lvReward, true); reward != nil {
|
||||||
this.module.Errorf("lv reward dispenseRes err:%v", lvReward)
|
this.module.Errorf("lv reward dispenseRes err:%v", lvReward)
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound, // 道具数量不足
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +162,10 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !bFound {
|
if !bFound {
|
||||||
code = pb.ErrorCode_TrollCityUnSellItem // 城市不卖这个物品
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_TrollCityUnSellItem, // 城市不卖这个物品
|
||||||
|
Title: pb.ErrorCode_TrollCityUnSellItem.ToString(),
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
caravan.Items[k].Count += v
|
caravan.Items[k].Count += v
|
||||||
@ -159,31 +176,37 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
cityInfo.Count[k] += v
|
cityInfo.Count[k] += v
|
||||||
if itemConf, err := this.configure.GetCaravanGoods(k); err == nil { // 更新商店库存
|
if itemConf, err := this.configure.GetCaravanGoods(k); err == nil { // 更新商店库存
|
||||||
if cityInfo.Count[k] > itemConf.Goodsnum {
|
if cityInfo.Count[k] > itemConf.Goodsnum {
|
||||||
code = pb.ErrorCode_TrollBuyMax // 商品数量不足
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_TrollBuyMax, // 商品数量不足
|
||||||
|
Title: pb.ErrorCode_TrollBuyMax.ToString(),
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
update["city"] = caravan.City
|
update["city"] = caravan.City
|
||||||
addScore -= price * v
|
addScore -= price * v
|
||||||
} else {
|
} else {
|
||||||
data = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Title: pb.GetErrorCodeMsg(code),
|
Code: pb.ErrorCode_ConfigNoFound, // 商品数量不足
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
}
|
}
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if this.module.ArrayBag(caravan, upperLimit) { // 背包满了
|
if this.module.ArrayBag(caravan, upperLimit) { // 背包满了
|
||||||
code = pb.ErrorCode_TrollMaxItemCount
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_TrollMaxItemCount,
|
||||||
|
Title: pb.ErrorCode_TrollMaxItemCount.ToString(),
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if code = this.module.DispenseRes(session, []*cfg.Gameatn{{
|
if errdata = this.module.DispenseRes(session, []*cfg.Gameatn{{
|
||||||
A: "attr",
|
A: "attr",
|
||||||
T: "merchantmoney",
|
T: "merchantmoney",
|
||||||
N: addScore,
|
N: addScore,
|
||||||
}}, true); code != pb.ErrorCode_Success {
|
}}, true); errdata != nil {
|
||||||
this.module.Errorf("获得虚拟币失败:%d", code)
|
this.module.Errorf("获得虚拟币失败:%v", errdata)
|
||||||
}
|
}
|
||||||
update["items"] = caravan.Items
|
update["items"] = caravan.Items
|
||||||
update["baglimit"] = caravan.Baglimit
|
update["baglimit"] = caravan.Baglimit
|
||||||
|
Loading…
Reference in New Issue
Block a user