增加登录天数
This commit is contained in:
parent
0be7aa3422
commit
5b2f8552e8
@ -162,3 +162,10 @@ func DaysSince(timestamp int64) int {
|
||||
days := int(startOfToday.Sub(startOfDay).Hours() / 24)
|
||||
return days
|
||||
}
|
||||
|
||||
func IsSameDay(timestamp1, timestamp2 int64) bool {
|
||||
t1 := time.Unix(timestamp1, 0)
|
||||
t2 := time.Unix(timestamp2, 0)
|
||||
|
||||
return t1.Year() == t2.Year() && t1.YearDay() == t2.YearDay()
|
||||
}
|
||||
|
||||
@ -583,6 +583,7 @@ func (p *PlayerBaseData) BackAsset() *msg.ResPlayerAsset {
|
||||
Login: int32(BaseMod.LoginTime),
|
||||
Logout: int32(BaseMod.LogoutTime),
|
||||
PExp: int32(BaseMod.PExp),
|
||||
LoginDay: int32(BaseMod.LoginDay),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ type Base struct {
|
||||
Star int
|
||||
Diamond int
|
||||
LoginTime int64
|
||||
LoginDay int // 登录天数
|
||||
LogoutTime int64
|
||||
RecoverTime int64
|
||||
FackBookId string
|
||||
@ -50,7 +51,11 @@ func (b *Base) InitData(Uid int) {
|
||||
}
|
||||
|
||||
func (b *Base) Login() {
|
||||
b.LoginTime = GoUtil.Now()
|
||||
Now := GoUtil.Now()
|
||||
if !GoUtil.IsSameDay(b.LoginTime, Now) {
|
||||
b.LoginDay += 1
|
||||
}
|
||||
b.LoginTime = Now
|
||||
b.LogoutTime = 0
|
||||
}
|
||||
|
||||
@ -145,6 +150,10 @@ func (b *Base) GetLogoutTime() int64 {
|
||||
return b.LogoutTime
|
||||
}
|
||||
|
||||
func (b *Base) GetLoginDay() int {
|
||||
return b.LoginDay
|
||||
}
|
||||
|
||||
func (b *Base) GetRecoverTime() int64 {
|
||||
return b.RecoverTime
|
||||
}
|
||||
|
||||
@ -2279,7 +2279,8 @@ type ResPlayerAsset struct {
|
||||
Exp int32 `protobuf:"varint,7,opt,name=exp,proto3" json:"exp,omitempty"`
|
||||
Login int32 `protobuf:"varint,8,opt,name=Login,proto3" json:"Login,omitempty"`
|
||||
Logout int32 `protobuf:"varint,9,opt,name=Logout,proto3" json:"Logout,omitempty"`
|
||||
PExp int32 `protobuf:"varint,10,opt,name=PExp,proto3" json:"PExp,omitempty"` // 玩家经验
|
||||
PExp int32 `protobuf:"varint,10,opt,name=PExp,proto3" json:"PExp,omitempty"` // 玩家经验
|
||||
LoginDay int32 `protobuf:"varint,11,opt,name=LoginDay,proto3" json:"LoginDay,omitempty"` // 登录天数
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -2384,6 +2385,13 @@ func (x *ResPlayerAsset) GetPExp() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ResPlayerAsset) GetLoginDay() int32 {
|
||||
if x != nil {
|
||||
return x.LoginDay
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// 客户端向服务器请求更新基本信息条目(没有响应)
|
||||
type UpdateBaseItemInfo struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
@ -23007,7 +23015,7 @@ const file_proto_Gameapi_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"FaceBookId\x18\x17 \x01(\tR\n" +
|
||||
"FaceBookId\"\x10\n" +
|
||||
"\x0eReqPlayerAsset\"\xf9\x01\n" +
|
||||
"\x0eReqPlayerAsset\"\x95\x02\n" +
|
||||
"\x0eResPlayerAsset\x12\x14\n" +
|
||||
"\x05dwUin\x18\x01 \x01(\x03R\x05dwUin\x12\x16\n" +
|
||||
"\x06energy\x18\x02 \x01(\x05R\x06energy\x12\x12\n" +
|
||||
@ -23019,7 +23027,8 @@ const file_proto_Gameapi_proto_rawDesc = "" +
|
||||
"\x05Login\x18\b \x01(\x05R\x05Login\x12\x16\n" +
|
||||
"\x06Logout\x18\t \x01(\x05R\x06Logout\x12\x12\n" +
|
||||
"\x04PExp\x18\n" +
|
||||
" \x01(\x05R\x04PExp\"\xbb\x01\n" +
|
||||
" \x01(\x05R\x04PExp\x12\x1a\n" +
|
||||
"\bLoginDay\x18\v \x01(\x05R\bLoginDay\"\xbb\x01\n" +
|
||||
"\x12UpdateBaseItemInfo\x12\x14\n" +
|
||||
"\x05dwUin\x18\x01 \x01(\x03R\x05dwUin\x12O\n" +
|
||||
"\vmUpdateItem\x18\x02 \x03(\v2-.tutorial.UpdateBaseItemInfo.MUpdateItemEntryR\vmUpdateItem\x1a>\n" +
|
||||
|
||||
Loading…
Reference in New Issue
Block a user