feat: 添加查成绩功能
This commit is contained in:
@@ -2,6 +2,7 @@ package scoresaber
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -15,12 +16,19 @@ func (c Command) ToString() string {
|
||||
if c.CommandName != "score" {
|
||||
return ""
|
||||
}
|
||||
strWithRank := "玩家 %s 使用 %s 在 %s 的 %s 难度中获得了 %d 分,排名第 %d,pp 为 %.2f。"
|
||||
strWithRank := "玩家 %s 使用 %s 在 %s 的 %s 难度(星级为%.1f)中获得了 %d 分,排名第 %d,pp 为 %.2f。"
|
||||
strWithoutRank := "玩家 %s 使用 %s 在 %s 的 %s 难度中获得了 %d 分,排名第 %d。"
|
||||
if c.CommandData.Leaderboard.Ranked {
|
||||
return fmt.Sprintf(strWithRank, c.CommandData.Score.LeaderboardPlayerInfo.Name, *c.CommandData.Score.DeviceHmd, c.CommandData.Leaderboard.SongName, c.CommandData.Leaderboard.Difficulty.DifficultyRaw, c.CommandData.Score.ModifiedScore, c.CommandData.Score.Rank, c.CommandData.Score.Pp)
|
||||
strWithOutDevice := "玩家 %s 在 %s 的 %s 难度(星级为%.1f)中获得了 %d 分,排名第 %d,pp 为 %.2f。"
|
||||
strWithOutDeviceAndRank := "玩家 %s 在 %s 的 %s 难度(星级为%.1f)中获得了 %d 分。"
|
||||
hardStr := strings.Split(c.CommandData.Leaderboard.Difficulty.DifficultyRaw, "_")[1]
|
||||
if c.CommandData.Leaderboard.Ranked && c.CommandData.Score.DeviceHmd != nil {
|
||||
return fmt.Sprintf(strWithRank, c.CommandData.Score.LeaderboardPlayerInfo.Name, *c.CommandData.Score.DeviceHmd, c.CommandData.Leaderboard.SongName, hardStr, c.CommandData.Leaderboard.Stars, c.CommandData.Score.ModifiedScore, c.CommandData.Score.Rank, c.CommandData.Score.Pp)
|
||||
} else if !c.CommandData.Leaderboard.Ranked && c.CommandData.Score.DeviceHmd != nil {
|
||||
return fmt.Sprintf(strWithoutRank, c.CommandData.Score.LeaderboardPlayerInfo.Name, *c.CommandData.Score.DeviceHmd, c.CommandData.Leaderboard.SongName, hardStr, c.CommandData.Score.ModifiedScore, c.CommandData.Score.Rank)
|
||||
} else if c.CommandData.Leaderboard.Ranked && c.CommandData.Score.DeviceHmd == nil {
|
||||
return fmt.Sprintf(strWithOutDevice, c.CommandData.Score.LeaderboardPlayerInfo.Name, c.CommandData.Leaderboard.SongName, hardStr, c.CommandData.Leaderboard.Stars, c.CommandData.Score.ModifiedScore, c.CommandData.Score.Rank, c.CommandData.Score.Pp)
|
||||
} else {
|
||||
return fmt.Sprintf(strWithoutRank, c.CommandData.Score.LeaderboardPlayerInfo.Name, *c.CommandData.Score.DeviceHmd, c.CommandData.Leaderboard.SongName, c.CommandData.Leaderboard.Difficulty.DifficultyRaw, c.CommandData.Score.ModifiedScore, c.CommandData.Score.Rank)
|
||||
return fmt.Sprintf(strWithOutDeviceAndRank, c.CommandData.Score.LeaderboardPlayerInfo.Name, c.CommandData.Leaderboard.SongName, hardStr, c.CommandData.Leaderboard.Stars, c.CommandData.Score.ModifiedScore)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,29 +76,29 @@ type Difficulty struct {
|
||||
|
||||
// Leaderboard 表示排行榜的信息
|
||||
type Leaderboard struct {
|
||||
ID int `json:"id"`
|
||||
SongHash string `json:"songHash"`
|
||||
SongName string `json:"songName"`
|
||||
SongSubName string `json:"songSubName"`
|
||||
SongAuthorName string `json:"songAuthorName"`
|
||||
LevelAuthorName string `json:"levelAuthorName"`
|
||||
Difficulty Difficulty `json:"difficulty"`
|
||||
MaxScore int `json:"maxScore"`
|
||||
CreatedDate time.Time `json:"createdDate"`
|
||||
RankedDate *time.Time `json:"rankedDate"`
|
||||
QualifiedDate *time.Time `json:"qualifiedDate"`
|
||||
LovedDate *time.Time `json:"lovedDate"`
|
||||
Ranked bool `json:"ranked"`
|
||||
Qualified bool `json:"qualified"`
|
||||
Loved bool `json:"loved"`
|
||||
MaxPP float64 `json:"maxPP"`
|
||||
Stars float64 `json:"stars"`
|
||||
Plays int `json:"plays"`
|
||||
DailyPlays int `json:"dailyPlays"`
|
||||
PositiveModifiers bool `json:"positiveModifiers"`
|
||||
PlayerScore *string `json:"playerScore"`
|
||||
CoverImage string `json:"coverImage"`
|
||||
Difficulties *string `json:"difficulties"`
|
||||
ID int `json:"id"`
|
||||
SongHash string `json:"songHash"`
|
||||
SongName string `json:"songName"`
|
||||
SongSubName string `json:"songSubName"`
|
||||
SongAuthorName string `json:"songAuthorName"`
|
||||
LevelAuthorName string `json:"levelAuthorName"`
|
||||
Difficulty Difficulty `json:"difficulty"`
|
||||
MaxScore int `json:"maxScore"`
|
||||
CreatedDate time.Time `json:"createdDate"`
|
||||
RankedDate *time.Time `json:"rankedDate"`
|
||||
QualifiedDate *time.Time `json:"qualifiedDate"`
|
||||
LovedDate *time.Time `json:"lovedDate"`
|
||||
Ranked bool `json:"ranked"`
|
||||
Qualified bool `json:"qualified"`
|
||||
Loved bool `json:"loved"`
|
||||
MaxPP float64 `json:"maxPP"`
|
||||
Stars float64 `json:"stars"`
|
||||
Plays int `json:"plays"`
|
||||
DailyPlays int `json:"dailyPlays"`
|
||||
PositiveModifiers bool `json:"positiveModifiers"`
|
||||
PlayerScore *string `json:"playerScore"`
|
||||
CoverImage string `json:"coverImage"`
|
||||
Difficulties interface{} `json:"difficulties"`
|
||||
}
|
||||
|
||||
// CommandData 表示命令的数据
|
||||
@@ -99,6 +107,52 @@ type CommandData struct {
|
||||
Leaderboard Leaderboard `json:"leaderboard"`
|
||||
}
|
||||
|
||||
// 表示记录的数据,本地储存
|
||||
type RecordDataLite struct {
|
||||
ID int `json:"id" db:"id"`
|
||||
ScoreID int `json:"scoreId" db:"score_id"`
|
||||
SsID string `json:"ssId" db:"ss_id"`
|
||||
Name string `json:"name" db:"name"`
|
||||
Country string `json:"country" db:"country"`
|
||||
SongName string `json:"songName" db:"song_name"`
|
||||
SongSubName string `json:"songSubName" db:"song_sub_name"`
|
||||
SongAuthorName string `json:"songAuthorName" db:"song_author_name"`
|
||||
SongHash string `json:"songHash" db:"song_hash"`
|
||||
CoverImage string `json:"coverImage" db:"cover_image"`
|
||||
DifficultyRaw string `json:"difficultyRaw" db:"difficulty_raw"`
|
||||
Stars float64 `json:"stars" db:"stars"`
|
||||
PP float64 `json:"pp" db:"pp"`
|
||||
Weight float64 `json:"weight" db:"weight"`
|
||||
Modifiers string `json:"modifiers" db:"modifiers"`
|
||||
Multiplier float64 `json:"multiplier" db:"multiplier"`
|
||||
BadCuts int `json:"badCuts" db:"bad_cuts"`
|
||||
MissedNotes int `json:"missedNotes" db:"missed_notes"`
|
||||
MaxCombo int `json:"maxCombo" db:"max_combo"`
|
||||
Score int `json:"score" db:"score"`
|
||||
FullCombo bool `json:"fullCombo" db:"full_combo"`
|
||||
DeviceHmd string `json:"deviceHmd" db:"device_hmd"`
|
||||
DeviceControllerLeft string `json:"deviceControllerLeft" db:"device_controller_left"`
|
||||
DeviceControllerRight string `json:"deviceControllerRight" db:"device_controller_right"`
|
||||
GeneratedTime string `json:"generatedTime" db:"generated_time"`
|
||||
}
|
||||
|
||||
func (r RecordDataLite) ToString() string {
|
||||
formatedStrRanked := "使用 %s 在 %s 的 %s 难度(%.1f星级)中获得了 %d 分,pp 为 %.2f。"
|
||||
formatedStrUnranked := "使用 %s 在 %s 的 %s 难度中获得了 %d 分。"
|
||||
formatedStrWithoutDevice := "在 %s 的 %s 难度(%.1f星级)中获得了 %d 分,pp 为 %.2f。"
|
||||
formatedStrWithoutDeviceAndRank := "在 %s 的 %s 难度(%.1f星级)中获得了 %d 分。"
|
||||
hardStr := strings.Split(r.DifficultyRaw, "_")[1]
|
||||
if r.Stars == 0 && r.DeviceHmd != "" {
|
||||
return fmt.Sprintf(formatedStrUnranked, r.DeviceHmd, r.SongName, hardStr, r.Score)
|
||||
} else if r.Stars != 0 && r.DeviceHmd != "" {
|
||||
return fmt.Sprintf(formatedStrRanked, r.DeviceHmd, r.SongName, hardStr, r.Stars, r.Score, r.PP)
|
||||
} else if r.Stars != 0 && r.DeviceHmd == "" {
|
||||
return fmt.Sprintf(formatedStrWithoutDevice, r.SongName, hardStr, r.Stars, r.Score, r.PP)
|
||||
} else {
|
||||
return fmt.Sprintf(formatedStrWithoutDeviceAndRank, r.SongName, hardStr, r.Stars, r.Score)
|
||||
}
|
||||
}
|
||||
|
||||
//用户信息
|
||||
|
||||
// ScoreStats 存储分数统计信息
|
||||
@@ -135,6 +189,7 @@ type PlayerDataLite struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
Name string `json:"name" db:"name"`
|
||||
Country string `json:"country" db:"country"`
|
||||
Device string `json:"device" db:"device"`
|
||||
PP float64 `json:"pp" db:"pp"`
|
||||
Rank int `json:"rank" db:"rank"`
|
||||
CountryRank int `json:"countryRank" db:"country_rank"`
|
||||
|
||||
Reference in New Issue
Block a user