邮件优化

This commit is contained in:
hahwu 2025-05-14 16:35:53 +08:00
parent f0416cbb1f
commit 220d2bfc10
8 changed files with 102 additions and 85 deletions

View File

@ -22,8 +22,10 @@ const (
type TriggerMail struct { type TriggerMail struct {
Id int Id int
Title string Title string
SubTitle string
Content string Content string
EnglistTitle string EnglistTitle string
SubTitleEn string
EnglistContent string EnglistContent string
Items []*item.Item Items []*item.Item
Trigger []string Trigger []string

View File

@ -15,8 +15,8 @@ import (
l "log" l "log"
"server/db" "server/db"
"server/game/internal" "server/game/internal"
MsgMod "server/game/mod/msg" // Ensure this package exists and is correctly referenced
MsqMod "server/game/mod/msg" MsgMod "server/game/mod/msg"
"server/msg" "server/msg"
"time" "time"
@ -269,7 +269,7 @@ func (ad *GameLogic) SetUserData(Uid int, Op int, Data interface{}) {
ad.FriendMgr.Send(&MsgMod.Msg{ ad.FriendMgr.Send(&MsgMod.Msg{
From: Uid, From: Uid,
To: Uid, To: Uid,
Type: MsqMod.HANDLE_TYPE_VAR_USER_SET, Type: MsgMod.HANDLE_TYPE_VAR_USER_SET,
SendT: GoUtil.Now(), SendT: GoUtil.Now(),
Extra: VarOpration{Type: Op, Data: Data}, Extra: VarOpration{Type: Op, Data: Data},
}) })

View File

@ -90,6 +90,7 @@ func ReqGmCommand_(player *Player, Command string) error {
VarMod := player.PlayMod.getVarMod() VarMod := player.PlayMod.getVarMod()
VarMod.DailyResetTime = 0 VarMod.DailyResetTime = 0
player.ZeroUpdate(nil) player.ZeroUpdate(nil)
player.LoginBackData()
case "addChampshipLog": case "addChampshipLog":
num, _ := strconv.Atoi(arg[1]) num, _ := strconv.Atoi(arg[1])
player.AddLog(num, friend.LOG_TYPE_PLAYROOM_CHAMPSHIP, fmt.Sprintf("%d_%d", 1, 1)) player.AddLog(num, friend.LOG_TYPE_PLAYROOM_CHAMPSHIP, fmt.Sprintf("%d_%d", 1, 1))
@ -388,6 +389,25 @@ func ReqGmCommand_(player *Player, Command string) error {
EndTime: EndTime, EndTime: EndTime,
Num: int32(Times), Num: int32(Times),
}) })
case "sendMail":
MailMod := player.PlayMod.getMailMod()
title := `MMM圣诞节奖励`
content := `测试`
MailMod.Send(title, "副标题", content, title, "副标题", content, []*item.Item{
{
Id: item.ITEM_DIAMOND_ID,
Num: 10,
},
{
Id: item.ITEM_ENERGY_ID,
Num: 10,
},
{
Id: item.ITEM_STAR_ID,
Num: 10,
},
}, 2)
player.PushClientRes(MailMod.BackData())
case "recoverUser": case "recoverUser":
file, err := os.OpenFile(conf.Server.GameConfPath+"user.info", os.O_RDWR|os.O_CREATE, 0666) file, err := os.OpenFile(conf.Server.GameConfPath+"user.info", os.O_RDWR|os.O_CREATE, 0666)
if err != nil { if err != nil {

View File

@ -245,7 +245,7 @@ func handle(p *Player, m *msg.Msg) error {
MailMod := p.PlayMod.getMailMod() MailMod := p.PlayMod.getMailMod()
mt, mc, mt_en, mc_en := mailCfg.GetChargeSendMail(PlayerSimpleData.Name) mt, mc, mt_en, mc_en := mailCfg.GetChargeSendMail(PlayerSimpleData.Name)
Items := ChargeItem(p, C.ChargeId) Items := ChargeItem(p, C.ChargeId)
MailId := MailMod.Send(mt, mc, mt_en, mc_en, Items, mail.MAIL_TYPE_GIFT) MailId := MailMod.Send(mt, "", mc, mt_en, "", mc_en, Items, mail.MAIL_TYPE_GIFT)
p.AddLog(m.From, friend.LOG_TYPE_CHARGE_SEND, fmt.Sprintf("%d", MailId)) p.AddLog(m.From, friend.LOG_TYPE_CHARGE_SEND, fmt.Sprintf("%d", MailId))
p.PushClientRes(MailMod.NotifyMail(MailId)) p.PushClientRes(MailMod.NotifyMail(MailId))
case msg.HANDLE_TYPE_CHARGE_RECEIVE: // 收到好友的感谢信 case msg.HANDLE_TYPE_CHARGE_RECEIVE: // 收到好友的感谢信
@ -256,7 +256,7 @@ func handle(p *Player, m *msg.Msg) error {
PlayerSimpleData := G_GameLogicPtr.GetResSimplePlayerByUid(m.From) PlayerSimpleData := G_GameLogicPtr.GetResSimplePlayerByUid(m.From)
MailMod := p.PlayMod.getMailMod() MailMod := p.PlayMod.getMailMod()
mt, mc, mt_en, mc_en := mailCfg.GetChargeReceiveMail(PlayerSimpleData.Name, Content) mt, mc, mt_en, mc_en := mailCfg.GetChargeReceiveMail(PlayerSimpleData.Name, Content)
MailId := MailMod.Send(mt, mc, mt_en, mc_en, nil, mail.MAIL_TYPE_NORMAL) MailId := MailMod.Send(mt, "", mc, mt_en, "", mc_en, nil, mail.MAIL_TYPE_NORMAL)
p.AddLog(m.From, friend.LOG_TYPE_CHARGE_RECEIVE, fmt.Sprintf("%d", MailId)) p.AddLog(m.From, friend.LOG_TYPE_CHARGE_RECEIVE, fmt.Sprintf("%d", MailId))
p.PushClientRes(MailMod.NotifyMail(MailId)) p.PushClientRes(MailMod.NotifyMail(MailId))
case msg.HANDLE_TYPE_WISHLIST_SEND: // 发送愿望单请求 case msg.HANDLE_TYPE_WISHLIST_SEND: // 发送愿望单请求
@ -385,7 +385,7 @@ func SyncMailMsg(p *Player) {
continue continue
} }
MailMod.ServerMail = append(MailMod.ServerMail, v.Id) MailMod.ServerMail = append(MailMod.ServerMail, v.Id)
MailMod.Send(v.Title, v.Content, v.TitleEn, v.ContentEn, v.Items, v.Mail_type) MailMod.Send(v.Title, "", v.Content, v.TitleEn, "", v.ContentEn, v.Items, v.Mail_type)
} }
p.PushClientRes(MailMod.BackData()) p.PushClientRes(MailMod.BackData())
} }
@ -846,30 +846,7 @@ func EmitRetireTrigger2(p *Player) {
} }
func LoignBack(p *Player) { func LoignBack(p *Player) {
BaseMod := p.PlayMod.getBaseMod()
if BaseMod.LoginBack {
return
}
PlayBaseMod := p.GetPlayerBaseMod()
Num1, Num2 := mailCfg.GetLoginBack(PlayBaseMod.Data.UserName)
Items := make([]*item.Item, 0)
if Num1 != 0 {
Items = append(Items, &item.Item{Id: item.ITEM_DIAMOND_ID, Num: Num1})
}
if Num2 != 0 {
Items = append(Items, &item.Item{Id: item.ITEM_DIAMOND_ID, Num: Num2})
}
if len(Items) != 0 {
MailMod := p.PlayMod.getMailMod()
MailMod.Send("Test Players' Refund",
`Welcome back to our game!
Here comes your refund for your scene progress and payment in test version!
Have fun in new version!`, "Test Players' Refund",
`Welcome back to our game!
Here comes your refund for your scene progress and payment in test version!
Have fun in new version!`, Items, mail.MAIL_TYPE_NORMAL)
}
BaseMod.LoginBack = true
} }
func Benchmark(player *Player) { func Benchmark(player *Player) {

View File

@ -51,7 +51,7 @@ func (player *Player) MailTrigger(Tr *quest.Trigger) bool {
Content := languageCfg.GetLanguage(BaseMod.Lang, v.Content) Content := languageCfg.GetLanguage(BaseMod.Lang, v.Content)
TitleEn := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_EN, v.Title) TitleEn := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_EN, v.Title)
ContentEn := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_EN, v.Content) ContentEn := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_EN, v.Content)
MailMod.Send(Title, Content, TitleEn, ContentEn, v.Items, mail.MAIL_TYPE_NORMAL) MailMod.Send(Title, "", Content, TitleEn, "", ContentEn, v.Items, mail.MAIL_TYPE_NORMAL)
MailMod.AddTriggerMail(v.Id) MailMod.AddTriggerMail(v.Id)
tr = true tr = true
} }

