bunmodel

package
v1.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PlayerMetaColumns = []string{"id", "name", "profile_url"}
View Source
var ServerMetaColumns = []string{"key", "url", "open"}
View Source
var TribeMetaColumns = []string{"id", "name", "tag", "profile_url"}
View Source
var VillageMetaColumns = []string{"id", "name", "profile_url", "x", "y", "continent"}

Functions

This section is empty.

Types

type Building

type Building struct {
	BuildTime       float64
	BuildTimeFactor float64
	Iron            int
	IronFactor      float64
	MaxLevel        int
	MinLevel        int
	Pop             int
	PopFactor       float64
	Stone           int
	StoneFactor     float64
	Wood            int
	WoodFactor      float64
}

type BuildingInfo

type BuildingInfo struct {
	Main       Building
	Barracks   Building
	Stable     Building
	Garage     Building
	Watchtower Building
	Snob       Building
	Smith      Building
	Place      Building
	Statue     Building
	Market     Building
	Wood       Building
	Stone      Building
	Iron       Building
	Farm       Building
	Storage    Building
	Hide       Building
	Wall       Building
}

func NewBuildingInfo

func NewBuildingInfo(info domain.BuildingInfo) BuildingInfo

func (BuildingInfo) ToDomain

func (b BuildingInfo) ToDomain() (domain.BuildingInfo, error)

type Ennoblement

type Ennoblement struct {
	bun.BaseModel `bun:"table:ennoblements,alias:ennoblement"`

	ID         int       `bun:"id,pk,autoincrement,identity"`
	ServerKey  string    `bun:"server_key,nullzero"`
	VillageID  int       `bun:"village_id,nullzero"`
	Village    Village   `bun:"village,rel:belongs-to,join:village_id=id,join:server_key=server_key"`
	NewOwnerID int       `bun:"new_owner_id,nullzero"`
	NewOwner   Player    `bun:"new_owner,rel:belongs-to,join:new_owner_id=id,join:server_key=server_key"`
	NewTribeID int       `bun:"new_tribe_id,nullzero"`
	NewTribe   Tribe     `bun:"new_tribe,rel:belongs-to,join:new_tribe_id=id,join:server_key=server_key"`
	OldOwnerID int       `bun:"old_owner_id,nullzero"`
	OldOwner   Player    `bun:"old_owner,rel:belongs-to,join:old_owner_id=id,join:server_key=server_key"`
	OldTribeID int       `bun:"old_tribe_id,nullzero"`
	OldTribe   Tribe     `bun:"old_tribe,rel:belongs-to,join:old_tribe_id=id,join:server_key=server_key"`
	Points     int       `bun:"points"`
	CreatedAt  time.Time `bun:"created_at,nullzero"`
}

func (Ennoblement) ToDomain

func (e Ennoblement) ToDomain() (domain.Ennoblement, error)

func (Ennoblement) ToDomainWithRelations

func (e Ennoblement) ToDomainWithRelations() (domain.EnnoblementWithRelations, error)

type Ennoblements

type Ennoblements []Ennoblement

func (Ennoblements) ToDomain

func (es Ennoblements) ToDomain() (domain.Ennoblements, error)

func (Ennoblements) ToDomainWithRelations

func (es Ennoblements) ToDomainWithRelations() (domain.EnnoblementsWithRelations, error)

type OpponentsDefeated

type OpponentsDefeated struct {
	RankAtt    int `bun:"rank_att"`
	ScoreAtt   int `bun:"score_att"`
	RankDef    int `bun:"rank_def"`
	ScoreDef   int `bun:"score_def"`
	RankSup    int `bun:"rank_sup"`
	ScoreSup   int `bun:"score_sup"`
	RankTotal  int `bun:"rank_total"`
	ScoreTotal int `bun:"score_total"`
}

func (OpponentsDefeated) ToDomain

type Player

