Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions logic/conversion/playerToLeaderboardEntry.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,34 @@ import (
"github.com/fluofoxxo/outrun/obj"
)

func PlayerToLeaderboardEntry(player netobj.Player) obj.LeaderboardEntry {
friendID := player.ID // TODO: is this right?
func PlayerToLeaderboardEntry(player netobj.Player, mode int64) obj.LeaderboardEntry {
friendID := player.ID
name := player.Username
url := player.Username + "_findme" // TODO: only used for testing right now
grade := player.PlayerState.Rank // TODO: _probably_ what this is, but unsure
grade := int64(1) // TODO: make this specifiable in the future (this is the high score ranking it seems)
exposeOnline := int64(0)
rankingScore := player.PlayerState.HighScore // TODO: this probably differs based on mode...
rankChanged := int64(2)
rankingScore := player.PlayerState.HighScore
rankChanged := int64(0)
isSentEnergy := int64(0)
expireTime := time.Now().UTC().Unix() + 12345
numRank := player.PlayerState.Rank + 1
expireTime := now.EndOfWeek().UTC().Unix()
numRank := player.PlayerState.Rank
loginTime := player.LastLogin
mainCharaID := player.PlayerState.MainCharaID
mainCharaLevel := int64(12) // TODO: remove testing
mainCharaLevel := player.CharacterState[0].Level // TODO: is this right?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. The main character is fetched by getting the index of the main character by player.PlayerState.MainCharaID. The player struct has a helper function for this: player.IndexOfChara(player.PlayerState.MainCharaID).
Likewise, this applies to line 26, and lines 28 and 30 with player.IndexOfChao(player.PlayerState.MainChaoID).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep that in mind.

subCharaID := player.PlayerState.SubCharaID
subCharaLevel := int64(34) // TODO: remove testing
subCharaLevel := player.CharacterState[1].Level
mainChaoID := player.PlayerState.MainChaoID
mainChaoLevel := int64(5) // TODO: remove testing
mainChaoLevel := player.ChaoState[0].Level
subChaoID := player.PlayerState.SubChaoID
subChaoLevel := int64(6) // TODO: remove testing
subChaoLevel := player.ChaoState[1].Level
language := int64(enums.LangEnglish)
league := player.PlayerState.Rank // TODO: check if this is right
league := player.PlayerState.RankingLeague
maxScore := player.PlayerState.HighScore
if mode == 1 { //timed mode?
rankingScore = player.PlayerState.TimedHighScore
league = player.PlayerState.QuickRankingLeague
maxScore = player.PlayerState.TimedHighScore
}
return obj.LeaderboardEntry{
friendID,
name,
Expand Down
6 changes: 4 additions & 2 deletions responses/leaderboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func WeeklyLeaderboardEntries(base responseobjs.BaseInfo, pe obj.LeaderboardEntr
func DefaultWeeklyLeaderboardEntries(base responseobjs.BaseInfo, player netobj.Player, mode int64) WeeklyLeaderboardEntriesResponse {
startTime := now.BeginningOfDay().UTC().Unix()
resetTime := startTime + 86400 // +1 Day
myEntry := conversion.PlayerToLeaderboardEntry(player)
myEntry := conversion.PlayerToLeaderboardEntry(player, mode)
return WeeklyLeaderboardEntries(
base,
//obj.DefaultLeaderboardEntry(uid),
Expand All @@ -82,7 +82,9 @@ func DefaultWeeklyLeaderboardEntries(base responseobjs.BaseInfo, player netobj.P
1,
mode,
0,
[]obj.LeaderboardEntry{},
[]obj.LeaderboardEntry{
myEntry,
},
)
}

Expand Down