This repository has been archived on 2024-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
core-old/internal/domain/village.go
Dawid Wysokiński 428333572d
All checks were successful
continuous-integration/drone/push Build is passing
refactor(rest): ennoblement - update model (#162)
Reviewed-on: twhelp/core#162
2023-01-21 14:20:48 +00:00

92 lines
1.6 KiB
Go

package domain
import (
"fmt"
"time"
)
type Village struct {
ID int64
Name string
Points int64
X int64
Y int64
Continent string
Bonus int64
PlayerID int64
ProfileURL string
ServerKey string
CreatedAt time.Time
}
func (v Village) FullName() string {
return fmt.Sprintf("%s (%d|%d) %s", v.Name, v.X, v.Y, v.Continent)
}
type VillageWithRelations struct {
Village
Player NullPlayerMetaWithRelations
}
type VillageMeta struct {
ID int64
Name string
X int64
Y int64
Continent string
ProfileURL string
}
type VillageMetaWithRelations struct {
VillageMeta
Player NullPlayerMetaWithRelations
}
func (v VillageMeta) FullName() string {
return fmt.Sprintf("%s (%d|%d) %s", v.Name, v.X, v.Y, v.Continent)
}
type CreateVillageParams struct {
ID int64
Name string
Points int64
X int64
Y int64
Continent string
Bonus int64
PlayerID int64
ProfileURL string
ServerKey string
}
type ListVillagesParams struct {
IDs []int64
ServerKeys []string
Pagination Pagination
}
type RefreshVillagesResult struct {
NumVillages int64
NumPlayerVillages int64
NumBarbarianVillages int64
NumBonusVillages int64
}
type VillageNotFoundError struct {
ID int64
}
func (e VillageNotFoundError) Error() string {
return fmt.Sprintf("village (id=%d) not found", e.ID)
}
func (e VillageNotFoundError) UserError() string {
return e.Error()
}
func (e VillageNotFoundError) Code() ErrorCode {
return ErrorCodeEntityNotFound
}