Skip to content

Commit

Permalink
reworking some cdn models, updating benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyagara committed Dec 10, 2023
1 parent eba11c7 commit 0f8042b
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 304 deletions.
105 changes: 0 additions & 105 deletions clients/cdragon/champion.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,111 +13,6 @@ type ChampionEndpoint struct {
internal *internal.Client
}

type ChampionData struct {
Passive struct {
Name string `json:"name"`
AbilityIconPath string `json:"abilityIconPath"`
AbilityVideoPath string `json:"abilityVideoPath"`
AbilityVideoImagePath string `json:"abilityVideoImagePath"`
Description string `json:"description"`
} `json:"passive"`
Name string `json:"name"`
Alias string `json:"alias"`
Title string `json:"title"`
ShortBio string `json:"shortBio"`
SquarePortraitPath string `json:"squarePortraitPath"`
StingerSFXPath string `json:"stingerSfxPath"`
ChooseVoPath string `json:"chooseVoPath"`
BanVoPath string `json:"banVoPath"`
Roles []string `json:"roles"`
RecommendedItemDefaults []any `json:"recommendedItemDefaults,omitempty"`
Skins []struct {
Emblems any `json:"emblems,omitempty"`
Name string `json:"name"`
SplashPath string `json:"splashPath"`
UncenteredSplashPath string `json:"uncenteredSplashPath"`
TilePath string `json:"tilePath"`
LoadScreenPath string `json:"loadScreenPath"`
SkinType string `json:"skinType"`
Rarity string `json:"rarity"`
SplashVideoPath string `json:"splashVideoPath"`
CollectionSplashVideoPath string `json:"collectionSplashVideoPath"`
FeaturesText string `json:"featuresText"`
ChromaPath string `json:"chromaPath"`
RarityGemPath string `json:"rarityGemPath"`
Description string `json:"description"`
SkinLines []struct {
ID int `json:"id"`
} `json:"skinLines"`
Chromas []struct {
Name string `json:"name"`
ChromaPath string `json:"chromaPath"`
Colors []string `json:"colors"`
Descriptions []struct {
Region string `json:"region"`
Description string `json:"description"`
} `json:"descriptions"`
Rarities []struct {
Region string `json:"region"`
Rarity int `json:"rarity"`
} `json:"rarities"`
ID int `json:"id"`
} `json:"chromas,omitempty"`
ID int `json:"id"`
RegionRarityID int `json:"regionRarityId"`
IsBase bool `json:"isBase"`
IsLegacy bool `json:"isLegacy"`
} `json:"skins"`
Spells []struct {
SpellKey string `json:"spellKey"`
Name string `json:"name"`
AbilityIconPath string `json:"abilityIconPath"`
AbilityVideoPath string `json:"abilityVideoPath"`
AbilityVideoImagePath string `json:"abilityVideoImagePath"`
Cost string `json:"cost"`
Cooldown string `json:"cooldown"`
Description string `json:"description"`
DynamicDescription string `json:"dynamicDescription"`
EffectAmounts struct {
Effect1Amount []float64 `json:"Effect1Amount"`
Effect2Amount []float64 `json:"Effect2Amount"`
Effect3Amount []float64 `json:"Effect3Amount"`
Effect4Amount []float64 `json:"Effect4Amount"`
Effect5Amount []float64 `json:"Effect5Amount"`
Effect6Amount []float64 `json:"Effect6Amount"`
Effect7Amount []float64 `json:"Effect7Amount"`
Effect8Amount []float64 `json:"Effect8Amount"`
Effect9Amount []float64 `json:"Effect9Amount"`
Effect10Amount []float64 `json:"Effect10Amount"`
} `json:"effectAmounts"`
Ammo struct {
AmmoRechargeTime []float64 `json:"ammoRechargeTime"`
MaxAmmo []int `json:"maxAmmo"`
} `json:"ammo"`
Range []float64 `json:"range"`
CostCoefficients []float64 `json:"costCoefficients"`
CooldownCoefficients []float64 `json:"cooldownCoefficients"`
Coefficients struct {
Coefficient1 float64 `json:"coefficient1"`
Coefficient2 float64 `json:"coefficient2"`
} `json:"coefficients"`
MaxLevel int `json:"maxLevel"`
} `json:"spells"`
TacticalInfo struct {
DamageType string `json:"damageType"`
Style int `json:"style"`
Difficulty int `json:"difficulty"`
} `json:"tacticalInfo"`
PlaystyleInfo struct {
Damage int `json:"damage"`
Durability int `json:"durability"`
CrowdControl int `json:"crowdControl"`
Mobility int `json:"mobility"`
Utility int `json:"utility"`
} `json:"playstyleInfo"`
ID int `json:"id"`
}

