feat: show party members in rankings and result screen

- Add Members field to RunRecord for party member names
- Save all party member names when recording a run
- Display party members in leaderboard (floor/gold tabs)
- Display party members in result screen rankings
- Solo runs show no party info, party runs show "(Alice, Bob, ...)"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-26 00:03:08 +09:00
parent f28160d4da
commit 087ce31164
5 changed files with 35 additions and 20 deletions

View File

@@ -18,10 +18,11 @@ type DB struct {
}
type RunRecord struct {
Player string `json:"player"`
Floor int `json:"floor"`
Score int `json:"score"`
Class string `json:"class,omitempty"`
Player string `json:"player"`
Floor int `json:"floor"`
Score int `json:"score"`
Class string `json:"class,omitempty"`
Members []string `json:"members,omitempty"` // party member names (empty for solo)
}
func Open(path string) (*DB, error) {
@@ -79,11 +80,11 @@ func (d *DB) GetProfile(fingerprint string) (string, error) {
return name, err
}
func (d *DB) SaveRun(player string, floor, score int, class string) error {
func (d *DB) SaveRun(player string, floor, score int, class string, members []string) error {
return d.db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket(bucketRankings)
id, _ := b.NextSequence()
record := RunRecord{Player: player, Floor: floor, Score: score, Class: class}
record := RunRecord{Player: player, Floor: floor, Score: score, Class: class, Members: members}
data, err := json.Marshal(record)
if err != nil {
return err

View File

@@ -38,9 +38,9 @@ func TestRanking(t *testing.T) {
os.Remove("test_rank.db")
}()
db.SaveRun("Alice", 20, 1500, "Warrior")
db.SaveRun("Bob", 15, 1000, "Mage")
db.SaveRun("Charlie", 20, 2000, "Rogue")
db.SaveRun("Alice", 20, 1500, "Warrior", nil)
db.SaveRun("Bob", 15, 1000, "Mage", nil)
db.SaveRun("Charlie", 20, 2000, "Rogue", nil)
rankings, err := db.TopRuns(10)
if err != nil {
@@ -63,10 +63,10 @@ func TestGetStats(t *testing.T) {
defer db.Close()
// Save some runs
db.SaveRun("Alice", 5, 100, "Warrior")
db.SaveRun("Alice", 10, 250, "Warrior")
db.SaveRun("Alice", 20, 500, "Warrior") // victory (floor >= 20)
db.SaveRun("Bob", 3, 50, "")
db.SaveRun("Alice", 5, 100, "Warrior", nil)
db.SaveRun("Alice", 10, 250, "Warrior", nil)
db.SaveRun("Alice", 20, 500, "Warrior", nil) // victory (floor >= 20)
db.SaveRun("Bob", 3, 50, "", nil)
stats, err := db.GetStats("Alice")
if err != nil {