type Player struct {
	bun.BaseModel `bun:"table:players,alias:player"`

	ID             int       `bun:"id,nullzero,pk"`
	ServerKey      string    `bun:"server_key,nullzero,pk"`
	Server         Server    `bun:"server,rel:belongs-to,join:server_key=key"`
	Name           string    `bun:"name,nullzero"`
	NumVillages    int       `bun:"num_villages"`
	Points         int       `bun:"points"`
	Rank           int       `bun:"rank"`
	TribeID        int       `bun:"tribe_id,nullzero"`
	Tribe          Tribe     `bun:"tribe,rel:belongs-to,join:tribe_id=id,join:server_key=server_key"`
	ProfileURL     string    `bun:"profile_url,nullzero"`
	BestRank       int       `bun:"best_rank"`
	BestRankAt     time.Time `bun:"best_rank_at,nullzero,default:CURRENT_TIMESTAMP"`
	MostPoints     int       `bun:"most_points"`
	MostPointsAt   time.Time `bun:"most_points_at,nullzero,default:CURRENT_TIMESTAMP"`
	MostVillages   int       `bun:"most_villages"`
	MostVillagesAt time.Time `bun:"most_villages_at,nullzero,default:CURRENT_TIMESTAMP"`
	LastActivityAt time.Time `bun:"last_activity_at,nullzero,default:CURRENT_TIMESTAMP"`
	CreatedAt      time.Time `bun:"created_at,nullzero,default:CURRENT_TIMESTAMP"`
	DeletedAt      time.Time `bun:"deleted_at,nullzero"`

	OpponentsDefeated
}

func (Player) ToDomain

func (p Player) ToDomain() (domain.Player, error)

func (Player) ToDomainWithRelations

func (p Player) ToDomainWithRelations() (domain.PlayerWithRelations, error)

func (Player) ToMeta

func (p Player) ToMeta() (domain.PlayerMeta, error)

func (Player) ToMetaWithRelations

func (p Player) ToMetaWithRelations() (domain.PlayerMetaWithRelations, error)

type PlayerSnapshot

type PlayerSnapshot struct {
	bun.BaseModel `bun:"table:player_snapshots,alias:ps"`

	ID          int       `bun:"id,pk,autoincrement,identity"`
	PlayerID    int       `bun:"player_id,nullzero"`
	TribeID     int       `bun:"tribe_id,nullzero"`
	ServerKey   string    `bun:"server_key,nullzero"`
	Tribe       Tribe     `bun:"tribe,rel:belongs-to,join:tribe_id=id,join:server_key=server_key"`
	Player      Player    `bun:"player,rel:belongs-to,join:player_id=id,join:server_key=server_key"`
	NumVillages int       `bun:"num_villages"`
	Points      int       `bun:"points"`
	Rank        int       `bun:"rank"`
	Date        time.Time `bun:"date,nullzero"`
	CreatedAt   time.Time `bun:"created_at,nullzero"`

	OpponentsDefeated
}

func (PlayerSnapshot) ToDomain

func (ps PlayerSnapshot) ToDomain() (domain.PlayerSnapshot, error)

func (PlayerSnapshot) ToDomainWithRelations

func (ps PlayerSnapshot) ToDomainWithRelations() (domain.PlayerSnapshotWithRelations, error)

type PlayerSnapshots

type PlayerSnapshots []PlayerSnapshot

func (PlayerSnapshots) ToDomain

func (pss PlayerSnapshots) ToDomain() (domain.PlayerSnapshots, error)

func (PlayerSnapshots) ToDomainWithRelations

func (pss PlayerSnapshots) ToDomainWithRelations() (domain.PlayerSnapshotsWithRelations, error)

type Players

type Players []Player

func (Players) ToDomain

func (ps Players) ToDomain() (domain.Players, error)

func (Players) ToDomainWithRelations

func (ps Players) ToDomainWithRelations() (domain.PlayersWithRelations, error)

