Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
827a1beccf
@ -50,9 +50,7 @@
|
||||
"sptalk": 11003,
|
||||
"buytalk": 11004,
|
||||
"cityeventpro": 50000,
|
||||
"cityevent": [
|
||||
1
|
||||
]
|
||||
"cityevent": 1
|
||||
},
|
||||
{
|
||||
"id": 102,
|
||||
@ -105,9 +103,7 @@
|
||||
"sptalk": 11003,
|
||||
"buytalk": 11004,
|
||||
"cityeventpro": 100000,
|
||||
"cityevent": [
|
||||
1
|
||||
]
|
||||
"cityevent": 1
|
||||
},
|
||||
{
|
||||
"id": 103,
|
||||
@ -161,9 +157,7 @@
|
||||
"sptalk": 11003,
|
||||
"buytalk": 11004,
|
||||
"cityeventpro": 50000,
|
||||
"cityevent": [
|
||||
1
|
||||
]
|
||||
"cityevent": 1
|
||||
},
|
||||
{
|
||||
"id": 104,
|
||||
@ -217,9 +211,7 @@
|
||||
"sptalk": 11003,
|
||||
"buytalk": 11004,
|
||||
"cityeventpro": 100000,
|
||||
"cityevent": [
|
||||
1
|
||||
]
|
||||
"cityevent": 1
|
||||
},
|
||||
{
|
||||
"id": 105,
|
||||
@ -272,8 +264,6 @@
|
||||
"sptalk": 11003,
|
||||
"buytalk": 11004,
|
||||
"cityeventpro": 50000,
|
||||
"cityevent": [
|
||||
1
|
||||
]
|
||||
"cityevent": 1
|
||||
}
|
||||
]
|
@ -58,8 +58,14 @@ func (this *apiComp) GotoCity(session comm.IUserSession, req *pb.CaravanGotoCity
|
||||
}
|
||||
if bNewTask { // 到该城市随机一个新的任务
|
||||
if newCity, e := this.module.configure.GetCaravanCity(req.City); e == nil {
|
||||
ipos := comm.GetRandW(newCity.Cityevent)
|
||||
list.Eventid = newCity.Cityevent[ipos] // 新的任务
|
||||
if elist, err := this.module.configure.GetCaravanEventByGroup(newCity.Cityevent); err == nil {
|
||||
var randW []int32
|
||||
for _, v := range elist {
|
||||
randW = append(randW, v.Eventweight)
|
||||
}
|
||||
list.Eventid = elist[comm.GetRandW(randW)].Id
|
||||
}
|
||||
// 新的任务
|
||||
// list.Tasktime = configure.Now().Unix()
|
||||
// if event := this.module.configure.GetCaravanEventById(list.Eventid); event != nil {
|
||||
// list.Task = event.Worldtask // 对应世界任务组
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var moduleName = "caravan"
|
||||
@ -24,6 +25,8 @@ const (
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Caravan
|
||||
lock sync.RWMutex
|
||||
event map[int32][]*cfg.GameCaravanEventData
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
@ -36,6 +39,19 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
this.LoadConfigure(game_caravan_thing, cfg.NewGameCaravanThing)
|
||||
this.LoadConfigure(game_caravan_event, cfg.NewGameCaravanEvent)
|
||||
this.LoadConfigure(game_caravan_rank, cfg.NewGameCaravanRank)
|
||||
configure.RegisterConfigure(game_caravan_event, cfg.NewGameCaravanRank, func() {
|
||||
this.lock.Lock()
|
||||
if v, err := this.GetConfigure(game_caravan_event); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
this.event = make(map[int32][]*cfg.GameCaravanEventData, 0)
|
||||
for _, v := range v.(*cfg.GameCaravanEvent).GetDataList() {
|
||||
this.event[v.Eventgroup] = append(this.event[v.Eventgroup], v)
|
||||
}
|
||||
}
|
||||
this.lock.Unlock()
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@ -139,20 +155,14 @@ func (this *configureComp) GetAllCaravanItem() (data []*cfg.GameCaravanThingData
|
||||
}
|
||||
|
||||
// 获取随机事件
|
||||
func (this *configureComp) GetCaravanEventById(id int32) (data *cfg.GameCaravanEventData, err error) {
|
||||
func (this *configureComp) GetCaravanEventByGroup(eventgroup int32) (data []*cfg.GameCaravanEventData, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_caravan_event); err == nil {
|
||||
if configure, ok := v.(*cfg.GameCaravanEvent); ok {
|
||||
if data = configure.Get(id); data == nil {
|
||||
err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id)
|
||||
this.module.Errorln(err)
|
||||
if data, ok = this.event[eventgroup]; !ok {
|
||||
err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, eventgroup)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -214,3 +224,19 @@ func (this *configureComp) GetCaravanRank(index int32) (reward *cfg.GameCaravanR
|
||||
err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index)
|
||||
return
|
||||
}
|
||||
func (this *configureComp) GetCaravanEventById(id int32) (data *cfg.GameCaravanEventData, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
)
|
||||
if v, err = this.GetConfigure(game_caravan_event); err == nil {
|
||||
if configure, ok := v.(*cfg.GameCaravanEvent); ok {
|
||||
if data = configure.Get(id); data == nil {
|
||||
err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id)
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id)
|
||||
return
|
||||
}
|
||||
|
@ -224,6 +224,7 @@ func (this *Caravan) refreshCaravanCityInfo(uid string, caravan *pb.DBCaravan) {
|
||||
|
||||
// 校验随机事件是否超时
|
||||
func (this *Caravan) CheckCaravanTask(session comm.IUserSession, data *pb.DBCaravan) (bTimeOut bool) {
|
||||
|
||||
if data.Eventid != 0 {
|
||||
if list, err := this.configure.GetCaravanEventById(data.Eventid); err == nil {
|
||||
// 校验任务是否超时
|
||||
|
@ -149,12 +149,14 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (errdata *pb.Er
|
||||
// 发所有道具
|
||||
item := this.configure.GetAllItemConfigure()
|
||||
for _, v := range item {
|
||||
if v.Bagtype != 0 {
|
||||
res = append(res, &cfg.Gameatn{
|
||||
A: "item",
|
||||
T: v.Id,
|
||||
N: 100,
|
||||
})
|
||||
}
|
||||
}
|
||||
errdata = this.DispenseRes(session, res, true)
|
||||
if errdata != nil {
|
||||
this.Errorf("资源发放失败,%v", errdata)
|
||||
|
@ -137,19 +137,22 @@ func (this *apiComp) Practice(session comm.IUserSession, req *pb.PracticePractic
|
||||
return
|
||||
}
|
||||
room.Knapsack[req.Teacher].Usenum++
|
||||
if tconfigure.Race != heroconf.Race {
|
||||
room.Knapsack[req.Teacher].Lastusetime = configure.Now().Unix()
|
||||
if tconfigure.Race != 0 && tconfigure.Race != heroconf.Race {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: fmt.Sprintf("the teacher race:%d and the herorace:%d is race no can use", tconfigure.Race, heroconf.Race),
|
||||
}
|
||||
return
|
||||
}
|
||||
if tconfigure.Job != heroconf.Job {
|
||||
if tconfigure.Job != 0 && tconfigure.Job != heroconf.Job {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: fmt.Sprintf("the teacher job:%d and the hero job:%d is race no can use", tconfigure.Job, heroconf.Job),
|
||||
}
|
||||
return
|
||||
}
|
||||
if tconfigure.BanHero == hero.HeroID { //禁止使用
|
||||
errdata = &pb.ErrorData{
|
||||
@ -181,7 +184,7 @@ func (this *apiComp) Practice(session comm.IUserSession, req *pb.PracticePractic
|
||||
}
|
||||
|
||||
if !utils.IsToday(room.Knapsack[req.Prop].Lastusetime) {
|
||||
room.Knapsack[req.Teacher].Usenum = 0
|
||||
room.Knapsack[req.Prop].Usenum = 0
|
||||
}
|
||||
|
||||
if room.Knapsack[req.Prop].Usenum >= tconfigure.Limitation {
|
||||
@ -193,20 +196,22 @@ func (this *apiComp) Practice(session comm.IUserSession, req *pb.PracticePractic
|
||||
return
|
||||
}
|
||||
room.Knapsack[req.Prop].Usenum++
|
||||
|
||||
if pconfigure.Race != heroconf.Race {
|
||||
room.Knapsack[req.Prop].Lastusetime = configure.Now().Unix()
|
||||
if pconfigure.Race != 0 && pconfigure.Race != heroconf.Race {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: fmt.Sprintf("the teacher race:%d and the herorace:%d is race no can use", tconfigure.Race, heroconf.Race),
|
||||
}
|
||||
return
|
||||
}
|
||||
if pconfigure.Job != heroconf.Job {
|
||||
if pconfigure.Job != 0 && pconfigure.Job != heroconf.Job {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: fmt.Sprintf("the teacher job:%d and the hero job:%d is race no can use", tconfigure.Job, heroconf.Job),
|
||||
}
|
||||
return
|
||||
}
|
||||
extra += int32(float64(pillarconfigure.PlacementDuration) * float64(pconfigure.Duration) / float64(1000))
|
||||
pillar.Prop = req.Prop
|
||||
|
@ -34,7 +34,7 @@ type GameCaravanCityData struct {
|
||||
Sptalk int32
|
||||
Buytalk int32
|
||||
Cityeventpro int32
|
||||
Cityevent []int32
|
||||
Cityevent int32
|
||||
}
|
||||
|
||||
const TypeId_GameCaravanCityData = 145138895
|
||||
@ -132,20 +132,7 @@ func (_v *GameCaravanCityData)Deserialize(_buf map[string]interface{}) (err erro
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["sptalk"].(float64); !_ok_ { err = errors.New("sptalk error"); return }; _v.Sptalk = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["buytalk"].(float64); !_ok_ { err = errors.New("buytalk error"); return }; _v.Buytalk = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["cityeventpro"].(float64); !_ok_ { err = errors.New("cityeventpro error"); return }; _v.Cityeventpro = int32(_tempNum_) }
|
||||
{
|
||||
var _arr_ []interface{}
|
||||
var _ok_ bool
|
||||
if _arr_, _ok_ = _buf["cityevent"].([]interface{}); !_ok_ { err = errors.New("cityevent error"); return }
|
||||
|
||||
_v.Cityevent = make([]int32, 0, len(_arr_))
|
||||
|
||||
for _, _e_ := range _arr_ {
|
||||
var _list_v_ int32
|
||||
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
|
||||
_v.Cityevent = append(_v.Cityevent, _list_v_)
|
||||
}
|
||||
}
|
||||
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["cityevent"].(float64); !_ok_ { err = errors.New("cityevent error"); return }; _v.Cityevent = int32(_tempNum_) }
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user