66 lines
3.1 KiB
Go
66 lines
3.1 KiB
Go
package model
|
|
|
|
import (
|
|
"git.lehouerou.net/laurent/sorare/football"
|
|
"git.lehouerou.net/laurent/sorare/types"
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type Card struct {
|
|
Id string `json:"id"`
|
|
AssetId string `json:"assetId"`
|
|
PlayerSlug string `json:"playerSlug"`
|
|
PlayerDisplayName string `json:"playerDisplayName"`
|
|
Rarity types.Rarity `json:"rarity"`
|
|
SerialNumber int `json:"serialNumber"`
|
|
SeasonStartYear int `json:"seasonStartYear"`
|
|
SingleCivilYear bool `json:"singleCivilYear"`
|
|
Supply int `json:"supply"`
|
|
TeamSlug string `json:"teamSlug"`
|
|
Name string `json:"name"`
|
|
PictureUrl string `json:"pictureUrl"`
|
|
Slug string `json:"slug"`
|
|
Power decimal.Decimal `json:"power"`
|
|
PowerMalusAfterTransfer decimal.Decimal `json:"powerMalusAfterTransfer"`
|
|
RivalsPower decimal.Decimal `json:"rivalsPower"`
|
|
Grade int `json:"grade"`
|
|
GradeAfterTransfer int `json:"gradeAfterTransfer"`
|
|
Xp int `json:"xp"`
|
|
XpAfterTransfer int `json:"xpAfterTransfer"`
|
|
XpNeededForNextGrade int `json:"xpNeededForNextGrade"`
|
|
XpNeededForCurrentGrade int `json:"xpNeededForCurrentGrade"`
|
|
InSeasonEligible bool `json:"inSeasonEligible"`
|
|
LevelUpAppliedCount int `json:"levelUpAppliedCount"`
|
|
MaxLevelUpAppliedCount int `json:"maxLevelUpAppliedCount"`
|
|
}
|
|
|
|
func NewCardFromSorare(card football.Card) Card {
|
|
return Card{
|
|
Id: card.Token.Id.Value,
|
|
AssetId: card.Token.AssetId,
|
|
PlayerSlug: card.Token.Metadata.Football.PlayerSlug,
|
|
PlayerDisplayName: card.Token.Metadata.Football.PlayerDisplayName,
|
|
Rarity: types.Rarity(card.Token.Metadata.Football.Rarity),
|
|
SerialNumber: card.Token.Metadata.Football.SerialNumber,
|
|
SeasonStartYear: card.Token.Metadata.Football.SeasonStartYear,
|
|
SingleCivilYear: card.Token.Metadata.Football.SingleCivilYear,
|
|
Supply: card.Token.Metadata.Football.Supply,
|
|
TeamSlug: card.Token.Metadata.Football.TeamSlug,
|
|
Name: card.Token.Name,
|
|
PictureUrl: card.Token.PictureUrl,
|
|
Slug: card.Token.Slug,
|
|
Power: card.Power,
|
|
PowerMalusAfterTransfer: card.PowerMalusAfterTransfer,
|
|
RivalsPower: card.RivalsPower,
|
|
Grade: card.Grade,
|
|
GradeAfterTransfer: card.GradeAfterTransfer,
|
|
Xp: card.Xp,
|
|
XpAfterTransfer: card.XpAfterTransfer,
|
|
XpNeededForNextGrade: card.XpNeededForNextGrade,
|
|
XpNeededForCurrentGrade: card.XpNeededForCurrentGrade,
|
|
InSeasonEligible: card.InSeasonEligible,
|
|
LevelUpAppliedCount: card.LevelUpAppliedCount,
|
|
MaxLevelUpAppliedCount: card.MaxLevelUpAppliedCount,
|
|
}
|
|
}
|