上传模块接口同步
This commit is contained in:
parent
8109ffe81d
commit
69d8663f90
@ -9,7 +9,7 @@ import (
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
type (
|
type (
|
||||||
IModuleCallSource struct {
|
ModuleCallSource struct {
|
||||||
Module string //来源模块
|
Module string //来源模块
|
||||||
FuncName string //来源方法
|
FuncName string //来源方法
|
||||||
Describe string //调用描述
|
Describe string //调用描述
|
||||||
@ -22,13 +22,13 @@ type (
|
|||||||
//道具背包接口
|
//道具背包接口
|
||||||
IItems interface {
|
IItems interface {
|
||||||
//查询用户背包物品数量
|
//查询用户背包物品数量
|
||||||
QueryItemAmount(uId string, itemid int32) (amount uint32)
|
QueryItemAmount(source *ModuleCallSource, uId string, itemid int32) (amount uint32)
|
||||||
//查询用户背包多个物品数量
|
//查询用户背包多个物品数量
|
||||||
QueryItemsAmount(uId string, itemid ...int32) (result map[int32]uint32)
|
QueryItemsAmount(source *ModuleCallSource, uId string, itemid ...int32) (result map[int32]uint32)
|
||||||
///添加单个物品到背包 (可以加物品和减物品)
|
///添加单个物品到背包 (可以加物品和减物品)
|
||||||
AddItem(uId string, itemid, addnum int32) (code pb.ErrorCode)
|
AddItem(source *ModuleCallSource, uId string, itemid, addnum int32) (code pb.ErrorCode)
|
||||||
///添加多个物品到背包 (可以加物品和减物品)
|
///添加多个物品到背包 (可以加物品和减物品)
|
||||||
AddItems(uId string, items map[int32]int32) (code pb.ErrorCode)
|
AddItems(source *ModuleCallSource, uId string, items map[int32]int32) (code pb.ErrorCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
//英雄
|
//英雄
|
||||||
@ -59,10 +59,10 @@ type (
|
|||||||
//武器模块
|
//武器模块
|
||||||
IEquipment interface {
|
IEquipment interface {
|
||||||
//查询服务资源数量 db id
|
//查询服务资源数量 db id
|
||||||
QueryEquipment(uid string, Id int32) (equipment pb.DB_Equipment, code pb.ErrorCode)
|
QueryEquipment(source *ModuleCallSource, uid string, Id int32) (equipment pb.DB_Equipment, code pb.ErrorCode)
|
||||||
//查询服务资源数量 参数武器配置id
|
//查询服务资源数量 参数武器配置id
|
||||||
QueryEquipmentAmount(uid string, equipmentId int32) (amount uint32)
|
QueryEquipmentAmount(source *ModuleCallSource, uid string, equipmentId int32) (amount uint32)
|
||||||
//新加武器
|
//新加武器
|
||||||
AddNewEquipments(uid string, eid int, add int32) (code pb.ErrorCode)
|
AddNewEquipments(source *ModuleCallSource, uid string, eid int, add int32) (code pb.ErrorCode)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -48,7 +48,7 @@ func (this *Items) OnInstallComp() {
|
|||||||
|
|
||||||
//IPack-------------------------------------------------------------------------------------------------------------------------------
|
//IPack-------------------------------------------------------------------------------------------------------------------------------
|
||||||
///查询用户背包物品数量
|
///查询用户背包物品数量
|
||||||
func (this *Items) QueryUserItemAmount(uId string, itemid int32) (amount uint32) {
|
func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, itemid int32) (amount uint32) {
|
||||||
defer log.Debugf("获取物品 uId:%s itemid:%d addnum:%d ", uId, itemid, amount)
|
defer log.Debugf("获取物品 uId:%s itemid:%d addnum:%d ", uId, itemid, amount)
|
||||||
amount = 0
|
amount = 0
|
||||||
if result := this.model_pack_comp.Pack_QueryUserPackItemsAmount(uId, itemid); result != nil && len(result) > 0 {
|
if result := this.model_pack_comp.Pack_QueryUserPackItemsAmount(uId, itemid); result != nil && len(result) > 0 {
|
||||||
@ -58,13 +58,13 @@ func (this *Items) QueryUserItemAmount(uId string, itemid int32) (amount uint32)
|
|||||||
}
|
}
|
||||||
|
|
||||||
///查询用户背包多个物品数量
|
///查询用户背包多个物品数量
|
||||||
func (this *Items) QueryUserItemsAmount(uId string, itemid ...int32) (result map[int32]uint32) {
|
func (this *Items) QueryItemsAmount(source *comm.ModuleCallSource, uId string, itemid ...int32) (result map[int32]uint32) {
|
||||||
result = this.model_pack_comp.Pack_QueryUserPackItemsAmount(uId, itemid...)
|
result = this.model_pack_comp.Pack_QueryUserPackItemsAmount(uId, itemid...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
///添加单个物品到背包 (可以加物品和减物品)
|
///添加单个物品到背包 (可以加物品和减物品)
|
||||||
func (this *Items) AddItem(uId string, itemid, addnum int32) (code pb.ErrorCode) {
|
func (this *Items) AddItem(source *comm.ModuleCallSource, uId string, itemid, addnum int32) (code pb.ErrorCode) {
|
||||||
var err error
|
var err error
|
||||||
defer log.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil)
|
defer log.Debugf("给用户添加物品 uId:%s itemid:%d addnum:%d issucc:%v", uId, itemid, addnum, err == nil)
|
||||||
if err = this.model_pack_comp.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil {
|
if err = this.model_pack_comp.Pack_AddItemToUserPack(uId, itemid, addnum); err != nil {
|
||||||
@ -81,7 +81,7 @@ func (this *Items) AddItem(uId string, itemid, addnum int32) (code pb.ErrorCode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
///添加多个物品到背包 (可以加物品和减物品)
|
///添加多个物品到背包 (可以加物品和减物品)
|
||||||
func (this *Items) AddItems(uId string, items map[int32]int32) (code pb.ErrorCode) {
|
func (this *Items) AddItems(source *comm.ModuleCallSource, uId string, items map[int32]int32) (code pb.ErrorCode) {
|
||||||
var err error
|
var err error
|
||||||
defer log.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil)
|
defer log.Debugf("给用户添加物品 uId:%s items:%d items:%v", uId, items, err == nil)
|
||||||
if err = this.model_pack_comp.Pack_AddItemsToUserPack(uId, items); err != nil {
|
if err = this.model_pack_comp.Pack_AddItemsToUserPack(uId, items); err != nil {
|
||||||
|
@ -35,7 +35,11 @@ func (this *Api_Comp) GetUserMailAttachment(session comm.IUserSession, agrs map[
|
|||||||
for _, v := range _data {
|
for _, v := range _data {
|
||||||
_items[int32(v.ItemId)] += int32(v.ItemCount)
|
_items[int32(v.ItemId)] += int32(v.ItemCount)
|
||||||
}
|
}
|
||||||
code = this.items.AddItems(mail.Uid, _items)
|
code = this.items.AddItems(&comm.ModuleCallSource{
|
||||||
|
Module: string(this.module.GetType()),
|
||||||
|
FuncName: "GetUserMailAttachment",
|
||||||
|
Describe: "领取附件",
|
||||||
|
}, mail.Uid, _items)
|
||||||
if code == pb.ErrorCode_Success {
|
if code == pb.ErrorCode_Success {
|
||||||
// 修改状态
|
// 修改状态
|
||||||
this.module.db_comp.Mail_UpdateMailAttachmentState(req.ObjID)
|
this.module.db_comp.Mail_UpdateMailAttachmentState(req.ObjID)
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
*/
|
*/
|
||||||
type ModuleBase struct {
|
type ModuleBase struct {
|
||||||
cbase.ModuleBase
|
cbase.ModuleBase
|
||||||
|
module core.IModule
|
||||||
service base.IRPCXService
|
service base.IRPCXService
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ type ModuleBase struct {
|
|||||||
func (this *ModuleBase) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
func (this *ModuleBase) 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.module = module
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +104,11 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p
|
|||||||
if module, err = this.service.GetModule(comm.SM_UserModule); err == nil {
|
if module, err = this.service.GetModule(comm.SM_UserModule); err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
source := &comm.ModuleCallSource{
|
||||||
|
Module: string(this.module.GetType()),
|
||||||
|
FuncName: "CheckConsumeRes",
|
||||||
|
Describe: "消耗资源",
|
||||||
|
}
|
||||||
equipment = module.(comm.IEquipment)
|
equipment = module.(comm.IEquipment)
|
||||||
//校验消费资源是否充足
|
//校验消费资源是否充足
|
||||||
for _, v := range res {
|
for _, v := range res {
|
||||||
@ -115,7 +122,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p
|
|||||||
code = pb.ErrorCode_ConfigurationException
|
code = pb.ErrorCode_ConfigurationException
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if amount = int32(items.QueryItemAmount(uid, int32(resID))); amount < v.N {
|
if amount = int32(items.QueryItemAmount(source, uid, int32(resID))); amount < v.N {
|
||||||
code = pb.ErrorCode_ResNoEnough
|
code = pb.ErrorCode_ResNoEnough
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -133,7 +140,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p
|
|||||||
code = pb.ErrorCode_ConfigurationException
|
code = pb.ErrorCode_ConfigurationException
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if amount = int32(equipment.QueryEquipmentAmount(uid, int32(resID))); amount < v.N {
|
if amount = int32(equipment.QueryEquipmentAmount(source, uid, int32(resID))); amount < v.N {
|
||||||
code = pb.ErrorCode_ResNoEnough
|
code = pb.ErrorCode_ResNoEnough
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -145,13 +152,13 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p
|
|||||||
user.AddAttributeValue(uid, v.T, -1*v.N)
|
user.AddAttributeValue(uid, v.T, -1*v.N)
|
||||||
} else if v.A == comm.ItemType { //道具资源
|
} else if v.A == comm.ItemType { //道具资源
|
||||||
resID, _ = strconv.Atoi(v.T)
|
resID, _ = strconv.Atoi(v.T)
|
||||||
items.AddItem(uid, int32(resID), -1*v.N)
|
items.AddItem(source, uid, int32(resID), -1*v.N)
|
||||||
} else if v.A == comm.CardType { //卡片资源
|
} else if v.A == comm.CardType { //卡片资源
|
||||||
resID, _ = strconv.Atoi(v.T)
|
resID, _ = strconv.Atoi(v.T)
|
||||||
hero.AddCard(uid, int32(resID), -1*v.N)
|
hero.AddCard(uid, int32(resID), -1*v.N)
|
||||||
} else if v.A == comm.EquipmentType {
|
} else if v.A == comm.EquipmentType {
|
||||||
resID, _ = strconv.Atoi(v.T)
|
resID, _ = strconv.Atoi(v.T)
|
||||||
equipment.AddNewEquipments(uid, resID, -1*v.N)
|
equipment.AddNewEquipments(source, uid, resID, -1*v.N)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user