Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
188f50c130
22
bin/json/game_sellcoefficient.json
Normal file
22
bin/json/game_sellcoefficient.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"character": 1,
|
||||||
|
"coefficient": 1000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"character": 2,
|
||||||
|
"coefficient": 1200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"character": 3,
|
||||||
|
"coefficient": 1500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"character": 4,
|
||||||
|
"coefficient": 2000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"character": 5,
|
||||||
|
"coefficient": 3000
|
||||||
|
}
|
||||||
|
]
|
@ -211,8 +211,6 @@ type (
|
|||||||
RemoveCondi(uid string, condiId int32) error
|
RemoveCondi(uid string, condiId int32) error
|
||||||
// 更新任务条件数据
|
// 更新任务条件数据
|
||||||
ChangeCondi(uid string, data map[int32]*pb.RtaskData) error
|
ChangeCondi(uid string, data map[int32]*pb.RtaskData) error
|
||||||
//任务触发
|
|
||||||
SendToRtask(session IUserSession, rtaskType TaskType, params ...int32) (code pb.ErrorCode)
|
|
||||||
//任务批量触发
|
//任务批量触发
|
||||||
TriggerTask(uid string, taskParams ...*TaskParam)
|
TriggerTask(uid string, taskParams ...*TaskParam)
|
||||||
// 获取任务条件记录
|
// 获取任务条件记录
|
||||||
|
@ -18,6 +18,8 @@ const (
|
|||||||
game_equipcompose = "game_equipcompose.json" //装备锻造
|
game_equipcompose = "game_equipcompose.json" //装备锻造
|
||||||
game_equipattribute = "game_equipattribute.json" //装备技能列表
|
game_equipattribute = "game_equipattribute.json" //装备技能列表
|
||||||
game_equipenchanting = "game_equipenchanting.json" //装备附魔
|
game_equipenchanting = "game_equipenchanting.json" //装备附魔
|
||||||
|
game_sellcoefficient = "game_sellcoefficient.json" //装备出售品质系数
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
///背包配置管理组件
|
///背包配置管理组件
|
||||||
@ -39,6 +41,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
this.LoadConfigure(game_equipcompose, cfg.NewGameEquipSCompose)
|
this.LoadConfigure(game_equipcompose, cfg.NewGameEquipSCompose)
|
||||||
this.LoadConfigure(game_equipattribute, cfg.NewGameEquipAttribute)
|
this.LoadConfigure(game_equipattribute, cfg.NewGameEquipAttribute)
|
||||||
this.LoadConfigure(game_equipenchanting, cfg.NewGameEquipEnchanting)
|
this.LoadConfigure(game_equipenchanting, cfg.NewGameEquipEnchanting)
|
||||||
|
this.LoadConfigure(game_sellcoefficient, cfg.NewGameSellCoefficient)
|
||||||
configure.RegisterConfigure(game_equip, cfg.NewGameEquip, func() {
|
configure.RegisterConfigure(game_equip, cfg.NewGameEquip, func() {
|
||||||
this.equiplock.Lock()
|
this.equiplock.Lock()
|
||||||
if v, err := this.GetConfigure(game_equip); err != nil {
|
if v, err := this.GetConfigure(game_equip); err != nil {
|
||||||
@ -282,8 +285,25 @@ func (this *configureComp) getEquipenchanting(id string) (result *cfg.GameEquipE
|
|||||||
} else {
|
} else {
|
||||||
if result, ok = v.(*cfg.GameEquipEnchanting).GetDataMap()[id]; !ok {
|
if result, ok = v.(*cfg.GameEquipEnchanting).GetDataMap()[id]; !ok {
|
||||||
err = fmt.Errorf("on found getEquipenchanting id:%s", id)
|
err = fmt.Errorf("on found getEquipenchanting id:%s", id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//读取装备出售系数配置
|
||||||
|
func (this *configureComp) getSellcoefficient(id int32) (result *cfg.GameSellCoefficientData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_sellcoefficient); err != nil {
|
||||||
this.module.Errorf("err:%v", err)
|
this.module.Errorf("err:%v", err)
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
if result, ok = v.(*cfg.GameSellCoefficient).GetDataMap()[id]; !ok {
|
||||||
|
err = fmt.Errorf("on found getSellcoefficient id:%d", id)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -235,6 +235,7 @@ func (this *Equipment) RecycleEquipments(session comm.IUserSession, equs []strin
|
|||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
equipments []*pb.DB_Equipment
|
equipments []*pb.DB_Equipment
|
||||||
|
sellconf *cfg.GameSellCoefficientData
|
||||||
confs []*cfg.GameEquipData
|
confs []*cfg.GameEquipData
|
||||||
sale [][]*cfg.Gameatn
|
sale [][]*cfg.Gameatn
|
||||||
)
|
)
|
||||||
@ -252,19 +253,24 @@ func (this *Equipment) RecycleEquipments(session comm.IUserSession, equs []strin
|
|||||||
}
|
}
|
||||||
if confs[i], err = this.configure.GetEquipmentConfigureById(v.CId); err != nil {
|
if confs[i], err = this.configure.GetEquipmentConfigureById(v.CId); err != nil {
|
||||||
this.Errorln(err)
|
this.Errorln(err)
|
||||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if confs[i].SmithySale == nil || len(confs[i].SmithySale) == 0 {
|
if confs[i].SmithySale == nil || len(confs[i].SmithySale) == 0 {
|
||||||
code = pb.ErrorCode_EquipmentNoCanSell
|
code = pb.ErrorCode_EquipmentNoCanSell
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if sellconf, err = this.configure.getSellcoefficient(int32(len(v.AdverbEntry) + 1)); err != nil {
|
||||||
|
this.Errorln(err)
|
||||||
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
|
return
|
||||||
|
}
|
||||||
sale[i] = make([]*cfg.Gameatn, len(confs[i].Sale))
|
sale[i] = make([]*cfg.Gameatn, len(confs[i].Sale))
|
||||||
for n, s := range confs[i].SmithySale {
|
for n, s := range confs[i].SmithySale {
|
||||||
_s := &cfg.Gameatn{
|
_s := &cfg.Gameatn{
|
||||||
A: s.A,
|
A: s.A,
|
||||||
T: s.T,
|
T: s.T,
|
||||||
N: int32(math.Floor(float64(s.N) * float64(discount+1000) / float64(1000))),
|
N: int32(math.Floor(float64(s.N) * (float64(discount+1000) / float64(1000)) * (float64(sellconf.Coefficient) / float64(1000)))),
|
||||||
}
|
}
|
||||||
sale[i][n] = _s
|
sale[i][n] = _s
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,20 @@ func (this *Pvp) readyTimeOut(task *timewheel.Task, args ...interface{}) {
|
|||||||
}, battle.RedSession, battle.BlueSession); err != nil {
|
}, battle.RedSession, battle.BlueSession); err != nil {
|
||||||
this.Errorln(err)
|
this.Errorln(err)
|
||||||
}
|
}
|
||||||
go this.practice.ChallengeResults(battle.Id, battle.Red.Uid, battle.Blue.Uid, 0)
|
|
||||||
|
switch battle.Ptype {
|
||||||
|
case pb.PvpType_friends:
|
||||||
|
var winside int32 = 0
|
||||||
|
if battle.Redformation != nil {
|
||||||
|
winside = 1
|
||||||
|
}
|
||||||
|
if battle.Blueformation != nil {
|
||||||
|
winside = 2
|
||||||
|
}
|
||||||
|
go this.practice.ChallengeResults(battle.Id, battle.Red.Uid, battle.Blue.Uid, winside)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +94,12 @@ func (this *ModelRtask) checkCondi(uid string, condiId int32) (err error, ok boo
|
|||||||
var condi *rtaskCondi
|
var condi *rtaskCondi
|
||||||
cond, ok := this.moduleRtask.handleMap.Load(condiId)
|
cond, ok := this.moduleRtask.handleMap.Load(condiId)
|
||||||
if !ok {
|
if !ok {
|
||||||
errors.Errorf("condiID: %v handle no found", condiId)
|
rcs := this.moduleRtask.getHandle(comm.TaskType(conf.Type))
|
||||||
return
|
for _, v:=range rcs {
|
||||||
|
if v.condId == condiId {
|
||||||
|
cond = v
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if condi, ok = cond.(*rtaskCondi); !ok {
|
if condi, ok = cond.(*rtaskCondi); !ok {
|
||||||
|
@ -45,9 +45,7 @@ type ModuleRtask struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewModule() core.IModule {
|
func NewModule() core.IModule {
|
||||||
return &ModuleRtask{
|
return &ModuleRtask{}
|
||||||
// handleMap: make(map[int32]*rtaskCondi),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModuleRtask) GetType() core.M_Modules {
|
func (this *ModuleRtask) GetType() core.M_Modules {
|
||||||
@ -57,7 +55,6 @@ func (this *ModuleRtask) GetType() core.M_Modules {
|
|||||||
func (this *ModuleRtask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
func (this *ModuleRtask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||||
err = this.ModuleBase.Init(service, module, options)
|
err = this.ModuleBase.Init(service, module, options)
|
||||||
this.service = service.(base.IRPCXService)
|
this.service = service.(base.IRPCXService)
|
||||||
// this.initRtaskVerifyHandle()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (this *ModuleRtask) Start() (err error) {
|
func (this *ModuleRtask) Start() (err error) {
|
||||||
@ -260,145 +257,6 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 条件校验初始
|
|
||||||
// Deprecated
|
|
||||||
func (this *ModuleRtask) initRtaskVerifyHandle() {
|
|
||||||
conf, err := this.configure.getRtaskCondiCfg()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range conf.GetDataList() {
|
|
||||||
if typeCfg, err := this.configure.getRtaskTypeById(v.Id); err == nil {
|
|
||||||
if typeCfg != nil {
|
|
||||||
switch comm.TaskType(typeCfg.Type) {
|
|
||||||
case comm.Rtype1:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verfiyRtype1,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype2:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verifyRtype2,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype3:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verifyRtype3,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype4:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verifyRtype4,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype5:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verifyRtype5,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype6:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verifyRtype6,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype8:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verfiyRtype8,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype9:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verfiyRtype9,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype10:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verfiyRtype10,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype11, comm.Rtype84, comm.Rtype85:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.lessEqualFirstParam,
|
|
||||||
verify: this.modelRtaskRecord.verifyFirstGreatEqualParam,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype18:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.greatEqualFirstParam,
|
|
||||||
verify: this.modelRtaskRecord.verifyFirstGreatEqualParam,
|
|
||||||
update: this.modelRtaskRecord.addUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype7, comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15,
|
|
||||||
comm.Rtype19, comm.Rtype21, comm.Rtype24,
|
|
||||||
comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38,
|
|
||||||
comm.Rtype39, comm.Rtype50, comm.Rtype51, comm.Rtype53,
|
|
||||||
comm.Rtype54, comm.Rtype57, comm.Rtype58, comm.Rtype60,
|
|
||||||
comm.Rtype62, comm.Rtype64, comm.Rtype69, comm.Rtype72, comm.Rtype88, comm.Rtype104,
|
|
||||||
comm.Rtype96, comm.Rtype105, comm.Rtype128, comm.Rtype130, comm.Rtype131,
|
|
||||||
comm.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146,
|
|
||||||
comm.Rtype147, comm.Rtype149, comm.Rtype153, comm.Rtype154, comm.Rtype155, comm.Rtype156:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.lessEqualFirstParam,
|
|
||||||
verify: this.modelRtaskRecord.verifyFirstGreatEqualParam,
|
|
||||||
update: this.modelRtaskRecord.addUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype20:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verifyRtype20,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype22, comm.Rtype109:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtaskRecord.verifyFirstEqualParam,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype63:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalFirstParam,
|
|
||||||
verify: this.modelRtask.verifyRtype63,
|
|
||||||
update: this.modelRtaskRecord.addUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype16, comm.Rtype17,
|
|
||||||
comm.Rtype35, comm.Rtype44,
|
|
||||||
comm.Rtype59, comm.Rtype61, comm.Rtype70:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.equalParams,
|
|
||||||
verify: this.modelRtaskRecord.verifyFromDb,
|
|
||||||
update: this.modelRtaskRecord.overrideUpdate,
|
|
||||||
})
|
|
||||||
case comm.Rtype23, comm.Rtype25, comm.Rtype29, comm.Rtype30, comm.Rtype31,
|
|
||||||
comm.Rtype32, comm.Rtype33, comm.Rtype34, comm.Rtype36,
|
|
||||||
comm.Rtype37, comm.Rtype40, comm.Rtype41,
|
|
||||||
comm.Rtype42, comm.Rtype43, comm.Rtype45,
|
|
||||||
comm.Rtype46, comm.Rtype47, comm.Rtype48, comm.Rtype49,
|
|
||||||
comm.Rtype52, comm.Rtype55, comm.Rtype56,
|
|
||||||
comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68, comm.Rtype140:
|
|
||||||
this.registerVerifyHandle(v.Id, &rtaskCondi{
|
|
||||||
find: this.modelRtaskRecord.lessThanParams,
|
|
||||||
verify: this.modelRtaskRecord.verifyFromDb,
|
|
||||||
update: this.modelRtaskRecord.addUpdate,
|
|
||||||
})
|
|
||||||
|
|
||||||
default:
|
|
||||||
log.Warnf("rtaskType[%v] not register", typeCfg.Type)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理触发的任务
|
// 处理触发的任务
|
||||||
func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
|
func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
|
||||||
uid := session.GetUserId()
|
uid := session.GetUserId()
|
||||||
@ -481,80 +339,6 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) {
|
|
||||||
uid := session.GetUserId()
|
|
||||||
if this.IsCross() {
|
|
||||||
//随机任务
|
|
||||||
if _, err := this.service.AcrossClusterRpcGo(
|
|
||||||
context.Background(),
|
|
||||||
session.GetServiecTag(),
|
|
||||||
comm.Service_Worker,
|
|
||||||
string(comm.Rpc_ModuleRtaskSendTask),
|
|
||||||
pb.RPCRTaskReq{Uid: uid, TaskType: int32(rtaskType), Param: params},
|
|
||||||
nil); err != nil {
|
|
||||||
this.Errorln(err)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Debug("任务事件触发",
|
|
||||||
log.Field{Key: "uid", Value: uid},
|
|
||||||
log.Field{Key: "taskType", Value: rtaskType},
|
|
||||||
log.Field{Key: "params", Value: params},
|
|
||||||
)
|
|
||||||
var (
|
|
||||||
condis []*rtaskCondi
|
|
||||||
)
|
|
||||||
|
|
||||||
condis = this.getHandle(rtaskType)
|
|
||||||
|
|
||||||
// for _, codiConf := range this.configure.getRtaskCondis(int32(rtaskType)) {
|
|
||||||
// v, ok := this.handleMap[codiConf.Id]
|
|
||||||
// if !ok {
|
|
||||||
// this.Warn("未注册事件处理器",
|
|
||||||
// log.Field{Key: "uid", Value: uid},
|
|
||||||
// log.Field{Key: "condiId", Value: codiConf.Id},
|
|
||||||
// )
|
|
||||||
// code = pb.ErrorCode_RtaskCondiNoFound
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if v.find == nil {
|
|
||||||
// this.Warn("未设置find Handle",
|
|
||||||
// log.Field{Key: "uid", Value: uid},
|
|
||||||
// log.Field{Key: "condiId", Value: codiConf.Id},
|
|
||||||
// )
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if condiId, _ := v.find(codiConf, params...); condiId != 0 {
|
|
||||||
// v.condId = codiConf.Id
|
|
||||||
// condis = append(condis, v)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// update
|
|
||||||
for _, v := range condis {
|
|
||||||
conf, err := this.configure.getRtaskTypeById(v.condId)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("get condId conf err:%v", err)
|
|
||||||
code = pb.ErrorCode_RtaskCondiNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if v.update != nil {
|
|
||||||
if err := v.update(uid, conf, params...); err != nil {
|
|
||||||
log.Errorf("update task:%v", err)
|
|
||||||
code = pb.ErrorCode_DBError
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam) {
|
func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam) {
|
||||||
this.Debug("任务处理",
|
this.Debug("任务处理",
|
||||||
log.Field{Key: "uid", Value: uid},
|
log.Field{Key: "uid", Value: uid},
|
||||||
|
@ -17,9 +17,7 @@ func (this *apiComp) SendCheck(session comm.IUserSession, req *pb.TaskSendReq) (
|
|||||||
func (this *apiComp) Send(session comm.IUserSession, req *pb.TaskSendReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) Send(session comm.IUserSession, req *pb.TaskSendReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
if imodule, err := this.service.GetModule(comm.ModuleRtask); err == nil {
|
if imodule, err := this.service.GetModule(comm.ModuleRtask); err == nil {
|
||||||
if itask, ok := imodule.(comm.IRtask); ok {
|
if itask, ok := imodule.(comm.IRtask); ok {
|
||||||
if code = itask.SendToRtask(session, comm.TaskType(req.TaskType), req.Params...); code != pb.ErrorCode_Success {
|
itask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.TaskType(req.TaskType), req.Params...))
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCheckCond := func(nextTaskId int32) *pb.DBWorldtask {
|
updateCheckCond := func(userTask *pb.DBWorldtask, nextTaskId int32) *pb.DBWorldtask {
|
||||||
//检查下个任务的完成条件
|
//检查下个任务的完成条件
|
||||||
nextTaskConf, err := this.module.configure.getWorldtaskById(nextTaskId)
|
nextTaskConf, err := this.module.configure.getWorldtaskById(nextTaskId)
|
||||||
if err != nil || curTaskConf == nil {
|
if err != nil || curTaskConf == nil {
|
||||||
@ -85,13 +85,16 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
userTask.CurrentTask = make(map[int32]*pb.Worldtask)
|
userTask.CurrentTask = make(map[int32]*pb.Worldtask)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(nextTaskConf.Completetask) == 1 && nextTaskConf.Completetask[0] == 0 {
|
update := make(map[string]interface{})
|
||||||
|
if (len(nextTaskConf.Completetask) == 1 && nextTaskConf.Completetask[0] == 0) ||
|
||||||
|
len(nextTaskConf.Completetask) == 0 {
|
||||||
wt := &pb.Worldtask{
|
wt := &pb.Worldtask{
|
||||||
TaskId: nextTaskId,
|
TaskId: nextTaskId,
|
||||||
TaskType: nextTaskConf.Des,
|
TaskType: nextTaskConf.Des,
|
||||||
CondiIds: []int32{},
|
CondiIds: []int32{},
|
||||||
}
|
}
|
||||||
userTask.CurrentTask[nextTaskConf.Group] = wt
|
userTask.CurrentTask[nextTaskConf.Group] = wt
|
||||||
|
update["currentTask"] = userTask.CurrentTask
|
||||||
} else {
|
} else {
|
||||||
for _, condiId := range nextTaskConf.Completetask {
|
for _, condiId := range nextTaskConf.Completetask {
|
||||||
if condiId == 0 {
|
if condiId == 0 {
|
||||||
@ -106,8 +109,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
log.Field{Key: "taskId", Value: nextTaskId},
|
log.Field{Key: "taskId", Value: nextTaskId},
|
||||||
log.Field{Key: "condiId", Value: condiId},
|
log.Field{Key: "condiId", Value: condiId},
|
||||||
)
|
)
|
||||||
rsp.CondiId = condiId
|
|
||||||
rsp.TaskId = nextTaskId
|
|
||||||
} else {
|
} else {
|
||||||
nwt, ok := userTask.CurrentTask[nextTaskConf.Group]
|
nwt, ok := userTask.CurrentTask[nextTaskConf.Group]
|
||||||
if ok {
|
if ok {
|
||||||
@ -121,20 +123,20 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
userTask.CurrentTask[nextTaskConf.Group] = nwt
|
||||||
}
|
update["currentTask"] = userTask.CurrentTask
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update := map[string]interface{}{
|
}
|
||||||
"currentTask": userTask.CurrentTask,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(update) > 0 {
|
||||||
if err := this.module.modelWorldtask.Change(uid, update); err != nil {
|
if err := this.module.modelWorldtask.Change(uid, update); err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return userTask
|
return userTask
|
||||||
}
|
}
|
||||||
@ -145,9 +147,9 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe
|
|||||||
|
|
||||||
nextTask := make(map[int32]*pb.Worldtask)
|
nextTask := make(map[int32]*pb.Worldtask)
|
||||||
for _, next := range nextTaskIds {
|
for _, next := range nextTaskIds {
|
||||||
userTask = updateCheckCond(next)
|
ut := updateCheckCond(userTask, next)
|
||||||
if userTask != nil {
|
if ut != nil {
|
||||||
for k, v := range userTask.CurrentTask {
|
for k, v := range ut.CurrentTask {
|
||||||
nextTask[k] = &pb.Worldtask{
|
nextTask[k] = &pb.Worldtask{
|
||||||
TaskId: v.TaskId,
|
TaskId: v.TaskId,
|
||||||
}
|
}
|
||||||
|
42
sys/configure/structs/Game.SellCoefficient.go
Normal file
42
sys/configure/structs/Game.SellCoefficient.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package cfg
|
||||||
|
|
||||||
|
type GameSellCoefficient struct {
|
||||||
|
_dataMap map[int32]*GameSellCoefficientData
|
||||||
|
_dataList []*GameSellCoefficientData
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGameSellCoefficient(_buf []map[string]interface{}) (*GameSellCoefficient, error) {
|
||||||
|
_dataList := make([]*GameSellCoefficientData, 0, len(_buf))
|
||||||
|
dataMap := make(map[int32]*GameSellCoefficientData)
|
||||||
|
for _, _ele_ := range _buf {
|
||||||
|
if _v, err2 := DeserializeGameSellCoefficientData(_ele_); err2 != nil {
|
||||||
|
return nil, err2
|
||||||
|
} else {
|
||||||
|
_dataList = append(_dataList, _v)
|
||||||
|
dataMap[_v.Character] = _v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &GameSellCoefficient{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (table *GameSellCoefficient) GetDataMap() map[int32]*GameSellCoefficientData {
|
||||||
|
return table._dataMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func (table *GameSellCoefficient) GetDataList() []*GameSellCoefficientData {
|
||||||
|
return table._dataList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (table *GameSellCoefficient) Get(key int32) *GameSellCoefficientData {
|
||||||
|
return table._dataMap[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
37
sys/configure/structs/Game.SellCoefficientData.go
Normal file
37
sys/configure/structs/Game.SellCoefficientData.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package cfg
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
type GameSellCoefficientData struct {
|
||||||
|
Character int32
|
||||||
|
Coefficient int32
|
||||||
|
}
|
||||||
|
|
||||||
|
const TypeId_GameSellCoefficientData = 46519505
|
||||||
|
|
||||||
|
func (*GameSellCoefficientData) GetTypeId() int32 {
|
||||||
|
return 46519505
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_v *GameSellCoefficientData)Deserialize(_buf map[string]interface{}) (err error) {
|
||||||
|
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["character"].(float64); !_ok_ { err = errors.New("character error"); return }; _v.Character = int32(_tempNum_) }
|
||||||
|
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["coefficient"].(float64); !_ok_ { err = errors.New("coefficient error"); return }; _v.Coefficient = int32(_tempNum_) }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeserializeGameSellCoefficientData(_buf map[string]interface{}) (*GameSellCoefficientData, error) {
|
||||||
|
v := &GameSellCoefficientData{}
|
||||||
|
if err := v.Deserialize(_buf); err == nil {
|
||||||
|
return v, nil
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user