获取体力优化

This commit is contained in:
hahwu 2025-11-11 10:21:42 +08:00
parent 8428678712
commit 9b17d14437
5 changed files with 80 additions and 7 deletions

View File

@ -339,7 +339,8 @@ func (p *Player) ZeroUpdate(a []interface{}) {
p.PlayMod.getFriendTreasureMod().ZeroUpdate() p.PlayMod.getFriendTreasureMod().ZeroUpdate()
// p.PushClientRes(p.PlayMod.getFriendTreasureMod().BackData()) // p.PushClientRes(p.PlayMod.getFriendTreasureMod().BackData())
// 限时事件 // 好友功能
p.PlayMod.getFriendMod().ZeroUpdate()
p.PlayMod.getLimitedTimeEventMod().ZeroUpdate(p.GetPlayerBaseMod().GetLevel()) p.PlayMod.getLimitedTimeEventMod().ZeroUpdate(p.GetPlayerBaseMod().GetLevel())
// playroom // playroom

View File

@ -524,6 +524,7 @@ func FriendListBackData(p *Player) {
FriendList: fl, FriendList: fl,
ReqApplyList: ReqFriendList, ReqApplyList: ReqFriendList,
Npc: GoUtil.IntToInt32(FriendMod.GetNpc()), Npc: GoUtil.IntToInt32(FriendMod.GetNpc()),
Sponsor: int32(FriendMod.GetSponsor()),
}) })
} }

View File

@ -1759,6 +1759,27 @@ func ReqApplyFriend(player *Player, buf []byte) error {
}) })
return fmt.Errorf("already apply") return fmt.Errorf("already apply")
} }
if req.Type == 1 {
Items, err := FriendMod.GetSponsorReward()
if err != nil {
player.SendErrClienRes(&msg.ResApplyFriend{
Code: msg.RES_CODE_FAIL,
Msg: err.Error(),
})
return err
}
err = player.HandleItem(Items, msg.ITEM_POP_LABEL_ApplyFriendSponsor.String())
if err != nil {
player.SendErrClienRes(&msg.ResApplyFriend{
Code: msg.RES_CODE_FAIL,
Msg: err.Error(),
})
return err
}
player.TeLog("friend_invite_reward", map[string]interface{}{
"item_list": Items,
})
}
m := &MsqMod.Msg{ m := &MsqMod.Msg{
Type: MsqMod.HANDLE_TYPE_APPLY, Type: MsqMod.HANDLE_TYPE_APPLY,
From: int(player.M_DwUin), From: int(player.M_DwUin),

View File

@ -23,6 +23,7 @@ type FriendMod struct {
Bubble map[int]*BubbleInfo // 气泡 Bubble map[int]*BubbleInfo // 气泡
ActivityLog []*ActLogInfo // 活动日志 ActivityLog []*ActLogInfo // 活动日志
ReplyList []*ReplyInfo // 好友回复列表 ReplyList []*ReplyInfo // 好友回复列表
DailySponsor int // 好友赞助次数
} }
type ReplyInfo struct { type ReplyInfo struct {
@ -200,6 +201,10 @@ func (f *FriendMod) InitData() {
} }
} }
func (f *FriendMod) ZeroUpdate() {
f.DailySponsor = f.GetDailySponsorLimit()
}
func (f *FriendMod) GetNpc() []int { func (f *FriendMod) GetNpc() []int {
return f.Npc return f.Npc
} }
@ -516,3 +521,26 @@ func (f *FriendMod) ReplyFriend(LogId int) *ReplyInfo {
} }
return nil return nil
} }
func (f *FriendMod) GetSponsor() int {
return f.DailySponsor
}
func (f *FriendMod) GetDailySponsorLimit() int {
len := len(f.FriendList)
if len < 5 {
return 3
}
if len <= 30 {
return 2
}
return 1
}
func (f *FriendMod) GetSponsorReward() ([]*item.Item, error) {
if f.DailySponsor <= 0 {
return nil, fmt.Errorf("no sponsor left")
}
f.DailySponsor--
return []*item.Item{item.NewItem(item.ITEM_ENERGY_ID, 25)}, nil
}

View File

