structs

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Multiplier
	QuintupleNegativePoints = &Effect{"Mul -5", "Event", "*", -5}
	QuadrupleNegativePoints = &Effect{"Mul -4", "Event", "*", -4}
	TripleNegativePoints    = &Effect{"Mul -3", "Event", "*", -3}
	DoubleNegativePoints    = &Effect{"Mul -2", "Event", "*", -2}
	SingleNegativePoints    = &Effect{"Mul -1", "Event", "*", -1}
	DoublePositivePoints    = &Effect{"Mul +2", "Event", "*", 2}
	TriplePositivePoints    = &Effect{"Mul +3", "Event", "*", 3}
	QuadruplePositivePoints = &Effect{"Mul +4", "Event", "*", 4}
	QuintuplePositivePoints = &Effect{"Mul +5", "Event", "*", 5}
	SixtuplePositivePoints  = &Effect{"Mul +6", "Event", "*", 6}

	// Additive
	SubFourPoints  = &Effect{"Sub 4", "Event", "-", 4}
	SubThreePoints = &Effect{"Sub 3", "Event", "-", 3}
	SubTwoPoints   = &Effect{"Sub 2", "Event", "-", 2}
	SubOnePoint    = &Effect{"Sub 1", "Event", "-", 1}
	AddOnePoint    = &Effect{"Add 1", "Event", "+", 1}
	AddTwoPoints   = &Effect{"Add 2", "Event", "+", 2}
	AddThreePoints = &Effect{"Add 3", "Event", "+", 3}
	AddFourPoints  = &Effect{"Add 4", "Event", "+", 4}
	AddFivePoints  = &Effect{"Add 5", "Event", "+", 5}

	// Special Effects
	ComebackBonus1         = &Effect{"Comeback 1", "User", "+", 1}
	ComebackBonus2         = &Effect{"Comeback 2", "User", "+", 2}
	ComebackBonus3         = &Effect{"Comeback 3", "User", "+", 3}
	ComebackBonus4         = &Effect{"Comeback 4", "User", "+", 4}
	ComebackBonus5         = &Effect{"Comeback 5", "User", "+", 5}
	LastChanceBonus        = &Effect{"Last Chance 1", "User", "+", 2}
	LastChanceBonus2       = &Effect{"Last Chance 2", "User", "+", 5}
	ReigningLeader         = &Effect{"Reigning Leader", "User", "+", 1}
	NoNegative             = &Effect{"No Negative", "User", "+", 0}
	ConsistentParticipant1 = &Effect{"Consistent Participant 1", "User", "+", 3}
	ConsistentParticipant2 = &Effect{"Consistent Participant 2", "User", "+", 5}

	// Map of all the effects
	Effects = map[string]*Effect{
		"Mul -5":                   QuintupleNegativePoints,
		"Mul -3":                   TripleNegativePoints,
		"Mul -2":                   DoubleNegativePoints,
		"Mul -1":                   SingleNegativePoints,
		"Mul +2":                   DoublePositivePoints,
		"Mul +3":                   TriplePositivePoints,
		"Mul +5":                   QuintuplePositivePoints,
		"Mul +6":                   SixtuplePositivePoints,
		"Sub 4":                    SubFourPoints,
		"Sub 3":                    SubThreePoints,
		"Sub 2":                    SubTwoPoints,
		"Sub 1":                    SubOnePoint,
		"Add 1":                    AddOnePoint,
		"Add 2":                    AddTwoPoints,
		"Add 3":                    AddThreePoints,
		"Add 4":                    AddFourPoints,
		"Add 5":                    AddFivePoints,
		"Comeback 1":               ComebackBonus1,
		"Comeback 2":               ComebackBonus2,
		"Comeback 3":               ComebackBonus3,
		"Comeback 4":               ComebackBonus4,
		"Comeback 5":               ComebackBonus5,
		"Last Chance":              LastChanceBonus,
		"Last Chance 2":            LastChanceBonus2,
		"Reigning Leader":          ReigningLeader,
		"No Negative":              NoNegative,
		"Consistent Participant 1": ConsistentParticipant1,
		"Consistent Participant 2": ConsistentParticipant2,
	}
)

