ecs/servers/game/handler/player_mail.go

195 lines
6.2 KiB
Go
Raw Normal View History

2025-06-04 18:17:39 +08:00
package handler
//func (this *PlayerHandler) MailRead(player *logic.Player, msg *net.Message) {
// var req = new(proto.MsgMailReadReq)
// var err = msg.Read(req)
// if err != nil {
// this.logger.Error("Read message failed, ", err)
// _ = player.TipNotice(proto.ErrMessageError)
// return
// }
//
// if req.Id == 0 {
// this.logger.Error("Parameter error, req.Id == 0")
// _ = player.TipNotice(proto.ErrParameterError)
// return
// }
//
// var mail = player.Mail[req.Id]
// if mail == nil {
// this.logger.Error("Parameter error, Player 'Mail' was not found, id: ", req.Id)
// _ = player.TipNotice(proto.ErrMailNotFound)
// return
// }
//
// if proto.MailStatus(mail.Status) >= proto.MailStatusHasRead {
// return
// }
//
// mail.Status = uint32(proto.MailStatusHasRead)
//
// player.SaveModel(mail)
//
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailRead, &proto.MsgMailReadAck{MailChange: &proto.MailChange{Id: mail.Id, Status: mail.Status}})
//
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailRead, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
//}
//
//func (this *PlayerHandler) MailReceive(player *logic.Player, msg *net.Message) {
// var req = new(proto.MsgMailReceiveReq)
// var err = msg.Read(req)
// if err != nil {
// this.logger.Error("Read message failed, ", err)
// _ = player.TipNotice(proto.ErrMessageError)
// return
// }
//
// if req.Id == 0 {
// this.logger.Error("Parameter error, req.Id == 0")
// _ = player.TipNotice(proto.ErrParameterError)
// return
// }
//
// var mail = player.Mail[req.Id]
// if mail == nil {
// this.logger.Error("Parameter error, Player 'Mail' was not found, id: ", req.Id)
// _ = player.TipNotice(proto.ErrMailNotFound)
// return
// }
//
// if proto.MailStatus(mail.Status) >= proto.MailStatusReceived {
// return
// }
//
// if len(mail.ItemId) == 0 || len(mail.ItemNum) == 0 {
// return
// }
//
// var rewardList []*proto.ItemPair
// for i := range mail.ItemId {
// _ = player.AddItem(mail.ItemId[i], mail.ItemNum[i], logic.LogTypeItemObtainByMail)
// rewardList = append(rewardList, &proto.ItemPair{ItemId: mail.ItemId[i], ItemNum: mail.ItemNum[i]})
// }
//
// mail.Status = uint32(proto.MailStatusReceived)
//
// player.SaveModel(mail)
//
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailReceive, &proto.MsgMailReceiveAck{
// MsgRewardListAck: &proto.MsgRewardListAck{RewardList: rewardList},
// MailChange: &proto.MailChange{Id: mail.Id, Status: mail.Status},
// })
//
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailReward, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
//}
//
//func (this *PlayerHandler) MailReceiveAll(player *logic.Player, _ *net.Message) {
// var rewardList []*proto.ItemPair
// var changeList []*proto.MailChange
// var itemPair = map[uint32]uint32{}
// for id, mail := range player.Mail {
// if proto.MailStatus(mail.Status) >= proto.MailStatusReceived {
// continue
// }
//
// if len(mail.ItemId) == 0 || len(mail.ItemNum) == 0 {
// return
// }
//
// for i := range mail.ItemId {
// itemPair[mail.ItemId[i]] += mail.ItemNum[i]
// }
//
// mail.Status = uint32(proto.MailStatusReceived)
// player.SaveModel(mail)
//
// changeList = append(changeList, &proto.MailChange{Id: id, Status: mail.Status})
//
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailReward, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
// }
//
// for itemId, itemNum := range itemPair {
// _ = player.AddItem(itemId, itemNum, logic.LogTypeItemObtainByMail)
// rewardList = append(rewardList, &proto.ItemPair{ItemId: itemId, ItemNum: itemNum})
// }
//
// if len(changeList) > 0 {
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailReceiveAll, &proto.MsgMailReceiveAllAck{
// MsgRewardListAck: &proto.MsgRewardListAck{RewardList: rewardList},
// ChangeList: changeList,
// })
// }
//}
//
//func (this *PlayerHandler) MailDelete(player *logic.Player, msg *net.Message) {
// var req = new(proto.MsgMailDeleteReq)
// var err = msg.Read(req)
// if err != nil {
// this.logger.Error("Read message failed, ", err)
// _ = player.TipNotice(proto.ErrMessageError)
// return
// }
//
// if req.Id == 0 {
// this.logger.Error("Parameter error, req.Id == 0")
// _ = player.TipNotice(proto.ErrParameterError)
// return
// }
//
// var mail = player.Mail[req.Id]
// if mail == nil {
// this.logger.Error("Parameter error, Player 'Mail' was not found, id: ", req.Id)
// _ = player.TipNotice(proto.ErrMailNotFound)
// return
// }
//
// if proto.MailType(mail.Type) == proto.MailTypeRegion {
// if proto.MailStatus(mail.Status) >= proto.MailStatusDeleted {
// return
// }
// mail.Status = uint32(proto.MailStatusDeleted)
// player.SaveModel(mail)
// } else {
// delete(player.Mail, req.Id)
// player.WipeModel(mail)
// }
//
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailDelete, &proto.MsgMailDeleteAck{MailChange: &proto.MailChange{Id: mail.Id, Status: mail.Status}})
//
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailDelete, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
//}
//
//func (this *PlayerHandler) MailDeleteAll(player *logic.Player, _ *net.Message) {
// var changeList []*proto.MailChange
// for id, mail := range player.Mail {
// if proto.MailStatus(mail.Status) < proto.MailStatusHasRead {
// continue
// }
//
// if len(mail.ItemId) > 0 {
// if proto.MailStatus(mail.Status) < proto.MailStatusReceived {
// continue
// }
// }
//
// if proto.MailType(mail.Type) == proto.MailTypeRegion {
// if proto.MailStatus(mail.Status) >= proto.MailStatusDeleted {
// continue
// }
// mail.Status = uint32(proto.MailStatusDeleted)
// player.SaveModel(mail)
// } else {
// delete(player.Mail, id)
// player.WipeModel(mail)
// }
//
// changeList = append(changeList, &proto.MailChange{Id: id, Status: uint32(proto.MailStatusDeleted)})
//
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailDelete, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
// }
//
// if len(changeList) > 0 {
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailDeleteAll, &proto.MsgMailDeleteAllAck{ChangeList: changeList})
// }
//}