出售或购买获取虚拟币

This commit is contained in:
meixiongfeng 2023-05-15 19:24:16 +08:00
parent fdbd9728f7
commit 26d84899d9

View File

@ -97,24 +97,28 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
totla += price * v
caravan.Items[k].Price = totla / caravan.Items[k].Count
// 同步更新该城市的 出售货物信息
if d, ok := cityInfo.Count[req.City]; ok {
if d < v {
if _, ok := cityInfo.Count[req.City]; ok {
if cityInfo.Count[req.City] < v {
code = pb.ErrorCode_TrollBuyMax // 商品数量不足
return
}
cityInfo.Count[req.City] -= v
update["city"] = caravan.City
}
addScore -= price * v
}
}
if code = this.module.DispenseRes(session, []*cfg.Gameatn{{
A: "attr",
T: "xnb",
T: "merchantmoney",
N: addScore,
}}, true); code != pb.ErrorCode_Success {
this.module.Errorf("获得虚拟币失败:%d", code)
}
update["item"] = caravan.Items
this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), update)
session.SendMsg(string(this.module.GetType()), "buyorsell", &pb.CaravanBuyOrSellResp{
Data: caravan,
})
return
}