锦标赛优化
This commit is contained in:
parent
feaf228b79
commit
e26e663d91
2
.gitignore
vendored
2
.gitignore
vendored
@ -23,3 +23,5 @@ src/server/gen-go
|
||||
src/server/GeoLite2-Country
|
||||
src/server/test/GeoLite2-Country
|
||||
src/server/msg/Gameapi_grpc.pb.go
|
||||
src/server/unit_test/*.exe*
|
||||
src/server/unit_test/log*
|
||||
@ -543,11 +543,8 @@ 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)
|
||||
var items []*item.Item
|
||||
items = p.GetChampshipReward(aid)
|
||||
if len(items) > 0 {
|
||||
p.SendActivityMail2(items, "backend_championship_mail_title", "backend_championship_mail_content")
|
||||
}
|
||||
@ -573,13 +570,13 @@ func (p *Player) GetChampshipReward(id int) []*item.Item {
|
||||
var maxRewardId int
|
||||
var items []*item.Item
|
||||
for _, v := range cfg.GetJackpotList() {
|
||||
if ChampionshipMod.GetScore() >= int(v.Score) && int(v.Id) > ChampionshipMod.GetRewardId() {
|
||||
if ChampionshipMod.GetScore() >= int(v.Total) && int(v.Id) > ChampionshipMod.GetRewardId() {
|
||||
maxRewardId = int(v.Id)
|
||||
items = append(items, item.MsgToItem(v.Items)...)
|
||||
items = item.Merge(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)
|
||||
items = item.Merge(items, []*item.Item{starItem})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -587,6 +584,29 @@ func (p *Player) GetChampshipReward(id int) []*item.Item {
|
||||
return items
|
||||
}
|
||||
|
||||
func (p *Player) GetChampshipRankReward(rank, aid int) ([]*item.Item, error) {
|
||||
ChampionshipMod := p.PlayMod.getChampshipMod()
|
||||
if aid == 0 { // 兼容旧数据,之前没有活动id的只要发放一次奖励
|
||||
return ChampionshipMod.GetRankReward(rank, aid)
|
||||
}
|
||||
if ChampionshipMod == nil {
|
||||
return nil, fmt.Errorf("championship mod is nil")
|
||||
}
|
||||
cfg := G_GameLogicPtr.ActivityMgr.GetChampshipCfg(aid)
|
||||
if cfg == nil {
|
||||
return nil, fmt.Errorf("championship config is nil")
|
||||
}
|
||||
rankRewardList := cfg.GetRankList()
|
||||
var items []*item.Item
|
||||
for _, v := range rankRewardList {
|
||||
if rank <= int(v.Max) && rank >= int(v.Min) {
|
||||
items = item.Merge(items, item.MsgToItem(v.Items))
|
||||
return items, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("no rank reward found for rank %d", rank)
|
||||
}
|
||||
|
||||
func (p *Player) GetDailyTaskActivityId() int {
|
||||
var activityId int
|
||||
activiyCfgList := G_GameLogicPtr.ActivityMgr.GetActivityList()
|
||||
|
||||
@ -160,6 +160,13 @@ func unmarshalActivityCfg(atype int, buf []byte) (interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
return cfg, nil
|
||||
case 9:
|
||||
cfg := &protoMsg.ChampionshipCfg{}
|
||||
err := proto.Unmarshal(buf, cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cfg, nil
|
||||
case 10:
|
||||
cfg := &protoMsg.CatReturnGiftCfg{}
|
||||
err := proto.Unmarshal(buf, cfg)
|
||||
|
||||
@ -2594,7 +2594,7 @@ func ReqChampshipRankReward(player *Player, req *msg.ReqChampshipRankReward) err
|
||||
_, myPreRank := player.GetChampshipRank()
|
||||
ChampshipMod := player.PlayMod.getChampshipMod()
|
||||
_, yesterdayActivityId := player.GetChampshipActivityId()
|
||||
itemList, err := ChampshipMod.GetRankReward(myPreRank, yesterdayActivityId)
|
||||
itemList, err := player.GetChampshipRankReward(myPreRank, yesterdayActivityId)
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResChampshipRankReward{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
|
||||
@ -1,15 +1,46 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
orderCfg "server/conf/order"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestChampionship(t *testing.T) {
|
||||
func TestChampionshipReward(t *testing.T) {
|
||||
player := getTestPlayer()
|
||||
player.GetChampshipMod().AddScore([]int{15, 15, 15})
|
||||
todayAid, yestAid := player.GetChampshipActivityId()
|
||||
items := player.GetChampshipReward(todayAid)
|
||||
fmt.Printf("today id %d items : %v\n", todayAid, items)
|
||||
player.GetChampshipMod().ZeroUpdate(todayAid)
|
||||
player.GetChampshipMod().AddScore([]int{15, 15, 15})
|
||||
yestAid = 0
|
||||
items = player.GetChampshipReward(yestAid)
|
||||
fmt.Printf("yesterday id %d items : %v\n", yestAid, items)
|
||||
}
|
||||
|
||||
func TestChampionshipRankReward(t *testing.T) {
|
||||
player := getTestPlayer()
|
||||
player.GetChampshipMod().AddScore([]int{15, 15, 15})
|
||||
_, yestAid := player.GetChampshipActivityId()
|
||||
items, err := player.GetChampshipRankReward(1, yestAid)
|
||||
if err != nil {
|
||||
fmt.Printf("get rank reward error : %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("yesterday id %d rank reward items : %v\n", yestAid, items)
|
||||
}
|
||||
yestAid = 0
|
||||
items, err = player.GetChampshipRankReward(2, yestAid)
|
||||
if err != nil {
|
||||
fmt.Printf("get rank reward error : %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("yesterday id %d rank reward items : %v\n", yestAid, items)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChampionshipZeroUpdate(t *testing.T) {
|
||||
player := getTestPlayer()
|
||||
player.GetChampshipMod().AddScore([]int{15, 15, 15})
|
||||
todayAid, _ := player.GetChampshipActivityId()
|
||||
DecorateMod := player.GetDecorateMod()
|
||||
orderFactor := orderCfg.GetOrderFactor(DecorateMod.GetAreaId())
|
||||
player.GetChampshipMod().GetReward(todayAid, orderFactor)
|
||||
fmt.Printf("before zero update today id %d score : %d\n", todayAid, player.GetChampshipMod().GetScore())
|
||||
player.ChampionshipZeroUpdate()
|
||||
}
|
||||
|
||||
@ -5,12 +5,12 @@
|
||||
"TCPAddr": ":3602",
|
||||
"WSAddr": ":3567",
|
||||
"RPCAddr": ":50051",
|
||||
"MySqlAddr": "127.0.0.1",
|
||||
"MySqlAddr": "112.124.54.243",
|
||||
"MySqlPort": "3306",
|
||||
"MySqlUsr": "root",
|
||||
"MySqlPwd": "IOagNEq3C84c-20CmHEin5iODVc=",
|
||||
"MySqlPwd": "-pDvPOK7dp1obN8e6hxSqYl9L4FaTCJDpN60B6I8Vg==",
|
||||
"MaxConnNum": 20000,
|
||||
"DbName": "merge_pet_1",
|
||||
"DbName": "pet_home_1",
|
||||
"HttpPort": ":8081",
|
||||
"AppPath": "./app",
|
||||
"TELOGDIR" : "./log/teLog/",
|
||||
@ -30,12 +30,12 @@
|
||||
"CenterAddr": "127.0.0.1:7000",
|
||||
"RemoteAddr":"127.0.0.1:9002",
|
||||
|
||||
"RedisAddr":"127.0.0.1",
|
||||
"RedisAddr":"112.124.54.243",
|
||||
"RedisPort" :"6379",
|
||||
"RedisPwd" :"",
|
||||
|
||||
"RedisWriteAddr":"127.0.0.1:6379",
|
||||
"RedisReadAddrs":"127.0.0.1:6379",
|
||||
"RedisWriteAddr":"112.124.54.243:6379",
|
||||
"RedisReadAddrs":"112.124.54.243:6379",
|
||||
"RedisMasterName":"mymaster",
|
||||
"RedisConnType":"Direct",
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user