diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index 24d9e8c6d..8fbcece0d 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -30,7 +30,8 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) equipStr map[int32]int32 = make(map[int32]int32) equipLv map[int32]int32 = make(map[int32]int32) hero *pb.DBHero - suite1Str, suite1Lv, suite2Str, suite2Lv int32 = math.MaxInt32, math.MaxInt32, math.MaxInt32, math.MaxInt32 + suite1Str, suite1Lv, suite2Str, suite2Lv int32 = math.MaxInt32, math.MaxInt32, math.MaxInt32, math.MaxInt32 + tasks []*comm.TaskParam = make([]*comm.TaskParam, 0) ) if code = this.EquipCheck(session, req); code != pb.ErrorCode_Success { @@ -168,20 +169,31 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) code = pb.ErrorCode_SystemError return } - this.module.ModuleRtask.SendToRtask(session, comm.Rtype5, utils.ToInt32(hero.HeroID), equipNum) + tasks = append(tasks, comm.GettaskParam(comm.Rtype5, 1, utils.ToInt32(hero.HeroID), equipNum)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype5, utils.ToInt32(hero.HeroID), equipNum) for k, v := range equipStr { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype41, utils.ToInt32(hero.HeroID), v, k) + tasks = append(tasks, comm.GettaskParam(comm.Rtype41, 1, utils.ToInt32(hero.HeroID), v, k)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype41, utils.ToInt32(hero.HeroID), v, k) } for k, v := range equipLv { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype42, utils.ToInt32(hero.HeroID), v, k) + tasks = append(tasks, comm.GettaskParam(comm.Rtype42, 1, utils.ToInt32(hero.HeroID), v, k)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype42, utils.ToInt32(hero.HeroID), v, k) } if hero.SuiteId != 0 { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype49, 1, hero.Suite1Star, hero.Suite1Lv) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype98, 1, hero.Suite1Lv) + tasks = append(tasks, comm.GettaskParam(comm.Rtype49, 1, hero.Suite1Star, hero.Suite1Lv)) + tasks = append(tasks, comm.GettaskParam(comm.Rtype98, 1, hero.Suite1Lv)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype49, 1, hero.Suite1Star, hero.Suite1Lv) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype98, 1, hero.Suite1Lv) } if hero.SuiteExtId != 0 { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype48, 1, hero.Suite2Star, hero.Suite2Lv) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype98, 1, hero.Suite1Lv) + tasks = append(tasks, comm.GettaskParam(comm.Rtype48, 1, hero.Suite2Star, hero.Suite2Lv)) + tasks = append(tasks, comm.GettaskParam(comm.Rtype98, 1, hero.Suite1Lv)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype48, 1, hero.Suite2Star, hero.Suite2Lv) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype98, 1, hero.Suite1Lv) + } + + if len(tasks) > 0 { + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) } session.SendMsg(string(this.module.GetType()), "equip", &pb.EquipmentEquipResp{Equipments: updatequipment}) diff --git a/modules/equipment/api_upgrade.go b/modules/equipment/api_upgrade.go index 83fb9a976..284c4b506 100644 --- a/modules/equipment/api_upgrade.go +++ b/modules/equipment/api_upgrade.go @@ -36,6 +36,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade issucc bool suite1Lv, suite2Lv int32 = math.MaxInt32, math.MaxInt32 user *pb.DBUser + tasks []*comm.TaskParam = make([]*comm.TaskParam, 0) ) if code = this.UpgradeCheck(session, req); code != pb.ErrorCode_Success { return @@ -169,21 +170,28 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade if hero.SuiteId != 0 { hero.Suite1Lv = suite1Lv - this.module.ModuleRtask.SendToRtask(session, comm.Rtype49, 1, hero.Suite1Star, hero.Suite1Lv) + tasks = append(tasks, comm.GettaskParam(comm.Rtype49, 1, hero.Suite1Star, hero.Suite1Lv)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype49, 1, hero.Suite1Star, hero.Suite1Lv) } if hero.SuiteExtId != 0 { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype48, 1, hero.Suite2Star, hero.Suite2Lv) + tasks = append(tasks, comm.GettaskParam(comm.Rtype48, 1, hero.Suite2Star, hero.Suite2Lv)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype48, 1, hero.Suite2Star, hero.Suite2Lv) } code = this.module.ModuleHero.UpdateEquipment(session, hero, equipments) } //随机任务触发 - this.module.ModuleRtask.SendToRtask(session, comm.Rtype43, 1, equipment.Lv) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype44, equipment.Lv) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype47, 1) + tasks = append(tasks, comm.GettaskParam(comm.Rtype43, 1, equipment.Lv)) + tasks = append(tasks, comm.GettaskParam(comm.Rtype44, 1, equipment.Lv)) + tasks = append(tasks, comm.GettaskParam(comm.Rtype47, 1)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype43, 1, equipment.Lv) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype44, equipment.Lv) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype47, 1) if conf.Pos == 7 { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype102, 1) + tasks = append(tasks, comm.GettaskParam(comm.Rtype102, 1)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype102, 1) } else if conf.Pos == 6 { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype100, 1) + tasks = append(tasks, comm.GettaskParam(comm.Rtype100, 1)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype100, 1) } //聊天系统通知 if user = this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { @@ -197,7 +205,11 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade this.module.Errorf("no found userdata uid:%s", session.GetUserId()) } } else { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype96, 1) + tasks = append(tasks, comm.GettaskParam(comm.Rtype96, 1)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype96, 1) + } + if len(tasks) > 0 { + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) } session.SendMsg(string(this.module.GetType()), "upgrade", &pb.EquipmentUpgradeResp{IsSucc: issucc, Equipment: modifyequipments}) return diff --git a/modules/equipment/modelEquipment.go b/modules/equipment/modelEquipment.go index 43623423a..c70dcf7b9 100644 --- a/modules/equipment/modelEquipment.go +++ b/modules/equipment/modelEquipment.go @@ -96,8 +96,8 @@ func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds ma var ( configure *cfg.GameEquip add map[string]*pb.DB_Equipment - uId string = session.GetUserId() - tasks []*comm.TaskParam + uId string = session.GetUserId() + tasks []*comm.TaskParam = make([]*comm.TaskParam, 0) ) if configure, err = this.module.configure.GetEquipmentConfigure(); err != nil { return diff --git a/modules/items/api_getlist.go b/modules/items/api_getlist.go index 28db88cdf..e15951b91 100644 --- a/modules/items/api_getlist.go +++ b/modules/items/api_getlist.go @@ -20,7 +20,6 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq) err error items []*pb.DB_UserItemData nt int64 - // tempgrids []*pb.DB_UserItemData grids []*pb.DB_UserItemData modifys []*pb.DB_UserItemData dels []*pb.DB_UserItemData diff --git a/modules/items/api_useItem.go b/modules/items/api_useItem.go index 66aa7d5a7..537b6b78e 100644 --- a/modules/items/api_useItem.go +++ b/modules/items/api_useItem.go @@ -61,8 +61,10 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq) } //随机任务 - this.module.ModuleRtask.SendToRtask(session, comm.Rtype22, 1) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype22, utils.ToInt32(sale.Prize[0].T)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype21, 1) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype22, utils.ToInt32(sale.Prize[0].T)) + this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype21, 1), comm.GettaskParam(comm.Rtype22, utils.ToInt32(sale.Prize[0].T))) + case 4: //自选宝箱 if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil { code = pb.ErrorCode_ConfigNoFound diff --git a/modules/shop/api_buy.go b/modules/shop/api_buy.go index 252595936..58dc0a6cf 100644 --- a/modules/shop/api_buy.go +++ b/modules/shop/api_buy.go @@ -28,6 +28,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (code pb record *pb.UserShopData need []*cfg.Gameatn give []*cfg.Gameatn + tasks []*comm.TaskParam = make([]*comm.TaskParam, 0) ) if code = this.BuyCheck(session, req); code != pb.ErrorCode_Success { return @@ -117,18 +118,26 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (code pb } //随机任务 - this.module.ModuleRtask.SendToRtask(session, comm.Rtype64, 1) + tasks = append(tasks, comm.GettaskParam(comm.Rtype64, 1)) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype64, 1) for _, v := range give { if v.A == comm.ItemType { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype65, v.N, utils.ToInt32(v.T)) + tasks = append(tasks, comm.GettaskParam(comm.Rtype65, v.N, utils.ToInt32(v.T))) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype65, v.N, utils.ToInt32(v.T)) } } - this.module.ModuleRtask.SendToRtask(session, comm.Rtype66, 1, int32(req.ShopType)) + tasks = append(tasks, comm.GettaskParam(comm.Rtype66, 1, int32(req.ShopType))) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype66, 1, int32(req.ShopType)) for _, v := range need { if v.A == comm.AttrType && (v.T == comm.ResGold || v.T == comm.ResDiamond) { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype67, v.N, utils.ToInt32(v.T)) + tasks = append(tasks, comm.GettaskParam(comm.Rtype67, v.N, utils.ToInt32(v.T))) + // this.module.ModuleRtask.SendToRtask(session, comm.Rtype67, v.N, utils.ToInt32(v.T)) } } + if len(tasks) > 0 { + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) + } + session.SendMsg(string(this.module.GetType()), "buy", &pb.ShopBuyResp{IsSucc: true}) return }