商队任务统计
This commit is contained in:
parent
a15be334b0
commit
a079a06c7c
@ -24,6 +24,9 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
||||
addScore int32 // 收益
|
||||
cityInfo *pb.CityInfo
|
||||
ok bool
|
||||
sellValue int32 // 任务统计 贩卖货物价值
|
||||
buyValue int32 // 任务统计 贩卖货物价值
|
||||
sellSpValue int32 // 任务统计 向指定X城市贩卖货物贩卖货物价值
|
||||
)
|
||||
update = make(map[string]interface{})
|
||||
if errdata = this.BuyOrSellCheck(session, req); errdata != nil {
|
||||
@ -51,7 +54,6 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
||||
// special 城市卖给玩家的商品
|
||||
// exspecial 城市想要玩家卖给他的商品库
|
||||
if !req.IsBuy { // 卖给npc
|
||||
|
||||
var cb int32 // 成本价
|
||||
for k, v := range req.Items {
|
||||
// 校验背包数据够不够
|
||||
@ -68,10 +70,11 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
||||
cb = items.Price // 获取成本价
|
||||
price = items.Price
|
||||
bFound := false
|
||||
for _, v := range cityInfo.Special {
|
||||
if v == k {
|
||||
for _, key := range cityInfo.Special {
|
||||
if key == k {
|
||||
if cityConf, err := this.module.configure.GetCaravanCity(req.City); err == nil {
|
||||
price = cityConf.Specialnum * price / 1000
|
||||
sellSpValue += cityConf.Specialnum * price * v / 1000
|
||||
bFound = true
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
@ -97,7 +100,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
sellValue += price * v
|
||||
if errdata = this.module.DispenseRes(session, []*cfg.Gameatn{{
|
||||
A: "attr",
|
||||
T: "merchantmoney",
|
||||
@ -176,7 +179,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
||||
}
|
||||
bFound := false
|
||||
// 计算均价
|
||||
totla := caravan.Items[k].Count * caravan.Items[k].Price
|
||||
buyValue = caravan.Items[k].Count * caravan.Items[k].Price
|
||||
var price int32
|
||||
price = caravan.Goods[k].Price
|
||||
for _, v := range cityInfo.Special {
|
||||
@ -194,8 +197,8 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
||||
}
|
||||
caravan.Items[k].Count += v
|
||||
|
||||
totla += price * v
|
||||
caravan.Items[k].Price = totla / caravan.Items[k].Count
|
||||
buyValue += price * v
|
||||
caravan.Items[k].Price = buyValue / caravan.Items[k].Count
|
||||
// 同步更新该城市的 出售货物信息
|
||||
cityInfo.Count[k] += v
|
||||
|
||||
@ -256,19 +259,9 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
||||
szTask = append(szTask, comm.GetBuriedParam(comm.Rtype209, req.City, opCount))
|
||||
} else { // 卖
|
||||
//向指定X城市贩卖货物,贩卖货物价值需要X虚拟币以上
|
||||
var price int32
|
||||
for k, v := range req.Items {
|
||||
|
||||
price += caravan.Items[k].Price * v
|
||||
}
|
||||
szTask = append(szTask, comm.GetBuriedParam(comm.Rtype210, req.City, price))
|
||||
|
||||
// 急需货物
|
||||
if v, ok := caravan.City[req.City]; ok {
|
||||
for range v.Exspecial {
|
||||
|
||||
}
|
||||
}
|
||||
szTask = append(szTask, comm.GetBuriedParam(comm.Rtype210, req.City, sellValue))
|
||||
// Rtype211 TaskType = 211 // 向指定X城市,贩卖价值X虚拟币以上的对应城市急需货物
|
||||
szTask = append(szTask, comm.GetBuriedParam(comm.Rtype211, req.City, sellValue))
|
||||
}
|
||||
szTask = append(szTask, comm.GetBuriedParam(comm.Rtype212, req.City)) // 接取任务后,商队抵达指定城市
|
||||
go this.module.ModuleBuried.TriggerBuried(session.Clone(), szTask...)
|
||||
|
Loading…
Reference in New Issue
Block a user