Files
GaCy-GO/internal/gameserver/currency_wars_encounter_reward_test.go
T

55 lines
2.3 KiB
Go
Raw Normal View History

package gameserver
import (
"testing"
"gac-hkrpg-go/internal/common"
pb "gac-hkrpg-go/protocol/proto"
)
func TestCurrencyWarsEncounterGoldRequiresThreshold(t *testing.T) {
c, err := common.LoadCurrencyWarsCatalog()
if err != nil {
t.Fatal(err)
}
player := &pb.NIHNGPKHEPC{Gold: 10}
run := &pb.MPIMAEMCEFH{NAGDJGMMCBE: []*pb.GridFightGameInfo{
{LEOIAOFBBFA: &pb.GridFightGameInfo_FAOCFBOFCJP{FAOCFBOFCJP: player}},
{LEOIAOFBBFA: &pb.GridFightGameInfo_EJIPINIKNCK{EJIPINIKNCK: &pb.HKFECLCHBFJ{}}},
{LEOIAOFBBFA: &pb.GridFightGameInfo_EBHDIOGALIE{EBHDIOGALIE: &pb.POCJDMMANBM{}}},
}}
branch := &pb.KKBGIPCAGGH{BOAMLLHPNEC: &pb.GridFightDropInfo{NMGIABHIJJB: []*pb.BCCONKJHDJL{{FKKGLFOHGGA: pb.MJJIFGINJAJ_MJJIFGINJAJ_item_value, Num: 6}}}}
updates, err := cwEncounterRewards(c, run, branch, 100, 70)
if err != nil || len(updates) == 0 || player.Gold != 16 {
t.Fatalf("perfect reward: gold=%d updates=%d err=%v", player.Gold, len(updates), err)
}
_, err = cwEncounterRewards(c, run, branch, 80, 70)
if err != nil || player.Gold != 22 {
t.Fatal("passing the threshold must award the selected option")
}
_, err = cwEncounterRewards(c, run, branch, 60, 70)
if err != nil || player.Gold != 22 {
t.Fatal("failing the threshold must not award the selected option")
}
}
func TestCurrencyWarsEncounterExperienceUpdatesLevel(t *testing.T) {
c, err := common.LoadCurrencyWarsCatalog()
if err != nil {
t.Fatal(err)
}
if len(c.PlayerLevels) < 2 {
t.Fatal("captured player levels missing")
}
first := c.PlayerLevels[0]
player := &pb.NIHNGPKHEPC{EHNJDIDABHD: first.Level, AFFCFLFIFPH: first.AvatarMaxNumber, NDAINFLOLPJ: c.PlayerLevels[len(c.PlayerLevels)-1].Level}
run := &pb.MPIMAEMCEFH{NAGDJGMMCBE: []*pb.GridFightGameInfo{
{LEOIAOFBBFA: &pb.GridFightGameInfo_FAOCFBOFCJP{FAOCFBOFCJP: player}},
{LEOIAOFBBFA: &pb.GridFightGameInfo_EBHDIOGALIE{EBHDIOGALIE: &pb.POCJDMMANBM{}}},
}}
branch := &pb.KKBGIPCAGGH{BOAMLLHPNEC: &pb.GridFightDropInfo{NMGIABHIJJB: []*pb.BCCONKJHDJL{{FKKGLFOHGGA: pb.MJJIFGINJAJ_MJJIFGINJAJ_exp, Num: first.LevelUpExp}}}}
updates, err := cwEncounterRewards(c, run, branch, cwPercentScale, 0)
if err != nil || player.EHNJDIDABHD <= first.Level || len(updates) == 0 {
t.Fatalf("EXP reward: player=%v updates=%d err=%v", player, len(updates), err)
}
}