Documentation ¶
Index ¶
- Constants
- Variables
- func HasAdminRole(roles []string) bool
- type Account
- type AccountManager
- func (am *AccountManager) Address(ctx context.Context, userID string) (string, error)
- func (am *AccountManager) AssetReserves(ctx context.Context, asaID uint64) (uint64, error)
- func (am *AccountManager) ClearCaches()
- func (am *AccountManager) Close() error
- func (am *AccountManager) FetchArc69Metadata(ctx context.Context, asaID uint64) (Arc69, error)
- func (am *AccountManager) FetchAssetInfo(ctx context.Context, asaID uint64) (models.Asset, error)
- func (am *AccountManager) GetDiscordUserID(ctx context.Context, address string) (string, error)
- func (am *AccountManager) GetPower(legends []uint64) int
- func (am *AccountManager) InitializeCaches(ctx context.Context) error
- func (am *AccountManager) InitializeLegendsCache(ctx context.Context) error
- func (am *AccountManager) InitializeOptInCache(ctx context.Context, asaID uint64) error
- func (am *AccountManager) IsDuplicateUser(ctx context.Context, userID, address string) bool
- func (am *AccountManager) LegendEmojis(asaIDs []uint64) []string
- func (am *AccountManager) LegendHolderDiscordIDs(ctx context.Context, logger *logrus.Logger) []string
- func (am *AccountManager) Legends(ctx context.Context, address string) ([]uint64, error)
- func (am *AccountManager) Register(ctx context.Context, userID, address string) error
- func (am *AccountManager) RewardAmount(ctx context.Context, rewardRate float64) (float64, error)
- func (am *AccountManager) SendLoot(ctx context.Context, asaID uint64, ledger map[string]float64) ([]string, error)
- func (am *AccountManager) TimeSinceLastAttack(address string) time.Duration
- func (am *AccountManager) ValidAsaAccounts(ctx context.Context, asaID uint64) ([]string, error)
- func (am *AccountManager) ValidateAccount(ctx context.Context, userID string) error
- func (am *AccountManager) ValidateGovernance(ctx context.Context, userID string) error
- func (am *AccountManager) ValidateLegends(ctx context.Context, address string) error
- func (am *AccountManager) ValidateOptIn(ctx context.Context, address string, asaID uint64) error
- type AccountStore
- type Arc69
- type Enemy
- type Game
- func (g *Game) AttackEnemy(ctx context.Context, msg Message) error
- func (g *Game) Close()
- func (g *Game) CreateEnemy(ctx context.Context)
- func (g *Game) HandleAccountErr(msg Message, inErr error) error
- func (g *Game) HandleDungeonMsg(ctx context.Context, msg Message) error
- func (g *Game) InitializeAndWait(ctx context.Context, d time.Duration) error
- func (g *Game) Play(ctx context.Context)
- func (g *Game) Register(ctx context.Context, msg Message) error
- func (g *Game) Send(msg string) error
- func (g *Game) SetBonusAssetDetails(ctx context.Context) error
- func (g *Game) SetReward2AssetDetails(ctx context.Context) error
- func (g *Game) StartRound(ctx context.Context)
- func (g *Game) StartRoundCoolDown()
- type GameConfig
- type InMemoryStore
- type Message
- type Properties
- type RedisStore
Constants ¶
const ( Unknown = iota Templar Berserker Shadowblade Purifier Guardian Archon Marauder Siegebreaker Inquisitor Seer Sage Raider Mini Corsair Outlaw Blademaster )
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 )
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 )
const ( RegisterCommand = "!register" AttackCommand = "!attack" )
const (
ValidAddressLength = 58
)
Variables ¶
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") )
var ( Limbo uint32 = 0 PlayerTurn uint32 = 1 )
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: "👼",
}
var (
ErrInvalidCommand = errors.New("game: invalid command")
)
var ErrMetadataNotFound = errors.New("metadata: no metadata found in transaction history")
ErrMetadataNotFound ...
var ErrUserNotRegistered = errors.New("accounts: user not registered")
var MainnetAsaToClass = map[uint64]uint64{}/* 164 elements not displayed */
var MainnetAsaToEmoji = map[uint64]string{}/* 164 elements not displayed */
var TestnetAsaToClass = map[uint64]uint64{ 21849216: Templar, 46001022: Berserker, 73723335: Mini, }
var TestnetAsaToEmoji = map[uint64]string{
21849216: "<:gregor:911337902078840853>",
46001022: "<:hjalmar:911339768187605002>",
73723335: "<:miniaowl:940384267190546442>",
}
Functions ¶
Types ¶
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) AssetReserves ¶
AssetReserves ...
func (*AccountManager) Close ¶
func (am *AccountManager) Close() error
func (*AccountManager) FetchArc69Metadata ¶
FetchArc69Metadata ...
func (*AccountManager) FetchAssetInfo ¶
FetchAssetInfo ...
func (*AccountManager) GetDiscordUserID ¶
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) Register ¶
func (am *AccountManager) Register(ctx context.Context, userID, address string) error
Register ...
func (*AccountManager) RewardAmount ¶
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 ¶
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 ¶
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 ...
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 (*Enemy) DropBonusLedger ¶
DropBonusLedger ...
type Game ¶
type Game struct { GameConfig DungeonInChan chan Message // contains filtered or unexported fields }
Game ...
func (*Game) AttackEnemy ¶
AttackEnemy ...
func (*Game) HandleAccountErr ¶
HandleAccountErr
func (*Game) HandleDungeonMsg ¶
HandleDungeonMsg ...
func (*Game) InitializeAndWait ¶
InitializeAndWait ...
func (*Game) SetBonusAssetDetails ¶
SetBonusAssetDetails ...
func (*Game) SetReward2AssetDetails ¶
SetReward2AssetDetails ...
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 ...
type InMemoryStore ¶
type InMemoryStore struct {
// contains filtered or unexported fields
}
InMemoryStore ...
type Properties ¶
Properties ...
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore ...