Merge branch 'sdk' into online

This commit is contained in:
hahwu 2026-01-19 11:18:32 +08:00
commit ef62a9ba63
12 changed files with 139 additions and 112 deletions

View File

@ -213,13 +213,12 @@ func (ad *GameLogic) NewAccountInsertDataToDB() bool {
Uid: insertId, Uid: insertId,
EventName: "register", EventName: "register",
}) })
G_GameLogicPtr.AddLog(&Log{ // 创建玩家日志
Uid: insertId, player := new(Player)
EventName: "register_info", BaseMod := player.PlayMod.getBaseMod()
Param: map[string]interface{}{ BaseMod.Account = ad.Db_AccountInfo.UserName
"username": ad.Db_AccountInfo.UserName, player.TeLog("register", nil)
},
})
return true return true
} }
@ -922,6 +921,7 @@ func Destroy() {
log.Debug("服务器下线") log.Debug("服务器下线")
if G_GameLogicPtr != nil { if G_GameLogicPtr != nil {
G_GameLogicPtr.M_Players.Range(func(k, v interface{}) bool { G_GameLogicPtr.M_Players.Range(func(k, v interface{}) bool {
v.(*Player).PushAndSendClienRes(&msg.ForceKickOut{})
v.(*Player).ClearData() v.(*Player).ClearData()
log.Debug("palyer %d 断开连接 写入数据", k) log.Debug("palyer %d 断开连接 写入数据", k)
return true return true

View File

@ -1,12 +1,11 @@
package game package game
import ( import (
"fmt"
activityCfg "server/conf/activity" activityCfg "server/conf/activity"
catnipCfg "server/conf/catnip" catnipCfg "server/conf/catnip"
guesscolorCfg "server/conf/guess_color" guesscolorCfg "server/conf/guess_color"
itemCfg "server/conf/item"
languageCfg "server/conf/language" languageCfg "server/conf/language"
mailCfg "server/conf/mail"
miningCfg "server/conf/mining" miningCfg "server/conf/mining"
passCfg "server/conf/pass" passCfg "server/conf/pass"
raceCfg "server/conf/race" raceCfg "server/conf/race"
@ -92,12 +91,28 @@ func (p *Player) ActivityLogin() {
// 发送活动邮件 // 发送活动邮件
func (p *Player) SendActivityMail(ItemId, ItemNum, ActivityId int, RewardItems []*item.Item) { func (p *Player) SendActivityMail(ItemId, ItemNum, ActivityId int, RewardItems []*item.Item) {
MailMod := p.PlayMod.getMailMod() MailMod := p.PlayMod.getMailMod()
ItemName, ItemNameEn := itemCfg.GetItemName(ItemId) activity_title_key, mail_title_key, mail_content_key := activityCfg.GetActivityRecycleMail(ActivityId)
ActivityTitle, ActivityTitleEn := activityCfg.GetActivityTitle(ActivityId) activity_title_zh := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_CN, activity_title_key)
mt, mc, mt_en, mc_en := mailCfg.GetRecallMail(ActivityTitle, ActivityTitleEn, ItemName, ItemNameEn) activity_title_en := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_EN, activity_title_key)
activity_title_pt := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_PTBR, activity_title_key)
mt_zh := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_CN, mail_title_key)
mc_zh := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_CN, mail_content_key)
mt_en := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_EN, mail_title_key)
mc_en := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_EN, mail_content_key)
mt_pt := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_PTBR, activity_title_key)
mc_pt := languageCfg.GetLanguage(msg.LANG_TYPE_LANG_PTBR, mail_content_key)
Items := []*item.Item{item.NewItem(ItemId, ItemNum)} Items := []*item.Item{item.NewItem(ItemId, ItemNum)}
Items = append(Items, RewardItems...) Items = append(Items, RewardItems...)
MailMod.Send(mt, "", mc, mt_en, "", mc_en, Items, mail.MAIL_TYPE_NORMAL) MailMod.SendMail(&mail.MailStruct{
Title: fmt.Sprintf(mt_zh, activity_title_zh),
Content: fmt.Sprintf(mc_zh, activity_title_zh),
TitleEn: fmt.Sprintf(mt_en, activity_title_en),
ContentEn: fmt.Sprintf(mc_en, activity_title_en),
TitlePtBr: fmt.Sprintf(mt_pt, activity_title_pt),
ContentPtBr: fmt.Sprintf(mc_pt, activity_title_pt),
Items: Items,
Type: mail.MAIL_TYPE_NORMAL,
})
} }
// 活动模块 零点更新 // 活动模块 零点更新

View File

@ -182,10 +182,7 @@ func HandleClientReq(args []interface{}) {
p.(*Player).PlayMod.getBaseMod().DiviceId = detail.Device //加锁 p.(*Player).PlayMod.getBaseMod().DiviceId = detail.Device //加锁
p.(*Player).PushClientRes(ResLogin) p.(*Player).PushClientRes(ResLogin)
p.(*Player).LoginBackData() p.(*Player).LoginBackData()
G_GameLogicPtr.AddLog(&Log{ p.(*Player).TeLog("Login_log", nil)
Uid: p.(*Player).M_DwUin,
EventName: "Login_log",
})
} }
p.(*Player).ProcessTrigger() p.(*Player).ProcessTrigger()
case "ReqServerTime": // 获取服务器时间 case "ReqServerTime": // 获取服务器时间

View File

@ -380,6 +380,7 @@ func ReqGmCommand_(player *Player, Command string) error {
player.PlayMod.ClearData(player) player.PlayMod.ClearData(player)
case "logout": case "logout":
player.PushAndSendClienRes(&msg.ForceKickOut{}) player.PushAndSendClienRes(&msg.ForceKickOut{})
player.ClearData()
case "resetFriend": case "resetFriend":
FriendMod := player.PlayMod.getFriendMod() FriendMod := player.PlayMod.getFriendMod()
FriendMod.FriendList = make(map[int]struct{}) FriendMod.FriendList = make(map[int]struct{})

View File

@ -15,6 +15,7 @@ import (
userCfg "server/conf/user" userCfg "server/conf/user"
"server/game/mod/activity" "server/game/mod/activity"
"server/game/mod/card" "server/game/mod/card"
"server/game/mod/decorate"
"server/game/mod/friend" "server/game/mod/friend"
"server/game/mod/item" "server/game/mod/item"
limitedTimeEvent "server/game/mod/limited_time_event" limitedTimeEvent "server/game/mod/limited_time_event"
@ -849,6 +850,71 @@ func (player *Player) FixOrderBug() {
} }
} }
func (player *Player) FixDecorate() {
DecorateMod := player.PlayMod.getDecorateMod()
area_id := DecorateMod.GetAreaId()
progress := DecorateMod.GetProgress()
if GoUtil.InArray(area_id, []int{3, 4, 5}) && progress >= 20 {
items := []*item.Item{}
for i := progress + 1; i <= 25; i++ {
if area_id == 3 && i == 25 {
items = append(items, item.NewItem(item.ITEM_ENERGY_ID, 50))
items = append(items, item.NewItem(101449, 1))
}
if area_id == 4 && i == 22 {
items = append(items, item.NewItem(906, 1))
}
if area_id == 4 && i == 25 {
items = append(items, item.NewItem(item.ITEM_ENERGY_ID, 50))
items = append(items, item.NewItem(101452, 1))
}
if area_id == 5 && i == 25 {
items = append(items, item.NewItem(item.ITEM_ENERGY_ID, 50))
items = append(items, item.NewItem(101450, 1))
}
}
title := "Game Update & Thank-You Gift"
content := `Hi there!
Thanks so much for your continued support!
We've made a few updates to the gameand as a small thank-you, we've prepared a special gift for you.
Happy merging!
Meowment Team`
title_ptbr := "Atualização do Jogo e Presente de Agradecimento"
content_ptbr := `Olá!
Muito obrigado pelo seu apoio contínuo!
Fizemos algumas atualizações no jogo e como forma de agradecimento, preparamos um presente especial para você.
Boa diversão nas combinações!
Equipe Meowment `
MailMod := player.PlayMod.getMailMod()
MailMod.SendMail(&mail.MailStruct{
Title: title,
Content: content,
TitleEn: title,
ContentEn: content,
TitlePtBr: title_ptbr,
ContentPtBr: content_ptbr,
Items: items,
Type: mail.MAIL_TYPE_NORMAL,
})
DecorateMod.AreaId = area_id + 1
DecorateMod.FinishList = make(map[int]struct{})
DecorateMod.Progress = 0
DecorateMod.PartCost = make(map[int]*decorate.PartCostInfo)
DecorateMod.PartClassPool = []int{}
DecorateMod.PartPool = make(map[int]int)
DecorateMod.InitData()
log.Debug("player id : %d fix decorate old area id : %d old progress : %d", player.M_DwUin, area_id, progress)
player.PushClientRes(DecorateMod.BackData())
}
}
func (player *Player) CreatePetOrder() { func (player *Player) CreatePetOrder() {
BaseMod := player.PlayMod.getBaseMod() BaseMod := player.PlayMod.getBaseMod()
ChessMod := player.PlayMod.getChessMod() ChessMod := player.PlayMod.getChessMod()

View File

@ -634,15 +634,14 @@ func LoggingMiddleware() MessageMiddleware {
return func(next MessageHandlerFunc) MessageHandlerFunc { return func(next MessageHandlerFunc) MessageHandlerFunc {
return func(message *msg.Msg) (interface{}, error) { return func(message *msg.Msg) (interface{}, error) {
start := time.Now() start := time.Now()
log.Debug("[Middleware] Processing message : %v, time: %v", message, start) // log.Debug("[Middleware] Processing message : %v, time: %v", message, start)
result, err := next(message) result, err := next(message)
duration := time.Since(start) duration := time.Since(start)
if err != nil { if err != nil {
log.Error("[Middleware] Message : %v failed, duration: %v, error: %v", message, duration, err) log.Error("[Middleware] Message handle type: %d; type: %d failed, duration: %v, error: %v", message.HandleType, message.Type, duration, err)
} else { } else {
log.Debug("[Middleware] Message : %v success, duration: %v", message, duration) log.Debug("[Middleware] Message handle type: %d; type: %d success, duration: %v", message.HandleType, message.Type, duration)
} }
return result, err return result, err

View File

@ -284,65 +284,6 @@ func (c *ChargeMod) FireFreeShop() ([]*item.Item, error) {
return chargeCfg.GetFreeShopReward(c.FreeShop), nil return chargeCfg.GetFreeShopReward(c.FreeShop), nil
} }
// 返回数据
// func (c *ChargeMod) BackData() *msg.ResCharge {
// SpecialShop := make(map[int32]*msg.ResSpecialShop)
// ChessShop := make(map[int32]*msg.ResChessShop)
// for k, v := range c.SpecialShop {
// SpecialShop[int32(k)] = &msg.ResSpecialShop{
// Grade: int32(v.Grade),
// Count: int32(v.Count),
// }
// }
// for k, v := range c.ChessShop {
// ChessShop[int32(k)] = &msg.ResChessShop{
// Diamond: int32(v.Diamond),
// Count: int32(v.Count),
// ChessId: int32(v.Id),
// }
// }
// resWish := &msg.WishList{}
// if c.WishList != nil {
// resWish = &msg.WishList{
// Id: int32(c.WishList.ItemId),
// Count: int32(c.WishList.Count),
// Uid: c.WishList.SendList,
// }
// }
// WeeklyDiscount := make(map[int32]*msg.WeeklyDiscountInfo)
// WeeklyDiscountInfo := chargeCfg.GetWeeklyInfoAll()
// if c.IsWeeklyDiscountDay() {
// for k, v := range WeeklyDiscountInfo {
// LimitNum := c.WeeklyDiscount[k]
// WeeklyDiscount[int32(k)] = &msg.WeeklyDiscountInfo{
// Discount: int32(v.Discount),
// Count: int32(v.WeeklyLimit - LimitNum),
// Id: int32(k),
// }
// }
// }
// return &msg.ResCharge{
// Charge: float32(c.Charge),
// Total: int32(c.Total),
// First: GoUtil.MapIntToSlice(c.EnergyShop),
// SpecialShop: SpecialShop,
// FreeShop: int32(c.FreeShop),
// ChessShop: ChessShop,
// Gift: GoUtil.MapIntToInt32(c.Gift),
// Ad: c.Ad,
// SpecialCharge: float32(c.SpecialCharge),
// SpecialChargeWeek: int32(GoUtil.FullWeeksSince(c.LastSpecialCharge)),
// TodayCharge: float32(c.TodayCharge),
// MonthCharge: float32(c.MonthCharge),
// Wish: resWish,
// AdEndTime: c.AdEndTime,
// WeeklyDiscount: WeeklyDiscount,
// PetWorkRemainTime: c.PetWorkTime,
// WeeklyEndTime: c.WeeklyEndTime,
// }
// }
func (c *ChargeMod) InitChessShop(Emit []int) { func (c *ChargeMod) InitChessShop(Emit []int) {
if len(Emit) == 0 { if len(Emit) == 0 {
return return
@ -366,26 +307,12 @@ func (c *ChargeMod) InitChessShop(Emit []int) {
ChessLv := mergeDataCfg.GetLvById(c) ChessLv := mergeDataCfg.GetLvById(c)
DynamicLv := mergeDataCfg.GetAdjust(v, p, 0) DynamicLv := mergeDataCfg.GetAdjust(v, p, 0)
ChessLv += DynamicLv ChessLv += DynamicLv
Diamond := math.Round(math.Pow(2, float64(ChessLv-1)) / 18) Diamond := math.Round(math.Pow(2, float64(ChessLv-1)) / 5)
Diamond = max(1, Diamond) Diamond = max(1, Diamond)
RandList = append(RandList, &Rand{ChessId: c, Diamond: int(Diamond)}) RandList = append(RandList, &Rand{ChessId: c, Diamond: int(Diamond)})
} }
} }
//ColorList = append(ColorList, ProduceList...)
} }
// for _, v := range ColorList {
// ColorType := mergeDataCfg.GetColorType(v)
// r := make([]*Rand, 0)
// switch ColorType {
// case mergeDataCfg.CHESS_PRODUCT_MAIN_TYPE:
// r = getChessMainRand(v)
// case mergeDataCfg.CHESS_PRODUCT_SECONDARY_TYPE:
// r = getChessSecondaryRand(v)
// case mergeDataCfg.CHESS_PRODUCT_SUB_TYPE:
// r = getChessSubRand(v)
// }
// RandList = append(RandList, r...)
// }
randList := make([]interface{}, len(RandList)) randList := make([]interface{}, len(RandList))
for k, v := range RandList { for k, v := range RandList {
randList[k] = v randList[k] = v
@ -450,10 +377,6 @@ func (c *ChargeMod) BuyChess(Chess int, IsWeeklyDiscount bool) ([]*item.Item, []
} }
func (c *ChargeMod) TriggerChargeUnlock(Lv int, Emit []int) { func (c *ChargeMod) TriggerChargeUnlock(Lv int, Emit []int) {
//UnlockLv := chargeCfg.GetUnlockShopLv()
// if Lv != UnlockLv {
// return
// }
c.InitChessShop(Emit) c.InitChessShop(Emit)
} }

View File

@ -62,7 +62,7 @@ func (f *FriendTreasureMod) Flip(Pos int) ([]*item.Item, int64, error) {
} }
f.Shift++ f.Shift++
Info := f.List[Pos] Info := f.List[Pos]
log.Debug("pos:%v, info:%v", Pos, Info) //log.Debug("pos:%v, info:%v", Pos, Info)
if Info.Uid != 0 { if Info.Uid != 0 {
log.Debug("uid:%v", Info.Uid) log.Debug("uid:%v", Info.Uid)
f.Uids = append(f.Uids, Info.Uid) f.Uids = append(f.Uids, Info.Uid)

View File

@ -259,7 +259,7 @@ func (p *Player) InitPlayer(UserName string) error {
ChessMod := p.PlayMod.getChessMod() ChessMod := p.PlayMod.getChessMod()
ChargeMod.FixBug(ChessMod.GetEmitList()) ChargeMod.FixBug(ChessMod.GetEmitList())
p.FixOrderBug() p.FixOrderBug()
p.FixDecorate()
return nil return nil
} }
@ -432,10 +432,11 @@ func (p *Player) Outline() {
BaseMod.Outline(int(Cacumulative)) BaseMod.Outline(int(Cacumulative))
p.PlayMod.save() p.PlayMod.save()
p.TeLog("logout", map[string]interface{}{ p.TeLog("logout", map[string]interface{}{
"order_list": p.PlayMod.getOrderMod().GetOrderList(), "caccumulative": Cacumulative,
"after_level": p.PlayMod.getBaseMod().GetLevel(), "order_list": p.PlayMod.getOrderMod().GetOrderList(),
"tmp_diamond": p.PlayMod.getBaseMod().GetDiamond(), "after_level": p.PlayMod.getBaseMod().GetLevel(),
"tmp_energy": p.PlayMod.getBaseMod().GetEnergy(), "tmp_diamond": p.PlayMod.getBaseMod().GetDiamond(),
"tmp_energy": p.PlayMod.getBaseMod().GetEnergy(),
}) })
p.UpdateUserInfo() p.UpdateUserInfo()
} }
@ -1052,7 +1053,10 @@ func (p *Player) TeLog(Type string, Param map[string]interface{}) {
Param: Param, Param: Param,
}) })
agent := p.GetAgent() agent := p.GetAgent()
if agent != nil { if Param == nil {
Param = make(map[string]interface{})
}
if agent != nil && Param != nil {
Param["Ip"] = agent.RemoteAddr().String() Param["Ip"] = agent.RemoteAddr().String()
} }
//Param["#zone_offset"] = -5 //Param["#zone_offset"] = -5

View File

@ -11,7 +11,7 @@ import (
) )
const ( const (
FEISHU_WEBHOOK = "https://gadmin.bywaystudios.com/api/feishu/notify" FEISHU_WEBHOOK = "https://gadmin.bywaystudios.com/api/alibaba/game/notify"
FEISHU_ORDER = "https://gadmin.bywaystudios.com/api/feishu/notify/order" FEISHU_ORDER = "https://gadmin.bywaystudios.com/api/feishu/notify/order"
) )
@ -21,10 +21,9 @@ func SendFeishuFatal(PlayerId int, FuncName string, msg string) error {
stack := make([]byte, 1024) stack := make([]byte, 1024)
length := runtime.Stack(stack, false) length := runtime.Stack(stack, false)
payload := map[string]interface{}{ payload := map[string]interface{}{
"notify_msg": fmt.Sprintf("游戏接口出错 %s:%d", conf.Server.GameName, PlayerId), "notify_msg": fmt.Sprintf("游戏接口出错 %s:%d[炸弹][炸弹][炸弹]", conf.Server.GameName, PlayerId),
"host": FuncName, "func_name": FuncName,
"event_name": fmt.Sprintf("%s\nStack trace:\n%s", msg, stack[:length]), "stack": fmt.Sprintf("%s\nStack trace:\n%s", msg, stack[:length]),
"severity": "High",
"alarm_time": time.Unix(time.Now().Unix(), 0).Format("2006-01-02 15:04:05"), "alarm_time": time.Unix(time.Now().Unix(), 0).Format("2006-01-02 15:04:05"),
} }

View File

@ -5,17 +5,19 @@ import (
activityCfg "server/conf/activity" activityCfg "server/conf/activity"
languageCfg "server/conf/language" languageCfg "server/conf/language"
userCfg "server/conf/user" userCfg "server/conf/user"
GoUtil "server/game_util"
"server/msg" "server/msg"
"testing" "testing"
) )
func Test(t *testing.T) { func Test(t *testing.T) {
GoUtil.SendFeishuFatal(0, "Test", "error")
i := userCfg.GetEnergyMulByLv(1) i := userCfg.GetEnergyMulByLv(1)
fmt.Println(i) fmt.Println(i)
} }
func TestGetActivityRecycleMail(t *testing.T) { func TestGetActivityRecycleMail(t *testing.T) {
title, mailTitle, mailContent := activityCfg.GetActivityRecycleMail(1) title, mailTitle, mailContent := activityCfg.GetActivityRecycleMail(7)
fmt.Println("title:", title) fmt.Println("title:", title)
fmt.Println("mailTitle:", mailTitle) fmt.Println("mailTitle:", mailTitle)
fmt.Println("mailContent:", mailContent) fmt.Println("mailContent:", mailContent)

View File

@ -0,0 +1,21 @@
package test
import (
"server/game"
"testing"
)
func TestFixDecorate(t *testing.T) {
// Initialize player
p := new(game.Player)
p.FixDecorate()
//
p.InitPlayer("202601K111")
p.FixDecorate()
DecorateMod := p.GetDecorateMod()
DecorateMod.AreaId = 3
DecorateMod.Progress = 22
p.FixDecorate()
}