View File

@ -185,23 +185,14 @@ func (l *LimitedTimeEventMod) GetMoneyCatReward(ChessList []int) []*item.Item {
Star := mergeDataCfg.GetMergeStar(ChessList) Star := mergeDataCfg.GetMergeStar(ChessList)
d := L.D.(*MoneyCat) d := L.D.(*MoneyCat)
mul := d.Mul mul := d.Mul
// 超时
if d.EndTime > 0 && GoUtil.Now() >= d.EndTime { MaxId := limitedTimeEventCfg.GetMoneyCatMax()
NextMul1, _ := limitedTimeEventCfg.GetMoneyCat(1) NextId := min(d.Id+1, MaxId)
NextMul2, Cd := limitedTimeEventCfg.GetMoneyCat(2) NextMul, Cd := limitedTimeEventCfg.GetMoneyCat(NextId)
d.EndTime = int64(Cd) + GoUtil.Now() d.Id = NextId
d.Mul = NextMul2 d.Mul = NextMul
d.Id = 2 d.EndTime = GoUtil.Now() + int64(Cd)
Star = int(math.Ceil(float64(Star) * (NextMul1 - 1))) Star = int(math.Ceil(float64(Star) * (mul - 1)))
} else {
MaxId := limitedTimeEventCfg.GetMoneyCatMax()
NextId := min(d.Id+1, MaxId)
NextMul, Cd := limitedTimeEventCfg.GetMoneyCat(NextId)
d.Id = NextId
d.Mul = NextMul
d.EndTime = GoUtil.Now() + int64(Cd)
Star = int(math.Ceil(float64(Star) * (mul - 1)))
}
return []*item.Item{{Id: item.ITEM_STAR_ID, Num: Star}} return []*item.Item{{Id: item.ITEM_STAR_ID, Num: Star}}
} }

