1
This commit is contained in:
parent
9529e48a52
commit
c624e7f0f4
@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
activityCfg "server/conf/activity"
|
||||
catnipCfg "server/conf/catnip"
|
||||
champshipCfg "server/conf/champship"
|
||||
dailyTaskCfg "server/conf/daily_task"
|
||||
guesscolorCfg "server/conf/guess_color"
|
||||
languageCfg "server/conf/language"
|
||||
@ -523,9 +522,8 @@ func (p *Player) GetChampshipActivityId() (int, int) {
|
||||
now := GoUtil.Now()
|
||||
yesterday := GoUtil.ZeroTimestamp() - 1
|
||||
level := p.GetBaseMod().GetLevel()
|
||||
champshipActivityIds := champshipCfg.GetChampshipActivityId()
|
||||
for _, v := range activiyCfgList {
|
||||
if !GoUtil.InArray(v.Id, champshipActivityIds) {
|
||||
if v.Type != activity.ACT_TYPE_CHAMPION {
|
||||
continue
|
||||
}
|
||||
if v.Level > level {
|
||||
@ -541,6 +539,54 @@ func (p *Player) GetChampshipActivityId() (int, int) {
|
||||
return todayActivityId, yesterdayActivityId
|
||||
}
|
||||
|
||||
func (p *Player) ChampionshipZeroUpdate() {
|
||||
todayActivityId, _ := p.GetChampshipActivityId()
|
||||
ChampionshipMod := p.PlayMod.getChampshipMod()
|
||||
aid := ChampionshipMod.AId
|
||||
cfg := G_GameLogicPtr.ActivityMgr.GetChampshipCfg(aid)
|
||||
if cfg == nil {
|
||||
return
|
||||
}
|
||||
items := p.GetChampshipReward(aid)
|
||||
if len(items) > 0 {
|
||||
p.SendActivityMail2(items, "backend_championship_mail_title", "backend_championship_mail_content")
|
||||
}
|
||||
p.PlayMod.getChampshipMod().ZeroUpdate(todayActivityId)
|
||||
}
|
||||
|
||||
func (p *Player) GetChampshipReward(id int) []*item.Item {
|
||||
ChampionshipMod := p.PlayMod.getChampshipMod()
|
||||
if id == 0 { // 兼容旧数据,之前没有活动id的只要发放一次奖励
|
||||
DecorateMod := p.PlayMod.getDecorateMod()
|
||||
orderFactor := orderCfg.GetOrderFactor(DecorateMod.GetAreaId())
|
||||
return ChampionshipMod.GetReward(0, orderFactor)
|
||||
}
|
||||
if ChampionshipMod == nil {
|
||||
return nil
|
||||
}
|
||||
cfg := G_GameLogicPtr.ActivityMgr.GetChampshipCfg(id)
|
||||
if cfg == nil {
|
||||
return nil
|
||||
}
|
||||
DecorateMod := p.PlayMod.getDecorateMod()
|
||||
orderFactor := orderCfg.GetOrderFactor(DecorateMod.GetAreaId())
|
||||
var maxRewardId int
|
||||
var items []*item.Item
|
||||
for _, v := range cfg.GetJackpotList() {
|
||||
if ChampionshipMod.GetScore() >= int(v.Score) && int(v.Id) > ChampionshipMod.GetRewardId() {
|
||||
maxRewardId = int(v.Id)
|
||||
items = append(items, item.MsgToItem(v.Items)...)
|
||||
if v.StarReward > 0 {
|
||||
itemNum := GoUtil.FormatStarItemNum(int(v.StarReward), orderFactor)
|
||||
starItem := item.NewItem(item.ITEM_STAR_ID, itemNum)
|
||||
items = append(items, starItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
ChampionshipMod.SetRewardId(maxRewardId)
|
||||
return items
|
||||
}
|
||||
|
||||
func (p *Player) GetDailyTaskActivityId() int {
|
||||
var activityId int
|
||||
activiyCfgList := G_GameLogicPtr.ActivityMgr.GetActivityList()
|
||||
|
||||
@ -184,3 +184,17 @@ func (r *ActivityMgr) GetCatReturnGiftCfg(id int) *protoMsg.CatReturnGiftCfg {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ActivityMgr) GetChampshipCfg(id int) *protoMsg.ChampionshipCfg {
|
||||
data := r.getData()
|
||||
data.mu.Lock()
|
||||
defer data.mu.Unlock()
|
||||
for _, v := range data.List {
|
||||
if v.Type == activity.ACT_TYPE_CHAMPION && v.Id == id {
|
||||
if cfg, ok := v.cfg.(*protoMsg.ChampionshipCfg); ok {
|
||||
return cfg
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -15,6 +15,8 @@ type ChampshipMod struct {
|
||||
RankReward bool
|
||||
PreMax int // 昨日最高档
|
||||
Max int // 历史最高档
|
||||
AId int // 活动id
|
||||
LastAId int // 上次活动id
|
||||
}
|
||||
|
||||
func (c *ChampshipMod) InitData() {}
|
||||
@ -24,11 +26,13 @@ func (c *ChampshipMod) isActive() bool {
|
||||
return GoUtil.Now()-GoUtil.ZeroTimestamp() >= 300
|
||||
}
|
||||
|
||||
func (c *ChampshipMod) ZeroUpdate() {
|
||||
func (c *ChampshipMod) ZeroUpdate(aid int) {
|
||||
c.PreMax = c.Reward
|
||||
c.Score = 0
|
||||
c.Reward = 0
|
||||
c.RankReward = false
|
||||
c.LastAId = c.AId
|
||||
c.AId = aid
|
||||
}
|
||||
|
||||
func (c *ChampshipMod) GetScore() int {
|
||||
@ -63,6 +67,13 @@ func (c *ChampshipMod) GetReward(activityId, orderFactor int) []*item.Item {
|
||||
return items
|
||||
}
|
||||
|
||||
func (c *ChampshipMod) GetRewardId() int {
|
||||
return c.Reward
|
||||
}
|
||||
|
||||
func (c *ChampshipMod) SetRewardId(rewardId int) {
|
||||
c.Reward = rewardId
|
||||
}
|
||||
func (c *ChampshipMod) BackData(myRank, myPreRank, todayActivityId, yesterdayActivityId int) *msg.ResChampship {
|
||||
rankReward := 0
|
||||
if c.RankReward {
|
||||
@ -94,3 +105,7 @@ func (c *ChampshipMod) GetH() int {
|
||||
func (c *ChampshipMod) GetN() int {
|
||||
return c.Max
|
||||
}
|
||||
|
||||
func (c *ChampshipMod) GetAId() int {
|
||||
return c.AId
|
||||
}
|
||||
|
||||
@ -310,7 +310,10 @@ func (p *Player) BackChampship() {
|
||||
ChampshipMod := p.PlayMod.getChampshipMod()
|
||||
rank, preRank := p.GetChampshipRank()
|
||||
todayActivityId, yesterdayActivityId := p.GetChampshipActivityId()
|
||||
p.PushClientRes(ChampshipMod.BackData(rank, preRank, todayActivityId, yesterdayActivityId))
|
||||
res := ChampshipMod.BackData(rank, preRank, todayActivityId, yesterdayActivityId)
|
||||
cfg := G_GameLogicPtr.ActivityMgr.GetChampshipCfg(todayActivityId)
|
||||
res.Cfg = cfg
|
||||
p.PushClientRes(res)
|
||||
}
|
||||
|
||||
// 获取冠军赛排名 redis缓存
|
||||
|
||||
@ -414,14 +414,7 @@ func (p *Player) ZeroUpdate(a []interface{}) {
|
||||
PlayroomMod.ResetWeeklyDiscount()
|
||||
}
|
||||
p.PlayroomBackData()
|
||||
todayActivityId, _ := p.GetChampshipActivityId()
|
||||
DecorateMod := p.PlayMod.getDecorateMod()
|
||||
orderFactor := orderCfg.GetOrderFactor(DecorateMod.GetAreaId())
|
||||
items := p.PlayMod.getChampshipMod().GetReward(todayActivityId, orderFactor)
|
||||
if len(items) > 0 {
|
||||
p.SendActivityMail2(items, "backend_championship_mail_title", "backend_championship_mail_content")
|
||||
}
|
||||
p.PlayMod.getChampshipMod().ZeroUpdate()
|
||||
p.ChampionshipZeroUpdate()
|
||||
p.BackChampship()
|
||||
p.InitActivity()
|
||||
p.ActivityZeroUpdate()
|
||||
|
||||
@ -2529,11 +2529,8 @@ func ReqChampship(player *Player, req *msg.ReqChampship) error {
|
||||
}
|
||||
func ReqChampshipReward(player *Player, req *msg.ReqChampshipReward) error {
|
||||
ChampshipMod := player.PlayMod.getChampshipMod()
|
||||
todayActivityId, _ := player.GetChampshipActivityId()
|
||||
DecorateMod := player.PlayMod.getDecorateMod()
|
||||
orderFactor := orderCfg.GetOrderFactor(DecorateMod.GetAreaId())
|
||||
rewardId := ChampshipMod.Reward
|
||||
itemList := ChampshipMod.GetReward(todayActivityId, orderFactor)
|
||||
itemList := player.GetChampshipReward(ChampshipMod.GetAId())
|
||||
err := player.HandleItem(itemList, msg.ITEM_POP_LABEL_ChampshipReward.String())
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResChampshipReward{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user