domain

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLocale = "ru"

Variables

View Source
var ErrAlreadyInSquad = errors.New("already in squad")
View Source
var ErrChatAlreadyAttached = errors.New("chat already attached")
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 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 Castle

type Castle string
const (
	CastleRed     Castle = "red"
	CastleYellow  Castle = "yellow"
	CastleGreen   Castle = "green"
	CastleBlue    Castle = "blue"
	CastleUnknown Castle = "unknown"
)

func FlagToCastle

func FlagToCastle(flag string) Castle

type Guild

type Guild struct {
	ID      string `bson:"_id"`
	SquadID string

	Name     string
	Tag      string
	LeaderID int64

	Level int

	CreatedAt int64
	UpdatedAt int64
}

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)

	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, name, tag, leaderPlayerName string, level int) (*Guild, 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)
}

Interfaces

type Item

type Item struct {
	ID   string
	Name string
	Type ItemType
}

Entity

type ItemType

type ItemType string

Constants

const (
	ItemTypeResources   ItemType = "resources"
	ItemTypeEquipment   ItemType = "equipment"
	ItemTypeCraft       ItemType = "craft"
	ItemTypeFood        ItemType = "food"
	ItemTypeConsumables ItemType = "consumables"
	ItemTypeMisc        ItemType = "misc"
)

type ItemTypeRepository

type ItemTypeRepository interface {
	Get(ctx context.Context, id string) (*Item, error)
	GetByName(ctx context.Context, name string) (*Item, error)

	List(ctx context.Context) ([]*Item, error)
	ListByType(ctx context.Context, itemType ItemType) ([]*Item, error)
}

type ItemUsecase

type ItemUsecase interface {
}

Interfaces

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

func (Player) Mention

func (p Player) Mention() string

func (Player) Updated

func (p Player) Updated() bool

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
}

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)

	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 RecipeRepository interface {
	Get(ctx context.Context, itemID string) (*Recipe, error)
	GetByItemID(ctx context.Context, itemID string) (*Recipe, error)

	List(ctx context.Context) ([]*Recipe, error)
}

type RecipeUsecase

type RecipeUsecase interface {
}

Interfaces

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 SquadRepository interface {
	Create(ctx context.Context, squad *Squad) error

	Get(ctx context.Context, id string) (*Squad, error)
	GetByChatID(ctx context.Context, chatID int64) (*Squad, error)

	Update(ctx context.Context, squad *Squad) error

	Delete(ctx context.Context, id string) error
}

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

type StockItemRepository interface {
	Create(ctx context.Context, obj *StockItem) error
}

type StockItemUsecase

type StockItemUsecase interface {
}

Interfaces

type StockType

type StockType string
const (
	StockTypePlayer    StockType = "player"
	StockTypeWarehouse StockType = "warehouse"
	StockTypeGuild     StockType = "guild"
)

Jump to

Keyboard shortcuts

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