邮件优化

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 {
Id int
Title string
SubTitle string
Content string
EnglistTitle string
SubTitleEn string
EnglistContent string
Items []*item.Item
Trigger []string

View File

@ -15,8 +15,8 @@ import (
l "log"
"server/db"
"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"
"time"
@ -269,7 +269,7 @@ func (ad *GameLogic) SetUserData(Uid int, Op int, Data interface{}) {
ad.FriendMgr.Send(&MsgMod.Msg{
From: Uid,
To: Uid,
Type: MsqMod.HANDLE_TYPE_VAR_USER_SET,
Type: MsgMod.HANDLE_TYPE_VAR_USER_SET,
SendT: GoUtil.Now(),
Extra: VarOpration{Type: Op, Data: Data},
})

View File

@ -90,6 +90,7 @@ func ReqGmCommand_(player *Player, Command string) error {
VarMod := player.PlayMod.getVarMod()
VarMod.DailyResetTime = 0
player.ZeroUpdate(nil)
player.LoginBackData()
case "addChampshipLog":
num, _ := strconv.Atoi(arg[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,
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":
file, err := os.OpenFile(conf.Server.GameConfPath+"user.info", os.O_RDWR|os.O_CREATE, 0666)
if err != nil {

View File

@ -245,7 +245,7 @@ func handle(p *Player, m *msg.Msg) error {
MailMod := p.PlayMod.getMailMod()
mt, mc, mt_en, mc_en := mailCfg.GetChargeSendMail(PlayerSimpleData.Name)
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.PushClientRes(MailMod.NotifyMail(MailId))
case msg.HANDLE_TYPE_CHARGE_RECEIVE: // 收到好友的感谢信
@ -256,7 +256,7 @@ func handle(p *Player, m *msg.Msg) error {
PlayerSimpleData := G_GameLogicPtr.GetResSimplePlayerByUid(m.From)
MailMod := p.PlayMod.getMailMod()
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.PushClientRes(MailMod.NotifyMail(MailId))
case msg.HANDLE_TYPE_WISHLIST_SEND: // 发送愿望单请求
@ -385,7 +385,7 @@ func SyncMailMsg(p *Player) {
continue
}
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())
}
@ -846,30 +846,7 @@ func EmitRetireTrigger2(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) {

View File

@ -51,7 +51,7 @@ func (player *Player) MailTrigger(Tr *quest.Trigger) bool {
Content := languageCfg.GetLanguage(BaseMod.Lang, v.Content)
TitleEn := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_EN, v.Title)
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)
tr = true
}

View File

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

View File

@ -27,8 +27,10 @@ const (
type MailInfo struct {
Title string // 邮件标题
SubTitle string // 邮件副标题
Content string // 邮件内容
TitleEn string // 邮件标题英文
SubTitleEn string // 邮件副标题英文
ContentEn string // 邮件内容英文
Items []*item.Item // 邮件道具
Type int //邮件类型
@ -44,12 +46,14 @@ 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.List[m.AutoId] = &MailInfo{
Title: Title,
SubTitle: SubTitle,
Content: Content,
TitleEn: TitleEn,
SubTitleEn: SubTitleEn,
ContentEn: ContentEn,
Items: Items,
Send: GoUtil.Now(),
@ -108,8 +112,10 @@ func (m *MailMod) BackData() *msg.ResMailList {
res.MailList[int32(k)] = &msg.MailInfo{
Id: int32(k),
Title: v.Title,
SubTitle: v.SubTitle,
Content: v.Content,
TitleEn: v.TitleEn,
SubTitleEn: v.SubTitleEn,
ContentEn: v.ContentEn,
Items: item.ItemToMsg(v.Items),
Status: int32(v.Status),

View File

@ -13824,6 +13824,8 @@ type MailInfo struct {
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"` // 英文标题
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
sizeCache protoimpl.SizeCache
}
@ -13921,6 +13923,20 @@ func (x *MailInfo) GetContentEn() string {
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 {
state protoimpl.MessageState `protogen:"open.v1"`
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" +
"\rMailListEntry\x12\x10\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" +
"\x02Id\x18\x01 \x01(\x05R\x02Id\x12\x14\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" +
"\x04Type\x18\a \x01(\x05R\x04Type\x12\x18\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" +
"MailNotify\x12&\n" +
"\x04Info\x18\x01 \x01(\v2\x12.tutorial.MailInfoR\x04Info\"\x1d\n" +