限时事件+NPC好友

This commit is contained in:
hahwu 2025-04-01 10:17:07 +08:00
parent ee5781df40
commit df19eaaf9f
5 changed files with 2123 additions and 1966 deletions

View File

@ -111,12 +111,11 @@ func (gl *GameLogic) ZeroFlush() {
// 中午更新
func (gl *GameLogic) NoonFlush() {
log.Debug("Server NoonFlush")
gl.Mdispatr.AfterFunc(time.Second*86400, func() {
gl.NoonFlush()
})
var a1 = []interface{}{gl.DailyTaskTimestamp}
gl.NotifyAll(MsgMod.MSG_NOON_UPDATE)
GoUtil.CallEvent(MergeConst.Notify_Midday_Renew, a1)
}
func (gl *GameLogic) SetPlayer(player *Player) {
@ -705,6 +704,7 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
RegisterMsgProcessFunc("ReqFriendTimeLine", ReqFriendTimeLine) // 请求好友时间线
RegisterMsgProcessFunc("ReqFriendRecommend", ReqFriendRecommend) // 获取推荐好友
RegisterMsgProcessFunc("ReqFriendTLUpvote", ReqFriendTLUpvote) // 请求时间线点赞
RegisterMsgProcessFunc("ReqAddNpc", ReqAddNpc) // 增加npc
RegisterMsgProcessFunc("ReqSearchPlayer", ReqSearchPlayer) // 搜索好友
RegisterMsgProcessFunc("ReqApplyFriend", ReqApplyFriend) // 申请好友

View File

@ -343,7 +343,7 @@ func SyncMailMsg(p *Player) {
func FriendListBackData(p *Player) {
FriendMod := p.PlayMod.getFriendMod()
var fl []*proto.ResPlayerSimple
for k := range FriendMod.FriendList {
for k := range FriendMod.GetFriendList() {
if k == int(p.M_DwUin) {
continue
}
@ -354,6 +354,7 @@ func FriendListBackData(p *Player) {
}
p.PushClientRes(&proto.ResFriendList{
FriendList: fl,
Npc: GoUtil.IntToInt32(FriendMod.GetNpc()),
})
}
@ -897,7 +898,7 @@ func GetUidByFaceBook(Fb string) (int, error) {
func NotifyAllFriend(p *Player, m1 *msg.Msg) {
m := m1.Clone()
FriendMod := p.PlayMod.getFriendMod()
for k := range FriendMod.FriendList {
for k := range FriendMod.GetFriendList() {
if k == int(p.M_DwUin) {
continue
}

View File

@ -2449,7 +2449,7 @@ func ReqFriendRecommend(player *Player, buf []byte) error {
n = 3
} else {
Active := 0
for k := range FriendMod.FriendList {
for k := range FriendMod.GetFriendList() {
PlayerSimpleData := G_GameLogicPtr.GetSimplePlayerByUid(k)
if PlayerSimpleData.Login > GoUtil.Now()-86400 {
Active++
@ -3976,3 +3976,16 @@ func ReqCatTrickReward(player *Player, buf []byte) error {
})
return nil
}
func ReqAddNpc(player *Player, buf []byte) error {
req := &msg.ReqAddNpc{}
proto.Unmarshal(buf, req)
FriendMod := player.PlayMod.getFriendMod()
FriendMod.SetNpc(int(req.NpcId))
player.PlayMod.save()
FriendListBackData(player)
player.PushClientRes(&msg.ResAddNpc{
Code: msg.RES_CODE_SUCCESS,
})
return nil
}

View File

@ -9,13 +9,19 @@ import (
)
type FriendMod struct {
FriendList map[int]struct{} // 好友列表
ApplyList map[int]int64 // 请求列表
SendApply map[int]int64 // 发送的申请
Card map[string]*card.CardInfo // 收到的申请交换
Log []*LogInfo // 日志
AutoId int
Id int64 // 已同步msg ID
FriendList map[int]struct{} // 好友列表
NewFriendList map[int]*FriendInfo // 好友列表
ApplyList map[int]int64 // 请求列表
SendApply map[int]int64 // 发送的申请
Card map[string]*card.CardInfo // 收到的申请交换
Log []*LogInfo // 日志
AutoId int
Id int64 // 已同步msg ID
Npc []int // npc id
}
type FriendInfo struct {
AddTime int64
}
const (
@ -65,6 +71,24 @@ func (f *FriendMod) InitData() {
if f.SendApply == nil {
f.SendApply = make(map[int]int64)
}
if f.NewFriendList == nil {
f.NewFriendList = make(map[int]*FriendInfo)
}
if len(f.FriendList) > 0 && len(f.NewFriendList) == 0 {
for k := range f.FriendList {
f.NewFriendList[k] = &FriendInfo{
AddTime: GoUtil.Now(),
}
}
}
}
func (f *FriendMod) GetNpc() []int {
return f.Npc
}
func (f *FriendMod) SetNpc(id int) {
f.Npc = append(f.Npc, id)
}
func (f *FriendMod) GetSyncId() int64 {
@ -76,7 +100,9 @@ func (f *FriendMod) SetSyncId(Id int64) {
}
func (f *FriendMod) AddFriend(id int) {
f.FriendList[id] = struct{}{}
f.NewFriendList[id] = &FriendInfo{
AddTime: GoUtil.Now(),
}
delete(f.ApplyList, id)
}
@ -97,11 +123,11 @@ func (f *FriendMod) DelCardInfo(Id string) {
}
func (f *FriendMod) DelFriend(id int) {
delete(f.FriendList, id)
delete(f.NewFriendList, id)
}
func (f *FriendMod) CheckFriend(Uid int) bool {
_, ok := f.FriendList[Uid]
_, ok := f.NewFriendList[Uid]
return ok
}
@ -114,11 +140,11 @@ func (f *FriendMod) CheckApply(id int) bool {
return ok
}
func (f *FriendMod) GetFriendNum() int {
return len(f.FriendList)
return len(f.NewFriendList)
}
func (f *FriendMod) GetFriendList() []int {
var list []int
for k := range f.FriendList {
for k := range f.NewFriendList {
list = append(list, k)
}
return list

File diff suppressed because it is too large Load Diff