View File

@ -26,15 +26,17 @@ const (
) )
type MailInfo struct { type MailInfo struct {
Title string // 邮件标题 Title string // 邮件标题
Content string // 邮件内容 SubTitle string // 邮件副标题
TitleEn string // 邮件标题英文 Content string // 邮件内容
ContentEn string // 邮件内容英文 TitleEn string // 邮件标题英文
Items []*item.Item // 邮件道具 SubTitleEn string // 邮件副标题英文
Type int //邮件类型 ContentEn string // 邮件内容英文
Send int64 // 发送时间 Items []*item.Item // 邮件道具
Del int64 // 删除时间 Type int //邮件类型
Status int Send int64 // 发送时间
Del int64 // 删除时间
Status int
} }
func (m *MailMod) InitData() { func (m *MailMod) InitData() {
@ -44,16 +46,18 @@ func (m *MailMod) InitData() {
} }
// 发送邮件 // 发送邮件
func (m *MailMod) Send(Title, Content, TitleEn, ContentEn string, Items []*item.Item, t int) int { func (m *MailMod) Send(Title, SubTitle, Content, TitleEn, SubTitleEn, ContentEn string, Items []*item.Item, t int) int {
m.AutoId++ m.AutoId++
m.List[m.AutoId] = &MailInfo{ m.List[m.AutoId] = &MailInfo{
Title: Title, Title: Title,
Content: Content, SubTitle: SubTitle,
TitleEn: TitleEn, Content: Content,
ContentEn: ContentEn, TitleEn: TitleEn,
Items: Items, SubTitleEn: SubTitleEn,
Send: GoUtil.Now(), ContentEn: ContentEn,
Type: t, Items: Items,
Send: GoUtil.Now(),
Type: t,
} }
return m.AutoId return m.AutoId
} }
@ -106,15 +110,17 @@ func (m *MailMod) BackData() *msg.ResMailList {
continue continue
} }
res.MailList[int32(k)] = &msg.MailInfo{ res.MailList[int32(k)] = &msg.MailInfo{
Id: int32(k), Id: int32(k),
Title: v.Title, Title: v.Title,
Content: v.Content, SubTitle: v.SubTitle,
TitleEn: v.TitleEn, Content: v.Content,
ContentEn: v.ContentEn, TitleEn: v.TitleEn,
Items: item.ItemToMsg(v.Items), SubTitleEn: v.SubTitleEn,
Status: int32(v.Status), ContentEn: v.ContentEn,
Time: int32(v.Send), Items: item.ItemToMsg(v.Items),
Type: int32(v.Type), Status: int32(v.Status),
Time: int32(v.Send),
Type: int32(v.Type),
} }
} }
return res return res

