add Continent method to Village struct

This commit is contained in:
Dawid Wysokiński 2020-06-07 17:27:20 +02:00
parent deeeccf998
commit fcd5cd5455
1 changed files with 12 additions and 0 deletions

View File

@ -1,5 +1,10 @@
package models
import (
"fmt"
"strconv"
)
type Village struct {
tableName struct{} `pg:"?SERVER.villages,alias:village"`
@ -14,6 +19,13 @@ type Village struct {
Player *Player `json:"player,omitempty" gqlgen:"-"`
}
func (v *Village) Continent() string {
if v == nil {
return ""
}
return fmt.Sprintf("k%c%c", strconv.FormatInt(int64(v.Y), 10)[0], strconv.FormatInt(int64(v.y), 10)[0]))
}
type VillageFilter struct {
tableName struct{} `urlstruct:"village"`