refactor: split domain/tw.go into multiple files
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
79f19b7a23
commit
c7efe7a240
|
@ -0,0 +1,18 @@
|
|||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
type Ennoblement struct {
|
||||
ID int64
|
||||
Village VillageMeta
|
||||
NewOwner NullPlayerMeta
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
func (e Ennoblement) IsBarbarian() bool {
|
||||
return !e.Village.Player.Valid
|
||||
}
|
||||
|
||||
func (e Ennoblement) IsSelfConquer() bool {
|
||||
return e.NewOwner.Player.ID == e.Village.Player.Player.ID
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package domain
|
||||
|
||||
type PlayerMeta struct {
|
||||
ID int64
|
||||
Name string
|
||||
ProfileURL string
|
||||
Tribe NullTribeMeta
|
||||
}
|
||||
|
||||
type NullPlayerMeta struct {
|
||||
Player PlayerMeta
|
||||
Valid bool
|
||||
}
|
|
@ -5,19 +5,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type TWVersion struct {
|
||||
Code string
|
||||
Host string
|
||||
Name string
|
||||
Timezone string
|
||||
}
|
||||
|
||||
type TWServer struct {
|
||||
Key string
|
||||
URL string
|
||||
Open bool
|
||||
}
|
||||
|
||||
type Tribe struct {
|
||||
ID int64
|
||||
Tag string
|
||||
|
@ -38,72 +25,6 @@ type NullTribeMeta struct {
|
|||
Valid bool
|
||||
}
|
||||
|
||||
type PlayerMeta struct {
|
||||
ID int64
|
||||
Name string
|
||||
ProfileURL string
|
||||
Tribe NullTribeMeta
|
||||
}
|
||||
|
||||
type NullPlayerMeta struct {
|
||||
Player PlayerMeta
|
||||
Valid bool
|
||||
}
|
||||
|
||||
type Village struct {
|
||||
ID int64
|
||||
FullName string
|
||||
ProfileURL string
|
||||
Points int64
|
||||
X int64
|
||||
Y int64
|
||||
Player NullPlayerMeta
|
||||
}
|
||||
|
||||
type VillageMeta struct {
|
||||
ID int64
|
||||
FullName string
|
||||
ProfileURL string
|
||||
Player NullPlayerMeta
|
||||
}
|
||||
|
||||
type Ennoblement struct {
|
||||
ID int64
|
||||
Village VillageMeta
|
||||
NewOwner NullPlayerMeta
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
func (e Ennoblement) IsBarbarian() bool {
|
||||
return !e.Village.Player.Valid
|
||||
}
|
||||
|
||||
func (e Ennoblement) IsSelfConquer() bool {
|
||||
return e.NewOwner.Player.ID == e.Village.Player.Player.ID
|
||||
}
|
||||
|
||||
type TWServerNotFoundError struct {
|
||||
VersionCode string
|
||||
Key string
|
||||
}
|
||||
|
||||
var _ TranslatableError = TWServerNotFoundError{}
|
||||
|
||||
func (e TWServerNotFoundError) Error() string {
|
||||
return fmt.Sprintf("server (versionCode=%s,key=%s) not found", e.VersionCode, e.Key)
|
||||
}
|
||||
|
||||
func (e TWServerNotFoundError) Slug() string {
|
||||
return "tw-server-not-found"
|
||||
}
|
||||
|
||||
func (e TWServerNotFoundError) Params() map[string]any {
|
||||
return map[string]any{
|
||||
"VersionCode": e.VersionCode,
|
||||
"Key": e.Key,
|
||||
}
|
||||
}
|
||||
|
||||
type TribeTagNotFoundError struct {
|
||||
VersionCode string
|
||||
ServerKey string
|
|
@ -0,0 +1,31 @@
|
|||
package domain
|
||||
|
||||
import "fmt"
|
||||
|
||||
type TWServer struct {
|
||||
Key string
|
||||
URL string
|
||||
Open bool
|
||||
}
|
||||
|
||||
type TWServerNotFoundError struct {
|
||||
VersionCode string
|
||||
Key string
|
||||
}
|
||||
|
||||
var _ TranslatableError = TWServerNotFoundError{}
|
||||
|
||||
func (e TWServerNotFoundError) Error() string {
|
||||
return fmt.Sprintf("server (versionCode=%s,key=%s) not found", e.VersionCode, e.Key)
|
||||
}
|
||||
|
||||
func (e TWServerNotFoundError) Slug() string {
|
||||
return "tw-server-not-found"
|
||||
}
|
||||
|
||||
func (e TWServerNotFoundError) Params() map[string]any {
|
||||
return map[string]any{
|
||||
"VersionCode": e.VersionCode,
|
||||
"Key": e.Key,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package domain
|
||||
|
||||
type TWVersion struct {
|
||||
Code string
|
||||
Host string
|
||||
Name string
|
||||
Timezone string
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package domain
|
||||
|
||||
type Village struct {
|
||||
ID int64
|
||||
FullName string
|
||||
ProfileURL string
|
||||
Points int64
|
||||
X int64
|
||||
Y int64
|
||||
Player NullPlayerMeta
|
||||
}
|
||||
|
||||
type VillageMeta struct {
|
||||
ID int64
|
||||
FullName string
|
||||
ProfileURL string
|
||||
Player NullPlayerMeta
|
||||
}
|
Loading…
Reference in New Issue