type Server

type Server struct {
	bun.BaseModel            `bun:"table:servers,alias:server"`
	Key                      string       `bun:"key,nullzero,pk"`
	URL                      string       `bun:"url,nullzero"`
	Open                     bool         `bun:"open"`
	Special                  bool         `bun:"special"`
	NumPlayers               int          `bun:"num_players"`
	NumActivePlayers         int          `bun:"num_active_players"`
	NumInactivePlayers       int          `bun:"num_inactive_players"`
	NumTribes                int          `bun:"num_tribes"`
	NumActiveTribes          int          `bun:"num_active_tribes"`
	NumInactiveTribes        int          `bun:"num_inactive_tribes"`
	NumVillages              int          `bun:"num_villages"`
	NumPlayerVillages        int          `bun:"num_player_villages"`
	NumBarbarianVillages     int          `bun:"num_barbarian_villages"`
	NumBonusVillages         int          `bun:"num_bonus_villages"`
	Config                   ServerConfig `bun:"config"`
	BuildingInfo             BuildingInfo `bun:"building_info"`
	UnitInfo                 UnitInfo     `bun:"unit_info"`
	CreatedAt                time.Time    `bun:"created_at,nullzero"`
	SnapshotCreatedAt        time.Time    `bun:"snapshot_created_at,nullzero"`
	PlayerDataUpdatedAt      time.Time    `bun:"player_data_synced_at,nullzero"`
	PlayerSnapshotsCreatedAt time.Time    `bun:"player_snapshots_created_at,nullzero"`
	TribeDataUpdatedAt       time.Time    `bun:"tribe_data_synced_at,nullzero"`
	TribeSnapshotsCreatedAt  time.Time    `bun:"tribe_snapshots_created_at,nullzero"`
	VillageDataUpdatedAt     time.Time    `bun:"village_data_synced_at,nullzero"`
	EnnoblementDataUpdatedAt time.Time    `bun:"ennoblement_data_synced_at,nullzero"`
	VersionCode              string       `bun:"version_code,nullzero"`
}

func (Server) ToDomain

func (s Server) ToDomain() (domain.Server, error)

func (Server) ToMeta

func (s Server) ToMeta() (domain.ServerMeta, error)

type ServerConfig

func NewServerConfig

func NewServerConfig(cfg domain.ServerConfig) ServerConfig

func (ServerConfig) ToDomain

func (s ServerConfig) ToDomain() (domain.ServerConfig, error)

type ServerConfigAlly

type ServerConfigAlly struct {
	AllytimeSupport       int
	FixedAllies           int
	Levels                int
	Limit                 int
	NoHarm                int
	NoJoin                int
	NoLeave               int
	NoOtherSupport        int
	NoOtherSupportType    int
	PointsMemberCount     int
	WarsAutoacceptDays    int
	WarsMemberRequirement int
	WarsPointsRequirement int
	XpRequirements        string
}

type ServerConfigBuild

type ServerConfigBuild struct {
	Destroy int
}

type ServerConfigBuildings

type ServerConfigBuildings struct {
	CustomBarracks   int
	CustomChurch     int
	CustomFarm       int
	CustomGarage     int
	CustomHide       int
	CustomIron       int
	CustomMain       int
	CustomMarket     int
	CustomPlace      int
	CustomSmith      int
	CustomSnob       int
	CustomStable     int
	CustomStatue     int
	CustomStone      int
	CustomStorage    int
	CustomWall       int
	CustomWatchtower int
	CustomWood       int
}

type ServerConfigCommands

type ServerConfigCommands struct {
	CommandCancelTime int
	MillisArrival     int
}

type ServerConfigCoord

type ServerConfigCoord struct {
	BonusNew        int
	BonusVillages   int
	EmptyVillages   int
	Func            int
	Inner           int
	MapSize         int
	NobleRestart    int
	SelectStart     int
	StartVillages   int
	VillageMoveWait int
}

