商队协议调整
This commit is contained in:
parent
7e3970ca2a
commit
2c77138db1
@ -159,18 +159,18 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
buyValue = caravan.Items[k].Count * caravan.Items[k].Price
|
buyValue = caravan.Items[k].Count * caravan.Items[k].Price
|
||||||
var price int32
|
var price int32
|
||||||
// 获取当前节点数据
|
// 获取当前节点数据
|
||||||
if len(caravan.Allgoods[k].Goods) == 0 {
|
if len(caravan.Allgoods) == 0 {
|
||||||
errdata = &pb.ErrorData{
|
errdata = &pb.ErrorData{
|
||||||
Code: pb.ErrorCode_TrollCityUnSellItem,
|
Code: pb.ErrorCode_TrollCityUnSellItem,
|
||||||
Title: pb.ErrorCode_TrollCityUnSellItem.ToString(),
|
Title: pb.ErrorCode_TrollCityUnSellItem.ToString(),
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
key := configure.Now().Hour() / (24 / len(caravan.Allgoods[k].Goods))
|
key := configure.Now().Hour() / (24 / len(caravan.Allgoods))
|
||||||
if _, ok := caravan.Allgoods[k].Goods[int32(key)]; !ok {
|
if _, ok := caravan.Allgoods[int32(key)].Goods[k]; !ok {
|
||||||
key = 0
|
key = 0
|
||||||
}
|
}
|
||||||
price = caravan.Allgoods[k].Goods[int32(key)]
|
price = caravan.Allgoods[int32(key)].Goods[k]
|
||||||
for _, v := range cityInfo.Special {
|
for _, v := range cityInfo.Special {
|
||||||
if v == k {
|
if v == k {
|
||||||
bFound = true
|
bFound = true
|
||||||
|
@ -53,7 +53,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.CaravanGetListRe
|
|||||||
}
|
}
|
||||||
cityRtime = utils.GetZeroTime(configure.Now().Unix())
|
cityRtime = utils.GetZeroTime(configure.Now().Unix())
|
||||||
if cityRtime != list.Citystime {
|
if cityRtime != list.Citystime {
|
||||||
list.Allgoods = make(map[string]*pb.GoodsInfo, 0)
|
list.Allgoods = make(map[int32]*pb.GoodsInfo, 0)
|
||||||
// 刷新城市货物信息
|
// 刷新城市货物信息
|
||||||
this.module.InitCaravanItemData(session.GetUserId(), list)
|
this.module.InitCaravanItemData(session.GetUserId(), list)
|
||||||
this.module.InitCaravanCityData(session.GetUserId(), list)
|
this.module.InitCaravanCityData(session.GetUserId(), list)
|
||||||
|
@ -42,7 +42,7 @@ func (this *modelCaravan) getCaravanList(uid string) (result *pb.DBCaravan, err
|
|||||||
//Oldprice: map[string]int32{},
|
//Oldprice: map[string]int32{},
|
||||||
Group: make(map[int32]bool, 0),
|
Group: make(map[int32]bool, 0),
|
||||||
Reward: make(map[int32]bool, 0),
|
Reward: make(map[int32]bool, 0),
|
||||||
Allgoods: map[string]*pb.GoodsInfo{},
|
Allgoods: map[int32]*pb.GoodsInfo{},
|
||||||
Period: map[string]*pb.GoodPeriod{},
|
Period: map[string]*pb.GoodPeriod{},
|
||||||
}
|
}
|
||||||
if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err {
|
if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err {
|
||||||
|
@ -138,22 +138,23 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) {
|
|||||||
}
|
}
|
||||||
items := this.configure.GetAllCaravanItem()
|
items := this.configure.GetAllCaravanItem()
|
||||||
|
|
||||||
data.Allgoods = make(map[string]*pb.GoodsInfo, 0)
|
data.Allgoods = make(map[int32]*pb.GoodsInfo, 0)
|
||||||
|
|
||||||
if data.Period == nil {
|
if data.Period == nil {
|
||||||
data.Period = make(map[string]*pb.GoodPeriod)
|
data.Period = make(map[string]*pb.GoodPeriod)
|
||||||
}
|
}
|
||||||
for _, c := range items {
|
var index int32
|
||||||
|
for index = 0; index < this.configure.GetCityRefreshTime(); index++ {
|
||||||
|
|
||||||
goodinfo := &pb.GoodsInfo{
|
goodinfo := &pb.GoodsInfo{
|
||||||
Goods: make(map[int32]int32, 0),
|
Goods: make(map[string]int32, 0),
|
||||||
}
|
|
||||||
var index int32
|
|
||||||
|
|
||||||
if _, ok := data.Period[c.Itemid]; !ok {
|
|
||||||
data.Period[c.Itemid] = &pb.GoodPeriod{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for index = 0; index < this.configure.GetCityRefreshTime(); index++ {
|
for _, c := range items {
|
||||||
|
|
||||||
|
if _, ok := data.Period[c.Itemid]; !ok {
|
||||||
|
data.Period[c.Itemid] = &pb.GoodPeriod{}
|
||||||
|
}
|
||||||
var price int32
|
var price int32
|
||||||
price = c.Goodsprice
|
price = c.Goodsprice
|
||||||
data.Period[c.Itemid].CurPeriod += 1
|
data.Period[c.Itemid].CurPeriod += 1
|
||||||
@ -195,9 +196,9 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) {
|
|||||||
if price > c.Pricemax { // 设置最大值
|
if price > c.Pricemax { // 设置最大值
|
||||||
price = c.Pricemax
|
price = c.Pricemax
|
||||||
}
|
}
|
||||||
goodinfo.Goods[index] = price
|
goodinfo.Goods[c.Itemid] = price
|
||||||
}
|
}
|
||||||
data.Allgoods[c.Itemid] = goodinfo
|
data.Allgoods[index] = goodinfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,24 +167,24 @@ type DBCaravan struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
|
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
|
||||||
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
|
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
|
||||||
Items map[string]*BagInfo `protobuf:"bytes,3,rep,name=items,proto3" json:"items" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // 背包数据
|
Items map[string]*BagInfo `protobuf:"bytes,3,rep,name=items,proto3" json:"items" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // 背包数据
|
||||||
City map[int32]*CityInfo `protobuf:"bytes,4,rep,name=city,proto3" json:"city" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // 城市信息
|
City map[int32]*CityInfo `protobuf:"bytes,4,rep,name=city,proto3" json:"city" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // 城市信息
|
||||||
Lv int32 `protobuf:"varint,5,opt,name=lv,proto3" json:"lv"` // 商队等级
|
Lv int32 `protobuf:"varint,5,opt,name=lv,proto3" json:"lv"` // 商队等级
|
||||||
Profit int64 `protobuf:"varint,6,opt,name=profit,proto3" json:"profit"` // 虚拟货利润
|
Profit int64 `protobuf:"varint,6,opt,name=profit,proto3" json:"profit"` // 虚拟货利润
|
||||||
Resettime int64 `protobuf:"varint,7,opt,name=resettime,proto3" json:"resettime"` // 赛季结算时间
|
Resettime int64 `protobuf:"varint,7,opt,name=resettime,proto3" json:"resettime"` // 赛季结算时间
|
||||||
Curcity int32 `protobuf:"varint,8,opt,name=curcity,proto3" json:"curcity"` // 当前城市
|
Curcity int32 `protobuf:"varint,8,opt,name=curcity,proto3" json:"curcity"` // 当前城市
|
||||||
Taskid int32 `protobuf:"varint,9,opt,name=taskid,proto3" json:"taskid"` // 对应对应世界任务组 worldtask
|
Taskid int32 `protobuf:"varint,9,opt,name=taskid,proto3" json:"taskid"` // 对应对应世界任务组 worldtask
|
||||||
Eventid int32 `protobuf:"varint,10,opt,name=eventid,proto3" json:"eventid"` // 特殊事件ID(事件配置唯一id)
|
Eventid int32 `protobuf:"varint,10,opt,name=eventid,proto3" json:"eventid"` // 特殊事件ID(事件配置唯一id)
|
||||||
Tasktime int64 `protobuf:"varint,11,opt,name=tasktime,proto3" json:"tasktime"` // 任务触发时间
|
Tasktime int64 `protobuf:"varint,11,opt,name=tasktime,proto3" json:"tasktime"` // 任务触发时间
|
||||||
Baglimit int32 `protobuf:"varint,12,opt,name=baglimit,proto3" json:"baglimit"` // 背包上限
|
Baglimit int32 `protobuf:"varint,12,opt,name=baglimit,proto3" json:"baglimit"` // 背包上限
|
||||||
Citystime int64 `protobuf:"varint,13,opt,name=citystime,proto3" json:"citystime"` // 城市刷新时间 固定每天0点刷新
|
Citystime int64 `protobuf:"varint,13,opt,name=citystime,proto3" json:"citystime"` // 城市刷新时间 固定每天0点刷新
|
||||||
Rtime int64 `protobuf:"varint,14,opt,name=rtime,proto3" json:"rtime"` // 客户端不用这个时间
|
Rtime int64 `protobuf:"varint,14,opt,name=rtime,proto3" json:"rtime"` // 客户端不用这个时间
|
||||||
Group map[int32]bool `protobuf:"bytes,15,rep,name=group,proto3" json:"group" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //服务器用
|
Group map[int32]bool `protobuf:"bytes,15,rep,name=group,proto3" json:"group" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //服务器用
|
||||||
Reward map[int32]bool `protobuf:"bytes,16,rep,name=reward,proto3" json:"reward" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 记录盈利奖励
|
Reward map[int32]bool `protobuf:"bytes,16,rep,name=reward,proto3" json:"reward" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 记录盈利奖励
|
||||||
Allgoods map[string]*GoodsInfo `protobuf:"bytes,17,rep,name=allgoods,proto3" json:"allgoods" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // key 货物ID
|
Allgoods map[int32]*GoodsInfo `protobuf:"bytes,17,rep,name=allgoods,proto3" json:"allgoods" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // key 周期
|
||||||
Period map[string]*GoodPeriod `protobuf:"bytes,18,rep,name=period,proto3" json:"period" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // key 货物ID
|
Period map[string]*GoodPeriod `protobuf:"bytes,18,rep,name=period,proto3" json:"period" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // key 货物ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DBCaravan) Reset() {
|
func (x *DBCaravan) Reset() {
|
||||||
@ -331,7 +331,7 @@ func (x *DBCaravan) GetReward() map[int32]bool {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DBCaravan) GetAllgoods() map[string]*GoodsInfo {
|
func (x *DBCaravan) GetAllgoods() map[int32]*GoodsInfo {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Allgoods
|
return x.Allgoods
|
||||||
}
|
}
|
||||||
@ -413,7 +413,7 @@ type GoodsInfo struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Goods map[int32]int32 `protobuf:"bytes,1,rep,name=goods,proto3" json:"goods" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // key 货物ID
|
Goods map[string]int32 `protobuf:"bytes,1,rep,name=goods,proto3" json:"goods" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // key 货物ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GoodsInfo) Reset() {
|
func (x *GoodsInfo) Reset() {
|
||||||
@ -448,7 +448,7 @@ func (*GoodsInfo) Descriptor() ([]byte, []int) {
|
|||||||
return file_caravan_caravan_db_proto_rawDescGZIP(), []int{4}
|
return file_caravan_caravan_db_proto_rawDescGZIP(), []int{4}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GoodsInfo) GetGoods() map[int32]int32 {
|
func (x *GoodsInfo) GetGoods() map[string]int32 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Goods
|
return x.Goods
|
||||||
}
|
}
|
||||||
@ -630,7 +630,7 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{
|
|||||||
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61,
|
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61,
|
||||||
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x47, 0x0a, 0x0d, 0x41, 0x6c, 0x6c, 0x67, 0x6f,
|
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x47, 0x0a, 0x0d, 0x41, 0x6c, 0x6c, 0x67, 0x6f,
|
||||||
0x6f, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18,
|
0x6f, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18,
|
||||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61,
|
0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61,
|
||||||
0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x47, 0x6f, 0x6f, 0x64,
|
0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x47, 0x6f, 0x6f, 0x64,
|
||||||
0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01,
|
0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01,
|
||||||
0x1a, 0x46, 0x0a, 0x0b, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
|
0x1a, 0x46, 0x0a, 0x0b, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12,
|
||||||
@ -648,7 +648,7 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{
|
|||||||
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x6e,
|
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x6e,
|
||||||
0x66, 0x6f, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x67,
|
0x66, 0x6f, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x67,
|
||||||
0x6f, 0x6f, 0x64, 0x73, 0x1a, 0x38, 0x0a, 0x0a, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x45, 0x6e, 0x74,
|
0x6f, 0x6f, 0x64, 0x73, 0x1a, 0x38, 0x0a, 0x0a, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x45, 0x6e, 0x74,
|
||||||
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
|
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
|
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
|
||||||
0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xbf,
|
0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xbf,
|
||||||
0x01, 0x0a, 0x0f, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e,
|
0x01, 0x0a, 0x0f, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e,
|
||||||
|
Loading…
Reference in New Issue
Block a user