This commit is contained in:
meixiongfeng 2022-11-07 22:52:03 +08:00
parent 45317f13fc
commit 034c6c8aca
6 changed files with 149 additions and 72 deletions

View File

@ -8,17 +8,17 @@ import (
) )
//参数校验 //参数校验
func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.TrollNpcRewardReq) (code pb.ErrorCode) { func (this *apiComp) NpcRewardCheck(session comm.IUserSession, req *pb.TrollNpcRewardReq) (code pb.ErrorCode) {
return return
} }
///美食城领取奖励 ///美食城领取奖励
func (this *apiComp) GetReward(session comm.IUserSession, req *pb.TrollNpcRewardReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) NpcReward(session comm.IUserSession, req *pb.TrollNpcRewardReq) (code pb.ErrorCode, data proto.Message) {
var ( var (
update map[string]interface{} update map[string]interface{}
) )
code = this.GetRewardCheck(session, req) code = this.NpcRewardCheck(session, req)
_troll, err := this.module.modelTroll.getTrollList(session.GetUserId()) _troll, err := this.module.modelTroll.getTrollList(session.GetUserId())
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
@ -28,19 +28,24 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.TrollNpcReward
if conf == nil { if conf == nil {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
} }
if confLv := this.configure.GetTrollLv(req.RewardId); confLv != nil {
if _troll.TotalEarn >= int64(confLv.Money) {
if _, ok := _troll.NpcReward[req.RewardId]; !ok { if _, ok := _troll.NpcReward[req.RewardId]; !ok {
this.module.ModifyTrollData(session.GetUserId(), update)
if code = this.module.DispenseRes(session, conf.Reword, true); code != pb.ErrorCode_Success { if code = this.module.DispenseRes(session, conf.Reword, true); code != pb.ErrorCode_Success {
return return
} }
_troll.NpcReward[req.RewardId] = 1 _troll.NpcReward[req.RewardId] = 1
update = make(map[string]interface{}, 0) update = make(map[string]interface{}, 0)
update["npcReward"] = _troll.NpcReward update["npcReward"] = _troll.NpcReward
this.module.ModifyTrollData(session.GetUserId(), update)
} else { } else {
code = pb.ErrorCode_TrollRepeatedReward code = pb.ErrorCode_TrollRepeatedReward
return return
} }
}
}
session.SendMsg(string(this.module.GetType()), TrollNpcRewardResp, &pb.TrollNpcRewardResp{Data: _troll}) session.SendMsg(string(this.module.GetType()), TrollNpcRewardResp, &pb.TrollNpcRewardResp{Data: _troll})
return return
} }

View File

@ -92,10 +92,10 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
if leftTime <= v { if leftTime <= v {
trolltrain.RefreshTime = time.Now().Unix() + int64(leftTime-v) trolltrain.RefreshTime = time.Now().Unix() + int64(leftTime-v)
trolltrain.TarinPos += index trolltrain.TarinPos += index
if trolltrain.RangeId != 0 { //if trolltrain.RangeId != 0 {
trolltrain.RangeId += index trolltrain.RangeId += index
trolltrain.RangeId = (trolltrain.RangeId % maxCoefficient) + 1 trolltrain.RangeId = (trolltrain.RangeId % maxCoefficient) + 1
} //}
trolltrain.TarinPos = (trolltrain.TarinPos % trainNum) + 1 trolltrain.TarinPos = (trolltrain.TarinPos % trainNum) + 1
break break

20
modules/user/api_sign.go Normal file
View File

@ -0,0 +1,20 @@
package user
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
//参数校验
func (this *apiComp) SignCheck(session comm.IUserSession, req *pb.UserSignReq) (code pb.ErrorCode) {
return
}
//登录
func (this *apiComp) Sign(session comm.IUserSession, req *pb.UserSignReq) (code pb.ErrorCode, data proto.Message) {
this.module.modelSign.checkResetSignData(session)
return
}

View File

@ -117,7 +117,7 @@ func (this *ModelSign) checkResetSignData(session comm.IUserSession) {
if bReward && _data != nil { // 发奖 if bReward && _data != nil { // 发奖
this.module.DispenseRes(session, _data.Loopgift, true) this.module.DispenseRes(session, _data.Loopgift, true)
} }
session.SendMsg(string(this.module.GetType()), "sign", &pb.UserSignPush{ session.SendMsg(string(this.module.GetType()), "sign", &pb.UserSignResp{
Data: sign, Data: sign,
Reward: bReward, Reward: bReward,
}) })

View File

@ -386,7 +386,7 @@ func (this *User) AddAttributeValue(session comm.IUserSession, attr string, add
} }
if bPush { //推送玩家账号信息变化消息 if bPush { //推送玩家账号信息变化消息
session.SendMsg(string(this.GetType()), "reschange", _change) session.SendMsg(string(this.GetType()), "reschanged", _change)
} }
return return
} }
@ -405,7 +405,7 @@ func (this *User) AddAttributeValues(session comm.IUserSession, attrs map[string
} }
if bPush { //推送玩家账号信息变化消息 if bPush { //推送玩家账号信息变化消息
session.SendMsg(string(this.GetType()), "reschange", _change) session.SendMsg(string(this.GetType()), "reschanged", _change)
} }
} }

