fix: 修复宠物升级经验显示与动态结算
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -122,3 +122,36 @@ func TestAddPetExpSmallRewardDoesNotJumpToMaxLevel(t *testing.T) {
|
||||
t.Fatalf("expected exp pool to decrease by %d, got %d", addExp, player.Info.ExpPool)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddPetExpUsesDynamicPerLevelRequirement(t *testing.T) {
|
||||
petID := firstPetIDForTest(t)
|
||||
petInfo := playermodel.GenPetInfo(petID, 31, 0, 0, 20, nil, 0)
|
||||
if petInfo == nil {
|
||||
t.Fatalf("failed to generate test pet")
|
||||
}
|
||||
|
||||
initialNeed := petInfo.NextLvExp
|
||||
if initialNeed <= 0 {
|
||||
t.Fatalf("expected positive exp requirement, got %d", initialNeed)
|
||||
}
|
||||
|
||||
player := &Player{
|
||||
baseplayer: baseplayer{
|
||||
Info: &playermodel.PlayerInfo{
|
||||
ExpPool: 1_000_000,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
player.AddPetExp(petInfo, initialNeed)
|
||||
|
||||
if petInfo.Level != 21 {
|
||||
t.Fatalf("expected pet level to become 21, got %d", petInfo.Level)
|
||||
}
|
||||
if petInfo.Exp != 0 {
|
||||
t.Fatalf("expected level-up to reset current level exp, got %d", petInfo.Exp)
|
||||
}
|
||||
if petInfo.NextLvExp == initialNeed {
|
||||
t.Fatalf("expected next level exp to change after leveling, still %d", petInfo.NextLvExp)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user