@ -102,6 +102,7 @@ const (
ITEM_POP_LABEL_ActPassReward ITEM_POP_LABEL = 75 // 通行证奖励 ITEM_POP_LABEL_ActPassReward ITEM_POP_LABEL = 75 // 通行证奖励
ITEM_POP_LABEL_FriendReplyHandle ITEM_POP_LABEL = 76 // 好友请求处理 ITEM_POP_LABEL_FriendReplyHandle ITEM_POP_LABEL = 76 // 好友请求处理
ITEM_POP_LABEL_GetChessRetireReward ITEM_POP_LABEL = 77 // 退役奖励 ITEM_POP_LABEL_GetChessRetireReward ITEM_POP_LABEL = 77 // 退役奖励
ITEM_POP_LABEL_ApplyFriendSponsor ITEM_POP_LABEL = 78 // 申请好友赞助
) )
// Enum value maps for ITEM_POP_LABEL. // Enum value maps for ITEM_POP_LABEL.
@ -185,6 +186,7 @@ var (
75: "ActPassReward", 75: "ActPassReward",
76: "FriendReplyHandle", 76: "FriendReplyHandle",
77: "GetChessRetireReward", 77: "GetChessRetireReward",
78: "ApplyFriendSponsor",
} }
ITEM_POP_LABEL_value = map[string]int32{ ITEM_POP_LABEL_value = map[string]int32{
"Playroom": 0, "Playroom": 0,
@ -265,6 +267,7 @@ var (
"ActPassReward": 75, "ActPassReward": 75,
"FriendReplyHandle": 76, "FriendReplyHandle": 76,
"GetChessRetireReward": 77, "GetChessRetireReward": 77,
"ApplyFriendSponsor": 78,
} }
) )
@ -14416,6 +14419,7 @@ type ResFriendList struct {
FriendList []*ResPlayerSimple `protobuf:"bytes,1,rep,name=FriendList,proto3" json:"FriendList,omitempty"` FriendList []*ResPlayerSimple `protobuf:"bytes,1,rep,name=FriendList,proto3" json:"FriendList,omitempty"`
ReqApplyList []int64 `protobuf:"varint,3,rep,packed,name=ReqApplyList,proto3" json:"ReqApplyList,omitempty"` // 已申请好友列表 ReqApplyList []int64 `protobuf:"varint,3,rep,packed,name=ReqApplyList,proto3" json:"ReqApplyList,omitempty"` // 已申请好友列表
Npc []int32 `protobuf:"varint,2,rep,packed,name=Npc,proto3" json:"Npc,omitempty"` // npc列表 Npc []int32 `protobuf:"varint,2,rep,packed,name=Npc,proto3" json:"Npc,omitempty"` // npc列表
Sponsor int32 `protobuf:"varint,4,opt,name=Sponsor,proto3" json:"Sponsor,omitempty"` // 今日赞助次数
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -14471,6 +14475,13 @@ func (x *ResFriendList) GetNpc() []int32 {
return nil return nil
} }
func (x *ResFriendList) GetSponsor() int32 {
if x != nil {
return x.Sponsor
}
return 0
}
type ReqAddNpc struct { type ReqAddNpc struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
NpcId int32 `protobuf:"varint,1,opt,name=NpcId,proto3" json:"NpcId,omitempty"` NpcId int32 `protobuf:"varint,1,opt,name=NpcId,proto3" json:"NpcId,omitempty"`
@ -15594,6 +15605,7 @@ func (x *ResFriendApplyNotify) GetTime() int32 {
type ReqApplyFriend struct { type ReqApplyFriend struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Uid int64 `protobuf:"varint,1,opt,name=Uid,proto3" json:"Uid,omitempty"` Uid int64 `protobuf:"varint,1,opt,name=Uid,proto3" json:"Uid,omitempty"`
Type int32 `protobuf:"varint,2,opt,name=Type,proto3" json:"Type,omitempty"` // 0:普通请求 1赞助请求
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -15635,6 +15647,13 @@ func (x *ReqApplyFriend) GetUid() int64 {
return 0 return 0
} }
func (x *ReqApplyFriend) GetType() int32 {
if x != nil {
return x.Type
}
return 0
}
type ResApplyFriend struct { type ResApplyFriend struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Code RES_CODE `protobuf:"varint,1,opt,name=Code,proto3,enum=tutorial.RES_CODE" json:"Code,omitempty"` Code RES_CODE `protobuf:"varint,1,opt,name=Code,proto3,enum=tutorial.RES_CODE" json:"Code,omitempty"`
@ -28164,13 +28183,14 @@ const file_proto_Gameapi_proto_rawDesc = "" +
"\x0fResFriendIgnore\x12&\n" + "\x0fResFriendIgnore\x12&\n" +
"\x04Code\x18\x01 \x01(\x0e2\x12.tutorial.RES_CODER\x04Code\x12\x10\n" + "\x04Code\x18\x01 \x01(\x0e2\x12.tutorial.RES_CODER\x04Code\x12\x10\n" +
"\x03Msg\x18\x02 \x01(\tR\x03Msg\"\x0f\n" + "\x03Msg\x18\x02 \x01(\tR\x03Msg\"\x0f\n" +
"\rReqFriendList\"\x80\x01\n" + "\rReqFriendList\"\x9a\x01\n" +
"\rResFriendList\x129\n" + "\rResFriendList\x129\n" +
"\n" + "\n" +
"FriendList\x18\x01 \x03(\v2\x19.tutorial.ResPlayerSimpleR\n" + "FriendList\x18\x01 \x03(\v2\x19.tutorial.ResPlayerSimpleR\n" +
"FriendList\x12\"\n" + "FriendList\x12\"\n" +
"\fReqApplyList\x18\x03 \x03(\x03R\fReqApplyList\x12\x10\n" + "\fReqApplyList\x18\x03 \x03(\x03R\fReqApplyList\x12\x10\n" +
"\x03Npc\x18\x02 \x03(\x05R\x03Npc\"!\n" + "\x03Npc\x18\x02 \x03(\x05R\x03Npc\x12\x18\n" +
"\aSponsor\x18\x04 \x01(\x05R\aSponsor\"!\n" +
"\tReqAddNpc\x12\x14\n" + "\tReqAddNpc\x12\x14\n" +
"\x05NpcId\x18\x01 \x01(\x05R\x05NpcId\"[\n" + "\x05NpcId\x18\x01 \x01(\x05R\x05NpcId\"[\n" +
"\tResAddNpc\x12&\n" + "\tResAddNpc\x12&\n" +
@ -28232,9 +28252,10 @@ const file_proto_Gameapi_proto_rawDesc = "" +
"\x14ResFriendApplyNotify\x121\n" + "\x14ResFriendApplyNotify\x121\n" +
"\x06Player\x18\x01 \x01(\v2\x19.tutorial.ResPlayerSimpleR\x06Player\x12\x12\n" + "\x06Player\x18\x01 \x01(\v2\x19.tutorial.ResPlayerSimpleR\x06Player\x12\x12\n" +
"\x04Type\x18\x02 \x01(\x05R\x04Type\x12\x12\n" + "\x04Type\x18\x02 \x01(\x05R\x04Type\x12\x12\n" +
"\x04Time\x18\x03 \x01(\x05R\x04Time\"\"\n" + "\x04Time\x18\x03 \x01(\x05R\x04Time\"6\n" +
"\x0eReqApplyFriend\x12\x10\n" + "\x0eReqApplyFriend\x12\x10\n" +
"\x03Uid\x18\x01 \x01(\x03R\x03Uid\"\\\n" + "\x03Uid\x18\x01 \x01(\x03R\x03Uid\x12\x12\n" +
"\x04Type\x18\x02 \x01(\x05R\x04Type\"\\\n" +
"\x0eResApplyFriend\x12&\n" + "\x0eResApplyFriend\x12&\n" +
"\x04Code\x18\x01 \x01(\x0e2\x12.tutorial.RES_CODER\x04Code\x12\x10\n" + "\x04Code\x18\x01 \x01(\x0e2\x12.tutorial.RES_CODER\x04Code\x12\x10\n" +
"\x03Msg\x18\x02 \x01(\tR\x03Msg\x12\x10\n" + "\x03Msg\x18\x02 \x01(\tR\x03Msg\x12\x10\n" +
@ -29084,7 +29105,7 @@ const file_proto_Gameapi_proto_rawDesc = "" +
"\x10ReqAdminShipping\x12\x18\n" + "\x10ReqAdminShipping\x12\x18\n" +
"\aOrderSn\x18\x01 \x01(\tR\aOrderSn\x12\x16\n" + "\aOrderSn\x18\x01 \x01(\tR\aOrderSn\x12\x16\n" +
"\x06Status\x18\x02 \x01(\x05R\x06Status\x12&\n" + "\x06Status\x18\x02 \x01(\x05R\x06Status\x12&\n" +
"\x0eChannelOrderSn\x18\x03 \x01(\tR\x0eChannelOrderSn*\xd6\v\n" + "\x0eChannelOrderSn\x18\x03 \x01(\tR\x0eChannelOrderSn*\xee\v\n" +
"\x0eITEM_POP_LABEL\x12\f\n" + "\x0eITEM_POP_LABEL\x12\f\n" +
"\bPlayroom\x10\x00\x12\r\n" + "\bPlayroom\x10\x00\x12\r\n" +
"\tPiggyBank\x10\x01\x12\n" + "\tPiggyBank\x10\x01\x12\n" +
@ -29172,7 +29193,8 @@ const file_proto_Gameapi_proto_rawDesc = "" +
"PassCharge\x10J\x12\x11\n" + "PassCharge\x10J\x12\x11\n" +
"\rActPassReward\x10K\x12\x15\n" + "\rActPassReward\x10K\x12\x15\n" +
"\x11FriendReplyHandle\x10L\x12\x18\n" + "\x11FriendReplyHandle\x10L\x12\x18\n" +
"\x14GetChessRetireReward\x10M*B\n" + "\x14GetChessRetireReward\x10M\x12\x16\n" +
"\x12ApplyFriendSponsor\x10N*B\n" +
"\vHANDLE_TYPE\x12\a\n" + "\vHANDLE_TYPE\x12\a\n" +
"\x03ADD\x10\x00\x12\v\n" + "\x03ADD\x10\x00\x12\v\n" +
"\aCOMPOSE\x10\x01\x12\a\n" + "\aCOMPOSE\x10\x01\x12\a\n" +