Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
1cf88da6ba
@ -3,6 +3,7 @@ package caravan
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
)
|
||||
|
||||
@ -16,9 +17,11 @@ func (this *apiComp) GotoCityCheck(session comm.IUserSession, req *pb.CaravanGot
|
||||
|
||||
func (this *apiComp) GotoCity(session comm.IUserSession, req *pb.CaravanGotoCityReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
||||
var (
|
||||
resp *pb.CaravanGetListResp
|
||||
res *cfg.Gameatn
|
||||
resp *pb.CaravanGotoCityResp
|
||||
res *cfg.Gameatn
|
||||
bNewTask bool
|
||||
)
|
||||
bNewTask = true
|
||||
if code = this.GotoCityCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
@ -27,7 +30,31 @@ func (this *apiComp) GotoCity(session comm.IUserSession, req *pb.CaravanGotoCity
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
// 获取事件
|
||||
if list.Eventid != 0 {
|
||||
if event := this.module.configure.GetAllCaravanEvent(list.Eventid); event != nil {
|
||||
// 校验任务是否超时
|
||||
if list.Tasktime-configure.Now().Unix() > int64(event.Eventtime) { //TODO 任务超时
|
||||
|
||||
}
|
||||
if event.Eventtype == 1 {
|
||||
code = pb.ErrorCode_TrollTask // 需要完成强制任务
|
||||
return
|
||||
} else {
|
||||
bNewTask = false
|
||||
}
|
||||
}
|
||||
}
|
||||
if bNewTask { // 到该城市随机一个新的任务
|
||||
if newCity := this.module.configure.GetCaravanCity(req.City); newCity != nil {
|
||||
ipos := comm.GetRandW(newCity.Cityevent)
|
||||
list.Eventid = newCity.Cityevent[ipos] // 新的任务
|
||||
list.Tasktime = configure.Now().Unix()
|
||||
if event := this.module.configure.GetAllCaravanEvent(list.Eventid); event != nil {
|
||||
list.Task = event.Worldtask // 对应世界任务组
|
||||
}
|
||||
}
|
||||
}
|
||||
if list.Curcity == req.City {
|
||||
code = pb.ErrorCode_TrollCity
|
||||
return
|
||||
@ -44,11 +71,13 @@ func (this *apiComp) GotoCity(session comm.IUserSession, req *pb.CaravanGotoCity
|
||||
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success { // 校验门票数量
|
||||
return
|
||||
}
|
||||
|
||||
list.Curcity = req.City
|
||||
this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), map[string]interface{}{
|
||||
"curcity": list.Curcity,
|
||||
})
|
||||
resp.Data = list
|
||||
session.SendMsg(string(this.module.GetType()), "getlist", resp)
|
||||
resp.Newtask = bNewTask
|
||||
session.SendMsg(string(this.module.GetType()), "gotocity", resp)
|
||||
return
|
||||
}
|
||||
|
@ -9,21 +9,28 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
game_caravan = "game_itinerant_city.json"
|
||||
game_caravan_lv = "game_itinerant_lv.json"
|
||||
game_caravan_reward = "game_itinerant_reward.json"
|
||||
game_caravan_thing = "game_itinerant_thing.json"
|
||||
game_caravan = "game_itinerant_city.json"
|
||||
game_caravan_lv = "game_itinerant_lv.json"
|
||||
game_caravan_reward = "game_itinerant_reward.json"
|
||||
game_caravan_thing = "game_itinerant_thing.json"
|
||||
game_itinerant_event = "game_itinerant_event.json"
|
||||
)
|
||||
|
||||
///配置管理基础组件
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Caravan
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||
|
||||
this.module = module.(*Caravan)
|
||||
this.LoadConfigure(game_caravan, cfg.NewGameitinerant_city)
|
||||
this.LoadConfigure(game_caravan_lv, cfg.NewGameitinerant_lv)
|
||||
this.LoadConfigure(game_caravan_reward, cfg.NewGameitinerant_reward)
|
||||
this.LoadConfigure(game_caravan_thing, cfg.NewGameitinerant_thing)
|
||||
this.LoadConfigure(game_itinerant_event, cfg.NewGameitinerant_event)
|
||||
return
|
||||
}
|
||||
|
||||
@ -108,3 +115,16 @@ func (this *configureComp) GetAllCaravanItem() (data []*cfg.Gameitinerant_thingD
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 获取随机事件
|
||||
func (this *configureComp) GetAllCaravanEvent(id int32) (data *cfg.Gameitinerant_eventData) {
|
||||
if v, err := this.GetConfigure(game_itinerant_event); err == nil {
|
||||
if configure, ok := v.(*cfg.Gameitinerant_event); ok {
|
||||
data = configure.Get(id)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
log.Errorf("get GetAllCaravanEvent conf err:%v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -229,13 +229,13 @@ type DBCaravan struct {
|
||||
Goods map[int32]*Goods `protobuf:"bytes,5,rep,name=goods,proto3" json:"goods" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // key 货物ID
|
||||
City map[int32]*CityInfo `protobuf:"bytes,6,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,7,opt,name=lv,proto3" json:"lv"` // 商队等级
|
||||
Profit int64 `protobuf:"varint,9,opt,name=profit,proto3" json:"profit"` // 虚拟货利润
|
||||
Resettime int64 `protobuf:"varint,10,opt,name=resettime,proto3" json:"resettime"` // 最后一次重置时间
|
||||
Curcity int32 `protobuf:"varint,11,opt,name=curcity,proto3" json:"curcity"` // 当前城市
|
||||
Task int32 `protobuf:"varint,12,opt,name=task,proto3" json:"task"`
|
||||
Eventid int32 `protobuf:"varint,13,opt,name=eventid,proto3" json:"eventid"` // 特殊事件ID
|
||||
Tasktime int32 `protobuf:"varint,14,opt,name=tasktime,proto3" json:"tasktime"` // 任务触发时间
|
||||
Baglimit int32 `protobuf:"varint,15,opt,name=baglimit,proto3" json:"baglimit"` // 背包上限
|
||||
Profit int64 `protobuf:"varint,8,opt,name=profit,proto3" json:"profit"` // 虚拟货利润
|
||||
Resettime int64 `protobuf:"varint,9,opt,name=resettime,proto3" json:"resettime"` // 最后一次重置时间
|
||||
Curcity int32 `protobuf:"varint,10,opt,name=curcity,proto3" json:"curcity"` // 当前城市
|
||||
Task int32 `protobuf:"varint,11,opt,name=task,proto3" json:"task"`
|
||||
Eventid int32 `protobuf:"varint,12,opt,name=eventid,proto3" json:"eventid"` // 特殊事件ID
|
||||
Tasktime int64 `protobuf:"varint,13,opt,name=tasktime,proto3" json:"tasktime"` // 任务触发时间
|
||||
Baglimit int32 `protobuf:"varint,14,opt,name=baglimit,proto3" json:"baglimit"` // 背包上限
|
||||
}
|
||||
|
||||
func (x *DBCaravan) Reset() {
|
||||
@ -354,7 +354,7 @@ func (x *DBCaravan) GetEventid() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DBCaravan) GetTasktime() int32 {
|
||||
func (x *DBCaravan) GetTasktime() int64 {
|
||||
if x != nil {
|
||||
return x.Tasktime
|
||||
}
|
||||
@ -408,17 +408,17 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{
|
||||
0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x2e,
|
||||
0x43, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x63, 0x69, 0x74, 0x79, 0x12,
|
||||
0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12,
|
||||
0x16, 0x0a, 0x06, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x16, 0x0a, 0x06, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74,
|
||||
0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x72, 0x65, 0x73, 0x65,
|
||||
0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x72, 0x65, 0x73, 0x65,
|
||||
0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79,
|
||||
0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74,
|
||||
0x61, 0x73, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x18, 0x0d,
|
||||
0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74,
|
||||
0x61, 0x73, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x18, 0x0c,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x12, 0x1a, 0x0a,
|
||||
0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x61, 0x67,
|
||||
0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x61, 0x67,
|
||||
0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x61, 0x67,
|
||||
0x6c, 0x69, 0x6d, 0x69, 0x74, 0x1a, 0x42, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e,
|
||||
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
|
||||
|
@ -278,7 +278,8 @@ type CaravanGotoCityResp struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Data *DBCaravan `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
|
||||
Data *DBCaravan `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
|
||||
Newtask bool `protobuf:"varint,2,opt,name=newtask,proto3" json:"newtask"` // 触发新的任务事件
|
||||
}
|
||||
|
||||
func (x *CaravanGotoCityResp) Reset() {
|
||||
@ -320,6 +321,13 @@ func (x *CaravanGotoCityResp) GetData() *DBCaravan {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *CaravanGotoCityResp) GetNewtask() bool {
|
||||
if x != nil {
|
||||
return x.Newtask
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var File_caravan_caravan_msg_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_caravan_caravan_msg_proto_rawDesc = []byte{
|
||||
@ -349,12 +357,13 @@ var file_caravan_caravan_msg_proto_rawDesc = []byte{
|
||||
0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x47, 0x6f, 0x74, 0x6f, 0x43, 0x69, 0x74, 0x79, 0x52, 0x65,
|
||||
0x71, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x04, 0x63, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x22, 0x35, 0x0a,
|
||||
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x22, 0x4f, 0x0a,
|
||||
0x13, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x47, 0x6f, 0x74, 0x6f, 0x43, 0x69, 0x74, 0x79,
|
||||
0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x52, 0x04,
|
||||
0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
0x64, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x77, 0x74, 0x61, 0x73, 0x6b, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6e, 0x65, 0x77, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x06,
|
||||
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -307,6 +307,7 @@ const (
|
||||
ErrorCode_TrollMaxItemCount ErrorCode = 3304 //背包格子达到上限
|
||||
ErrorCode_TrollRepeatedReward ErrorCode = 3305 //奖励重复领取
|
||||
ErrorCode_TrollCity ErrorCode = 3306 // 已经在该城市了
|
||||
ErrorCode_TrollTask ErrorCode = 3307 // 任务没完成
|
||||
// horoscope
|
||||
ErrorCode_HoroscopeNotTurnedOn ErrorCode = 3401 //未开启
|
||||
ErrorCode_HoroscopeRestCDNoEnd ErrorCode = 3402 //重置cd未结束
|
||||
@ -651,6 +652,7 @@ var (
|
||||
3304: "TrollMaxItemCount",
|
||||
3305: "TrollRepeatedReward",
|
||||
3306: "TrollCity",
|
||||
3307: "TrollTask",
|
||||
3401: "HoroscopeNotTurnedOn",
|
||||
3402: "HoroscopeRestCDNoEnd",
|
||||
3501: "PrivilegeNotFound",
|
||||
@ -979,6 +981,7 @@ var (
|
||||
"TrollMaxItemCount": 3304,
|
||||
"TrollRepeatedReward": 3305,
|
||||
"TrollCity": 3306,
|
||||
"TrollTask": 3307,
|
||||
"HoroscopeNotTurnedOn": 3401,
|
||||
"HoroscopeRestCDNoEnd": 3402,
|
||||
"PrivilegeNotFound": 3501,
|
||||
@ -1079,7 +1082,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_errorcode_proto_rawDesc = []byte{
|
||||
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2a, 0xe4, 0x3b, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
||||
0x6f, 0x2a, 0xf4, 0x3b, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
||||
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10,
|
||||
0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76,
|
||||
@ -1452,6 +1455,7 @@ var file_errorcode_proto_rawDesc = []byte{
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x10, 0xe8, 0x19, 0x12, 0x18, 0x0a, 0x13, 0x54, 0x72, 0x6f, 0x6c, 0x6c,
|
||||
0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x10, 0xe9,
|
||||
0x19, 0x12, 0x0e, 0x0a, 0x09, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x43, 0x69, 0x74, 0x79, 0x10, 0xea,
|
||||
0x19, 0x12, 0x0e, 0x0a, 0x09, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x54, 0x61, 0x73, 0x6b, 0x10, 0xeb,
|
||||
0x19, 0x12, 0x19, 0x0a, 0x14, 0x48, 0x6f, 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x4e, 0x6f,
|
||||
0x74, 0x54, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x4f, 0x6e, 0x10, 0xc9, 0x1a, 0x12, 0x19, 0x0a, 0x14,
|
||||
0x48, 0x6f, 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x52, 0x65, 0x73, 0x74, 0x43, 0x44, 0x4e,
|
||||
|
Loading…
Reference in New Issue
Block a user