type ServerConfigGame

type ServerConfigGame struct {
	Archer             int
	BarbarianMaxPoints int
	BarbarianRise      float64
	BarbarianShrink    int
	BaseProduction     int
	BuildtimeFormula   int
	Church             int
	Event              int
	FakeLimit          float64
	FarmLimit          int
	Hauls              int
	HaulsBase          int
	HaulsMax           int
	Knight             int
	KnightNewItems     int
	Scavenging         int
	Stronghold         int
	SuppressEvents     int
	Tech               int
	Watchtower         int
}

type ServerConfigMisc

type ServerConfigMisc struct {
	KillRanking     int
	TradeCancelTime int
	Tutorial        int
}

type ServerConfigNewbie

type ServerConfigNewbie struct {
	Days                 int
	Ratio                int
	RatioDays            int
	RemoveNewbieVillages int
}

type ServerConfigNight

type ServerConfigNight struct {
	Active    int
	DefFactor float64
	Duration  int
	EndHour   int
	StartHour int
}

type ServerConfigSitter

type ServerConfigSitter struct {
	Allow int
}

type ServerConfigSleep

type ServerConfigSleep struct {
	Active   int
	Delay    int
	Max      int
	MaxAwake int
	Min      int
	MinAwake int
	WarnTime int
}

type ServerConfigSnob

type ServerConfigSnob struct {
	CheapRebuild  int
	CoinIron      int
	CoinStone     int
	CoinWood      int
	Factor        float64
	Gold          int
	MaxDist       int
	NoBarbConquer int
	Rise          int
}

type ServerConfigWin

type ServerConfigWin struct {
	Check int
}

type ServerSnapshot added in v1.1.0

type ServerSnapshot struct {
	bun.BaseModel `bun:"table:server_snapshots,alias:ss"`

	ID                   int       `bun:"id,pk,autoincrement,identity"`
	ServerKey            string    `bun:"server_key,nullzero"`
	Server               Server    `bun:"server,rel:belongs-to,join:server_key=key"`
	NumPlayers           int       `bun:"num_players"`
	NumActivePlayers     int       `bun:"num_active_players"`
	NumInactivePlayers   int       `bun:"num_inactive_players"`
	NumTribes            int       `bun:"num_tribes"`
	NumActiveTribes      int       `bun:"num_active_tribes"`
	NumInactiveTribes    int       `bun:"num_inactive_tribes"`
	NumVillages          int       `bun:"num_villages"`
	NumPlayerVillages    int       `bun:"num_player_villages"`
	NumBarbarianVillages int       `bun:"num_barbarian_villages"`
	NumBonusVillages     int       `bun:"num_bonus_villages"`
	Date                 time.Time `bun:"date,nullzero"`
	CreatedAt            time.Time `bun:"created_at,nullzero"`
}

func (ServerSnapshot) ToDomain added in v1.1.0

func (ss ServerSnapshot) ToDomain() (domain.ServerSnapshot, error)

func (ServerSnapshot) ToDomainWithRelations added in v1.3.0

func (ss ServerSnapshot) ToDomainWithRelations() (domain.ServerSnapshotWithRelations, error)

type ServerSnapshots added in v1.1.0

type ServerSnapshots []ServerSnapshot

func (ServerSnapshots) ToDomain added in v1.1.0

func (sss ServerSnapshots) ToDomain() (domain.ServerSnapshots, error)

func (ServerSnapshots) ToDomainWithRelations added in v1.3.0

func (sss ServerSnapshots) ToDomainWithRelations() (domain.ServerSnapshotsWithRelations, error)

type Servers

type Servers []Server

func (Servers) ToDomain

func (ss Servers) ToDomain() (domain.Servers, error)

type Tribe