Functions

func UpdatePinnedChampionshipMessage added in v0.4.1

func UpdatePinnedChampionshipMessage(writeMsgData *types.WriteMessageData, utils types.Utils, msgToPin tgbotapi.Message)

func WriteChampionshipResetMessage added in v0.4.1

func WriteChampionshipResetMessage(curChamp, prevChamp *Championship, writeMsgData *types.WriteMessageData, utils types.Utils)

Types

type Championship added in v0.4.1

type Championship struct {
	Name         string
	StartDate    time.Time
	Duration     time.Duration
	Status       string
	FinalRanking []Rank
}

func CreateChampionship added in v0.4.1

func CreateChampionship(name string, startDate time.Time, duration time.Duration) *Championship

func NewChampionship added in v0.4.1

func NewChampionship(name string, startDate time.Time, duration time.Duration, status string, finalRanking []Rank) *Championship

func NewEndedChampionship added in v0.4.1

func NewEndedChampionship(name string, startDate time.Time, duration time.Duration, finalRanking []Rank) *Championship

func ReadFromFile added in v0.4.1

func ReadFromFile(utils types.Utils) *Championship

func (*Championship) End added in v0.4.1

func (c *Championship) End(finalRanking []Rank)

func (*Championship) Reset added in v0.4.1

func (c *Championship) Reset(ranking []Rank, writeMsgData *types.WriteMessageData, utils types.Utils)

func (*Championship) SaveOnFile added in v0.4.1

func (c *Championship) SaveOnFile(utils types.Utils)

type ChampionshipResetPinnedMessage added in v0.4.1

type ChampionshipResetPinnedMessage struct {
	Exist     bool
	ChatID    int64
	MessageID int
}
var (
	PinnedChampionshipResetMessage ChampionshipResetPinnedMessage
)

type Effect added in v0.2.0

type Effect struct {
	Name  string
	Scope string
	Key   string
	Value int
}

type EffectPresence added in v0.2.4

type EffectPresence struct {
	Effect   *Effect
	Possible float64
	Amount   types.Interval
}

type Rank added in v0.4.1

type Rank struct {
	UserTelegramID int64
	Username       string
	Points         int
	Partecipations int
}

Rank is the type used for manage the leaderboard

func GetRanking added in v0.4.1

func GetRanking(Users map[int64]*User, scope RankScope, excludeNonParticipants bool) []Rank

type RankScope added in v0.4.1

type RankScope string

RankScope is the type used for define the ranking scope (daily, championship, total) during the /ranking command execution

const (
	RankScopeDay          RankScope = "day"
	RankScopeChampionship RankScope = "championship"
	RankScopeTotal        RankScope = "total"

	// DefaultRankScope is the default ranking scope used when no scope is provided
	DefaultRankScope = RankScopeChampionship
)

type User

type User struct {
	TelegramUser                    *tgbotapi.User
	TelegramID                      int64
	UserName                        string
	TotalPoints                     int
	TotalEventPartecipations        int
	TotalEventWins                  int
	DailyPoints                     int
	DailyEventPartecipations        int
	DailyEventWins                  int
	ChampionshipPoints              int
	ChampionshipEventPartecipations int
	ChampionshipEventWins           int
	TotalChampionshipPartecipations int
	TotalChampionshipWins           int
	DailyPartecipationStreak        int
	DailyActivityStreak             int
	Effects                         []*Effect
	FirstParticipation              time.Time
}

func NewUser

func NewUser(telegramUser *tgbotapi.User) *User

func (*User) AddEffect added in v0.2.5

func (u *User) AddEffect(effectToAdd *Effect)

func (*User) Minimize added in v0.2.5

func (u *User) Minimize() *UserMinimal

func (*User) RemoveEffect added in v0.2.5

func (u *User) RemoveEffect(effectToRemove *Effect)

func (*User) StringifyEffects added in v0.2.4

func (u *User) StringifyEffects(brackets bool) string

type UserMinimal added in v0.2.5

type UserMinimal struct {
	TelegramID int64
	UserName   string
}

Jump to

Keyboard shortcuts

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