diff --git a/bin/json/game_sellcoefficient.json b/bin/json/game_sellcoefficient.json new file mode 100644 index 000000000..34a36df15 --- /dev/null +++ b/bin/json/game_sellcoefficient.json @@ -0,0 +1,22 @@ +[ + { + "character": 1, + "coefficient": 1000 + }, + { + "character": 2, + "coefficient": 1200 + }, + { + "character": 3, + "coefficient": 1500 + }, + { + "character": 4, + "coefficient": 2000 + }, + { + "character": 5, + "coefficient": 3000 + } +] \ No newline at end of file diff --git a/comm/imodule.go b/comm/imodule.go index 7aa497aaa..7cc95747f 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -211,8 +211,6 @@ type ( RemoveCondi(uid string, condiId int32) 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) // 获取任务条件记录 diff --git a/modules/equipment/configure.go b/modules/equipment/configure.go index e096f971d..9733f8c97 100644 --- a/modules/equipment/configure.go +++ b/modules/equipment/configure.go @@ -18,6 +18,8 @@ const ( game_equipcompose = "game_equipcompose.json" //装备锻造 game_equipattribute = "game_equipattribute.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_equipattribute, cfg.NewGameEquipAttribute) this.LoadConfigure(game_equipenchanting, cfg.NewGameEquipEnchanting) + this.LoadConfigure(game_sellcoefficient, cfg.NewGameSellCoefficient) configure.RegisterConfigure(game_equip, cfg.NewGameEquip, func() { this.equiplock.Lock() if v, err := this.GetConfigure(game_equip); err != nil { @@ -282,7 +285,24 @@ func (this *configureComp) getEquipenchanting(id string) (result *cfg.GameEquipE } else { if result, ok = v.(*cfg.GameEquipEnchanting).GetDataMap()[id]; !ok { err = fmt.Errorf("on found getEquipenchanting id:%s", id) - this.module.Errorf("err:%v", err) + 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) + return + } else { + if result, ok = v.(*cfg.GameSellCoefficient).GetDataMap()[id]; !ok { + err = fmt.Errorf("on found getSellcoefficient id:%d", id) return } } diff --git a/modules/equipment/module.go b/modules/equipment/module.go index f2545feee..63f373f96 100644 --- a/modules/equipment/module.go +++ b/modules/equipment/module.go @@ -235,6 +235,7 @@ func (this *Equipment) RecycleEquipments(session comm.IUserSession, equs []strin var ( err error equipments []*pb.DB_Equipment + sellconf *cfg.GameSellCoefficientData confs []*cfg.GameEquipData 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 { this.Errorln(err) - code = pb.ErrorCode_EquipmentOnFoundEquipment + code = pb.ErrorCode_ConfigNoFound return } if confs[i].SmithySale == nil || len(confs[i].SmithySale) == 0 { code = pb.ErrorCode_EquipmentNoCanSell 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)) for n, s := range confs[i].SmithySale { _s := &cfg.Gameatn{ A: s.A, 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 } diff --git a/modules/pvp/module.go b/modules/pvp/module.go index ac6119bc0..dfddca3eb 100644 --- a/modules/pvp/module.go +++ b/modules/pvp/module.go @@ -228,7 +228,20 @@ func (this *Pvp) readyTimeOut(task *timewheel.Task, args ...interface{}) { }, battle.RedSession, battle.BlueSession); err != nil { 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 + } + } } diff --git a/modules/rtask/model_rtask.go b/modules/rtask/model_rtask.go index 544ab37f7..c5d7712bc 100644 --- a/modules/rtask/model_rtask.go +++ b/modules/rtask/model_rtask.go @@ -94,8 +94,12 @@ func (this *ModelRtask) checkCondi(uid string, condiId int32) (err error, ok boo var condi *rtaskCondi cond, ok := this.moduleRtask.handleMap.Load(condiId) if !ok { - errors.Errorf("condiID: %v handle no found", condiId) - return + rcs := this.moduleRtask.getHandle(comm.TaskType(conf.Type)) + for _, v:=range rcs { + if v.condId == condiId { + cond = v + } + } } if condi, ok = cond.(*rtaskCondi); !ok { diff --git a/modules/rtask/module.go b/modules/rtask/module.go index cbf07b1a7..406c94666 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -45,9 +45,7 @@ type ModuleRtask struct { } func NewModule() core.IModule { - return &ModuleRtask{ - // handleMap: make(map[int32]*rtaskCondi), - } + return &ModuleRtask{} } 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) { err = this.ModuleBase.Init(service, module, options) this.service = service.(base.IRPCXService) - // this.initRtaskVerifyHandle() return } func (this *ModuleRtask) Start() (err error) { @@ -260,145 +257,6 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { 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) { uid := session.GetUserId() @@ -481,80 +339,6 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com 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) { this.Debug("任务处理", log.Field{Key: "uid", Value: uid}, diff --git a/modules/task/api_send.go b/modules/task/api_send.go index 8c46cfcdc..3091f5fdc 100644 --- a/modules/task/api_send.go +++ b/modules/task/api_send.go @@ -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) { if imodule, err := this.service.GetModule(comm.ModuleRtask); err == nil { if itask, ok := imodule.(comm.IRtask); ok { - if code = itask.SendToRtask(session, comm.TaskType(req.TaskType), req.Params...); code != pb.ErrorCode_Success { - return - } + itask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.TaskType(req.TaskType), req.Params...)) } } diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index ff9900e83..8f69b0813 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -70,7 +70,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe return } - updateCheckCond := func(nextTaskId int32) *pb.DBWorldtask { + updateCheckCond := func(userTask *pb.DBWorldtask, nextTaskId int32) *pb.DBWorldtask { //检查下个任务的完成条件 nextTaskConf, err := this.module.configure.getWorldtaskById(nextTaskId) 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) } - 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{ TaskId: nextTaskId, TaskType: nextTaskConf.Des, CondiIds: []int32{}, } userTask.CurrentTask[nextTaskConf.Group] = wt + update["currentTask"] = userTask.CurrentTask } else { for _, condiId := range nextTaskConf.Completetask { if condiId == 0 { @@ -105,9 +108,8 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe log.Field{Key: "uid", Value: uid}, log.Field{Key: "taskId", Value: nextTaskId}, log.Field{Key: "condiId", Value: condiId}, - ) - rsp.CondiId = condiId - rsp.TaskId = nextTaskId + ) + } else { nwt, ok := userTask.CurrentTask[nextTaskConf.Group] if ok { @@ -121,19 +123,19 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe } } userTask.CurrentTask[nextTaskConf.Group] = nwt + update["currentTask"] = userTask.CurrentTask } } } + } } - update := map[string]interface{}{ - "currentTask": userTask.CurrentTask, - } - - if err := this.module.modelWorldtask.Change(uid, update); err != nil { - code = pb.ErrorCode_DBError - return nil + if len(update) > 0 { + if err := this.module.modelWorldtask.Change(uid, update); err != nil { + code = pb.ErrorCode_DBError + return nil + } } return userTask @@ -145,9 +147,9 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe nextTask := make(map[int32]*pb.Worldtask) for _, next := range nextTaskIds { - userTask = updateCheckCond(next) - if userTask != nil { - for k, v := range userTask.CurrentTask { + ut := updateCheckCond(userTask, next) + if ut != nil { + for k, v := range ut.CurrentTask { nextTask[k] = &pb.Worldtask{ TaskId: v.TaskId, } diff --git a/sys/configure/structs/Game.SellCoefficient.go b/sys/configure/structs/Game.SellCoefficient.go new file mode 100644 index 000000000..3f35471ef --- /dev/null +++ b/sys/configure/structs/Game.SellCoefficient.go @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +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] +} + + diff --git a/sys/configure/structs/Game.SellCoefficientData.go b/sys/configure/structs/Game.SellCoefficientData.go new file mode 100644 index 000000000..b63c7a25f --- /dev/null +++ b/sys/configure/structs/Game.SellCoefficientData.go @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +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 + } +}