View File

@ -2183,18 +2183,14 @@ func (x *UserGetServerDataResp) GetData() *DBServerData {
return nil return nil
} }
// 推送签到信息 type UserSignReq struct {
type UserSignPush struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Data *DBSign `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
Reward bool `protobuf:"varint,2,opt,name=reward,proto3" json:"reward"` // 是否领奖
} }
func (x *UserSignPush) Reset() { func (x *UserSignReq) Reset() {
*x = UserSignPush{} *x = UserSignReq{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_user_user_msg_proto_msgTypes[43] mi := &file_user_user_msg_proto_msgTypes[43]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -2202,13 +2198,13 @@ func (x *UserSignPush) Reset() {
} }
} }
func (x *UserSignPush) String() string { func (x *UserSignReq) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*UserSignPush) ProtoMessage() {} func (*UserSignReq) ProtoMessage() {}
func (x *UserSignPush) ProtoReflect() protoreflect.Message { func (x *UserSignReq) ProtoReflect() protoreflect.Message {
mi := &file_user_user_msg_proto_msgTypes[43] mi := &file_user_user_msg_proto_msgTypes[43]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -2220,19 +2216,61 @@ func (x *UserSignPush) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use UserSignPush.ProtoReflect.Descriptor instead. // Deprecated: Use UserSignReq.ProtoReflect.Descriptor instead.
func (*UserSignPush) Descriptor() ([]byte, []int) { func (*UserSignReq) Descriptor() ([]byte, []int) {
return file_user_user_msg_proto_rawDescGZIP(), []int{43} return file_user_user_msg_proto_rawDescGZIP(), []int{43}
} }
func (x *UserSignPush) GetData() *DBSign { // 推送签到信息
type UserSignResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data *DBSign `protobuf:"bytes,1,opt,name=data,proto3" json:"data"`
Reward bool `protobuf:"varint,2,opt,name=reward,proto3" json:"reward"` // 是否领奖
}
func (x *UserSignResp) Reset() {
*x = UserSignResp{}
if protoimpl.UnsafeEnabled {
mi := &file_user_user_msg_proto_msgTypes[44]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UserSignResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserSignResp) ProtoMessage() {}
func (x *UserSignResp) ProtoReflect() protoreflect.Message {
mi := &file_user_user_msg_proto_msgTypes[44]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UserSignResp.ProtoReflect.Descriptor instead.
func (*UserSignResp) Descriptor() ([]byte, []int) {
return file_user_user_msg_proto_rawDescGZIP(), []int{44}
}
func (x *UserSignResp) GetData() *DBSign {
if x != nil { if x != nil {
return x.Data return x.Data
} }
return nil return nil
} }
func (x *UserSignPush) GetReward() bool { func (x *UserSignResp) GetReward() bool {
if x != nil { if x != nil {
return x.Reward return x.Reward
} }
@ -2405,12 +2443,13 @@ var file_user_user_msg_proto_rawDesc = []byte{
0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x12, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x12,
0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e,
0x44, 0x42, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x44, 0x42, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61,
0x74, 0x61, 0x22, 0x43, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x53, 0x69, 0x67, 0x6e, 0x50, 0x75, 0x74, 0x61, 0x22, 0x0d, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65,
0x73, 0x68, 0x12, 0x1b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x71, 0x22, 0x43, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x73,
0x32, 0x07, 0x2e, 0x44, 0x42, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x16, 0x0a, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x2e, 0x44, 0x42, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x16,
0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x0a, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -2425,7 +2464,7 @@ func file_user_user_msg_proto_rawDescGZIP() []byte {
return file_user_user_msg_proto_rawDescData return file_user_user_msg_proto_rawDescData
} }
var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 44) var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 45)
var file_user_user_msg_proto_goTypes = []interface{}{ var file_user_user_msg_proto_goTypes = []interface{}{
(*UserLoginReq)(nil), // 0: UserLoginReq (*UserLoginReq)(nil), // 0: UserLoginReq
(*UserLoginResp)(nil), // 1: UserLoginResp (*UserLoginResp)(nil), // 1: UserLoginResp
@ -2470,36 +2509,37 @@ var file_user_user_msg_proto_goTypes = []interface{}{
(*UserDataListResp)(nil), // 40: UserDataListResp (*UserDataListResp)(nil), // 40: UserDataListResp
(*UserGetServerDataReq)(nil), // 41: UserGetServerDataReq (*UserGetServerDataReq)(nil), // 41: UserGetServerDataReq
(*UserGetServerDataResp)(nil), // 42: UserGetServerDataResp (*UserGetServerDataResp)(nil), // 42: UserGetServerDataResp
(*UserSignPush)(nil), // 43: UserSignPush (*UserSignReq)(nil), // 43: UserSignReq
(*DBUser)(nil), // 44: DBUser (*UserSignResp)(nil), // 44: UserSignResp
(*DBUserExpand)(nil), // 45: DBUserExpand (*DBUser)(nil), // 45: DBUser
(ErrorCode)(0), // 46: ErrorCode (*DBUserExpand)(nil), // 46: DBUserExpand
(*CacheUser)(nil), // 47: CacheUser (ErrorCode)(0), // 47: ErrorCode
(*DBUserSetting)(nil), // 48: DBUserSetting (*CacheUser)(nil), // 48: CacheUser
(*DBPagodaRecord)(nil), // 49: DBPagodaRecord (*DBUserSetting)(nil), // 49: DBUserSetting
(*DBHuntingRank)(nil), // 50: DBHuntingRank (*DBPagodaRecord)(nil), // 50: DBPagodaRecord
(*DBVikingRank)(nil), // 51: DBVikingRank (*DBHuntingRank)(nil), // 51: DBHuntingRank
(*DBServerData)(nil), // 52: DBServerData (*DBVikingRank)(nil), // 52: DBVikingRank
(*DBSign)(nil), // 53: DBSign (*DBServerData)(nil), // 53: DBServerData
(*DBSign)(nil), // 54: DBSign
} }
var file_user_user_msg_proto_depIdxs = []int32{ var file_user_user_msg_proto_depIdxs = []int32{
44, // 0: UserLoginResp.data:type_name -> DBUser 45, // 0: UserLoginResp.data:type_name -> DBUser
45, // 1: UserLoginResp.ex:type_name -> DBUserExpand 46, // 1: UserLoginResp.ex:type_name -> DBUserExpand
44, // 2: UserInfoResp.data:type_name -> DBUser 45, // 2: UserInfoResp.data:type_name -> DBUser
45, // 3: UserInfoResp.ex:type_name -> DBUserExpand 46, // 3: UserInfoResp.ex:type_name -> DBUserExpand
46, // 4: UserRegisterResp.Code:type_name -> ErrorCode 47, // 4: UserRegisterResp.Code:type_name -> ErrorCode
47, // 5: UserLoadResp.data:type_name -> CacheUser 48, // 5: UserLoadResp.data:type_name -> CacheUser
48, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting 49, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting
48, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting 49, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting
44, // 8: UserBattlerecordResp.data:type_name -> DBUser 45, // 8: UserBattlerecordResp.data:type_name -> DBUser
45, // 9: UserBattlerecordResp.ex:type_name -> DBUserExpand 46, // 9: UserBattlerecordResp.ex:type_name -> DBUserExpand
49, // 10: UserBattlerecordResp.pagodaRecord:type_name -> DBPagodaRecord 50, // 10: UserBattlerecordResp.pagodaRecord:type_name -> DBPagodaRecord
50, // 11: UserBattlerecordResp.huntingRecord:type_name -> DBHuntingRank 51, // 11: UserBattlerecordResp.huntingRecord:type_name -> DBHuntingRank
51, // 12: UserBattlerecordResp.vikingRecord:type_name -> DBVikingRank 52, // 12: UserBattlerecordResp.vikingRecord:type_name -> DBVikingRank
47, // 13: UserOnlineResp.users:type_name -> CacheUser 48, // 13: UserOnlineResp.users:type_name -> CacheUser
44, // 14: UserDataListResp.users:type_name -> DBUser 45, // 14: UserDataListResp.users:type_name -> DBUser
52, // 15: UserGetServerDataResp.data:type_name -> DBServerData 53, // 15: UserGetServerDataResp.data:type_name -> DBServerData
53, // 16: UserSignPush.data:type_name -> DBSign 54, // 16: UserSignResp.data:type_name -> DBSign
17, // [17:17] is the sub-list for method output_type 17, // [17:17] is the sub-list for method output_type
17, // [17:17] is the sub-list for method input_type 17, // [17:17] is the sub-list for method input_type
17, // [17:17] is the sub-list for extension type_name 17, // [17:17] is the sub-list for extension type_name
@ -3037,7 +3077,19 @@ func file_user_user_msg_proto_init() {
} }
} }
file_user_user_msg_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { file_user_user_msg_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserSignPush); i { switch v := v.(*UserSignReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_user_user_msg_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserSignResp); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -3055,7 +3107,7 @@ func file_user_user_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_user_user_msg_proto_rawDesc, RawDescriptor: file_user_user_msg_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 44, NumMessages: 45,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },