aegirdungeons

package module
v0.0.0-...-1de85f0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

README

aegir-dungeons

Aegir Dungeons is a discord game run by the community members.

Documentation

Index

Constants

View Source
const (
	Unknown = iota
	Templar
	Berserker
	Shadowblade
	Purifier
	Guardian
	Archon
	Marauder
	Siegebreaker
	Inquisitor
	Seer
	Sage
	Raider
	Mini
	Corsair
	Outlaw
	Blademaster
)
View Source
const (
	AlgoNodeTestnet = "https://testnet-api.algonode.cloud"
	AlgoNodeMainnet = "https://mainnet-api.algonode.cloud"

	AlgoNodeIndexerTestnet = "https://testnet-idx.algonode.cloud"
	AlgoNodeIndexerMainnet = "https://mainnet-idx.algonode.cloud"

	AlgoExplorerTestnet = "https://testnet.algoexplorerapi.io"
	AlgoExplorerMainnet = "https://algoexplorerapi.io"

	NewAlgoExplorerTestnet = "https://node.testnet.algoexplorerapi.io"
	NewAlgoExplorerMainnet = "https://node.algoexplorerapi.io"

	NewAlgoExplorerIndexerTestnet = "https://algoindexer.testnet.algoexplorerapi.io"
	NewAlgoExplorerIndexerMainnet = "https://algoindexer.algoexplorerapi.io"

	IndexerTestnet = "https://testnet.algoexplorerapi.io/idx2"
	IndexerMainnet = "https://algoexplorerapi.io/idx2"

	TestnetDungeonGoldTokenID = 46192450
	MainnetDungeonGoldTokenID = 411521263

	TestnetAegirTokenID = 51294904
	MainnetAegirTokenID = 453816186
)
View Source
const (
	DAGRemoji                = "<:dAGR:930481439605149736>"
	GuildID                  = "883754257612943371"
	AdminRoleID              = "903319921679818782"
	DungeoneerRoleID         = "911491170981527602"
	MythicHolderRoleID       = "982018103149998101"
	GeneralChatMention       = "<#903284194921295893>"
	AdminRoleMention         = "<@&" + AdminRoleID + ">"
	DungeoneerRoleMention    = "<@&" + DungeoneerRoleID + ">"
	MythicHolderRoleMention  = "<@&" + MythicHolderRoleID + ">"
	DecimalAdjustment        = 1000000
	DefaultRoundCooldown     = 10 * time.Second
	DefaultPower             = 10
	DefaultAttackCooldown    = 5 * time.Second
	DefaultMinFee            = 0.001 * 1000000
	DefaultRewardAmount      = 10 * DecimalAdjustment
	DefaultMaxEnemyHealth    = 4000
	DefaultMinEnemyHealth    = 1500
	DefaultRewardRatePerHour = 0.000015
	DefaultMaxRewards        = 5000
	DefaultMaxRewards2       = 100
)
View Source
const (
	RegisterCommand = "!register"
	AttackCommand   = "!attack"
)
View Source
const (
	ValidAddressLength = 58
)

Variables

View Source
var (
	ErrNoUserFound             = errors.New("accounts: no user found")
	ErrNoLegends               = errors.New("accounts: no legends in account")
	ErrNotOptedIn              = errors.New("accounts: account has not opted into rewards")
	ErrInvalidAddress          = errors.New("accounts: invalid address")
	ErrAssetNotFound           = errors.New("accounts: asset not found")
	ErrMultipleRegisteredUsers = errors.New("accounts: multiple users found with same address")
	ErrDiscordUserIDNotFound   = errors.New("accounts: discord user id not found")
)
View Source
var (
	Limbo      uint32 = 0
	PlayerTurn uint32 = 1
)
View Source
var Enemies = map[int]string{
	0:  "👹",
	1:  "👺",
	2:  "👻",
	3:  "💀",
	4:  "👿",
	5:  "😱",
	6:  "🤢",
	7:  "🤖",
	8:  "😾",
	9:  "🤕",
	10: "🤪",
	11: "😘",
	12: "👽",
	13: "🤡",
	14: "🧟",
	15: "🧞",
	16: "🧝",
	17: "🧛",
	18: "🧚",
	19: "🧙",
	20: "👼",
}
View Source
var (
	ErrInvalidCommand = errors.New("game: invalid command")
)
View Source
var ErrMetadataNotFound = errors.New("metadata: no metadata found in transaction history")

ErrMetadataNotFound ...

View Source
var ErrUserNotRegistered = errors.New("accounts: user not registered")
View Source
var MainnetAsaToClass = map[uint64]uint64{}/* 164 elements not displayed */
View Source
var MainnetAsaToEmoji = map[uint64]string{}/* 164 elements not displayed */
View Source
var TestnetAsaToClass = map[uint64]uint64{
	21849216: Templar,
	46001022: Berserker,
	73723335: Mini,
}
View Source
var TestnetAsaToEmoji = map[uint64]string{
	21849216: "<:gregor:911337902078840853>",
	46001022: "<:hjalmar:911339768187605002>",
	73723335: "<:miniaowl:940384267190546442>",
}

