储蓄金
This commit is contained in:
parent
5eb865c139
commit
16e3e1d37c
@ -778,7 +778,11 @@
|
||||
"n": 50000
|
||||
}
|
||||
],
|
||||
"overexp_reward": 1000,
|
||||
"overexp_reward": {
|
||||
"a": "attr",
|
||||
"t": "gold",
|
||||
"n": 1000
|
||||
},
|
||||
"voucher": {
|
||||
"a": "item",
|
||||
"t": "10000035",
|
||||
|
@ -34,9 +34,22 @@ func (this *apiComp) Deposit(session comm.IUserSession, req *pb.UserDepositReq)
|
||||
return
|
||||
}
|
||||
|
||||
gold := user.Deposit
|
||||
reward := this.module.globalConf.OverexpReward
|
||||
if reward == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
this.module.DispenseRes(session, []*cfg.Gameatn{{A: "attr", T: "gold", N: int32(gold)}}, true)
|
||||
atn := &cfg.Gameatn{
|
||||
A: reward.A,
|
||||
T: reward.T,
|
||||
N: int32(user.Deposit),
|
||||
}
|
||||
|
||||
this.module.DispenseRes(session, []*cfg.Gameatn{atn}, true)
|
||||
|
||||
// 储蓄金清零
|
||||
update := map[string]interface{}{
|
||||
@ -49,12 +62,16 @@ func (this *apiComp) Deposit(session comm.IUserSession, req *pb.UserDepositReq)
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.module.Errorf("更新储蓄金失败 uid:%v gold:%v err:%v", session.GetUserId(), gold, err)
|
||||
this.module.Errorf("更新储蓄金失败 uid:%v res:%v err:%v", session.GetUserId(), atn, err)
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), UserSubTYpeModifyBgp, &pb.UserDepositResp{
|
||||
Gold: gold,
|
||||
session.SendMsg(string(this.module.GetType()), "deposit", &pb.UserDepositResp{
|
||||
Atn: &pb.UserAssets{
|
||||
A: atn.A,
|
||||
T: atn.T,
|
||||
N: atn.N,
|
||||
},
|
||||
})
|
||||
|
||||
return
|
||||
|
46
modules/user/api_getdeposit.go
Normal file
46
modules/user/api_getdeposit.go
Normal file
@ -0,0 +1,46 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
// 储蓄金获取
|
||||
func (this *apiComp) GetdepositCheck(session comm.IUserSession, req *pb.UserGetdepositReq) (errdata *pb.ErrorData) {
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) Getdeposit(session comm.IUserSession, req *pb.UserGetdepositReq) (errdata *pb.ErrorData) {
|
||||
if errdata = this.GetdepositCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
user := this.module.GetUser(session.GetUserId())
|
||||
|
||||
if user == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserSessionNobeing,
|
||||
Title: pb.ErrorCode_UserSessionNobeing.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
reward := this.module.globalConf.OverexpReward
|
||||
if reward == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "getdeposit", &pb.UserDepositResp{
|
||||
Atn: &pb.UserAssets{
|
||||
A: reward.A,
|
||||
T: reward.T,
|
||||
N: int32(user.Deposit),
|
||||
},
|
||||
})
|
||||
|
||||
return
|
||||
}
|
@ -267,16 +267,16 @@ func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{
|
||||
nextLvConf = this.module.configure.GetPlayerlvConf(curLv + 1)
|
||||
}
|
||||
|
||||
var gold int32
|
||||
var res int32
|
||||
if nextLvConf == nil {
|
||||
curLvConf := this.module.configure.GetPlayerlvConf(curLv)
|
||||
reward := this.module.globalConf.OverexpReward
|
||||
|
||||
if curExp < int64(curLvConf.Exp) {
|
||||
gold = int32(curExp) * reward
|
||||
res = int32(curExp) * reward.N
|
||||
} else {
|
||||
yu := int32(curExp) - curLvConf.Exp
|
||||
gold = yu * reward
|
||||
res = yu * reward.N
|
||||
}
|
||||
|
||||
// this.module.DispenseRes(ul.session, []*cfg.Gameatn{{A: "attr", T: "gold", N: gold}}, true)
|
||||
@ -338,7 +338,7 @@ func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{
|
||||
if nextLvConf == nil {
|
||||
update := map[string]interface{}{
|
||||
"exp": curExp,
|
||||
"deposit": gold,
|
||||
"deposit": res,
|
||||
}
|
||||
if err := this.module.modelUser.Change(ul.session.GetUserId(), update); err != nil {
|
||||
this.module.Error("玩家经验更新",
|
||||
|
@ -3178,7 +3178,7 @@ type UserDepositResp struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Gold int64 `protobuf:"varint,1,opt,name=gold,proto3" json:"gold"`
|
||||
Atn *UserAssets `protobuf:"bytes,1,opt,name=atn,proto3" json:"atn"`
|
||||
}
|
||||
|
||||
func (x *UserDepositResp) Reset() {
|
||||
@ -3213,11 +3213,97 @@ func (*UserDepositResp) Descriptor() ([]byte, []int) {
|
||||
return file_user_user_msg_proto_rawDescGZIP(), []int{60}
|
||||
}
|
||||
|
||||
func (x *UserDepositResp) GetGold() int64 {
|
||||
func (x *UserDepositResp) GetAtn() *UserAssets {
|
||||
if x != nil {
|
||||
return x.Gold
|
||||
return x.Atn
|
||||
}
|
||||
return 0
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取储蓄金
|
||||
type UserGetdepositReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *UserGetdepositReq) Reset() {
|
||||
*x = UserGetdepositReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_user_user_msg_proto_msgTypes[61]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UserGetdepositReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UserGetdepositReq) ProtoMessage() {}
|
||||
|
||||
func (x *UserGetdepositReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_user_user_msg_proto_msgTypes[61]
|
||||
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 UserGetdepositReq.ProtoReflect.Descriptor instead.
|
||||
func (*UserGetdepositReq) Descriptor() ([]byte, []int) {
|
||||
return file_user_user_msg_proto_rawDescGZIP(), []int{61}
|
||||
}
|
||||
|
||||
type UserGetdepositResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Atn *UserAssets `protobuf:"bytes,1,opt,name=atn,proto3" json:"atn"`
|
||||
}
|
||||
|
||||
func (x *UserGetdepositResp) Reset() {
|
||||
*x = UserGetdepositResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_user_user_msg_proto_msgTypes[62]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UserGetdepositResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UserGetdepositResp) ProtoMessage() {}
|
||||
|
||||
func (x *UserGetdepositResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_user_user_msg_proto_msgTypes[62]
|
||||
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 UserGetdepositResp.ProtoReflect.Descriptor instead.
|
||||
func (*UserGetdepositResp) Descriptor() ([]byte, []int) {
|
||||
return file_user_user_msg_proto_rawDescGZIP(), []int{62}
|
||||
}
|
||||
|
||||
func (x *UserGetdepositResp) GetAtn() *UserAssets {
|
||||
if x != nil {
|
||||
return x.Atn
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_user_user_msg_proto protoreflect.FileDescriptor
|
||||
@ -3471,10 +3557,15 @@ var file_user_user_msg_proto_rawDesc = []byte{
|
||||
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x10, 0x0a,
|
||||
0x0e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x71, 0x22,
|
||||
0x25, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65,
|
||||
0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x67, 0x6f, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x04, 0x67, 0x6f, 0x6c, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x30, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65,
|
||||
0x73, 0x70, 0x12, 0x1d, 0x0a, 0x03, 0x61, 0x74, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x61, 0x74,
|
||||
0x6e, 0x22, 0x13, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72, 0x47, 0x65, 0x74, 0x64, 0x65, 0x70, 0x6f,
|
||||
0x73, 0x69, 0x74, 0x52, 0x65, 0x71, 0x22, 0x33, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x47, 0x65,
|
||||
0x74, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x03,
|
||||
0x61, 0x74, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72,
|
||||
0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x61, 0x74, 0x6e, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -3489,7 +3580,7 @@ func file_user_user_msg_proto_rawDescGZIP() []byte {
|
||||
return file_user_user_msg_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 61)
|
||||
var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 63)
|
||||
var file_user_user_msg_proto_goTypes = []interface{}{
|
||||
(*UserLoginReq)(nil), // 0: UserLoginReq
|
||||
(*UserLoginResp)(nil), // 1: UserLoginResp
|
||||
@ -3552,46 +3643,50 @@ var file_user_user_msg_proto_goTypes = []interface{}{
|
||||
(*UserRandomNameResp)(nil), // 58: UserRandomNameResp
|
||||
(*UserDepositReq)(nil), // 59: UserDepositReq
|
||||
(*UserDepositResp)(nil), // 60: UserDepositResp
|
||||
(*DBUser)(nil), // 61: DBUser
|
||||
(*DBUserExpand)(nil), // 62: DBUserExpand
|
||||
(ErrorCode)(0), // 63: ErrorCode
|
||||
(*CacheUser)(nil), // 64: CacheUser
|
||||
(*DBUserSetting)(nil), // 65: DBUserSetting
|
||||
(*DBPagodaRecord)(nil), // 66: DBPagodaRecord
|
||||
(*DBHuntingRank)(nil), // 67: DBHuntingRank
|
||||
(*DBVikingRank)(nil), // 68: DBVikingRank
|
||||
(*DBServerData)(nil), // 69: DBServerData
|
||||
(*DBSign)(nil), // 70: DBSign
|
||||
(*UserAtno)(nil), // 71: UserAtno
|
||||
(*UserAssets)(nil), // 72: UserAssets
|
||||
(*UserGetdepositReq)(nil), // 61: UserGetdepositReq
|
||||
(*UserGetdepositResp)(nil), // 62: UserGetdepositResp
|
||||
(*DBUser)(nil), // 63: DBUser
|
||||
(*DBUserExpand)(nil), // 64: DBUserExpand
|
||||
(ErrorCode)(0), // 65: ErrorCode
|
||||
(*CacheUser)(nil), // 66: CacheUser
|
||||
(*DBUserSetting)(nil), // 67: DBUserSetting
|
||||
(*DBPagodaRecord)(nil), // 68: DBPagodaRecord
|
||||
(*DBHuntingRank)(nil), // 69: DBHuntingRank
|
||||
(*DBVikingRank)(nil), // 70: DBVikingRank
|
||||
(*DBServerData)(nil), // 71: DBServerData
|
||||
(*DBSign)(nil), // 72: DBSign
|
||||
(*UserAtno)(nil), // 73: UserAtno
|
||||
(*UserAssets)(nil), // 74: UserAssets
|
||||
}
|
||||
var file_user_user_msg_proto_depIdxs = []int32{
|
||||
61, // 0: UserLoginResp.data:type_name -> DBUser
|
||||
62, // 1: UserLoginResp.ex:type_name -> DBUserExpand
|
||||
61, // 2: UserInfoResp.data:type_name -> DBUser
|
||||
62, // 3: UserInfoResp.ex:type_name -> DBUserExpand
|
||||
63, // 4: UserRegisterResp.Code:type_name -> ErrorCode
|
||||
64, // 5: UserLoadResp.data:type_name -> CacheUser
|
||||
65, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting
|
||||
65, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting
|
||||
63, // 8: UserModifynameResp.code:type_name -> ErrorCode
|
||||
61, // 9: UserBattlerecordResp.data:type_name -> DBUser
|
||||
62, // 10: UserBattlerecordResp.ex:type_name -> DBUserExpand
|
||||
66, // 11: UserBattlerecordResp.pagodaRecord:type_name -> DBPagodaRecord
|
||||
67, // 12: UserBattlerecordResp.huntingRecord:type_name -> DBHuntingRank
|
||||
68, // 13: UserBattlerecordResp.vikingRecord:type_name -> DBVikingRank
|
||||
64, // 14: UserOnlineResp.users:type_name -> CacheUser
|
||||
61, // 15: UserDataListResp.users:type_name -> DBUser
|
||||
69, // 16: UserGetServerDataResp.data:type_name -> DBServerData
|
||||
70, // 17: UserSignResp.data:type_name -> DBSign
|
||||
70, // 18: UserChangeTipsResp.data:type_name -> DBSign
|
||||
71, // 19: UserSellResReq.atno:type_name -> UserAtno
|
||||
72, // 20: UserSellResResp.atn:type_name -> UserAssets
|
||||
21, // [21:21] is the sub-list for method output_type
|
||||
21, // [21:21] is the sub-list for method input_type
|
||||
21, // [21:21] is the sub-list for extension type_name
|
||||
21, // [21:21] is the sub-list for extension extendee
|
||||
0, // [0:21] is the sub-list for field type_name
|
||||
63, // 0: UserLoginResp.data:type_name -> DBUser
|
||||
64, // 1: UserLoginResp.ex:type_name -> DBUserExpand
|
||||
63, // 2: UserInfoResp.data:type_name -> DBUser
|
||||
64, // 3: UserInfoResp.ex:type_name -> DBUserExpand
|
||||
65, // 4: UserRegisterResp.Code:type_name -> ErrorCode
|
||||
66, // 5: UserLoadResp.data:type_name -> CacheUser
|
||||
67, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting
|
||||
67, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting
|
||||
65, // 8: UserModifynameResp.code:type_name -> ErrorCode
|
||||
63, // 9: UserBattlerecordResp.data:type_name -> DBUser
|
||||
64, // 10: UserBattlerecordResp.ex:type_name -> DBUserExpand
|
||||
68, // 11: UserBattlerecordResp.pagodaRecord:type_name -> DBPagodaRecord
|
||||
69, // 12: UserBattlerecordResp.huntingRecord:type_name -> DBHuntingRank
|
||||
70, // 13: UserBattlerecordResp.vikingRecord:type_name -> DBVikingRank
|
||||
66, // 14: UserOnlineResp.users:type_name -> CacheUser
|
||||
63, // 15: UserDataListResp.users:type_name -> DBUser
|
||||
71, // 16: UserGetServerDataResp.data:type_name -> DBServerData
|
||||
72, // 17: UserSignResp.data:type_name -> DBSign
|
||||
72, // 18: UserChangeTipsResp.data:type_name -> DBSign
|
||||
73, // 19: UserSellResReq.atno:type_name -> UserAtno
|
||||
74, // 20: UserSellResResp.atn:type_name -> UserAssets
|
||||
74, // 21: UserDepositResp.atn:type_name -> UserAssets
|
||||
74, // 22: UserGetdepositResp.atn:type_name -> UserAssets
|
||||
23, // [23:23] is the sub-list for method output_type
|
||||
23, // [23:23] is the sub-list for method input_type
|
||||
23, // [23:23] is the sub-list for extension type_name
|
||||
23, // [23:23] is the sub-list for extension extendee
|
||||
0, // [0:23] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_user_user_msg_proto_init() }
|
||||
@ -4340,6 +4435,30 @@ func file_user_user_msg_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_user_user_msg_proto_msgTypes[61].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UserGetdepositReq); 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[62].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UserGetdepositResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -4347,7 +4466,7 @@ func file_user_user_msg_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_user_user_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 61,
|
||||
NumMessages: 63,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
@ -238,7 +238,7 @@ type GameGlobalData struct {
|
||||
FightPs int32
|
||||
PlayerBodychange int32
|
||||
MrylReward []*Gameatn
|
||||
OverexpReward int32
|
||||
OverexpReward *Gameatn
|
||||
Voucher *Gameatn
|
||||
}
|
||||
|
||||
@ -983,7 +983,7 @@ func (_v *GameGlobalData)Deserialize(_buf map[string]interface{}) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["overexp_reward"].(float64); !_ok_ { err = errors.New("overexp_reward error"); return }; _v.OverexpReward = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["overexp_reward"].(map[string]interface{}); !_ok_ { err = errors.New("overexp_reward error"); return }; if _v.OverexpReward, err = DeserializeGameatn(_x_); err != nil { return } }
|
||||
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["voucher"].(map[string]interface{}); !_ok_ { err = errors.New("voucher error"); return }; if _v.Voucher, err = DeserializeGameatn(_x_); err != nil { return } }
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user