type Tribe struct {
	bun.BaseModel `bun:"table:tribes,alias:tribe"`

	ID             int       `bun:"id,nullzero,pk"`
	ServerKey      string    `bun:"server_key,nullzero,pk"`
	Server         Server    `bun:"server,rel:belongs-to,join:server_key=key"`
	Name           string    `bun:"name,nullzero"`
	Tag            string    `bun:"tag,nullzero"`
	NumMembers     int       `bun:"num_members"`
	NumVillages    int       `bun:"num_villages"`
	Points         int       `bun:"points"`
	AllPoints      int       `bun:"all_points"`
	Rank           int       `bun:"rank"`
	Dominance      float64   `bun:"dominance"`
	ProfileURL     string    `bun:"profile_url,nullzero"`
	BestRank       int       `bun:"best_rank,nullzero,default:999999"`
	BestRankAt     time.Time `bun:"best_rank_at,nullzero,default:CURRENT_TIMESTAMP"`
	MostPoints     int       `bun:"most_points"`
	MostPointsAt   time.Time `bun:"most_points_at,nullzero,default:CURRENT_TIMESTAMP"`
	MostVillages   int       `bun:"most_villages"`
	MostVillagesAt time.Time `bun:"most_villages_at,nullzero,default:CURRENT_TIMESTAMP"`
	CreatedAt      time.Time `bun:"created_at,nullzero,default:CURRENT_TIMESTAMP"`
	DeletedAt      time.Time `bun:"deleted_at,nullzero"`

	OpponentsDefeated
}

func (Tribe) ToDomain

func (t Tribe) ToDomain() (domain.Tribe, error)

func (Tribe) ToDomainWithRelations added in v1.8.0

func (t Tribe) ToDomainWithRelations() (domain.TribeWithRelations, error)

func (Tribe) ToMeta

func (t Tribe) ToMeta() (domain.TribeMeta, error)

type TribeChange

type TribeChange struct {
	bun.BaseModel `bun:"table:tribe_changes,alias:tc"`

	ID         int       `bun:"id,pk,autoincrement,identity"`
	ServerKey  string    `bun:"server_key,nullzero"`
	PlayerID   int       `bun:"player_id,nullzero"`
	Player     Player    `bun:"player,rel:belongs-to,join:player_id=id,join:server_key=server_key"`
	NewTribeID int       `bun:"new_tribe_id,nullzero"`
	NewTribe   Tribe     `bun:"new_tribe,rel:belongs-to,join:new_tribe_id=id,join:server_key=server_key"`
	OldTribeID int       `bun:"old_tribe_id,nullzero"`
	OldTribe   Tribe     `bun:"old_tribe,rel:belongs-to,join:old_tribe_id=id,join:server_key=server_key"`
	CreatedAt  time.Time `bun:"created_at,nullzero"`
}

func (TribeChange) ToDomain

func (tc TribeChange) ToDomain() (domain.TribeChange, error)

func (TribeChange) ToDomainWithRelations

func (tc TribeChange) ToDomainWithRelations() (domain.TribeChangeWithRelations, error)

type TribeChanges

type TribeChanges []TribeChange

func (TribeChanges) ToDomain

func (tcs TribeChanges) ToDomain() (domain.TribeChanges, error)

func (TribeChanges) ToDomainWithRelations

func (tcs TribeChanges) ToDomainWithRelations() (domain.TribeChangesWithRelations, error)

type TribeSnapshot

type TribeSnapshot struct {
	bun.BaseModel `bun:"table:tribe_snapshots,alias:ts"`

	ID          int       `bun:"id,pk,autoincrement,identity"`
	TribeID     int       `bun:"tribe_id,nullzero"`
	ServerKey   string    `bun:"server_key,nullzero"`
	Tribe       Tribe     `bun:"tribe,rel:belongs-to,join:tribe_id=id,join:server_key=server_key"`
	NumMembers  int       `bun:"num_members"`
	NumVillages int       `bun:"num_villages"`
	Points      int       `bun:"points"`
	AllPoints   int       `bun:"all_points"`
	Rank        int       `bun:"rank"`
	Dominance   float64   `bun:"dominance"`
	Date        time.Time `bun:"date,nullzero"`
	CreatedAt   time.Time `bun:"created_at,nullzero"`

	OpponentsDefeated
}