// Retrieves more information about a champion, includes skins, spells and tips.
func (e *ChampionEndpoint) ByName(ctx context.Context, version string, champion string) (*ChampionData, error) {
logger := e.internal.Logger("CDragon_Champion_ByName")
Expand Down
130 changes: 130 additions & 0 deletions clients/cdragon/models.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package cdragon

type ChampionData struct {
Passive ChampionPassive `json:"passive,omitempty"`
Name string `json:"name,omitempty"`
Alias string `json:"alias,omitempty"`
Title string `json:"title,omitempty"`
ShortBio string `json:"shortBio,omitempty"`
SquarePortraitPath string `json:"squarePortraitPath,omitempty"`
StingerSFXPath string `json:"stingerSfxPath,omitempty"`
ChooseVoPath string `json:"chooseVoPath,omitempty"`
BanVoPath string `json:"banVoPath,omitempty"`
Roles []string `json:"roles,omitempty"`
RecommendedItemDefaults []any `json:"recommendedItemDefaults,omitempty"`
Skins []ChampionSkins `json:"skins,omitempty"`
Spells []ChampionSpells `json:"spells,omitempty"`
TacticalInfo ChampionTacticalInfo `json:"tacticalInfo,omitempty"`
PlaystyleInfo ChampionPlaystyleInfo `json:"playstyleInfo,omitempty"`
ID int `json:"id,omitempty"`
}

type ChampionPassive struct {
Name string `json:"name,omitempty"`
AbilityIconPath string `json:"abilityIconPath,omitempty"`
AbilityVideoPath string `json:"abilityVideoPath,omitempty"`
AbilityVideoImagePath string `json:"abilityVideoImagePath,omitempty"`
Description string `json:"description,omitempty"`
}

type ChampionSkins struct {
Emblems any `json:"emblems,omitempty"`
Name string `json:"name,omitempty"`
SplashPath string `json:"splashPath,omitempty"`
UncenteredSplashPath string `json:"uncenteredSplashPath,omitempty"`
TilePath string `json:"tilePath,omitempty"`
LoadScreenPath string `json:"loadScreenPath,omitempty"`
SkinType string `json:"skinType,omitempty"`
Rarity string `json:"rarity,omitempty"`
SplashVideoPath string `json:"splashVideoPath,omitempty"`
CollectionSplashVideoPath string `json:"collectionSplashVideoPath,omitempty"`
FeaturesText string `json:"featuresText,omitempty"`
ChromaPath string `json:"chromaPath,omitempty"`
RarityGemPath string `json:"rarityGemPath,omitempty"`
Description string `json:"description,omitempty"`
SkinLines []ChampionSkinLines `json:"skinLines,omitempty"`
Chromas []ChampionSkinChromas `json:"chromas,omitempty"`
ID int `json:"id,omitempty"`
RegionRarityID int `json:"regionRarityId,omitempty"`
IsBase bool `json:"isBase,omitempty"`
IsLegacy bool `json:"isLegacy,omitempty"`
}

type ChampionSkinLines struct {
ID int `json:"id,omitempty"`
}

type ChampionSkinChromas struct {
Name string `json:"name,omitempty"`
ChromaPath string `json:"chromaPath,omitempty"`
Colors []string `json:"colors,omitempty"`
Descriptions []ChampionSkinChromaDescriptions `json:"descriptions,omitempty"`
Rarities []ChampionSkinChromaRarities `json:"rarities,omitempty"`
ID int `json:"id,omitempty"`
}

type ChampionSkinChromaDescriptions struct {
Region string `json:"region,omitempty"`
Description string `json:"description,omitempty"`
}

type ChampionSkinChromaRarities struct {
Region string `json:"region,omitempty"`
Rarity int `json:"rarity,omitempty"`
}

type ChampionSpells struct {
SpellKey string `json:"spellKey,omitempty"`
Name string `json:"name,omitempty"`
AbilityIconPath string `json:"abilityIconPath,omitempty"`
AbilityVideoPath string `json:"abilityVideoPath,omitempty"`
AbilityVideoImagePath string `json:"abilityVideoImagePath,omitempty"`
Cost string `json:"cost,omitempty"`
Cooldown string `json:"cooldown,omitempty"`
Description string `json:"description,omitempty"`
DynamicDescription string `json:"dynamicDescription,omitempty"`
EffectAmounts ChampionSpellEffectAmounts `json:"effectAmounts,omitempty"`
Ammo ChampionSpellAmmo `json:"ammo,omitempty"`
Range []float64 `json:"range,omitempty"`
CostCoefficients []float64 `json:"costCoefficients,omitempty"`
CooldownCoefficients []float64 `json:"cooldownCoefficients,omitempty"`
Coefficients ChampionSpellCoefficients `json:"coefficients,omitempty"`
MaxLevel int `json:"maxLevel,omitempty"`
}

type ChampionSpellEffectAmounts struct {
Effect1Amount []float64 `json:"Effect1Amount,omitempty"`
Effect2Amount []float64 `json:"Effect2Amount,omitempty"`
Effect3Amount []float64 `json:"Effect3Amount,omitempty"`
Effect4Amount []float64 `json:"Effect4Amount,omitempty"`
Effect5Amount []float64 `json:"Effect5Amount,omitempty"`
Effect6Amount []float64 `json:"Effect6Amount,omitempty"`
Effect7Amount []float64 `json:"Effect7Amount,omitempty"`
Effect8Amount []float64 `json:"Effect8Amount,omitempty"`
Effect9Amount []float64 `json:"Effect9Amount,omitempty"`
Effect10Amount []float64 `json:"Effect10Amount,omitempty"`
}

type ChampionSpellAmmo struct {
AmmoRechargeTime []float64 `json:"ammoRechargeTime,omitempty"`
MaxAmmo []int `json:"maxAmmo,omitempty"`
}

type ChampionSpellCoefficients struct {
Coefficient1 float64 `json:"coefficient1,omitempty"`
Coefficient2 float64 `json:"coefficient2,omitempty"`
}

type ChampionPlaystyleInfo struct {
Damage int `json:"damage,omitempty"`
Durability int `json:"durability,omitempty"`
CrowdControl int `json:"crowdControl,omitempty"`
Mobility int `json:"mobility,omitempty"`
Utility int `json:"utility,omitempty"`
}

type ChampionTacticalInfo struct {
DamageType string `json:"damageType,omitempty"`
Style int `json:"style,omitempty"`
Difficulty int `json:"difficulty,omitempty"`
}
132 changes: 2 additions & 130 deletions clients/ddragon/champion.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,144 +13,16 @@ type ChampionEndpoint struct {
internal *internal.Client
}

type ChampionsData struct {
Data map[string]Champion `json:"data"`
Type string `json:"type"`
Format string `json:"format"`
Version string `json:"version"`
}

type Champion struct {
Version string `json:"version"`
ID string `json:"id"`
Key string `json:"key"`
Name string `json:"name"`
Title string `json:"title"`
Blurb string `json:"blurb"`
Partype string `json:"partype"`
Tags []string `json:"tags"`
Image Image `json:"image"`
Stats ChampionStats `json:"stats"`
Info struct {
Attack int `json:"attack"`
Defense int `json:"defense"`
Magic int `json:"magic"`
Difficulty int `json:"difficulty"`
} `json:"info"`
}

type FullChampionData struct {
Data map[string]FullChampion `json:"data"`
Type string `json:"type"`
Format string `json:"format"`
Version string `json:"version"`
}

type FullChampion struct {
ID string `json:"id"`
Key string `json:"key"`
Name string `json:"name"`
Title string `json:"title"`
Lore string `json:"lore"`
Blurb string `json:"blurb"`
Partype string `json:"partype"`
Skins []struct {
ID string `json:"id"`
Name string `json:"name"`
Num int `json:"num"`
Chromas bool `json:"chromas"`
} `json:"skins"`
AllyTips []string `json:"allytips"`
EnemyTips []string `json:"enemytips"`
Tags []string `json:"tags"`
Spells []struct {
DataValues struct {
} `json:"datavalues"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Tooltip string `json:"tooltip"`
CooldownBurn string `json:"cooldownBurn"`
CostBurn string `json:"costBurn"`
CostType string `json:"costType"`
MaxAmmo string `json:"maxammo"`
RangeBurn string `json:"rangeBurn"`
Resource string `json:"resource"`
Leveltip struct {
Label []string `json:"label"`
Effect []string `json:"effect"`
} `json:"leveltip"`
Cooldown []float64 `json:"cooldown"`
Cost []float64 `json:"cost"`
// Not modeled
Effect []any `json:"effect,omitempty"`
// Not modeled
EffectBurn []any `json:"effectBurn,omitempty"`
// Not modeled
Vars []any `json:"vars,omitempty"`
Range []int `json:"range"`
Image Image `json:"image"`
MaxRank int `json:"maxrank"`
} `json:"spells"`
Recommended []any `json:"recommended,omitempty"`
Passive struct {
Name string `json:"name"`
Description string `json:"description"`
Image Image `json:"image"`
} `json:"passive"`
Image Image `json:"image"`
Stats ChampionStats `json:"stats"`
Info struct {
Attack int `json:"attack"`
Defense int `json:"defense"`
Magic int `json:"magic"`
Difficulty int `json:"difficulty"`
} `json:"info"`
}

type ChampionStats struct {
HP float64 `json:"hp"`
HPPerLevel float64 `json:"hpperlevel"`
MP float64 `json:"mp"`
MPPerLevel float64 `json:"mpperlevel"`
MovementSpeed float64 `json:"movespeed"`
Armor float64 `json:"armor"`
ArmorPerLevel float64 `json:"armorperlevel"`
SpellBlock float64 `json:"spellblock"`
SpellBlockPerLevel float64 `json:"spellblockperlevel"`
AttackRange float64 `json:"attackrange"`
HPRegen float64 `json:"hpregen"`
HPRegenPerLevel float64 `json:"hpregenperlevel"`
MPRegen float64 `json:"mpregen"`
MPRegenPerLevel float64 `json:"mpregenperlevel"`
Crit float64 `json:"crit"`
CritPerLevel float64 `json:"critperlevel"`
AttackDamage float64 `json:"attackdamage"`
AttackDamagePerLevel float64 `json:"attackdamageperlevel"`
AttackSpeedPerLevel float64 `json:"attackspeedperlevel"`
AttackSpeed float64 `json:"attackspeed"`
}

type Image struct {
Full string `json:"full"`
Sprite string `json:"sprite"`
Group string `json:"group"`
X int `json:"x"`
Y int `json:"y"`
W int `json:"w"`
H int `json:"h"`
}

// Get all champions basic information, includes stats, tags, title and blurb.
func (e *ChampionEndpoint) AllChampions(ctx context.Context, version string, language Language) (map[string]Champion, error) {
func (e *ChampionEndpoint) AllChampions(ctx context.Context, version string, language Language) (map[string]AllChampionsDataDTO, error) {
logger := e.internal.Logger("DDragon_Champion_AllChampions")
logger.Debug().Msg("Method started execution")
equinoxReq, err := e.internal.Request(ctx, logger, api.D_DRAGON_BASE_URL_FORMAT, http.MethodGet, "", fmt.Sprintf(ChampionsURL, version, language), "", nil)
if err != nil {
logger.Error().Err(err).Msg("Error creating request")
return nil, err
}
var data ChampionsData
var data AllChampionsDTO
err = e.internal.Execute(ctx, equinoxReq, &data)
if err != nil {
logger.Error().Err(err).Msg("Error executing request")
Expand Down
Loading

0 comments on commit 0f8042b

Please sign in to comment.