Functions

func HasAdminRole

func HasAdminRole(roles []string) bool

HasAdminRole ...

Types

type Account

type Account struct {
	DiscordID string
	Address   string
}

Account ...

type AccountManager

type AccountManager struct {
	LastAttack map[string]time.Time
	AsaToClass map[uint64]uint64
	AsaToEmoji map[uint64]string
	// contains filtered or unexported fields
}

AccountManager ...

func NewAccountManager

func NewAccountManager(cfg GameConfig, asaID uint64) (*AccountManager, error)

NewAccountManager ...

func (*AccountManager) Address

func (am *AccountManager) Address(ctx context.Context, userID string) (string, error)

Address ...

func (*AccountManager) AssetReserves

func (am *AccountManager) AssetReserves(ctx context.Context, asaID uint64) (uint64, error)

AssetReserves ...

func (*AccountManager) ClearCaches

func (am *AccountManager) ClearCaches()

ClearCaches ...

func (*AccountManager) Close

func (am *AccountManager) Close() error

func (*AccountManager) FetchArc69Metadata

func (am *AccountManager) FetchArc69Metadata(ctx context.Context, asaID uint64) (Arc69, error)

FetchArc69Metadata ...

func (*AccountManager) FetchAssetInfo

func (am *AccountManager) FetchAssetInfo(ctx context.Context, asaID uint64) (models.Asset, error)

FetchAssetInfo ...

func (*AccountManager) GetDiscordUserID

func (am *AccountManager) GetDiscordUserID(ctx context.Context, address string) (string, error)

GetDiscordUserID ...

func (*AccountManager) GetPower

func (am *AccountManager) GetPower(legends []uint64) int

GetPower ...

func (*AccountManager) InitializeCaches

func (am *AccountManager) InitializeCaches(ctx context.Context) error

InitializeCaches ...

func (*AccountManager) InitializeLegendsCache

func (am *AccountManager) InitializeLegendsCache(ctx context.Context) error

InitializeLegendsCache ...

func (*AccountManager) InitializeOptInCache

func (am *AccountManager) InitializeOptInCache(ctx context.Context, asaID uint64) error

InitializeOptInCache ...

func (*AccountManager) IsDuplicateUser

func (am *AccountManager) IsDuplicateUser(ctx context.Context, userID, address string) bool

IsDuplicateUser ...

func (*AccountManager) LegendEmojis

func (am *AccountManager) LegendEmojis(asaIDs []uint64) []string

LegendEmojis ...

func (*AccountManager) LegendHolderDiscordIDs

func (am *AccountManager) LegendHolderDiscordIDs(ctx context.Context, logger *logrus.Logger) []string

LegendHolderDiscordIDs ...

func (*AccountManager) Legends

func (am *AccountManager) Legends(ctx context.Context, address string) ([]uint64, error)

Legends ...

func (*AccountManager) Register

func (am *AccountManager) Register(ctx context.Context, userID, address string) error

Register ...

func (*AccountManager) RewardAmount

func (am *AccountManager) RewardAmount(ctx context.Context, rewardRate float64) (float64, error)

RewardAmount ...

func (*AccountManager) SendLoot

func (am *AccountManager) SendLoot(ctx context.Context, asaID uint64, ledger map[string]float64) ([]string, error)

SendLoot ...

func (*AccountManager) TimeSinceLastAttack

func (am *AccountManager) TimeSinceLastAttack(address string) time.Duration

TimeSinceLastAttack ...

func (*AccountManager) ValidAsaAccounts

func (am *AccountManager) ValidAsaAccounts(ctx context.Context, asaID uint64) ([]string, error)

ValidAsaAccounts ...

func (*AccountManager) ValidateAccount

func (am *AccountManager) ValidateAccount(ctx context.Context, userID string) error

ValidateAccount ...

func (*AccountManager) ValidateGovernance

func (am *AccountManager) ValidateGovernance(ctx context.Context, userID string) error

ValidateGovernance ...

func (*AccountManager) ValidateLegends

func (am *AccountManager) ValidateLegends(ctx context.Context, address string) error

ValidateLegends ...

func (*AccountManager) ValidateOptIn

func (am *AccountManager) ValidateOptIn(ctx context.Context, address string, asaID uint64) error

ValidateOptIn ...

type AccountStore

type AccountStore interface {
	Set(ctx context.Context, key string, value string) error
	Get(ctx context.Context, key string) (string, error)
	Close() error
}

AccountStore ...

type Arc69

type Arc69 struct {
	Standard    string     `json:"standard"`
	Description string     `json:"description"`
	ExternalURL string     `json:"external_url"`
	MimeType    string     `json:"mime_type"`
	Properties  Properties `json:"properties"`
}

Arc69 ...

func FetchArc69Metadata

