111 lines
3.1 KiB
Go
111 lines
3.1 KiB
Go
package common
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestCurrencyWarsScoreCalculations(t *testing.T) {
|
|
score, err := LoadCurrencyWarsScore(nil)
|
|
if err != nil {
|
|
t.Fatalf("load CW score: %v", err)
|
|
}
|
|
if score.WeeklyCap != 18000 {
|
|
t.Errorf("expected weekly cap 18000, got %d", score.WeeklyCap)
|
|
}
|
|
if len(score.Divisions) == 0 || len(score.Rules) == 0 {
|
|
t.Fatal("empty divisions or rules in CW score")
|
|
}
|
|
|
|
// Division 20920: ScoreRule 1, WeeklyScoreModify 100, ExpModify 180.
|
|
// Chapter 2, Section 4 won (or lost on 2-5): matches upstream test at line 11065!
|
|
weekly, expBase, expExtra := score.CalculateRunScore(20920, false, 2, 4, true)
|
|
if weekly != 13200 {
|
|
t.Errorf("expected weekly score 13200, got %d", weekly)
|
|
}
|
|
if expBase != 725 {
|
|
t.Errorf("expected exp base 725, got %d", expBase)
|
|
}
|
|
if expExtra != 580 {
|
|
t.Errorf("expected exp extra 580, got %d", expExtra)
|
|
}
|
|
|
|
// Offering Level calculation: 800 EXP per level for Offering 16 (Season 2)
|
|
level, remainder := score.OfferingLevel(1305)
|
|
if level != 1 {
|
|
t.Errorf("expected level 1, got %d", level)
|
|
}
|
|
if remainder != 505 {
|
|
t.Errorf("expected remainder 505, got %d", remainder)
|
|
}
|
|
}
|
|
|
|
func TestCurrencyWarsTraitsCatalog(t *testing.T) {
|
|
traits, err := LoadCurrencyWarsTraits(nil)
|
|
if err != nil {
|
|
t.Fatalf("load CW traits: %v", err)
|
|
}
|
|
if len(traits.Traits) < 60 {
|
|
t.Fatalf("expected at least 60 traits, got %d", len(traits.Traits))
|
|
}
|
|
|
|
// Trait 1001 (Express Cohort) has thresholds [2, 4, 6]
|
|
tr, ok := traits.Trait(1001)
|
|
if !ok {
|
|
t.Fatal("trait 1001 missing")
|
|
}
|
|
if len(tr.Thresholds) != 3 {
|
|
t.Fatalf("expected 3 thresholds, got %d", len(tr.Thresholds))
|
|
}
|
|
|
|
if layer := traits.ActiveLayer(1001, 1); layer != 0 {
|
|
t.Errorf("expected layer 0 for count 1, got %d", layer)
|
|
}
|
|
if layer := traits.ActiveLayer(1001, 3); layer != 2 {
|
|
t.Errorf("expected layer 2 for count 3, got %d", layer)
|
|
}
|
|
if layer := traits.ActiveLayer(1001, 5); layer != 4 {
|
|
t.Errorf("expected layer 4 for count 5, got %d", layer)
|
|
}
|
|
if layer := traits.ActiveLayer(1001, 6); layer != 6 {
|
|
t.Errorf("expected layer 6 for count 6, got %d", layer)
|
|
}
|
|
}
|
|
|
|
func TestCurrencyWarsAugmentsCatalog(t *testing.T) {
|
|
catalog, err := LoadCurrencyWarsAugments(nil)
|
|
if err != nil {
|
|
t.Fatalf("load CW augments: %v", err)
|
|
}
|
|
if len(catalog.Augments) != 304 {
|
|
t.Fatalf("expected 304 augments, got %d", len(catalog.Augments))
|
|
}
|
|
|
|
aug, ok := catalog.Augment(100101)
|
|
if !ok {
|
|
t.Fatal("augment 100101 missing")
|
|
}
|
|
if aug.Quality != 1 {
|
|
t.Errorf("expected quality 1, got %d", aug.Quality)
|
|
}
|
|
if !catalog.IsEligible(aug, 1, true) {
|
|
t.Error("expected augment 100101 to be eligible in chapter 1 overclock")
|
|
}
|
|
if catalog.IsEligible(aug, 3, true) {
|
|
t.Error("expected augment 100101 to not be eligible in chapter 3")
|
|
}
|
|
}
|
|
|
|
func TestCurrencyWarsNodeDropsCatalog(t *testing.T) {
|
|
drops, err := LoadCurrencyWarsNodeDrops(nil)
|
|
if err != nil {
|
|
t.Fatalf("load CW node drops: %v", err)
|
|
}
|
|
if len(drops.NodeDrops) == 0 {
|
|
t.Fatal("expected node drops rules")
|
|
}
|
|
rule900, ok := drops.NodeDrops["900"]
|
|
if !ok || rule900.Rolls != 4 {
|
|
t.Errorf("expected rule 900 with 4 rolls, got %v", rule900)
|
|
}
|
|
}
|