邮件功能
This commit is contained in:
parent
1a9ea12307
commit
3aa08943b2
@ -324,32 +324,64 @@ enum UpgradeMasterType {
|
|||||||
MasterTreasureRefine = 4;
|
MasterTreasureRefine = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MailType 邮件类型
|
||||||
|
enum MailType {
|
||||||
|
MailTypeNone = 0;
|
||||||
|
|
||||||
|
// 普通邮件
|
||||||
|
MailNormal = 1;
|
||||||
|
|
||||||
|
// 特殊邮件
|
||||||
|
MailSpecial = 2;
|
||||||
|
|
||||||
|
// 后台邮件
|
||||||
|
MailBackground = 3;
|
||||||
|
|
||||||
|
// 全服邮件
|
||||||
|
MailAllRegion = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum MailStatus {
|
||||||
|
|
||||||
|
//未读
|
||||||
|
Unread = 0;
|
||||||
|
|
||||||
|
//已读
|
||||||
|
HasRead = 1;
|
||||||
|
|
||||||
|
//已领取
|
||||||
|
Received = 2;
|
||||||
|
|
||||||
|
//已删除
|
||||||
|
Deleted = 3;
|
||||||
|
}
|
||||||
|
|
||||||
enum AttrType {
|
enum AttrType {
|
||||||
AttrTypeNone = 0; //无属性
|
AttrTypeNone = 0; //无属性
|
||||||
Attack = 1; //攻击
|
Attack = 1; //攻击
|
||||||
Hp = 2; //生命
|
Hp = 2; //生命
|
||||||
AttrPhysicalDefense = 3; //物防
|
PhysicalDefense = 3; //物防
|
||||||
AttrMagicDefense = 4; //法防
|
MagicDefense = 4; //法防
|
||||||
AttrAttackRatio = 5; //攻击加成
|
AttackRatio = 5; //攻击加成
|
||||||
AttrHpRatio = 6; //生命加成
|
HpRatio = 6; //生命加成
|
||||||
AttrPhysicalDefenseRatio = 7; //物防加成
|
PhysicalDefenseRatio = 7; //物防加成
|
||||||
AttrMagicDefenseRatio = 8; //法防加成
|
MagicDefenseRatio = 8; //法防加成
|
||||||
AttrDamageRatio = 9; //伤害加成
|
DamageRatio = 9; //伤害加成
|
||||||
AttrDamageRelief = 10; //伤害减免
|
DamageRelief = 10; //伤害减免
|
||||||
AttrCriticalRatio = 11; //暴击几率
|
CriticalRate = 11; //暴击几率
|
||||||
AttrCriticalResistance = 12; //抗暴几率
|
CriticalResistance = 12; //抗暴几率
|
||||||
AttrCriticalDamage = 13; //暴击伤害
|
CriticalDamage = 13; //暴击伤害
|
||||||
AttrCriticalDamageRelief = 14; //暴伤减免
|
CriticalDamageRelief = 14; //暴伤减免
|
||||||
AttrHitRate = 15; //命中几率
|
HitRate = 15; //命中几率
|
||||||
AttrDodgeRate = 16; //闪避几率
|
DodgeRate = 16; //闪避几率
|
||||||
AttrTreatRatio = 17; //治疗加成
|
TreatRatio = 17; //治疗加成
|
||||||
AttrByTreatedRatio = 18; //被治疗率
|
ByTreatedRate = 18; //被治疗率
|
||||||
AttrFinalDamageRatio = 19; //最终增伤
|
FinalDamageRatio = 19; //最终增伤
|
||||||
AttrFinalDamageRelief = 20; //最终减伤
|
FinalDamageRelief = 20; //最终减伤
|
||||||
AttrBlockRate = 21; //格挡
|
BlockRate = 21; //格挡
|
||||||
AttrBlockResistance = 22; //抗格挡
|
BlockResistance = 22; //抗格挡
|
||||||
AttrSpeed = 23; //速度
|
AttrNums = 23; //属性总数量
|
||||||
Nums = 24; //属性总数量
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
90
proto/idl/mod_mail.proto
Normal file
90
proto/idl/mod_mail.proto
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package Pb;
|
||||||
|
option go_package = "pb/";
|
||||||
|
|
||||||
|
import "enums.proto";
|
||||||
|
import "mod_item.proto";
|
||||||
|
|
||||||
|
// ModId.ModuleMail = 8000;
|
||||||
|
// 邮件模块消息定义
|
||||||
|
// 如果定义的消息内没有字段或者消息被注释掉了,说明该请求不需要参数,发送消息时仅发送包头即可,包体可为空, 返回的消息亦是如此。
|
||||||
|
|
||||||
|
message Mail {
|
||||||
|
uint64 Uid = 1; //唯一ID
|
||||||
|
MailType Type = 2; //邮件类型,见MailType
|
||||||
|
string title = 3; //标题
|
||||||
|
string content = 4; //内容
|
||||||
|
int64 CreateTime = 5; //创建时间
|
||||||
|
int64 Expiration = 6; //过期时间,0不过期
|
||||||
|
MailStatus Status = 7; //邮件状态,见MailStatus
|
||||||
|
repeated string Args = 8; //邮件参数,用于替换内容中的占符
|
||||||
|
repeated Item ItemList = 9; //物品列表, 没有物品为空
|
||||||
|
}
|
||||||
|
|
||||||
|
message MailChange {
|
||||||
|
uint64 Uid = 1; //唯一ID
|
||||||
|
MailStatus Status = 7; //邮件状态,见MailStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgId.ModMailList = 8001;
|
||||||
|
// MsgId.ModMailSend = 8002;
|
||||||
|
// 邮件列表返回
|
||||||
|
message MailListAck {
|
||||||
|
repeated Mail MailList = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgId.ModMailSend = 8002;
|
||||||
|
// 邮件发送请求
|
||||||
|
message MailSendReq {
|
||||||
|
uint64 UserId = 1; //用户ID
|
||||||
|
uint32 AreaId = 2; //区ID(服务器ID)
|
||||||
|
uint64 RoleId = 3; //角色ID
|
||||||
|
Mail Mail = 4; //邮件
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgId.ModMailSend = 8002;
|
||||||
|
// 邮件发送返回
|
||||||
|
message MailSendAck {
|
||||||
|
Mail Mail = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgId.ModMailChange = 8003;
|
||||||
|
// 邮件为变更列表返回
|
||||||
|
message MailChangeListAck {
|
||||||
|
repeated MailChange ChangeList = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgId.ModMailRead = 8004;
|
||||||
|
// 邮件读取请求
|
||||||
|
message MailReadReq {
|
||||||
|
uint64 Uid = 1; //唯一ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgId.ModMailReceive = 8005;
|
||||||
|
// 邮件物品领取请求
|
||||||
|
message MailReceiveReq {
|
||||||
|
uint64 Uid = 1; //唯一ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgId.ModMailReceiveAll = 8006;
|
||||||
|
// 邮件物品领取所有
|
||||||
|
message MailReceiveAllReq {
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgId.ModMailReceive = 8005;
|
||||||
|
// MsgId.ModMailReceiveAll = 8006;
|
||||||
|
// 邮件物品领取返回
|
||||||
|
message MailReceiveAck {
|
||||||
|
repeated Item ItemList = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgId.ModMailDelete = 8007;
|
||||||
|
// 邮件删除请求
|
||||||
|
message MailDeleteReq {
|
||||||
|
uint64 Uid = 1; //唯一ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// MsgId.ModMailDeleteAll = 8008;
|
||||||
|
// 邮件删除所有请求
|
||||||
|
message MailDeleteAllReq {
|
||||||
|
}
|
@ -1,194 +1,251 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
//func (this *PlayerHandler) MailRead(player *logic.Player, msg *net.Message) {
|
import (
|
||||||
// var req = new(proto.MsgMailReadReq)
|
"ecs/proto"
|
||||||
// var err = msg.Read(req)
|
"ecs/proto/pb"
|
||||||
// if err != nil {
|
"ecs/servers/game/logic"
|
||||||
// this.logger.Error("Read message failed, ", err)
|
"github.com/oylshe1314/framework/net"
|
||||||
// _ = player.TipNotice(proto.ErrMessageError)
|
)
|
||||||
// return
|
|
||||||
// }
|
func (this *PlayerHandler) MailSend(player *logic.Player, msg *net.Message) {
|
||||||
//
|
var req = new(pb.MailSendReq)
|
||||||
// if req.Id == 0 {
|
var err = msg.Read(req)
|
||||||
// this.logger.Error("Parameter error, req.Id == 0")
|
if err != nil {
|
||||||
// _ = player.TipNotice(proto.ErrParameterError)
|
this.logger.Error("Read message failed, ", err)
|
||||||
// return
|
_ = player.TipNotice(proto.TipMessageError)
|
||||||
// }
|
return
|
||||||
//
|
}
|
||||||
// var mail = player.Mail[req.Id]
|
|
||||||
// if mail == nil {
|
if req.UserId == 0 {
|
||||||
// this.logger.Error("Parameter error, Player 'Mail' was not found, id: ", req.Id)
|
this.logger.Error("Parameter error, req.UserId == 0")
|
||||||
// _ = player.TipNotice(proto.ErrMailNotFound)
|
_ = player.TipNotice(proto.TipParameterError)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusHasRead {
|
if req.AreaId == 0 {
|
||||||
// return
|
this.logger.Error("Parameter error, req.AreaId == 0")
|
||||||
// }
|
_ = player.TipNotice(proto.TipParameterError)
|
||||||
//
|
return
|
||||||
// mail.Status = uint32(proto.MailStatusHasRead)
|
}
|
||||||
//
|
|
||||||
// player.SaveModel(mail)
|
if req.RoleId == 0 {
|
||||||
//
|
this.logger.Error("Parameter error, req.RoleId == 0")
|
||||||
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailRead, &proto.MsgMailReadAck{MailChange: &proto.MailChange{Id: mail.Id, Status: mail.Status}})
|
_ = player.TipNotice(proto.TipParameterError)
|
||||||
//
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Mail == nil {
|
||||||
|
this.logger.Error("Parameter error, req.Mail == nil")
|
||||||
|
_ = player.TipNotice(proto.TipParameterError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = player.TipNotice(proto.TipServerError)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *PlayerHandler) MailRead(player *logic.Player, msg *net.Message) {
|
||||||
|
var req = new(pb.MailReadReq)
|
||||||
|
var err = msg.Read(req)
|
||||||
|
if err != nil {
|
||||||
|
this.logger.Error("Read message failed, ", err)
|
||||||
|
_ = player.TipNotice(proto.TipMessageError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Uid == 0 {
|
||||||
|
this.logger.Error("Parameter error, req.Uid == 0")
|
||||||
|
_ = player.TipNotice(proto.TipParameterError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var mail = player.Mail[req.Uid]
|
||||||
|
if mail == nil {
|
||||||
|
this.logger.Error("Parameter error, player 'Mail' was not found, req.Uid: ", req.Uid)
|
||||||
|
_ = player.TipNotice(proto.TipMailNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if pb.MailStatus(mail.Status) >= pb.MailStatus_HasRead {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mail.Status = uint32(pb.MailStatus_HasRead)
|
||||||
|
|
||||||
|
player.SaveModel(mail)
|
||||||
|
|
||||||
|
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailRead, &pb.MailChangeListAck{
|
||||||
|
ChangeList: []*pb.MailChange{{Uid: mail.Uid, Status: pb.MailStatus(mail.Status)}},
|
||||||
|
})
|
||||||
|
|
||||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailRead, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
// 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) {
|
func (this *PlayerHandler) MailReceive(player *logic.Player, msg *net.Message) {
|
||||||
// var req = new(proto.MsgMailReceiveReq)
|
var req = new(pb.MailReceiveReq)
|
||||||
// var err = msg.Read(req)
|
var err = msg.Read(req)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// this.logger.Error("Read message failed, ", err)
|
this.logger.Error("Read message failed, ", err)
|
||||||
// _ = player.TipNotice(proto.ErrMessageError)
|
_ = player.TipNotice(proto.TipMessageError)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if req.Id == 0 {
|
if req.Uid == 0 {
|
||||||
// this.logger.Error("Parameter error, req.Id == 0")
|
this.logger.Error("Parameter error, req.Uid == 0")
|
||||||
// _ = player.TipNotice(proto.ErrParameterError)
|
_ = player.TipNotice(proto.TipParameterError)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// var mail = player.Mail[req.Id]
|
var mail = player.Mail[req.Uid]
|
||||||
// if mail == nil {
|
if mail == nil {
|
||||||
// this.logger.Error("Parameter error, Player 'Mail' was not found, id: ", req.Id)
|
this.logger.Error("Parameter error, player 'Mail' was not found, req.Uid: ", req.Uid)
|
||||||
// _ = player.TipNotice(proto.ErrMailNotFound)
|
_ = player.TipNotice(proto.TipMailNotFound)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusReceived {
|
if len(mail.Items) == 0 {
|
||||||
// return
|
this.logger.Error("Parameter error, len(mail.Items) == 0, req.Uid: ", req.Uid)
|
||||||
// }
|
_ = player.TipNotice(proto.TipMailNoItems)
|
||||||
//
|
return
|
||||||
// if len(mail.ItemId) == 0 || len(mail.ItemNum) == 0 {
|
}
|
||||||
// return
|
|
||||||
// }
|
if pb.MailStatus(mail.Status) >= pb.MailStatus_Received {
|
||||||
//
|
return
|
||||||
// var rewardList []*proto.ItemPair
|
}
|
||||||
// for i := range mail.ItemId {
|
|
||||||
// _ = player.AddItem(mail.ItemId[i], mail.ItemNum[i], logic.LogTypeItemObtainByMail)
|
var itemList []*pb.Item
|
||||||
// rewardList = append(rewardList, &proto.ItemPair{ItemId: mail.ItemId[i], ItemNum: mail.ItemNum[i]})
|
for i := range mail.Items {
|
||||||
// }
|
_ = player.AddItem(mail.Items[i][0], mail.Items[i][1], logic.LogTypeItemObtainByMail)
|
||||||
//
|
itemList = append(itemList, &pb.Item{ItemId: mail.Items[i][0], ItemNum: mail.Items[i][1]})
|
||||||
// mail.Status = uint32(proto.MailStatusReceived)
|
}
|
||||||
//
|
|
||||||
// player.SaveModel(mail)
|
mail.Status = uint32(pb.MailStatus_Received)
|
||||||
//
|
|
||||||
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailReceive, &proto.MsgMailReceiveAck{
|
player.SaveModel(mail)
|
||||||
// MsgRewardListAck: &proto.MsgRewardListAck{RewardList: rewardList},
|
|
||||||
// MailChange: &proto.MailChange{Id: mail.Id, Status: mail.Status},
|
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailReceive, &pb.MailReceiveAck{
|
||||||
// })
|
ItemList: itemList,
|
||||||
//
|
})
|
||||||
|
|
||||||
|
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailChange, &pb.MailChangeListAck{
|
||||||
|
ChangeList: []*pb.MailChange{{Uid: mail.Uid, Status: pb.MailStatus(mail.Status)}},
|
||||||
|
})
|
||||||
|
|
||||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailReward, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
// 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) {
|
func (this *PlayerHandler) MailReceiveAll(player *logic.Player, _ *net.Message) {
|
||||||
// var rewardList []*proto.ItemPair
|
var changeList []*pb.MailChange
|
||||||
// var changeList []*proto.MailChange
|
var mailItems = map[uint32]uint32{}
|
||||||
// var itemPair = map[uint32]uint32{}
|
for uid, mail := range player.Mail {
|
||||||
// for id, mail := range player.Mail {
|
if pb.MailStatus(mail.Status) >= pb.MailStatus_Received {
|
||||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusReceived {
|
continue
|
||||||
// continue
|
}
|
||||||
// }
|
|
||||||
//
|
if len(mail.Items) == 0 {
|
||||||
// if len(mail.ItemId) == 0 || len(mail.ItemNum) == 0 {
|
continue
|
||||||
// return
|
}
|
||||||
// }
|
|
||||||
//
|
for i := range mail.Items {
|
||||||
// for i := range mail.ItemId {
|
mailItems[mail.Items[i][0]] += mail.Items[i][1]
|
||||||
// itemPair[mail.ItemId[i]] += mail.ItemNum[i]
|
}
|
||||||
// }
|
|
||||||
//
|
mail.Status = uint32(pb.MailStatus_Received)
|
||||||
// mail.Status = uint32(proto.MailStatusReceived)
|
player.SaveModel(mail)
|
||||||
// player.SaveModel(mail)
|
|
||||||
//
|
changeList = append(changeList, &pb.MailChange{Uid: uid, Status: pb.MailStatus(mail.Status)})
|
||||||
// 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)
|
//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 {
|
var itemList []*pb.Item
|
||||||
// _ = player.AddItem(itemId, itemNum, logic.LogTypeItemObtainByMail)
|
for itemId, itemNum := range mailItems {
|
||||||
// rewardList = append(rewardList, &proto.ItemPair{ItemId: itemId, ItemNum: itemNum})
|
_ = player.AddItem(itemId, itemNum, logic.LogTypeItemObtainByMail)
|
||||||
// }
|
itemList = append(itemList, &pb.Item{ItemId: itemId, ItemNum: itemNum})
|
||||||
//
|
}
|
||||||
// if len(changeList) > 0 {
|
|
||||||
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailReceiveAll, &proto.MsgMailReceiveAllAck{
|
if len(itemList) > 0 {
|
||||||
// MsgRewardListAck: &proto.MsgRewardListAck{RewardList: rewardList},
|
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailReceiveAll, &pb.MailReceiveAck{
|
||||||
// ChangeList: changeList,
|
ItemList: itemList,
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
//}
|
|
||||||
//
|
if len(changeList) > 0 {
|
||||||
//func (this *PlayerHandler) MailDelete(player *logic.Player, msg *net.Message) {
|
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailChange, &pb.MailChangeListAck{
|
||||||
// var req = new(proto.MsgMailDeleteReq)
|
ChangeList: changeList,
|
||||||
// var err = msg.Read(req)
|
})
|
||||||
// if err != nil {
|
}
|
||||||
// this.logger.Error("Read message failed, ", err)
|
}
|
||||||
// _ = player.TipNotice(proto.ErrMessageError)
|
|
||||||
// return
|
func (this *PlayerHandler) MailDelete(player *logic.Player, msg *net.Message) {
|
||||||
// }
|
var req = new(pb.MailDeleteReq)
|
||||||
//
|
var err = msg.Read(req)
|
||||||
// if req.Id == 0 {
|
if err != nil {
|
||||||
// this.logger.Error("Parameter error, req.Id == 0")
|
this.logger.Error("Read message failed, ", err)
|
||||||
// _ = player.TipNotice(proto.ErrParameterError)
|
_ = player.TipNotice(proto.TipMessageError)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// var mail = player.Mail[req.Id]
|
if req.Uid == 0 {
|
||||||
// if mail == nil {
|
this.logger.Error("Parameter error, req.Uid == 0")
|
||||||
// this.logger.Error("Parameter error, Player 'Mail' was not found, id: ", req.Id)
|
_ = player.TipNotice(proto.TipParameterError)
|
||||||
// _ = player.TipNotice(proto.ErrMailNotFound)
|
return
|
||||||
// return
|
}
|
||||||
// }
|
|
||||||
//
|
var mail = player.Mail[req.Uid]
|
||||||
// if proto.MailType(mail.Type) == proto.MailTypeRegion {
|
if mail == nil {
|
||||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusDeleted {
|
//this.logger.Error("Parameter error, Player 'Mail' was not found, req.Uid: ", req.Uid)
|
||||||
// return
|
//_ = player.TipNotice(proto.TipMailNotFound)
|
||||||
// }
|
return
|
||||||
// mail.Status = uint32(proto.MailStatusDeleted)
|
}
|
||||||
// player.SaveModel(mail)
|
|
||||||
// } else {
|
if pb.MailType(mail.Type) == pb.MailType_MailAllRegion {
|
||||||
// delete(player.Mail, req.Id)
|
if pb.MailStatus(mail.Status) >= pb.MailStatus_Deleted {
|
||||||
// player.WipeModel(mail)
|
return
|
||||||
// }
|
}
|
||||||
//
|
mail.Status = uint32(pb.MailStatus_Deleted)
|
||||||
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailDelete, &proto.MsgMailDeleteAck{MailChange: &proto.MailChange{Id: mail.Id, Status: mail.Status}})
|
player.SaveModel(mail)
|
||||||
//
|
} else {
|
||||||
|
delete(player.Mail, req.Uid)
|
||||||
|
player.WipeModel(mail)
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailChange, &pb.MailChangeListAck{
|
||||||
|
ChangeList: []*pb.MailChange{{Uid: mail.Uid, Status: pb.MailStatus(mail.Status)}},
|
||||||
|
})
|
||||||
|
|
||||||
// this.eventManager.PlayerMailLog(player, logic.LogTypeMailDelete, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
// 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) {
|
func (this *PlayerHandler) MailDeleteAll(player *logic.Player, _ *net.Message) {
|
||||||
// var changeList []*proto.MailChange
|
var changeList []*pb.MailChange
|
||||||
// for id, mail := range player.Mail {
|
for id, mail := range player.Mail {
|
||||||
// if proto.MailStatus(mail.Status) < proto.MailStatusHasRead {
|
if pb.MailStatus(mail.Status) < pb.MailStatus_HasRead {
|
||||||
// continue
|
continue
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if len(mail.ItemId) > 0 {
|
if len(mail.Items) > 0 {
|
||||||
// if proto.MailStatus(mail.Status) < proto.MailStatusReceived {
|
if pb.MailStatus(mail.Status) < pb.MailStatus_Received {
|
||||||
// continue
|
continue
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if proto.MailType(mail.Type) == proto.MailTypeRegion {
|
if pb.MailType(mail.Type) == pb.MailType_MailAllRegion {
|
||||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusDeleted {
|
if pb.MailStatus(mail.Status) >= pb.MailStatus_Deleted {
|
||||||
// continue
|
continue
|
||||||
// }
|
}
|
||||||
// mail.Status = uint32(proto.MailStatusDeleted)
|
mail.Status = uint32(pb.MailStatus_Deleted)
|
||||||
// player.SaveModel(mail)
|
player.SaveModel(mail)
|
||||||
// } else {
|
} else {
|
||||||
// delete(player.Mail, id)
|
delete(player.Mail, id)
|
||||||
// player.WipeModel(mail)
|
player.WipeModel(mail)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// changeList = append(changeList, &proto.MailChange{Id: id, Status: uint32(proto.MailStatusDeleted)})
|
changeList = append(changeList, &pb.MailChange{Uid: id, Status: pb.MailStatus_Deleted})
|
||||||
//
|
|
||||||
//this.eventManager.PlayerMailLog(player, logic.LogTypeMailDelete, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
//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 {
|
if len(changeList) > 0 {
|
||||||
// _ = player.Send(proto.ModIdMail, proto.MsgIdMailDeleteAll, &proto.MsgMailDeleteAllAck{ChangeList: changeList})
|
_ = player.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailChange, &pb.MailChangeListAck{ChangeList: changeList})
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
@ -1,84 +1,71 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
//type PlayerMail struct {
|
import (
|
||||||
// Id uint64 `bson:"id" key:"1"`
|
"ecs/proto/pb"
|
||||||
// Type uint32 `bson:"type"`
|
)
|
||||||
// Title string `bson:"title"`
|
|
||||||
// Content string `bson:"content"`
|
type PlayerMail struct {
|
||||||
// Args []string `bson:"args"`
|
Uid uint64 `bson:"uid" key:"1"`
|
||||||
// Status uint32 `bson:"status"`
|
Type uint32 `bson:"type"`
|
||||||
// ItemId []uint32 `bson:"item_id"`
|
Title string `bson:"title"`
|
||||||
// ItemNum []uint32 `bson:"item_num"`
|
Content string `bson:"content"`
|
||||||
// CreateTime int64 `bson:"create_time"`
|
Status uint32 `bson:"status"`
|
||||||
// Expiration int64 `bson:"expiration"`
|
CreateTime int64 `bson:"create_time"`
|
||||||
//}
|
Expiration int64 `bson:"expiration"`
|
||||||
//
|
Args []string `bson:"args"`
|
||||||
//func (this *PlayerMail) BuildMsgMail() *proto.Mail {
|
Items [][2]uint32 `bson:"items"`
|
||||||
// var itemList []*proto.ItemPair
|
}
|
||||||
// for i, itemId := range this.ItemId {
|
|
||||||
// itemList = append(itemList, &proto.ItemPair{ItemId: itemId, ItemNum: this.ItemNum[i]})
|
func (this *PlayerMail) BuildMsgMail() *pb.Mail {
|
||||||
// }
|
var itemList []*pb.Item
|
||||||
// return &proto.Mail{
|
for i := range this.Items {
|
||||||
// Id: this.Id,
|
itemList = append(itemList, &pb.Item{ItemId: this.Items[i][0], ItemNum: this.Items[i][1]})
|
||||||
// Type: this.Type,
|
}
|
||||||
// Title: this.Title,
|
return &pb.Mail{
|
||||||
// Content: this.Content,
|
Uid: this.Uid,
|
||||||
// Args: this.Args,
|
Type: pb.MailType(this.Type),
|
||||||
// Status: this.Status,
|
Title: this.Title,
|
||||||
// ItemList: itemList,
|
Content: this.Content,
|
||||||
// CreateTime: this.CreateTime,
|
CreateTime: this.CreateTime,
|
||||||
// Expiration: this.Expiration,
|
Expiration: this.Expiration,
|
||||||
// }
|
Status: pb.MailStatus(this.Status),
|
||||||
//}
|
Args: this.Args,
|
||||||
//
|
ItemList: itemList,
|
||||||
//func (this *Player) AddMail(tipe proto.MailType, title, content string, args []string, itemId, itemNum []uint32, createTime int64, expiration ...int64) {
|
}
|
||||||
// counter, err := this.manager.mongoClient.Counter("mail_id", 1)
|
}
|
||||||
// if err != nil {
|
|
||||||
// this.manager.logger.Error("Get counter failed, ", err)
|
func (this *Player) AddMail(uid uint64, tipe pb.MailType, title, content string, createTime, expiration int64, args []string, items [][2]uint32) {
|
||||||
// return
|
var mail = &PlayerMail{
|
||||||
// }
|
Uid: uid,
|
||||||
//
|
Type: uint32(tipe),
|
||||||
// this.addMail(util.EncryptUid(counter), tipe, title, content, args, itemId, itemNum, createTime, expiration...)
|
Title: title,
|
||||||
//}
|
Content: content,
|
||||||
//
|
Status: uint32(pb.MailStatus_Unread),
|
||||||
//func (this *Player) addMail(mailId uint64, tipe proto.MailType, title, content string, args []string, itemId, itemNum []uint32, createTime int64, expiration ...int64) {
|
CreateTime: createTime,
|
||||||
// var mail = &PlayerMail{
|
Expiration: expiration,
|
||||||
// Id: mailId,
|
Args: args,
|
||||||
// Type: uint32(tipe),
|
Items: items,
|
||||||
// Title: title,
|
}
|
||||||
// Content: content,
|
|
||||||
// Args: args,
|
this.Mail[mail.Uid] = mail
|
||||||
// Status: uint32(proto.MailStatusUnread),
|
this.SaveModel(mail)
|
||||||
// ItemId: itemId,
|
|
||||||
// ItemNum: itemNum,
|
_ = this.Send(pb.ModId_ModuleMail, pb.MsgId_ModMailSend, &pb.MailSendAck{Mail: mail.BuildMsgMail()})
|
||||||
// CreateTime: createTime,
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if len(expiration) > 0 {
|
|
||||||
// mail.Expiration = expiration[0]
|
|
||||||
// } else {
|
|
||||||
// mail.Expiration = mail.CreateTime + util.DayTotalSeconds*30
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// this.Mail[mail.Id] = mail
|
|
||||||
// this.SaveModel(mail)
|
|
||||||
//
|
|
||||||
// _ = this.Send(proto.ModIdMail, proto.MsgIdMailSend, &proto.MsgMailSendAck{Mail: mail.BuildMsgMail()})
|
|
||||||
//
|
|
||||||
//this.manager.eventManager.PlayerMailLog(this, LogTypeMailGet, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
//this.manager.eventManager.PlayerMailLog(this, LogTypeMailGet, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//func (this *Player) BuildMsgMailListAck() *proto.MsgMailListAck {
|
func (this *Player) BuildMsgMailListAck() *pb.MailListAck {
|
||||||
// var mailList []*proto.Mail
|
var mailList []*pb.Mail
|
||||||
// for _, mail := range this.Mail {
|
for _, mail := range this.Mail {
|
||||||
// if proto.MailStatus(mail.Status) >= proto.MailStatusDeleted {
|
if pb.MailStatus(mail.Status) >= pb.MailStatus_Deleted {
|
||||||
// continue
|
continue
|
||||||
// }
|
}
|
||||||
// var itemList []*proto.ItemPair
|
var itemList []*pb.Item
|
||||||
// for i := range mail.ItemId {
|
for i := range mail.Items {
|
||||||
// itemList = append(itemList, &proto.ItemPair{ItemId: mail.ItemId[i], ItemNum: mail.ItemNum[i]})
|
itemList = append(itemList, &pb.Item{ItemId: mail.Items[i][0], ItemNum: mail.Items[i][1]})
|
||||||
// }
|
}
|
||||||
// mailList = append(mailList, mail.BuildMsgMail())
|
mailList = append(mailList, mail.BuildMsgMail())
|
||||||
// }
|
}
|
||||||
// return &proto.MsgMailListAck{List: mailList}
|
return &pb.MailListAck{MailList: mailList}
|
||||||
//}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user