View File

@ -13815,15 +13815,17 @@ func (x *ResMailList) GetMailList() map[int32]*MailInfo {
type MailInfo struct { type MailInfo struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` // 邮件id Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` // 邮件id
Title string `protobuf:"bytes,2,opt,name=Title,proto3" json:"Title,omitempty"` // 标题 Title string `protobuf:"bytes,2,opt,name=Title,proto3" json:"Title,omitempty"` // 标题
Content string `protobuf:"bytes,3,opt,name=Content,proto3" json:"Content,omitempty"` // 内容 Content string `protobuf:"bytes,3,opt,name=Content,proto3" json:"Content,omitempty"` // 内容
Time int32 `protobuf:"varint,4,opt,name=Time,proto3" json:"Time,omitempty"` // 时间 Time int32 `protobuf:"varint,4,opt,name=Time,proto3" json:"Time,omitempty"` // 时间
Status int32 `protobuf:"varint,5,opt,name=Status,proto3" json:"Status,omitempty"` // 0 未读 1 已读 2 已领取 3 已删除 Status int32 `protobuf:"varint,5,opt,name=Status,proto3" json:"Status,omitempty"` // 0 未读 1 已读 2 已领取 3 已删除
Items []*ItemInfo `protobuf:"bytes,6,rep,name=Items,proto3" json:"Items,omitempty"` // 奖励 Items []*ItemInfo `protobuf:"bytes,6,rep,name=Items,proto3" json:"Items,omitempty"` // 奖励
Type int32 `protobuf:"varint,7,opt,name=Type,proto3" json:"Type,omitempty"` //邮件类型 1普通邮件 2节日邮件 3 礼包邮件 Type int32 `protobuf:"varint,7,opt,name=Type,proto3" json:"Type,omitempty"` //邮件类型 1普通邮件 2节日邮件 3 礼包邮件
TitleEn string `protobuf:"bytes,8,opt,name=TitleEn,proto3" json:"TitleEn,omitempty"` // 英文标题 TitleEn string `protobuf:"bytes,8,opt,name=TitleEn,proto3" json:"TitleEn,omitempty"` // 英文标题
ContentEn string `protobuf:"bytes,9,opt,name=ContentEn,proto3" json:"ContentEn,omitempty"` // 英文内容 ContentEn string `protobuf:"bytes,9,opt,name=ContentEn,proto3" json:"ContentEn,omitempty"` // 英文内容
SubTitle string `protobuf:"bytes,10,opt,name=SubTitle,proto3" json:"SubTitle,omitempty"` // 子标题
SubTitleEn string `protobuf:"bytes,11,opt,name=SubTitleEn,proto3" json:"SubTitleEn,omitempty"` // 英文子标题
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
@ -13921,6 +13923,20 @@ func (x *MailInfo) GetContentEn() string {
return "" return ""
} }
func (x *MailInfo) GetSubTitle() string {
if x != nil {
return x.SubTitle
}
return ""
}
func (x *MailInfo) GetSubTitleEn() string {
if x != nil {
return x.SubTitleEn
}
return ""
}
type MailNotify struct { type MailNotify struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
Info *MailInfo `protobuf:"bytes,1,opt,name=Info,proto3" json:"Info,omitempty"` Info *MailInfo `protobuf:"bytes,1,opt,name=Info,proto3" json:"Info,omitempty"`
@ -23619,7 +23635,7 @@ const file_proto_Gameapi_proto_rawDesc = "" +
"\bMailList\x18\x01 \x03(\v2#.tutorial.ResMailList.MailListEntryR\bMailList\x1aO\n" + "\bMailList\x18\x01 \x03(\v2#.tutorial.ResMailList.MailListEntryR\bMailList\x1aO\n" +
"\rMailListEntry\x12\x10\n" + "\rMailListEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\x05R\x03key\x12(\n" + "\x03key\x18\x01 \x01(\x05R\x03key\x12(\n" +
"\x05value\x18\x02 \x01(\v2\x12.tutorial.MailInfoR\x05value:\x028\x01\"\xec\x01\n" + "\x05value\x18\x02 \x01(\v2\x12.tutorial.MailInfoR\x05value:\x028\x01\"\xa8\x02\n" +
"\bMailInfo\x12\x0e\n" + "\bMailInfo\x12\x0e\n" +
"\x02Id\x18\x01 \x01(\x05R\x02Id\x12\x14\n" + "\x02Id\x18\x01 \x01(\x05R\x02Id\x12\x14\n" +
"\x05Title\x18\x02 \x01(\tR\x05Title\x12\x18\n" + "\x05Title\x18\x02 \x01(\tR\x05Title\x12\x18\n" +
@ -23629,7 +23645,12 @@ const file_proto_Gameapi_proto_rawDesc = "" +
"\x05Items\x18\x06 \x03(\v2\x12.tutorial.ItemInfoR\x05Items\x12\x12\n" + "\x05Items\x18\x06 \x03(\v2\x12.tutorial.ItemInfoR\x05Items\x12\x12\n" +
"\x04Type\x18\a \x01(\x05R\x04Type\x12\x18\n" + "\x04Type\x18\a \x01(\x05R\x04Type\x12\x18\n" +
"\aTitleEn\x18\b \x01(\tR\aTitleEn\x12\x1c\n" + "\aTitleEn\x18\b \x01(\tR\aTitleEn\x12\x1c\n" +
"\tContentEn\x18\t \x01(\tR\tContentEn\"4\n" + "\tContentEn\x18\t \x01(\tR\tContentEn\x12\x1a\n" +
"\bSubTitle\x18\n" +
" \x01(\tR\bSubTitle\x12\x1e\n" +
"\n" +
"SubTitleEn\x18\v \x01(\tR\n" +
"SubTitleEn\"4\n" +
"\n" + "\n" +
"MailNotify\x12&\n" + "MailNotify\x12&\n" +
"\x04Info\x18\x01 \x01(\v2\x12.tutorial.MailInfoR\x04Info\"\x1d\n" + "\x04Info\x18\x01 \x01(\v2\x12.tutorial.MailInfoR\x04Info\"\x1d\n" +