Skip to content

Commit

Permalink
fixing constants values and types
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyagara committed May 16, 2024
1 parent d55a634 commit 7cdf323
Show file tree
Hide file tree
Showing 11 changed files with 294 additions and 175 deletions.
83 changes: 57 additions & 26 deletions clients/lol/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "strconv"

// Spec version = 6461993a9c4165ddca053929f19f6d0e3eb1ca14

// Platform routes for League of Legends and Teamfight Tactics.
// Platform routes for League of Legends.
type PlatformRoute string

const (
Expand Down Expand Up @@ -146,7 +146,7 @@ func (route TournamentRegion) String() string {
}
}

// League of Legends and Teamfight Tactics ranked tiers, such as gold, diamond, challenger, etc.
// League of Legends ranked tiers, such as gold, diamond, challenger, etc.
type Tier string

const (
Expand Down Expand Up @@ -189,7 +189,7 @@ func (tier Tier) String() string {
}
}

// League of Legends and Teamfight Tactics rank divisions, I, II, III, IV, and (deprecated) V.
// League of Legends rank divisions, I, II, III, IV, and (deprecated) V.
type Division string

const (
Expand Down Expand Up @@ -218,63 +218,94 @@ func (division Division) String() string {
}
}

// League of Legends and Teamfight Tactics game types: matched game, custom game, or tutorial game.
// Team IDs for League of Legends.
type Team int32

// https://github.com/MingweiSamuel/Riven/blob/v/2.x.x/riven/src/consts/team.rs

const (
// Team ID zero for 2v2v2v2 Arena `CHERRY` game mode. (TODO: SUBJECT TO CHANGE?)
ZERO Team = 0
// Blue team (bottom left on Summoner's Rift).
BLUE Team = 100
// Red team (top right on Summoner's Rift).
RED Team = 200
// "killerTeamId" when Baron Nashor spawns and kills Rift Herald.
OTHER Team = 300
)

func (team Team) String() string {
switch team {
case ZERO:
return "0"
case BLUE:
return "100"
case RED:
return "200"
case OTHER:
return "300"
default:
return strconv.FormatInt(int64(team), 10)
}
}

// League of Legends game types: matched game, custom game, or tutorial game.
type GameType string

const (
// Custom games
CUSTOM_GAME_GAMETYPE GameType = "CUSTOM_GAME"
CUSTOM_GAME_GAMETYPE GameType = "CUSTOM"
// all other games
MATCHED_GAME_GAMETYPE GameType = "MATCHED_GAME"
MATCHED_GAME_GAMETYPE GameType = "MATCHED"
// Tutorial games
TUTORIAL_GAME_GAMETYPE GameType = "TUTORIAL_GAME"
TUTORIAL_GAME_GAMETYPE GameType = "TUTORIAL"
)

func (gameType GameType) String() string {
switch gameType {
case CUSTOM_GAME_GAMETYPE:
return "CUSTOM_GAME"
return "CUSTOM"
case MATCHED_GAME_GAMETYPE:
return "MATCHED_GAME"
return "MATCHED"
case TUTORIAL_GAME_GAMETYPE:
return "TUTORIAL_GAME"
return "TUTORIAL"
default:
return string(gameType)
}
}

// League of Legends and Teamfight Tactics ranked queue types.
type QueueType int32
// League of Legends ranked queue types.
type QueueType string

const (
// "Arena" games
CHERRY_QUEUETYPE QueueType = 1710
CHERRY_QUEUETYPE QueueType = "CHERRY"
// 5v5 Ranked Flex games
RANKED_FLEX_SR_QUEUETYPE QueueType = 440
RANKED_FLEX_SR_QUEUETYPE QueueType = "RANKED_FLEX_SR"
// # Deprecated
//
// 3v3 Ranked Flex games
RANKED_FLEX_TT_QUEUETYPE QueueType = 470
RANKED_FLEX_TT_QUEUETYPE QueueType = "RANKED_FLEX_TT"
// 5v5 Ranked Solo games
RANKED_SOLO_5X5_QUEUETYPE QueueType = 420
RANKED_SOLO_5X5_QUEUETYPE QueueType = "RANKED_SOLO_5X5"
)