func (TribeSnapshot) ToDomain

func (ts TribeSnapshot) ToDomain() (domain.TribeSnapshot, error)

func (TribeSnapshot) ToDomainWithRelations

func (ts TribeSnapshot) ToDomainWithRelations() (domain.TribeSnapshotWithRelations, error)

type TribeSnapshots

type TribeSnapshots []TribeSnapshot

func (TribeSnapshots) ToDomain

func (tss TribeSnapshots) ToDomain() (domain.TribeSnapshots, error)

func (TribeSnapshots) ToDomainWithRelations

func (tss TribeSnapshots) ToDomainWithRelations() (domain.TribeSnapshotsWithRelations, error)

type Tribes

type Tribes []Tribe

func (Tribes) ToDomain

func (ts Tribes) ToDomain() (domain.Tribes, error)

func (Tribes) ToDomainWithRelations added in v1.8.0

func (ts Tribes) ToDomainWithRelations() (domain.TribesWithRelations, error)

type Unit

type Unit struct {
	Attack         int
	BuildTime      float64
	Carry          int
	Defense        int
	DefenseArcher  int
	DefenseCavalry int
	Pop            int
	Speed          float64
}

type UnitInfo

type UnitInfo struct {
	Spear    Unit
	Sword    Unit
	Axe      Unit
	Archer   Unit
	Spy      Unit
	Light    Unit
	Marcher  Unit
	Heavy    Unit
	Ram      Unit
	Catapult Unit
	Knight   Unit
	Snob     Unit
	Militia  Unit
}

func NewUnitInfo

func NewUnitInfo(info domain.UnitInfo) UnitInfo

func (UnitInfo) ToDomain

func (u UnitInfo) ToDomain() (domain.UnitInfo, error)

type Version

type Version struct {
	bun.BaseModel `bun:"table:versions,alias:version"`

	Code     string `bun:"code,pk"`
	Name     string `bun:"name"`
	Host     string `bun:"host"`
	Timezone string `bun:"timezone"`
}

func (Version) ToDomain

func (v Version) ToDomain() (domain.Version, error)

type Versions

type Versions []Version

func (Versions) ToDomain

func (vs Versions) ToDomain() (domain.Versions, error)

type Village

type Village struct {
	bun.BaseModel `bun:"table:villages,alias:village"`

	ID         int       `bun:"id,nullzero,pk"`
	ServerKey  string    `bun:"server_key,nullzero,pk"`
	Name       string    `bun:"name,nullzero"`
	Points     int       `bun:"points"`
	X          int       `bun:"x"`
	Y          int       `bun:"y"`
	Continent  string    `bun:"continent"`
	Bonus      int       `bun:"bonus"`
	PlayerID   int       `bun:"player_id,nullzero"`
	Player     Player    `bun:"player,rel:belongs-to,join:player_id=id,join:server_key=server_key"`
	ProfileURL string    `bun:"profile_url,nullzero"`
	CreatedAt  time.Time `bun:"created_at,nullzero"`
}

func (Village) ToDomain

func (v Village) ToDomain() (domain.Village, error)

func (Village) ToDomainWithRelations

func (v Village) ToDomainWithRelations() (domain.VillageWithRelations, error)

func (Village) ToMeta

func (v Village) ToMeta() (domain.VillageMeta, error)

type Villages

type Villages []Village

func (Villages) ToDomain

func (vs Villages) ToDomain() (domain.Villages, error)

func (Villages) ToDomainWithRelations

func (vs Villages) ToDomainWithRelations() (domain.VillagesWithRelations, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL