fix(server): restore achievements, progress, claims and experience
Load ordinary achievements and send transactional gameplay progress notifications. Restore main-story clears and recorded gacha history without duplicate credit. Validate claim thresholds and prior tiers, credit wallet rewards and persist achievement experience in login responses.
This commit is contained in:
@@ -3,6 +3,8 @@ package gamedata
|
||||
import (
|
||||
"bd2server/internal/server/wire"
|
||||
"database/sql"
|
||||
"encoding/binary"
|
||||
"math"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -32,3 +34,25 @@ func TestAchievementCounterDesignUsesRootGroupsAndBothContents(t *testing.T) {
|
||||
t.Fatalf("wrong group index: %#v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAchievementRewardDesignIncludesOrdinaryZeroContentsAndTargets(t *testing.T) {
|
||||
db, err := sql.Open("sqlite", ":memory:")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
db.Exec("CREATE TABLE AchievementTable(ProtoBuf BLOB)")
|
||||
raw := wire.AppendVarint(wire.AppendVarint(nil, 9, 987), 11, 1)
|
||||
raw = wire.AppendVarint(raw, 8, 9)
|
||||
raw = append(raw, 25)
|
||||
raw = binary.LittleEndian.AppendUint64(raw, math.Float64bits(10))
|
||||
db.Exec("INSERT INTO AchievementTable VALUES (?)", raw)
|
||||
d := &MissionDesign{Achievements: map[AchievementKey]AchievementDesign{}}
|
||||
if err := loadAchievementRows(db, d); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, ok := d.Achievements[AchievementKey{GroupID: 987, ID: 1}]
|
||||
if !ok || got.Target != 10 || got.AddExp != 9 {
|
||||
t.Fatalf("ordinary=%+v exists=%v", got, ok)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user