func (queueType QueueType) String() string {
switch queueType {
case CHERRY_QUEUETYPE:
return "1710"
return "CHERRY"
case RANKED_FLEX_SR_QUEUETYPE:
return "440"
return "RANKED_FLEX_SR"
case RANKED_FLEX_TT_QUEUETYPE:
return "470"
return "RANKED_FLEX_TT"
case RANKED_SOLO_5X5_QUEUETYPE:
return "420"
return "RANKED_SOLO_5X5"
default:
return string(queueType)
}
}

// League of Legends and Teamfight Tactics game modes, such as Classic,
// League of Legends game modes, such as Classic,
// ARAM, URF, One For All, Ascension, etc.
type GameMode string

Expand Down Expand Up @@ -388,7 +419,7 @@ func (gameMode GameMode) String() string {
}
}

// League of Legends and Teamfight Tactics maps.
// League of Legends maps.
type Map int64

const (
Expand Down Expand Up @@ -460,8 +491,8 @@ const (
VALORAN_CITY_PARK_MAP Map = 18
)

func (lolMap Map) String() string {
switch lolMap {
func (gameMap Map) String() string {
switch gameMap {
case ARENA_MAP:
return "30"
case BUTCHERS_BRIDGE_MAP:
Expand Down Expand Up @@ -493,11 +524,11 @@ func (lolMap Map) String() string {
case VALORAN_CITY_PARK_MAP:
return "18"
default:
return strconv.FormatInt(int64(lolMap), 10)
return strconv.FormatInt(int64(gameMap), 10)
}
}

// League of Legends and Teamfight Tactics queues.
// League of Legends queues.
type Queue int32

const (
Expand Down
10 changes: 5 additions & 5 deletions clients/lol/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func (endpoint *MatchV5) ByID(ctx context.Context, route api.RegionalRoute, matc
// [match-v5.getMatchIdsByPUUID]
//
// [match-v5.getMatchIdsByPUUID]: https://developer.riotgames.com/api-methods/#match-v5/GET_getMatchIdsByPUUID
func (endpoint *MatchV5) ListByPUUID(ctx context.Context, route api.RegionalRoute, puuid string, startTime int64, endTime int64, queue int32, type_ string, start int32, count int32) ([]string, error) {
func (endpoint *MatchV5) ListByPUUID(ctx context.Context, route api.RegionalRoute, puuid string, startTime int64, endTime int64, queue Queue, matchType string, start int32, count int32) ([]string, error) {
logger := endpoint.internal.Logger("LOL_MatchV5_ListByPUUID")
urlComponents := []string{"https://", route.String(), api.RIOT_API_BASE_URL_FORMAT, "/lol/match/v5/matches/by-puuid/", puuid, "/ids"}
request, err := endpoint.internal.Request(ctx, logger, http.MethodGet, urlComponents, "match-v5.getMatchIdsByPUUID", nil)
Expand All @@ -769,18 +769,18 @@ func (endpoint *MatchV5) ListByPUUID(ctx context.Context, route api.RegionalRout
if endTime != -1 {
values.Set("endTime", strconv.FormatInt(endTime, 10))
}
if matchType != "" {
values.Set("type", matchType)
}
if queue != -1 {
values.Set("queue", strconv.FormatInt(int64(queue), 10))
values.Set("queue", queue.String())
}
if start != -1 {
values.Set("start", strconv.FormatInt(int64(start), 10))
}
if startTime != -1 {
values.Set("startTime", strconv.FormatInt(startTime, 10))
}
if type_ != "" {
values.Set("type", type_)
}
request.Request.URL.RawQuery = values.Encode()
var data []string
err = endpoint.internal.Execute(ctx, request, &data)
Expand Down
44 changes: 22 additions & 22 deletions clients/lol/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ type ClashTournamentV1DTO struct {

// league-v4.LeagueEntryDTO
type LeagueEntryV4DTO struct {
LeagueID string `json:"leagueId,omitempty"`
LeagueID string `json:"leagueId,omitempty"`
QueueType QueueType `json:"queueType,omitempty"`
// The player's division within a tier.
Rank Division `json:"rank,omitempty"`
// Player's encrypted summonerId.
Expand All @@ -163,8 +164,7 @@ type LeagueEntryV4DTO struct {
MiniSeries LeagueMiniSeriesV4DTO `json:"miniSeries,omitempty"`
LeaguePoints int32 `json:"leaguePoints,omitempty"`
// Losing team on Summoners Rift.
Losses int32 `json:"losses,omitempty"`
QueueType QueueType `json:"queueType,omitempty"`
Losses int32 `json:"losses,omitempty"`
// Winning team on Summoners Rift.
Wins int32 `json:"wins,omitempty"`
FreshBlood bool `json:"freshBlood,omitempty"`
Expand All @@ -175,7 +175,8 @@ type LeagueEntryV4DTO struct {

// league-exp-v4.LeagueEntryDTO
type LeagueExpLeagueEntryV4DTO struct {
LeagueID string `json:"leagueId,omitempty"`
LeagueID string `json:"leagueId,omitempty"`
QueueType QueueType `json:"queueType,omitempty"`
// The player's division within a tier.
Rank Division `json:"rank,omitempty"`
// Player's summonerId (Encrypted)
Expand All @@ -184,8 +185,7 @@ type LeagueExpLeagueEntryV4DTO struct {
MiniSeries LeagueExpMiniSeriesV4DTO `json:"miniSeries,omitempty"`
LeaguePoints int32 `json:"leaguePoints,omitempty"`
// Losing team on Summoners Rift. Second through eighth placement in Teamfight Tactics.
Losses int32 `json:"losses,omitempty"`
QueueType QueueType `json:"queueType,omitempty"`
Losses int32 `json:"losses,omitempty"`
// Winning team on Summoners Rift. First placement in Teamfight Tactics.
Wins int32 `json:"wins,omitempty"`
FreshBlood bool `json:"freshBlood,omitempty"`
Expand Down Expand Up @@ -223,9 +223,9 @@ type LeagueItemV4DTO struct {
type LeagueListV4DTO struct {
LeagueID string `json:"leagueId,omitempty"`
Name string `json:"name,omitempty"`
Queue QueueType `json:"queue,omitempty"`
Tier Tier `json:"tier,omitempty"`
Entries []LeagueItemV4DTO `json:"entries,omitempty"`
Queue QueueType `json:"queue,omitempty"`
}

// league-v4.MiniSeriesDTO
Expand Down Expand Up @@ -453,13 +453,13 @@ type MatchEventsTimeLineV5DTO struct {
ItemID int32 `json:"itemId,omitempty"`
KillStreakLength int32 `json:"killStreakLength,omitempty"`
KillerID int32 `json:"killerId,omitempty"`
KillerTeamID int32 `json:"killerTeamId,omitempty"`
KillerTeamID Team `json:"killerTeamId,omitempty"`
Level int32 `json:"level,omitempty"`
MultiKillLength int32 `json:"multiKillLength,omitempty"`
ParticipantID int32 `json:"participantId,omitempty"`
ShutdownBounty int32 `json:"shutdownBounty,omitempty"`
SkillSlot int32 `json:"skillSlot,omitempty"`
TeamID int32 `json:"teamId,omitempty"`
TeamID Team `json:"teamId,omitempty"`
VictimID int32 `json:"victimId,omitempty"`
WinningTeam int32 `json:"winningTeam,omitempty"`
}
Expand Down Expand Up @@ -507,9 +507,9 @@ type MatchInfoV5DTO struct {
// Unix timestamp for when match starts on the game server.
GameStartTimestamp int64 `json:"gameStartTimestamp,omitempty"`
// Refer to the Game Constants documentation.
MapID int32 `json:"mapId,omitempty"`
MapID Map `json:"mapId,omitempty"`
// Refer to the Game Constants documentation.
QueueID int32 `json:"queueId,omitempty"`
QueueID Queue `json:"queueId,omitempty"`
}

// match-v5.MetadataTimeLineDto
Expand Down Expand Up @@ -714,7 +714,7 @@ type MatchParticipantV5DTO struct {
Summoner2Casts int32 `json:"summoner2Casts,omitempty"`
Summoner2ID int32 `json:"summoner2Id,omitempty"`
SummonerLevel int32 `json:"summonerLevel,omitempty"`
TeamID int32 `json:"teamId,omitempty"`
TeamID Team `json:"teamId,omitempty"`
TimeCCingOthers int32 `json:"timeCCingOthers,omitempty"`
TimePlayed int32 `json:"timePlayed,omitempty"`
TotalAllyJungleMinionsKilled int32 `json:"totalAllyJungleMinionsKilled,omitempty"`
Expand Down Expand Up @@ -791,7 +791,7 @@ type MatchPositionV5DTO struct {
type MatchTeamV5DTO struct {
Bans []MatchBanV5DTO `json:"bans,omitempty"`
Objectives MatchObjectivesV5DTO `json:"objectives,omitempty"`
TeamID int32 `json:"teamId,omitempty"`
TeamID Team `json:"teamId,omitempty"`
Win bool `json:"win,omitempty"`
}

Expand Down Expand Up @@ -831,7 +831,7 @@ type SpectatorBannedChampionV5DTO struct {
// The turn during which the champion was banned
PickTurn int32 `json:"pickTurn,omitempty"`
// The ID of the team that banned the champion
TeamID int64 `json:"teamId,omitempty"`
TeamID Team `json:"teamId,omitempty"`
}

// spectator-v5.CurrentGameInfo
Expand All @@ -852,12 +852,12 @@ type SpectatorCurrentGameInfoV5DTO struct {
GameID int64 `json:"gameId,omitempty"`
// The amount of time in seconds that has passed since the game started
GameLength int64 `json:"gameLength,omitempty"`
// The queue type (queue types are documented on the Game Constants page)
GameQueueConfigID int64 `json:"gameQueueConfigId,omitempty"`
// The game start time represented in epoch milliseconds
GameStartTime int64 `json:"gameStartTime,omitempty"`
// The ID of the map
MapID int64 `json:"mapId,omitempty"`
MapID Map `json:"mapId,omitempty"`
// The queue type (queue types are documented on the Game Constants page)
GameQueueConfigID Queue `json:"gameQueueConfigId,omitempty"`
}

// spectator-v5.CurrentGameParticipant
Expand All @@ -880,7 +880,7 @@ type SpectatorCurrentGameParticipantV5DTO struct {
// The ID of the second summoner spell used by this participant
Spell2ID int64 `json:"spell2Id,omitempty"`
// The team ID of this participant, indicating the participant's team
TeamID int64 `json:"teamId,omitempty"`
TeamID Team `json:"teamId,omitempty"`
// Flag indicating whether or not this participant is a bot
Bot bool `json:"bot,omitempty"`
}
Expand All @@ -907,10 +907,10 @@ type SpectatorFeaturedGameInfoV5DTO struct {
GameID int64 `json:"gameId,omitempty"`
// The amount of time in seconds that has passed since the game started
GameLength int64 `json:"gameLength,omitempty"`
// The queue type (queue types are documented on the Game Constants page)
GameQueueConfigID int64 `json:"gameQueueConfigId,omitempty"`
// The ID of the map
MapID int64 `json:"mapId,omitempty"`
MapID Map `json:"mapId,omitempty"`
// The queue type (queue types are documented on the Game Constants page)
GameQueueConfigID Queue `json:"gameQueueConfigId,omitempty"`
}

// spectator-v5.FeaturedGames
Expand Down Expand Up @@ -951,7 +951,7 @@ type SpectatorParticipantV5DTO struct {
// The ID of the second summoner spell used by this participant
Spell2ID int64 `json:"spell2Id,omitempty"`
// The team ID of this participant, indicating the participant's team
TeamID int64 `json:"teamId,omitempty"`
TeamID Team `json:"teamId,omitempty"`
// Flag indicating whether or not this participant is a bot
Bot bool `json:"bot,omitempty"`
}
Expand Down
Loading

0 comments on commit 7cdf323

Please sign in to comment.