Documentation
¶
Index ¶
- Constants
- Variables
- type Castle
- type Guild
- type GuildRepository
- type GuildUsecase
- type Item
- type ItemType
- type ItemTypeRepository
- type ItemUsecase
- type Player
- type PlayerRepository
- type PlayerSort
- type PlayerUsecase
- type Recipe
- type RecipeRepository
- type RecipeUsecase
- type Squad
- type SquadRepository
- type SquadUsecase
- type StockItem
- type StockItemRepository
- type StockItemUsecase
- type StockType
Constants ¶
View Source
const DefaultLocale = "ru"
Variables ¶
View Source
var ErrAlreadyInGuild = errors.New("already in guild")
View Source
var ErrAlreadyInSquad = errors.New("already in squad")
View Source
var ErrChatAlreadyAttached = errors.New("chat already attached")
View Source
var ErrGuildAlreadyExists = errors.New("guild already exists")
View Source
var ErrGuildNotFound = errors.New("guild not found")
Errors
View Source
var ErrInvalidText = errors.New("invalid text")
View Source
var ErrInvalidUsername = errors.New("invalid username")
View Source
var ErrItemNotFound = errors.New("item not found")
Errors
View Source
var ErrLeaderCannotLeave = errors.New("leader cannot leave squad")
View Source
var ErrNeedProfileUpdate = errors.New("need profile update")
View Source
var ErrNotInSquad = errors.New("not in squad")
View Source
var ErrNotInSquadChat = errors.New("not in squad chat")
View Source
var ErrPlayerNotFound = errors.New("player not found")
Errors
View Source
var ErrRecipeNotFound = errors.New("recipe not found")
Errors
View Source
var ErrSquadNotFound = errors.New("squad not found")
Errors
View Source
var ErrStockItemNotFound = errors.New("stock item not found")
Errors
View Source
var ErrUnsupportedLanguage = errors.New("unsupported language")
View Source
var Locales = []string{"en", "ru"}
View Source
var ProfileUpdateInterval = 48 * time.Hour
View Source
var UsernameRegex = regexp.MustCompile(`^\w{4,32}$`)
Constants
Functions ¶
This section is empty.
Types ¶
type Guild ¶
type Guild struct {
ID string `bson:"_id"`
SquadID string
HQLocation string
Name string
Tag string
LeaderID int64
Level int
CreatedAt time.Time
UpdatedAt time.Time
}
Entity
type GuildRepository ¶
type GuildRepository interface {
Create(ctx context.Context, obj *Guild) error
Get(ctx context.Context, id string) (*Guild, error)
GetByTag(ctx context.Context, tag string) (*Guild, error)
GetByLeader(ctx context.Context, leaderID int64) (*Guild, error)
GetBySquadAndName(ctx context.Context, squadID, name string) (*Guild, error)
ListBySquad(ctx context.Context, squadID string) ([]*Guild, error)
Update(ctx context.Context, obj *Guild) error
Delete(ctx context.Context, id string) error
}
type GuildUsecase ¶
type GuildUsecase interface {
Create(ctx context.Context, scope permissions.Scope, leader int64, name, tag, hqLocation string, level int) (*Guild, error)
DeleteByLeader(ctx context.Context, scope permissions.Scope, leaderID int64, chatID int64) error
DeleteByTag(ctx context.Context, scope permissions.Scope, tag string, chatID int64) error
Get(ctx context.Context, scope permissions.Scope, id string) (*Guild, error)
GetByTag(ctx context.Context, scope permissions.Scope, tag string) (*Guild, error)
GetByLeader(ctx context.Context, scope permissions.Scope, leaderID int64) (*Guild, error)
GetBySquadAndName(ctx context.Context, scope permissions.Scope, squadID, name string) (*Guild, error)
ListBySquad(ctx context.Context, scope permissions.Scope, squadID string) ([]*Guild, error)
Update(ctx context.Context, scope permissions.Scope, name, tag, hqLocation string, level int) (*Guild, error)
ParseGuild(ctx context.Context, scope permissions.Scope, msg string) (*Guild, error)
ParseList(ctx context.Context, scope permissions.Scope, msg string) (*Guild, error)
}
Interfaces
type ItemTypeRepository ¶
type Player ¶
type Player struct {
ID int64 `bson:"_id"`
Username string
PlayerRole permissions.PlayerRole
Locale string
SquadID *string
SquadRole permissions.SquadRole
GuildID *string
GuildRole permissions.SquadRole
FirstSeen time.Time
LastSeen time.Time
// Basic info
Castle Castle
PlayerName string
Level int
CurrentExp int
NextLevelExp int
BasicsUpdatedAt time.Time
// Stats
Rank int
Str int
Dex int
Vit int
DetailedStats map[string]int
StatsUpdatedAt time.Time
// School
Schools map[string]int // SchoolID -> Level
SchoolsUpdatedAt time.Time
// Balance
PlayerBalance int
BankBalance int
BalanceUpdatedAt time.Time
}
Entity
type PlayerRepository ¶
type PlayerRepository interface {
Create(ctx context.Context, obj *Player) error
Get(ctx context.Context, id int64) (*Player, error)
GetByUsername(ctx context.Context, username string) (*Player, error)
ListBySquad(ctx context.Context, squadID string, sort PlayerSort) ([]*Player, error)
ListByGuild(ctx context.Context, guildID string, sort PlayerSort) ([]*Player, error)
CountBySquad(ctx context.Context, squadID string) (int64, error)
CountByGuild(ctx context.Context, guildID string) (int64, error)
Update(ctx context.Context, obj *Player) error
Delete(ctx context.Context, id int64) error
RemoveGuild(ctx context.Context, guildID string) error
}
type PlayerSort ¶
type PlayerSort int
const ( PlayerSortLevel PlayerSort = iota PlayerSortRank PlayerSortBalance )
type PlayerUsecase ¶
type PlayerUsecase interface {
Create(ctx context.Context, scope permissions.Scope, id int64, username string) (*Player, error)
Get(ctx context.Context, scope permissions.Scope, id int64) (*Player, error)
GetByUsername(ctx context.Context, scope permissions.Scope, username string) (*Player, error)
ListBySquad(ctx context.Context, scope permissions.Scope, squadID string, sort PlayerSort) ([]*Player, error)
ListByGuild(ctx context.Context, scope permissions.Scope, guildID string, sort PlayerSort) ([]*Player, error)
ParseMe(ctx context.Context, scope permissions.Scope, me string) (*Player, error)
ParseHero(ctx context.Context, scope permissions.Scope, hero string) (*Player, error)
ParseSchool(ctx context.Context, scope permissions.Scope, school string) (*Player, error)
SquadAdd(ctx context.Context, scope permissions.Scope, id int64) (*Player, error)
SquadRemove(ctx context.Context, scope permissions.Scope, id int64) (*Player, error)
Locale(ctx context.Context, scope permissions.Scope, locale string) (*Player, error)
Seen(ctx context.Context, scope permissions.Scope, username string) (*Player, error)
}
Interfaces
type Recipe ¶
type Recipe struct {
ItemID string
RequiredSchool string
RequiredSchoolLevel int
Mana int
Components map[string]int // ItemID -> Quantity
}
Entity
type RecipeRepository ¶
type Squad ¶
type Squad struct {
ID string `bson:"_id"`
ChatID int64
Name string
Castle Castle
CreatedAt time.Time
UpdatedAt time.Time
}
Entity
type SquadRepository ¶
type SquadUsecase ¶
type SquadUsecase interface {
Create(ctx context.Context, scope permissions.Scope, chatID int64, name string) (*Squad, error)
Get(ctx context.Context, scope permissions.Scope, id string) (*Squad, error)
GetByChatID(ctx context.Context, scope permissions.Scope, chatID int64) (*Squad, error)
ChangeChatID(ctx context.Context, scope permissions.Scope, chatID int64) (*Squad, error)
ChangeName(ctx context.Context, scope permissions.Scope, name string) (*Squad, error)
Delete(ctx context.Context, scope permissions.Scope) error
}
Interfaces
type StockItem ¶
type StockItem struct {
ID string `bson:"_id"`
StockID string // PlayerID or GuildID (Depending on StockType)
StockType StockType
Location string // g_3_3 or nothing
ItemType ItemType
ItemID int
Sharpness int // If w34_1 then 1 goes here
Quantity int
UpdatedAt int64
}
Entity
type StockItemRepository ¶
Click to show internal directories.
Click to hide internal directories.