上传接口调整
This commit is contained in:
parent
9c0eb14e76
commit
82bf9f6d26
@ -161,7 +161,7 @@ func (c *ConnServiceImpl) ReceiveMsg() (errdata *pb.ErrorData, msg *pb.UserMessa
|
||||
}
|
||||
|
||||
// err notify
|
||||
func (c *ConnServiceImpl) handleNotify(msg *pb.UserMessage) (code pb.ErrorCode) {
|
||||
func (c *ConnServiceImpl) handleNotify(msg *pb.UserMessage) (errdata *pb.ErrorData) {
|
||||
if msg.MainType == "notify" && msg.SubType == "errornotify" {
|
||||
rsp := &pb.NotifyErrorNotifyPush{}
|
||||
if !comm.ProtoUnmarshal(msg, rsp) {
|
||||
|
@ -17,8 +17,8 @@ var (
|
||||
)
|
||||
|
||||
type PttService interface {
|
||||
Login(sid, account string) (code pb.ErrorCode)
|
||||
CreateRole(nickName string, gender, figure int32) (code pb.ErrorCode)
|
||||
Login(sid, account string) (errdata *pb.ErrorData)
|
||||
CreateRole(nickName string, gender, figure int32) (errdata *pb.ErrorData)
|
||||
GetUser() *UserInfo
|
||||
SetUser(dbUser *pb.DBUser, dbUserExpand *pb.DBUserExpand)
|
||||
SendToClient(mainType, subType string, rsp proto.Message) error
|
||||
@ -70,7 +70,7 @@ func (p *PttServiceImpl) SendToClient(mainType, subType string, rsp proto.Messag
|
||||
}
|
||||
|
||||
// Login
|
||||
func (p *PttServiceImpl) Login(sid, account string) (code pb.ErrorCode) {
|
||||
func (p *PttServiceImpl) Login(sid, account string) (errdata *pb.ErrorData) {
|
||||
head := &pb.UserMessage{MainType: string(comm.ModuleUser), SubType: user.UserSubTypeLogin}
|
||||
head.Sec = common.BuildSecStr(sid, account)
|
||||
req := &pb.UserLoginReq{
|
||||
@ -104,7 +104,7 @@ func (p *PttServiceImpl) Ping(sid, account string) {
|
||||
}
|
||||
|
||||
// create role
|
||||
func (p *PttServiceImpl) CreateRole(nickName string, gender, figure int32) (code pb.ErrorCode) {
|
||||
func (p *PttServiceImpl) CreateRole(nickName string, gender, figure int32) (errdata *pb.ErrorData) {
|
||||
head := &pb.UserMessage{MainType: string(comm.ModuleUser), SubType: user.UserSubTypeCreate}
|
||||
head.Sec = common.BuildSecStr(p.user.DbUser.Sid, p.user.DbUser.Binduid)
|
||||
if err := p.connService.SendMsg(head, &pb.UserCreateReq{
|
||||
|
@ -16,7 +16,7 @@ func (e *CustomError) Error() string {
|
||||
return e.Code.String()
|
||||
}
|
||||
|
||||
func NewCustomError(code pb.ErrorCode) error {
|
||||
func NewCustomError(errdata *pb.ErrorData) error {
|
||||
// 初次调用得用Wrap方法,进行实例化
|
||||
return errors.Wrap(&CustomError{
|
||||
Code: code,
|
||||
|
100
comm/imodule.go
100
comm/imodule.go
@ -30,7 +30,7 @@ type (
|
||||
|
||||
type (
|
||||
ISys interface {
|
||||
IsAccess(funcName string, uid string) (code pb.ErrorCode)
|
||||
IsAccess(funcName string, uid string) (errdata *pb.ErrorData)
|
||||
ValidCond(uid string, conf *cfg.GameOpencondData) string
|
||||
CheckLvUpCond(session IUserSession, lv int32)
|
||||
CheckTaskCond(session IUserSession, id int32)
|
||||
@ -51,19 +51,19 @@ type (
|
||||
//查询用户背包多个物品数量
|
||||
QueryItemsAmount(uId string, itemid ...string) (result map[string]uint32)
|
||||
///添加单个物品到背包 (可以加物品和减物品)
|
||||
AddItem(session IUserSession, itemid string, addnum int32, bPush bool) (code pb.ErrorCode)
|
||||
AddItem(session IUserSession, itemid string, addnum int32, bPush bool) (errdata *pb.ErrorData)
|
||||
///添加多个物品到背包 (可以加物品和减物品)
|
||||
AddItems(session IUserSession, items map[string]int32, bPush bool) (change []*pb.DB_UserItemData, code pb.ErrorCode)
|
||||
AddItems(session IUserSession, items map[string]int32, bPush bool) (change []*pb.DB_UserItemData, errdata *pb.ErrorData)
|
||||
///清理道具
|
||||
CleanItems(session IUserSession) (code pb.ErrorCode)
|
||||
CleanItems(session IUserSession) (errdata *pb.ErrorData)
|
||||
///购买统一入场券
|
||||
BuyUnifiedTicket(session IUserSession, buynum int32) (code pb.ErrorCode)
|
||||
BuyUnifiedTicket(session IUserSession, buynum int32) (errdata *pb.ErrorData)
|
||||
///刷新恢复入场券
|
||||
RecoverTicket(session IUserSession) (code pb.ErrorCode)
|
||||
RecoverTicket(session IUserSession) (errdata *pb.ErrorData)
|
||||
//出售道具
|
||||
SellItem(session IUserSession, items map[string]int32, bPush bool) (errdata *pb.ErrorData, atno []*pb.UserAtno)
|
||||
|
||||
CleanItemById(session IUserSession, t string) (code pb.ErrorCode)
|
||||
CleanItemById(session IUserSession, t string) (errdata *pb.ErrorData)
|
||||
}
|
||||
|
||||
//英雄
|
||||
@ -72,22 +72,22 @@ type (
|
||||
QueryHeroByConfId(uId string, heroCfgId string) (hero *pb.DBHero)
|
||||
|
||||
// 批量创建英雄
|
||||
CreateRepeatHeros(session IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, atno []*pb.UserAtno, code pb.ErrorCode)
|
||||
CreateRepeatHeros(session IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData)
|
||||
// 获取英雄
|
||||
// heroId 英雄ID
|
||||
GetHeroByObjID(uid, heroId string) (*pb.DBHero, pb.ErrorCode)
|
||||
GetHeroByObjID(uid, heroId string) (hero *pb.DBHero, errdata *pb.ErrorData)
|
||||
// 佩戴装备
|
||||
UpdateEquipment(session IUserSession, hero *pb.DBHero, equip []*pb.DB_Equipment) (code pb.ErrorCode)
|
||||
UpdateEquipment(session IUserSession, hero *pb.DBHero, equip []*pb.DB_Equipment) (errdata *pb.ErrorData)
|
||||
//获取玩家英雄列表
|
||||
GetHeroList(uid string) []*pb.DBHero
|
||||
//清理玩家英雄数据
|
||||
CleanData(uid string)
|
||||
// 获取指定星级等级的英雄
|
||||
GetSpecifiedHero(session IUserSession, heroConfId string, star, lv int32) (code pb.ErrorCode)
|
||||
GetSpecifiedHero(session IUserSession, heroConfId string, star, lv int32) (errdata *pb.ErrorData)
|
||||
// 英雄加经验
|
||||
AddHeroExp(session IUserSession, heroObjID string, exp int32) (curAddExp int32, code pb.ErrorCode)
|
||||
AddHeroExp(session IUserSession, heroObjID string, exp int32) (curAddExp int32, errdata *pb.ErrorData)
|
||||
// 英雄练功
|
||||
KungFuHero(session IUserSession, heroObjID string, bKongfu bool, kongfuUid string) (code pb.ErrorCode)
|
||||
KungFuHero(session IUserSession, heroObjID string, bKongfu bool, kongfuUid string) (errdata *pb.ErrorData)
|
||||
|
||||
//Create Monster
|
||||
CreateMonster(heroCid string, star, lv int32) (hero *pb.DBHero)
|
||||
@ -112,10 +112,10 @@ type (
|
||||
CheckJuexingHeroNum(uid string, juexingLv int32, star int32) int32
|
||||
|
||||
// 获取所有满星满级满觉醒的英雄
|
||||
GetAllMaxHero(session IUserSession) (code pb.ErrorCode)
|
||||
GetAllMaxHero(session IUserSession) (errdata *pb.ErrorData)
|
||||
|
||||
// 教习登记
|
||||
RegisterInstructor(session IUserSession, heroOid []string, registerId int32) (code pb.ErrorCode)
|
||||
RegisterInstructor(session IUserSession, heroOid []string, registerId int32) (errdata *pb.ErrorData)
|
||||
|
||||
// 跨服查询英雄详细信息
|
||||
QueryCrossMultipleHeroinfo(oid []string) (hero []*pb.DBHero, err error)
|
||||
@ -135,9 +135,9 @@ type (
|
||||
//查询用户属性值 例如 金币 经验
|
||||
QueryAttributeValue(uid string, attr string) (value int64)
|
||||
//添加/减少属性值 第四个参数控制是否推送给前端
|
||||
AddAttributeValue(session IUserSession, attr string, add int32, bPush bool) (code pb.ErrorCode)
|
||||
AddAttributeValue(session IUserSession, attr string, add int32, bPush bool) (errdata *pb.ErrorData)
|
||||
// 批量处理
|
||||
AddAttributeValues(session IUserSession, attrs map[string]int32, bPush bool) (code pb.ErrorCode)
|
||||
AddAttributeValues(session IUserSession, attrs map[string]int32, bPush bool) (errdata *pb.ErrorData)
|
||||
//用户改变事件
|
||||
EventUserChanged(session IUserSession)
|
||||
EventUserVipChanged(session IUserSession)
|
||||
@ -163,24 +163,24 @@ type (
|
||||
BingoSetUserLv(session IUserSession, lv int32) error
|
||||
BingoSetUserVipLv(session IUserSession, lv int32) error
|
||||
//添加皮肤资源接口
|
||||
AddPer(session IUserSession, pers map[string]int32, bPush bool) (code pb.ErrorCode)
|
||||
AddPer(session IUserSession, pers map[string]int32, bPush bool) (errdata *pb.ErrorData)
|
||||
}
|
||||
//武器模块
|
||||
IEquipment interface {
|
||||
//查询服务资源数量
|
||||
QueryEquipments(uid string) (equipment []*pb.DB_Equipment, code pb.ErrorCode)
|
||||
QueryEquipments(uid string) (equipment []*pb.DB_Equipment, errdata *pb.ErrorData)
|
||||
//查询服务资源数量 db id
|
||||
QueryEquipment(uid string, Id string) (equipment *pb.DB_Equipment, code pb.ErrorCode)
|
||||
QueryEquipment(uid string, Id string) (equipment *pb.DB_Equipment, errdata *pb.ErrorData)
|
||||
//查询服务资源数量 参数武器配置id
|
||||
QueryEquipmentAmount(uid string, equipmentId string) (amount uint32)
|
||||
//添加新武器
|
||||
AddNewEquipments(session IUserSession, cIds map[string]uint32, bPush bool) (change []*pb.DB_Equipment, code pb.ErrorCode)
|
||||
AddNewEquipments(session IUserSession, cIds map[string]uint32, bPush bool) (change []*pb.DB_Equipment, errdata *pb.ErrorData)
|
||||
//添加所有装备
|
||||
AddAllEquipments(session IUserSession) (code pb.ErrorCode)
|
||||
AddAllEquipments(session IUserSession) (errdata *pb.ErrorData)
|
||||
//创建装备
|
||||
NewEquipment(uid, cid string) (errdata *pb.ErrorData, equip *pb.DB_Equipment)
|
||||
//添加装备
|
||||
AddEquipment(session IUserSession, equip *pb.DB_Equipment) (code pb.ErrorCode)
|
||||
AddEquipment(session IUserSession, equip *pb.DB_Equipment) (errdata *pb.ErrorData)
|
||||
//出售装备
|
||||
SellEquipments(session IUserSession, equs []string) (errdata *pb.ErrorData, atno []*pb.UserAtno)
|
||||
//回收装备接口
|
||||
@ -195,11 +195,11 @@ type (
|
||||
pos: 位置(-1 表示随机位置 大于0 表示获得指定位置 )
|
||||
lv: 装备等级
|
||||
*/
|
||||
GetForgeEquip(session IUserSession, suiteId int32, pos int32, lv int32, dyweight []int32) (eruip *pb.DB_Equipment, code pb.ErrorCode)
|
||||
GetForgeEquip(session IUserSession, suiteId int32, pos int32, lv int32, dyweight []int32) (eruip *pb.DB_Equipment, errdata *pb.ErrorData)
|
||||
}
|
||||
|
||||
IMline interface {
|
||||
ModifyMlineDataByNanduID(session IUserSession, id int32) (code pb.ErrorCode)
|
||||
ModifyMlineDataByNanduID(session IUserSession, id int32) (errdata *pb.ErrorData)
|
||||
/// 查询章节ID
|
||||
GetUserMlineData(uid string, chapterType int32) (chapterId int32)
|
||||
|
||||
@ -229,7 +229,7 @@ type (
|
||||
// 随机任务
|
||||
IRtask interface {
|
||||
// 条件校验
|
||||
CheckCondi(uid string, condiId int32, p ...int32) (code pb.ErrorCode)
|
||||
CheckCondi(uid string, condiId int32, p ...int32) (errdata *pb.ErrorData)
|
||||
// 多条件校验
|
||||
CheckCondis(uid string, condiIds ...int32) (condIds []int32)
|
||||
// 远程任务条件校验
|
||||
@ -261,15 +261,15 @@ type (
|
||||
//聊天系统
|
||||
IChat interface {
|
||||
//推送消息到世界频道
|
||||
SendWorldChat(msg *pb.DBChat) (code pb.ErrorCode)
|
||||
SendWorldChat(msg *pb.DBChat) (errdata *pb.ErrorData)
|
||||
//推送聊天消息到工会
|
||||
SendUnionChat(msg *pb.DBChat) (code pb.ErrorCode)
|
||||
SendUnionChat(msg *pb.DBChat) (errdata *pb.ErrorData)
|
||||
//推送消息到用户
|
||||
SendUserChat(msg *pb.DBChat) (code pb.ErrorCode)
|
||||
SendUserChat(msg *pb.DBChat) (errdata *pb.ErrorData)
|
||||
//广播系统消息
|
||||
SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value0, value1 int32, agrs ...string) (code pb.ErrorCode)
|
||||
SendSysChatToWorld(ctype ChatSystemType, appenddata interface{}, value0, value1 int32, agrs ...string) (errdata *pb.ErrorData)
|
||||
//广播系统消息
|
||||
SendSysChatToUser(session IUserSession, ctype ChatSystemType, value0, value1 int32, agrs ...string) (code pb.ErrorCode)
|
||||
SendSysChatToUser(session IUserSession, ctype ChatSystemType, value0, value1 int32, agrs ...string) (errdata *pb.ErrorData)
|
||||
}
|
||||
|
||||
//战斗系统
|
||||
@ -289,24 +289,24 @@ type (
|
||||
///获取战斗详情
|
||||
GetBattleInfo(req *pb.BattleGetInfoReq) (errdata *pb.ErrorData, resp *pb.BattleGetInfoResp)
|
||||
///创建战斗角色
|
||||
CreateRolesByFormat(fid int32) (captain int32, roles []*pb.BattleRole, code pb.ErrorCode)
|
||||
CreateRolesByFormat(fid int32) (captain int32, roles []*pb.BattleRole, errdata *pb.ErrorData)
|
||||
///创建战斗角色
|
||||
CreateRolesByHeros(heros []*pb.DBHero) (roles []*pb.BattleRole, code pb.ErrorCode)
|
||||
CreateRolesByHeros(heros []*pb.DBHero) (roles []*pb.BattleRole, errdata *pb.ErrorData)
|
||||
///创建战斗服务
|
||||
CreateBattleServer(req *pb.BattleInfo) (code pb.ErrorCode)
|
||||
CreateBattleServer(req *pb.BattleInfo) (errdata *pb.ErrorData)
|
||||
///战斗指令输入
|
||||
InCmdBattle(req *pb.BattleInCmdReq) (code pb.ErrorCode)
|
||||
InCmdBattle(req *pb.BattleInCmdReq) (errdata *pb.ErrorData)
|
||||
///战斗认输请求
|
||||
ConcedeBattle(req *pb.BattleConcedeReq) (code pb.ErrorCode)
|
||||
ConcedeBattle(req *pb.BattleConcedeReq) (errdata *pb.ErrorData)
|
||||
//校验战报
|
||||
CheckBattleReport(session IUserSession, report *pb.BattleReport) (errdata *pb.ErrorData, iswin bool)
|
||||
}
|
||||
IGm interface {
|
||||
CreateCmd(session IUserSession, cmd string) (code pb.ErrorCode)
|
||||
CreateCmd(session IUserSession, cmd string) (errdata *pb.ErrorData)
|
||||
}
|
||||
// 修改爬塔
|
||||
IPagoda interface {
|
||||
ModifyPagodaFloor(session IUserSession, level int32) (code pb.ErrorCode)
|
||||
ModifyPagodaFloor(session IUserSession, level int32) (errdata *pb.ErrorData)
|
||||
CheckUserBasePagodaInfo(uid string) (data *pb.DBPagodaRecord) // 查询玩家最佳通关记录
|
||||
|
||||
// Check Rtype84 Rtype85 Rtype86
|
||||
@ -316,9 +316,9 @@ type (
|
||||
}
|
||||
|
||||
IHeroFetter interface {
|
||||
ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) // 修改羁绊信息
|
||||
QueryHeroFetter(uid string) (data []*pb.DBHeroFetter) // 查询所有的羁绊信息
|
||||
AddHeroFetterData(uid string, heroConfId string) (code pb.ErrorCode) // 创建一条羁绊信息
|
||||
ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (errdata *pb.ErrorData) // 修改羁绊信息
|
||||
QueryHeroFetter(uid string) (data []*pb.DBHeroFetter) // 查询所有的羁绊信息
|
||||
AddHeroFetterData(uid string, heroConfId string) (errdata *pb.ErrorData) // 创建一条羁绊信息
|
||||
SendRpcAddHero(uid string, heroConfId string, serverTag string) (err error)
|
||||
|
||||
// 获取 某个阵营的羁绊数据
|
||||
@ -332,18 +332,18 @@ type (
|
||||
TriggerMF(session IUserSession, Boosid string) (err error)
|
||||
}
|
||||
IViking interface {
|
||||
CompleteAllLevel(session IUserSession) (code pb.ErrorCode)
|
||||
CompleteAllLevel(session IUserSession) (errdata *pb.ErrorData)
|
||||
CheckUserBaseVikingInfo(uid string) (data []*pb.DBVikingRank) // 查询玩家最佳通关记录
|
||||
IReddot
|
||||
// 自动购买门票
|
||||
AutoBuyTicket(session IUserSession, bossId, difficulty int32) (code pb.ErrorCode)
|
||||
AutoBuyTicket(session IUserSession, bossId, difficulty int32) (errdata *pb.ErrorData)
|
||||
// 自动战斗 战斗信息
|
||||
AutoBattleInfo(session IUserSession, battle *pb.BattleFormation, bossId, difficulty int32) (errdata *pb.ErrorData, battleInfo *pb.BattleInfo)
|
||||
AutoBattleOver(session IUserSession, Report *pb.BattleReport, autoBattle *pb.DBAutoBattle) (errdata *pb.ErrorData, atno []*pb.UserAtno)
|
||||
CheckBattelParameter(session IUserSession, battle *pb.BattleFormation, bossid, difficulty int32) (code pb.ErrorCode)
|
||||
CheckBattelParameter(session IUserSession, battle *pb.BattleFormation, bossid, difficulty int32) (errdata *pb.ErrorData)
|
||||
}
|
||||
IHunting interface {
|
||||
CompleteAllLevel(session IUserSession) (code pb.ErrorCode)
|
||||
CompleteAllLevel(session IUserSession) (errdata *pb.ErrorData)
|
||||
CheckUserBaseHuntingInfo(uid string) (data []*pb.DBHuntingRank) // 查询玩家最佳通关记录
|
||||
IReddot
|
||||
}
|
||||
@ -376,7 +376,7 @@ type (
|
||||
// 创建一个新的特权卡
|
||||
Delivery(session IUserSession, pId string) (errdata *pb.ErrorData, items []*pb.UserAssets)
|
||||
// 续费特权卡
|
||||
RenewPrivilegeCard(session IUserSession, cId string) (code pb.ErrorCode)
|
||||
RenewPrivilegeCard(session IUserSession, cId string) (errdata *pb.ErrorData)
|
||||
// 检查特权 参数 计费点 返回值 是否有特权
|
||||
CheckPrivilege(session IUserSession, cId string) bool
|
||||
// 检查每日特权邮件
|
||||
@ -438,7 +438,7 @@ type (
|
||||
//支付模块
|
||||
IPay interface {
|
||||
//模拟发货
|
||||
ModulePayDelivery(session IUserSession, Productid string, Price int32) (code pb.ErrorCode)
|
||||
ModulePayDelivery(session IUserSession, Productid string, Price int32) (errdata *pb.ErrorData)
|
||||
}
|
||||
//支付发货
|
||||
IPayDelivery interface {
|
||||
@ -450,7 +450,7 @@ type (
|
||||
//查询战斗数
|
||||
QueryBattle(id string) (battle *pb.DBPvpBattle, err error)
|
||||
//创建实时Pvp
|
||||
CreatePvp(red, blue *pb.PvpUserInfo, ptype pb.PvpType) (battleId string, code pb.ErrorCode)
|
||||
CreatePvp(red, blue *pb.PvpUserInfo, ptype pb.PvpType) (battleId string, errdata *pb.ErrorData)
|
||||
//推送战斗输出指令
|
||||
PvpOutCmdPush(out *pb.PvpOutCmdPush)
|
||||
//推送战斗结束
|
||||
@ -469,7 +469,7 @@ type (
|
||||
ITaskComplete
|
||||
IOpenCmdNotice
|
||||
//添加武馆资源
|
||||
AddItems(session IUserSession, items map[string]int32, bPush bool) (code pb.ErrorCode)
|
||||
AddItems(session IUserSession, items map[string]int32, bPush bool) (errdata *pb.ErrorData)
|
||||
//pvp切磋结果通知
|
||||
ChallengeResults(bid, red, bule string, winSide int32)
|
||||
|
||||
@ -479,7 +479,7 @@ type (
|
||||
|
||||
//捕羊大赛
|
||||
IParkour interface {
|
||||
AddMounts(session IUserSession, mounts map[string]int32, bPush bool) (code pb.ErrorCode)
|
||||
AddMounts(session IUserSession, mounts map[string]int32, bPush bool) (errdata *pb.ErrorData)
|
||||
}
|
||||
|
||||
ITools interface {
|
||||
|
@ -43,7 +43,7 @@ func (this *modelBattleComp) queryrecord(oid string) (record *pb.DBBattleRecord,
|
||||
}
|
||||
|
||||
//创建pve 战斗记录
|
||||
func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattleEVEReq) (record *pb.DBBattleRecord, code pb.ErrorCode) {
|
||||
func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattleEVEReq) (record *pb.DBBattleRecord, errdata *pb.ErrorData) {
|
||||
record = &pb.DBBattleRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Title: req.Title,
|
||||
@ -231,7 +231,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
|
||||
//创建pve 战斗记录
|
||||
func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattlePVEReq) (record *pb.DBBattleRecord, code pb.ErrorCode) {
|
||||
func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattlePVEReq) (record *pb.DBBattleRecord, errdata *pb.ErrorData) {
|
||||
var (
|
||||
heros []*pb.DBHero = make([]*pb.DBHero, 5)
|
||||
buff *cfg.GamePandamasBuffData
|
||||
@ -336,7 +336,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
|
||||
//创建pve 战斗记录
|
||||
func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattlePVBReq) (record *pb.DBBattleRecord, code pb.ErrorCode) {
|
||||
func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattlePVBReq) (record *pb.DBBattleRecord, errdata *pb.ErrorData) {
|
||||
var (
|
||||
buff *cfg.GamePandamasBuffData
|
||||
)
|
||||
@ -444,7 +444,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
|
||||
//创建pvp 战斗请求
|
||||
func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattlePVPReq) (record *pb.DBBattleRecord, code pb.ErrorCode) {
|
||||
func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattlePVPReq) (record *pb.DBBattleRecord, errdata *pb.ErrorData) {
|
||||
record = &pb.DBBattleRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Title: req.Title,
|
||||
@ -499,7 +499,7 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
|
||||
//创建pvp 战斗请求
|
||||
func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype pb.BattleType, req *pb.BattleRTPVPReq) (record *pb.DBBattleRecord, code pb.ErrorCode) {
|
||||
func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype pb.BattleType, req *pb.BattleRTPVPReq) (record *pb.DBBattleRecord, errdata *pb.ErrorData) {
|
||||
record = &pb.DBBattleRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Title: req.Title,
|
||||
@ -567,7 +567,7 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
|
||||
}
|
||||
|
||||
//创建pve 战斗记录
|
||||
func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattleLPVEReq) (record *pb.DBBattleRecord, code pb.ErrorCode) {
|
||||
func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattleLPVEReq) (record *pb.DBBattleRecord, errdata *pb.ErrorData) {
|
||||
var (
|
||||
heros []*pb.DBHero = make([]*pb.DBHero, 5)
|
||||
buff *cfg.GamePandamasBuffData
|
||||
@ -662,7 +662,7 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelBattleComp) createBattleRole(hero *pb.DBHero, tid, pos int) (role *pb.BattleRole, code pb.ErrorCode) {
|
||||
func (this *modelBattleComp) createBattleRole(hero *pb.DBHero, tid, pos int) (role *pb.BattleRole, errdata *pb.ErrorData) {
|
||||
role = &pb.BattleRole{
|
||||
Tid: int32(tid),
|
||||
Oid: hero.Id,
|
||||
@ -724,7 +724,7 @@ func (this *modelBattleComp) createBattleRole(hero *pb.DBHero, tid, pos int) (ro
|
||||
}
|
||||
|
||||
//创建怪物阵营
|
||||
func (this *modelBattleComp) createMasterRoles(comp, wheel int, fid int32) (captain int32, roles []*pb.BattleRole, code pb.ErrorCode) {
|
||||
func (this *modelBattleComp) createMasterRoles(comp, wheel int, fid int32) (captain int32, roles []*pb.BattleRole, errdata *pb.ErrorData) {
|
||||
var (
|
||||
result []*cfg.GameMonsterFormatData
|
||||
err error
|
||||
|
@ -282,13 +282,13 @@ func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLP
|
||||
}
|
||||
|
||||
///创建角色列表 更具Format表格
|
||||
func (this *Battle) CreateRolesByFormat(fid int32) (captain int32, roles []*pb.BattleRole, code pb.ErrorCode) {
|
||||
func (this *Battle) CreateRolesByFormat(fid int32) (captain int32, roles []*pb.BattleRole, errdata *pb.ErrorData) {
|
||||
captain, roles, code = this.modelBattle.createMasterRoles(2, 0, fid)
|
||||
return
|
||||
}
|
||||
|
||||
///创建角色列表 更具英雄列表
|
||||
func (this *Battle) CreateRolesByHeros(heros []*pb.DBHero) (roles []*pb.BattleRole, code pb.ErrorCode) {
|
||||
func (this *Battle) CreateRolesByHeros(heros []*pb.DBHero) (roles []*pb.BattleRole, errdata *pb.ErrorData) {
|
||||
roles = make([]*pb.BattleRole, len(heros))
|
||||
for i, v := range heros {
|
||||
if v != nil {
|
||||
|
@ -31,13 +31,13 @@ func (this *apiComp) Ench(session comm.IUserSession, req *pb.EquipmentEnchReq) (
|
||||
AttrValue int32
|
||||
err error
|
||||
)
|
||||
if code = this.EnchCheck(session, req); errdata != nil {
|
||||
if errdata = this.EnchCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if conf, err = this.module.configure.getEquipenchanting(req.Itemid); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
@ -49,26 +49,23 @@ func (this *apiComp) Ench(session comm.IUserSession, req *pb.EquipmentEnchReq) (
|
||||
T: req.Itemid,
|
||||
N: 1,
|
||||
})
|
||||
if code = this.module.ConsumeRes(session, need, true); errdata != nil {
|
||||
if errdata = this.module.ConsumeRes(session, need, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if equip, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), req.Eid); err != nil {
|
||||
this.module.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), req.Eid, err)
|
||||
code = pb.ErrorCode_SystemError
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if equip.AdverbEntry[req.Index] == nil || equip.AdverbEntry[req.Index].AttrName != conf.Attrkey {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: req.String(),
|
||||
}
|
||||
return
|
||||
@ -82,16 +79,16 @@ func (this *apiComp) Ench(session comm.IUserSession, req *pb.EquipmentEnchReq) (
|
||||
"isInitialState": false,
|
||||
}); err != nil {
|
||||
log.Errorf("Upgrade err:%v", err)
|
||||
code = pb.ErrorCode_SystemError
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if equip.HeroId != "" {
|
||||
equipments = make([]*pb.DB_Equipment, 8)
|
||||
if hero, code = this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), equip.HeroId); errdata != nil {
|
||||
if hero, errdata = this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), equip.HeroId); errdata != nil {
|
||||
this.module.Errorf("Upgrade code:%d", code)
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
|
@ -75,7 +75,7 @@ func (this *Equipment) EventUserOffline(uid, sessionid string) {
|
||||
|
||||
//IEquipment-------------------------------------------------------------------------------------------------------------------------------
|
||||
//查询武器信息
|
||||
func (this *Equipment) QueryEquipment(uid string, id string) (equipment *pb.DB_Equipment, code pb.ErrorCode) {
|
||||
func (this *Equipment) QueryEquipment(uid string, id string) (equipment *pb.DB_Equipment, errdata *pb.ErrorData) {
|
||||
var err error
|
||||
if uid == "" || id == "" {
|
||||
this.Errorf("请求参数错误 uid:%s Id:%s", uid, id)
|
||||
@ -96,7 +96,7 @@ func (this *Equipment) QueryEquipment(uid string, id string) (equipment *pb.DB_E
|
||||
}
|
||||
|
||||
//查询服务资源数量
|
||||
func (this *Equipment) QueryEquipments(uid string) (equipment []*pb.DB_Equipment, code pb.ErrorCode) {
|
||||
func (this *Equipment) QueryEquipments(uid string) (equipment []*pb.DB_Equipment, errdata *pb.ErrorData) {
|
||||
var err error
|
||||
if uid == "" {
|
||||
this.Errorf("请求参数错误 uid:%s ", uid)
|
||||
@ -123,7 +123,7 @@ func (this *Equipment) QueryEquipmentAmount(uid string, equipmentId string) (amo
|
||||
}
|
||||
|
||||
//添加武器
|
||||
func (this *Equipment) AddNewEquipments(session comm.IUserSession, cIds map[string]uint32, bPush bool) (change []*pb.DB_Equipment, code pb.ErrorCode) {
|
||||
func (this *Equipment) AddNewEquipments(session comm.IUserSession, cIds map[string]uint32, bPush bool) (change []*pb.DB_Equipment, errdata *pb.ErrorData) {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
@ -392,7 +392,7 @@ func (this *Equipment) GetActionableSuit(uid string) (errdata *pb.ErrorData, Sui
|
||||
pos: 位置(-1 表示随机位置 大于0 表示获得指定位置 )
|
||||
lv: 装备等级
|
||||
*/
|
||||
func (this *Equipment) GetForgeEquip(session comm.IUserSession, suiteId int32, pos int32, lv int32, dyweight []int32) (eruip *pb.DB_Equipment, code pb.ErrorCode) {
|
||||
func (this *Equipment) GetForgeEquip(session comm.IUserSession, suiteId int32, pos int32, lv int32, dyweight []int32) (eruip *pb.DB_Equipment, errdata *pb.ErrorData) {
|
||||
var (
|
||||
configures []*cfg.GameEquipData
|
||||
lvs []*cfg.GameEquipData
|
||||
|
@ -502,7 +502,7 @@ func (this *ModelHero) cleanData(uid string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, exp int32, model *db.DBModel) (curAddExp int32, code pb.ErrorCode) {
|
||||
func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, exp int32, model *db.DBModel) (curAddExp int32, errdata *pb.ErrorData) {
|
||||
var (
|
||||
preLv int32 //加经验之前的等级
|
||||
curExp int32 // 加经验之后的经验
|
||||
|
@ -78,7 +78,7 @@ func (this *Hero) Start() (err error) {
|
||||
}
|
||||
|
||||
// 创建单个叠加英雄
|
||||
func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, bFirst bool, atno []*pb.UserAtno, code pb.ErrorCode) {
|
||||
func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, bFirst bool, atno []*pb.UserAtno, errdata *pb.ErrorData) {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
@ -271,7 +271,7 @@ func (this *Hero) EventUserOffline(uid, sessionid string) {
|
||||
}
|
||||
|
||||
// 批量创建多个英雄
|
||||
func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, atno []*pb.UserAtno, code pb.ErrorCode) {
|
||||
func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, atno []*pb.UserAtno, errdata *pb.ErrorData) {
|
||||
var (
|
||||
changeList []*pb.DBHero
|
||||
firstGet []string
|
||||
@ -307,7 +307,7 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string]
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Hero) AddHeroExp(session comm.IUserSession, heroObjID string, exp int32) (curAddExp int32, code pb.ErrorCode) {
|
||||
func (this *Hero) AddHeroExp(session comm.IUserSession, heroObjID string, exp int32) (curAddExp int32, errdata *pb.ErrorData) {
|
||||
var (
|
||||
_hero *pb.DBHero
|
||||
_changeHero []*pb.DBHero // 变化的英雄
|
||||
|
@ -25,7 +25,7 @@ func (this *apiComp) SellItem(session comm.IUserSession, req *pb.ItemsSellItemRe
|
||||
itemcf *cfg.GameItemData
|
||||
sale []*cfg.Gameatn
|
||||
)
|
||||
if code = this.SellItemCheck(session, req); errdata != nil {
|
||||
if errdata = this.SellItemCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if item, err = this.module.modelItems.QueryUserPackByGridId(session.GetUserId(), req.GridId); err != nil {
|
||||
@ -36,11 +36,17 @@ func (this *apiComp) SellItem(session comm.IUserSession, req *pb.ItemsSellItemRe
|
||||
return
|
||||
}
|
||||
if itemcf, err = this.module.configure.GetItemConfigure(item.ItemId); err != nil {
|
||||
code = pb.ErrorCode_ConfigurationException
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigurationException,
|
||||
Title: pb.ErrorCode_ConfigurationException.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if itemcf.Sale == nil || len(itemcf.Sale) == 0 {
|
||||
code = pb.ErrorCode_ItemsUseNoCanSell
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ItemsUseNoCanSell,
|
||||
Title: pb.ErrorCode_ItemsUseNoCanSell.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if req.Amount > item.Amount {
|
||||
@ -57,11 +63,11 @@ func (this *apiComp) SellItem(session comm.IUserSession, req *pb.ItemsSellItemRe
|
||||
sale[i] = &temp
|
||||
sale[i].N = v.N * int32(req.Amount)
|
||||
}
|
||||
if code = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
if errdata = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
item.Amount = item.Amount - req.Amount
|
||||
if code = this.module.AddItemforGrid(session, req.GridId, -1*int32(req.Amount), true); errdata != nil {
|
||||
if errdata = this.module.AddItemforGrid(session, req.GridId, -1*int32(req.Amount), true); errdata != nil {
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "sellitem", &pb.ItemsSellItemResp{GridId: req.GridId, Amount: req.Amount, Issucc: true})
|
||||
|
@ -42,9 +42,9 @@ func (this *apiComp) Sellinbulk(session comm.IUserSession, req *pb.ItemsSellinbu
|
||||
cids[i] = v.ItemId
|
||||
}
|
||||
if itemcf, err = this.module.configure.GetItemConfigures(cids); err != nil {
|
||||
code = pb.ErrorCode_ConfigurationException
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigurationException,
|
||||
Title: pb.ErrorCode_ConfigurationException.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
@ -71,15 +71,15 @@ func (this *apiComp) Sellinbulk(session comm.IUserSession, req *pb.ItemsSellinbu
|
||||
items[i].Amount = items[i].Amount - req.Amount[i]
|
||||
}
|
||||
|
||||
if code = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
if errdata = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = this.module.modelItems.UpdateUserPack(session.GetUserId(), items...); err != nil {
|
||||
this.module.Errorln(err)
|
||||
code = pb.ErrorCode_DBError
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
|
@ -1,6 +1,7 @@
|
||||
package items
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
@ -25,7 +26,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
||||
itemcf *cfg.GameItemData
|
||||
prop []*cfg.GameDropData
|
||||
)
|
||||
if code = this.UseitemCheck(session, req); errdata != nil {
|
||||
if errdata = this.UseitemCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if item, err = this.module.modelItems.QueryUserPackByGridId(session.GetUserId(), req.GridId); err != nil {
|
||||
@ -36,7 +37,10 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
||||
return
|
||||
}
|
||||
if itemcf, err = this.module.configure.GetItemConfigure(item.ItemId); err != nil {
|
||||
code = pb.ErrorCode_ConfigurationException
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigurationException,
|
||||
Title: pb.ErrorCode_ConfigurationException.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
switch itemcf.Usetype {
|
||||
@ -50,19 +54,23 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
||||
})
|
||||
|
||||
}
|
||||
if code = this.module.AddItemforGrid(session, req.GridId, -1*int32(req.Amount), true); errdata != nil {
|
||||
if errdata = this.module.AddItemforGrid(session, req.GridId, -1*int32(req.Amount), true); errdata != nil {
|
||||
return
|
||||
}
|
||||
if code = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
if errdata = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
break
|
||||
case itemuse_optionalbox: //自选宝箱
|
||||
if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: fmt.Sprintf("掉落组未找到:%d", itemcf.BoxId),
|
||||
}
|
||||
return
|
||||
}
|
||||
if code = this.module.AddItemforGrid(session, req.GridId, -1*int32(req.Amount), true); errdata != nil {
|
||||
if errdata = this.module.AddItemforGrid(session, req.GridId, -1*int32(req.Amount), true); errdata != nil {
|
||||
return
|
||||
}
|
||||
var sale []*cfg.Gameatn
|
||||
@ -86,33 +94,45 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
||||
return
|
||||
}
|
||||
|
||||
if code = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
if errdata = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
case itemuse_randombox: //宝箱
|
||||
if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: fmt.Sprintf("掉落组未找到:%d", itemcf.BoxId),
|
||||
}
|
||||
return
|
||||
}
|
||||
sale := make([]*cfg.Gameatn, 0)
|
||||
for i := uint32(0); i < req.Amount; i++ {
|
||||
sale = append(sale, RandomProps(prop).Prize...)
|
||||
}
|
||||
if code = this.module.AddItemforGrid(session, req.GridId, -1*int32(req.Amount), true); errdata != nil {
|
||||
if errdata = this.module.AddItemforGrid(session, req.GridId, -1*int32(req.Amount), true); errdata != nil {
|
||||
return
|
||||
}
|
||||
if code = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
if errdata = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
case itemuse_synthesis: //合成
|
||||
user := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
reward := this.module.ModuleTools.GetGroupDataByLottery(itemcf.BoxId, user.Vip, user.Lv) // 走新的掉落
|
||||
if reward == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: fmt.Sprintf("掉落组未找到:%d", itemcf.BoxId),
|
||||
}
|
||||
return
|
||||
}
|
||||
if itemcf.SynthetizeNum*int32(req.Amount) > int32(item.Amount) { //碎片数量不够
|
||||
code = pb.ErrorCode_ItemsNoEnough
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ItemsNoEnough,
|
||||
Title: pb.ErrorCode_ItemsNoEnough.ToString(),
|
||||
Message: fmt.Sprintf("道具Id:%d", itemcf.Id),
|
||||
}
|
||||
return
|
||||
}
|
||||
sale := make([]*cfg.Gameatn, 0, len(itemcf.SynthetizeDeplete))
|
||||
@ -123,11 +143,11 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
||||
N: v.N * int32(req.Amount),
|
||||
})
|
||||
}
|
||||
if code = this.module.ConsumeRes(session, sale, true); errdata != nil {
|
||||
if errdata = this.module.ConsumeRes(session, sale, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if code = this.module.AddItemforGrid(session, req.GridId, -1*itemcf.SynthetizeNum*int32(req.Amount), true); errdata != nil {
|
||||
if errdata = this.module.AddItemforGrid(session, req.GridId, -1*itemcf.SynthetizeNum*int32(req.Amount), true); errdata != nil {
|
||||
return
|
||||
}
|
||||
sale = make([]*cfg.Gameatn, 0, len(prop))
|
||||
@ -138,12 +158,16 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq)
|
||||
N: v1.N * int32(req.Amount),
|
||||
})
|
||||
}
|
||||
if code = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
if errdata = this.module.DispenseRes(session, sale, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
default:
|
||||
code = pb.ErrorCode_ItemsUseNotSupported
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ItemsUseNotSupported,
|
||||
Title: pb.ErrorCode_ItemsUseNotSupported.ToString(),
|
||||
Message: fmt.Sprintf("道具使用类型:%d", itemcf.Usetype),
|
||||
}
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "useitem", &pb.ItemsUseItemResp{GridId: req.GridId, Amount: req.Amount, Issucc: true})
|
||||
|
@ -1,6 +1,7 @@
|
||||
package items
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
@ -96,11 +97,23 @@ func (this *Items) AddItemforGrid(session comm.IUserSession, gridid string, addn
|
||||
if change, err = this.modelItems.AddItemToUserPackByGrid(session.GetUserId(), gridid, addnum); err != nil {
|
||||
this.Errorf("给用户添加物品 uId:%s gridid:%d addnum:%d err:%v", session.GetUserId(), gridid, addnum, err)
|
||||
if err == ItemNotEnoughError {
|
||||
code = pb.ErrorCode_ItemsNoEnough
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ItemsNoEnough,
|
||||
Title: pb.ErrorCode_ItemsNoEnough.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
} else if err == PackGridNumUpper {
|
||||
code = pb.ErrorCode_ItemsGridNumUpper
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ItemsGridNumUpper,
|
||||
Title: pb.ErrorCode_ItemsGridNumUpper.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
} else {
|
||||
code = pb.ErrorCode_Unknown
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_Unknown,
|
||||
Title: pb.ErrorCode_Unknown.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -121,11 +134,23 @@ func (this *Items) AddItem(session comm.IUserSession, itemid string, addnum int3
|
||||
if change, err = this.modelItems.AddItemToUserPack(session.GetUserId(), itemid, addnum); err != nil {
|
||||
this.Errorf("给用户添加物品 uId:%s itemid:%d addnum:%d err:%v", session.GetUserId(), itemid, addnum, err)
|
||||
if err == ItemNotEnoughError {
|
||||
code = pb.ErrorCode_ItemsNoEnough
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ItemsNoEnough,
|
||||
Title: pb.ErrorCode_ItemsNoEnough.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
} else if err == PackGridNumUpper {
|
||||
code = pb.ErrorCode_ItemsGridNumUpper
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ItemsGridNumUpper,
|
||||
Title: pb.ErrorCode_ItemsGridNumUpper.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
} else {
|
||||
code = pb.ErrorCode_Unknown
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_Unknown,
|
||||
Title: pb.ErrorCode_Unknown.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -137,7 +162,7 @@ func (this *Items) AddItem(session comm.IUserSession, itemid string, addnum int3
|
||||
}
|
||||
|
||||
///添加多个物品到背包 (可以加物品和减物品)
|
||||
func (this *Items) AddItems(session comm.IUserSession, items map[string]int32, bPush bool) (change []*pb.DB_UserItemData, code pb.ErrorCode) {
|
||||
func (this *Items) AddItems(session comm.IUserSession, items map[string]int32, bPush bool) (change []*pb.DB_UserItemData, errdata *pb.ErrorData) {
|
||||
var (
|
||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
||||
err error
|
||||
@ -192,13 +217,13 @@ func (this *Items) CleanItems(session comm.IUserSession) (errdata *pb.ErrorData)
|
||||
|
||||
//购买门票道具
|
||||
func (this *Items) BuyUnifiedTicket(session comm.IUserSession, buynum int32) (errdata *pb.ErrorData) {
|
||||
_, code = this.modelItems.buyTicket(session, buynum)
|
||||
_, errdata = this.modelItems.buyTicket(session, buynum)
|
||||
return
|
||||
}
|
||||
|
||||
//回复道具
|
||||
func (this *Items) RecoverTicket(session comm.IUserSession) (errdata *pb.ErrorData) {
|
||||
code = this.modelItems.recoverTicket(session)
|
||||
errdata = this.modelItems.recoverTicket(session)
|
||||
return
|
||||
}
|
||||
|
||||
@ -219,7 +244,11 @@ func (this *Items) SellItem(session comm.IUserSession, items map[string]int32, b
|
||||
grids = append(grids, k)
|
||||
}
|
||||
if _itmes, err = this.modelItems.QueryUserPackByGridIds(session.GetUserId(), grids); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
for _, v := range _itmes {
|
||||
@ -230,11 +259,19 @@ func (this *Items) SellItem(session comm.IUserSession, items map[string]int32, b
|
||||
if g, ok = _grids[k]; ok {
|
||||
if int32(g.Amount) <= v {
|
||||
if itemcf, err = this.configure.GetItemConfigure(g.ItemId); err != nil {
|
||||
code = pb.ErrorCode_ConfigurationException
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigurationException,
|
||||
Title: pb.ErrorCode_ConfigurationException.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if itemcf.Sale == nil || len(itemcf.Sale) == 0 {
|
||||
code = pb.ErrorCode_ItemsUseNoCanSell
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ItemsUseNoCanSell,
|
||||
Title: pb.ErrorCode_ItemsUseNoCanSell.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
for _, v1 := range itemcf.Sale {
|
||||
@ -250,16 +287,24 @@ func (this *Items) SellItem(session comm.IUserSession, items map[string]int32, b
|
||||
}
|
||||
change = append(change, g)
|
||||
} else {
|
||||
code = pb.ErrorCode_ItemsNoEnough
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ItemsNoEnough,
|
||||
Title: pb.ErrorCode_ItemsNoEnough.ToString(),
|
||||
Message: fmt.Sprintf("道具id:%s 数量:%d", g.ItemId, g.Amount),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
code = pb.ErrorCode_ItemsNoFoundGird
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ItemsNoFoundGird,
|
||||
Title: pb.ErrorCode_ItemsNoFoundGird.ToString(),
|
||||
Message: fmt.Sprintf("道具id:%s", k),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if code, atno = this.DispenseAtno(session, sale, bPush); errdata != nil {
|
||||
if errdata, atno = this.DispenseAtno(session, sale, bPush); errdata != nil {
|
||||
return
|
||||
}
|
||||
if len(change) > 0 && bPush {
|
||||
@ -286,9 +331,12 @@ func (this *Items) CleanItemById(session comm.IUserSession, t string) (errdata *
|
||||
}
|
||||
}
|
||||
this.modelItems.DeleteUserPack(session.GetUserId(), itmes...)
|
||||
code = pb.ErrorCode_Success
|
||||
return
|
||||
}
|
||||
code = pb.ErrorCode_DataNotFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DataNotFound,
|
||||
Title: pb.ErrorCode_DataNotFound.ToString(),
|
||||
Message: fmt.Sprintf("道具id:%s", t),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func (this *Pvp) QueryBattle(id string) (battle *pb.DBPvpBattle, err error) {
|
||||
}
|
||||
|
||||
//创建Pvp
|
||||
func (this *Pvp) CreatePvp(red, blue *pb.PvpUserInfo, ptype pb.PvpType) (battleId string, code pb.ErrorCode) {
|
||||
func (this *Pvp) CreatePvp(red, blue *pb.PvpUserInfo, ptype pb.PvpType) (battleId string, errdata *pb.ErrorData) {
|
||||
this.Debug("CreatePvp", log.Field{Key: "ptype", Value: ptype.String()}, log.Field{Key: "red", Value: red.String()}, log.Field{Key: "blue", Value: blue.String()})
|
||||
var (
|
||||
battle *BattleItem
|
||||
|
@ -253,7 +253,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
|
||||
}
|
||||
|
||||
// 处理触发的任务
|
||||
func (this *ModuleRtask) processOneTask(session comm.IUserSession, record *pb.DBRtaskRecord, rtaskType comm.TaskType, params ...int32) (condIds []int32, code pb.ErrorCode) {
|
||||
func (this *ModuleRtask) processOneTask(session comm.IUserSession, record *pb.DBRtaskRecord, rtaskType comm.TaskType, params ...int32) (condIds []int32, errdata *pb.ErrorData) {
|
||||
uid := session.GetUserId()
|
||||
handles := this.getHandle(rtaskType)
|
||||
|
||||
|
@ -367,7 +367,7 @@ func (this *User) QueryAttributeValue(uid string, attr string) (value int64) {
|
||||
return
|
||||
}
|
||||
|
||||
func (this *User) change(session comm.IUserSession, attr string, add int32) (change *pb.UserResChangedPush, code pb.ErrorCode) {
|
||||
func (this *User) change(session comm.IUserSession, attr string, add int32) (change *pb.UserResChangedPush, errdata *pb.ErrorData) {
|
||||
if add == 0 {
|
||||
log.Warn("attr no changed",
|
||||
log.Field{Key: "uid", Value: session.GetUserId()},
|
||||
|
Loading…
Reference in New Issue
Block a user