func FetchArc69Metadata(ctx context.Context, ai *indexer.Client, asaID uint64, senderAddr string) (uint64, Arc69, error)

type Enemy

type Enemy struct {
	Name              string
	Health            float64
	RewardAmount      float64
	RewardAmount2     float64
	BonusRewardAmount float64

	BonusLooters map[string]float64
	// contains filtered or unexported fields
}

Enemy ...

func NewEnemy

func NewEnemy(name string, health float64) Enemy

NewEnemy ...

func RandomEnemy

func RandomEnemy(minHP, maxHP int) Enemy

RandomEnermy ...

func (*Enemy) AddLooter2

func (e *Enemy) AddLooter2(address string)

AddLooter2 ...

func (*Enemy) Damage

func (e *Enemy) Damage(address string, amount float64)

Damage ...

func (*Enemy) DropBonusLedger

func (e *Enemy) DropBonusLedger() map[string]float64

DropBonusLedger ...

func (*Enemy) DropLedger

func (e *Enemy) DropLedger() map[string]float64

DropLedger ...

func (*Enemy) DropLedger2

func (e *Enemy) DropLedger2() map[string]float64

DropLedger2...

func (*Enemy) String

func (e *Enemy) String() string

String ...

type Game

type Game struct {
	GameConfig

	DungeonInChan chan Message
	// contains filtered or unexported fields
}

Game ...

func NewGame

func NewGame(logger *logrus.Logger, cfg GameConfig) (*Game, error)

NewGame ...

func (*Game) AttackEnemy

func (g *Game) AttackEnemy(ctx context.Context, msg Message) error

AttackEnemy ...

func (*Game) Close

func (g *Game) Close()

Close ...

func (*Game) CreateEnemy

func (g *Game) CreateEnemy(ctx context.Context)

CreateEnemy ...

func (*Game) HandleAccountErr

func (g *Game) HandleAccountErr(msg Message, inErr error) error

HandleAccountErr

func (*Game) HandleDungeonMsg

func (g *Game) HandleDungeonMsg(ctx context.Context, msg Message) error

HandleDungeonMsg ...

func (*Game) InitializeAndWait

func (g *Game) InitializeAndWait(ctx context.Context, d time.Duration) error

InitializeAndWait ...

func (*Game) Play

func (g *Game) Play(ctx context.Context)

Play ...

func (*Game) Register

func (g *Game) Register(ctx context.Context, msg Message) error

Register ...

func (*Game) Send

func (g *Game) Send(msg string) error

Send ...

func (*Game) SetBonusAssetDetails

func (g *Game) SetBonusAssetDetails(ctx context.Context) error

SetBonusAssetDetails ...

func (*Game) SetReward2AssetDetails

func (g *Game) SetReward2AssetDetails(ctx context.Context) error

SetReward2AssetDetails ...

func (*Game) StartRound

func (g *Game) StartRound(ctx context.Context)

StartRound ...

func (*Game) StartRoundCoolDown

func (g *Game) StartRoundCoolDown()

StartRoundCoolDown ...

type GameConfig

type GameConfig struct {
	Port                    string
	BankPublic              string
	BankMnemonic            string
	DiscordToken            string
	DungeonDiscordChannelID string
	RedisAddress            string
	MainnetEnabled          bool
	RoundCoolDown           time.Duration
	AttackCoolDown          time.Duration
	MinEnemyHealth          int
	MaxEnemyHealth          int

	RewardAmount float64
	RewardRate   float64

	RewardAssetID2 uint64
	RewardRate2    float64

	BonusTokenID uint64
	BonusRewards float64
}

GameConfig ...

func NewGameConfig

func NewGameConfig() (GameConfig, error)

NewGameConfig

type InMemoryStore

type InMemoryStore struct {
	// contains filtered or unexported fields
}

InMemoryStore ...

func NewInMemoryStore

func NewInMemoryStore() *InMemoryStore

NewInMemoryStore ...

func (*InMemoryStore) Close

func (ims *InMemoryStore) Close() error

Close ...

func (*InMemoryStore) Get

func (ims *InMemoryStore) Get(_ context.Context, key string) (string, error)

Get ...

func (*InMemoryStore) Set

func (ims *InMemoryStore) Set(_ context.Context, key string, value string) error

Set ...

type Message

type Message struct {
	DiscordUser *discordgo.User
	Content     string
	Roles       []string
}

Message ...

type Properties

type Properties struct {
	Level  string `json:"Level"`
	Rarity string `json:"Rarity"`
}

Properties ...

type RedisStore

type RedisStore struct {
	// contains filtered or unexported fields
}

RedisStore ...

func NewRedisStore

func NewRedisStore(url string) (*RedisStore, error)

NewRedisStore ...

func (*RedisStore) Close

func (r *RedisStore) Close() error

Close ...

func (*RedisStore) Get

func (r *RedisStore) Get(ctx context.Context, key string) (string, error)

Get ...

func (*RedisStore) Set

func (r *RedisStore) Set(ctx context.Context, key string, value string) error

Set ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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