events

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PinnedResetMessage      EventsResetMessage
	HintRewardedUsers       = make(map[string][]*structs.UserMinimal)
	Events                  *EventsData
	AssignEventsWithDefault = func(utils types.Utils) {
		Events = NewEventsData(true, utils)
	}
)
View Source
var (
	SetsFunctions = FuncMap{
		"Equal":            equal,
		"Short Equal":      shortEqual,
		"Repeat":           repeat,
		"Mirror":           mirror,
		"Rise":             rise,
		"Short Rise":       shortRise,
		"Short Fall":       shortFall,
		"Rapid Rise":       rapidRise,
		"Short Rapid Rise": shortRapidRise,
		"Short Rapid Fall": shortRapidFall,
		"Double":           double,
		"Short Triple":     shortTriple,
		"Perfect Square":   perfectSquare,
	}
	Sets = SetSlice{
		{"Equal", "aa:aa", "static", false, equal},
		{"Short Equal", "?a:aa", "static", false, shortEqual},
		{"Repeat", "ab:ab", "static", false, repeat},
		{"Mirror", "ab:ba", "static", false, mirror},
		{"Rise", "ab:cd", "static", false, rise},
		{"Short Rise", "?a:bc", "static", false, shortRise},
		{"Short Fall", "?c:ba", "static", false, shortFall},
		{"Rapid Rise", "ac:eg", "static", false, rapidRise},
		{"Short Rapid Rise", "?a:ce", "static", false, shortRapidRise},
		{"shortRapidFall", "?e:ca", "static", false, shortRapidFall},
		{"double", "n:2*n", "static", false, double},
		{"shortTriple", "?n:3*n", "static", false, shortTriple},
		{"Perfect Square", "[unnamed]", "static", false, perfectSquare},
	}
	SetsJson = SetJsonSlice{}

	AssignSetsFromSetsJson = func(utils types.Utils) {
		Sets = SetsJson.ToSlice()
	}
	AssignSetsWithDefault = func(utils types.Utils) {
		Sets = SetSlice{
			{"Equal", "aa:aa", "static", false, equal},
			{"Short Equal", "?a:aa", "static", false, shortEqual},
			{"Repeat", "ab:ab", "static", false, repeat},
			{"Mirror", "ab:ba", "static", false, mirror},
			{"Rise", "ab:cd", "static", false, rise},
			{"Short Rise", "?a:bc", "static", false, shortRise},
			{"Short Fall", "?c:ba", "static", false, shortFall},
			{"Rapid Rise", "ac:eg", "static", false, rapidRise},
			{"Short Rapid Rise", "?a:ce", "static", false, shortRapidRise},
			{"Short Rapid Fall", "?e:ca", "static", false, shortRapidFall},
			{"Double", "n:2*n", "static", false, double},
			{"Short Triple", "?n:3*n", "static", false, shortTriple},
			{"Perfect Square", "[unnamed]", "static", false, perfectSquare},
		}
	}
)

Functions

func CalculateStatus added in v0.2.4

func CalculateStatus(time time.Time) (bool, int)

func CalculateValid added in v0.2.4

func CalculateValid(time time.Time) bool

func RemoveValue added in v0.2.4

func RemoveValue(s []string, value string) []string

func SplitTime added in v0.2.4

func SplitTime(time time.Time) (int, int, int, int)

func UpdatePinnedMessage added in v0.2.5

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

Types

type Event added in v0.2.4

type Event struct {
	Time           time.Time
	Name           string
	Points         int
	Enabled        bool
	Effects        []*structs.Effect
	Activation     *EventActivation
	Partecipations map[int64]*EventPartecipation
}

func EventsOf added in v0.2.5

func EventsOf(setFunc func(int, int, int, int) bool) []*Event

func NewEvent added in v0.2.4

func NewEvent(eventTime time.Time) *Event

func (*Event) Activate added in v0.2.4

func (e *Event) Activate(by *structs.User, at, telegramAt time.Time, points int)

func (*Event) AddEffect added in v0.2.4

func (e *Event) AddEffect(effect *structs.Effect)

func (*Event) HasPartecipated added in v0.2.4

func (e *Event) HasPartecipated(userID int64) bool

func (*Event) Partecipate added in v0.2.4

func (e *Event) Partecipate(by *structs.User, at time.Time)

func (*Event) Reset added in v0.2.4

func (e *Event) Reset()

func (*Event) StringifyEffects added in v0.2.5

func (e *Event) StringifyEffects() string

type EventActivation added in v0.2.4

type EventActivation struct {
	ActivatedBy  *structs.User
	ActivatedAt  time.Time
	ArrivedAt    time.Time
	EarnedPoints int
}

type EventPartecipation added in v0.2.4

type EventPartecipation struct {
	PartecipatedBy *structs.User
	PartecipatedAt time.Time
}

type EventsData added in v0.2.4

type EventsData struct {
	Map   EventsMap
	Keys  EventsKeys
	Stats EventsStats
}

func NewEventsData added in v0.2.4

func NewEventsData(newEffects bool, utils types.Utils) *EventsData

func (*EventsData) AssignRandomEffects added in v0.2.4

func (ed *EventsData) AssignRandomEffects(utils types.Utils, effects ...structs.EffectPresence)

func (*EventsData) EnabledRandomSets added in v0.2.4

func (ed *EventsData) EnabledRandomSets(percentage types.Interval, utils types.Utils) error

func (*EventsData) Reset added in v0.2.4

func (ed *EventsData) Reset(newEffects bool, writeMsgData *types.WriteMessageData, utils types.Utils)

func (*EventsData) SaveOnFile added in v0.2.4

func (ed *EventsData) SaveOnFile(utils types.Utils)

func (*EventsData) WriteResetMessage added in v0.2.4

func (ed *EventsData) WriteResetMessage(writeMsgData *types.WriteMessageData, utils types.Utils)

type EventsKeys added in v0.2.0

type EventsKeys []string

type EventsMap

type EventsMap map[string]*Event

type EventsResetMessage added in v0.2.5

type EventsResetMessage struct {
	Exist     bool
	ChatID    int64
	MessageID int
}

type EventsStats added in v0.2.4

type EventsStats struct {
	TotalSetsNum      int
	EnabledSetsNum    int
	EnabledSets       []string
	TotalEventsNum    int
	EnabledEventsNum  int
	EnabledPointsSum  int
	EnabledEffectsNum int
	EnabledEffects    map[string]int
}

type FuncMap added in v0.2.4

type FuncMap map[string]func(h1, h2, m1, m2 int) bool

type Set added in v0.2.4

type Set struct {
	Name     string
	Pattern  string
	Typology string
	Enabled  bool
	Verify   func(h1, h2, m1, m2 int) bool
}

type SetJson added in v0.2.4

type SetJson struct {
	Name     string
	Pattern  string
	Typology string
	Enabled  bool
}

type SetJsonSlice added in v0.2.4

type SetJsonSlice []*SetJson

func (SetJsonSlice) ToSlice added in v0.2.4

func (sj SetJsonSlice) ToSlice() SetSlice

type SetSlice added in v0.2.4

type SetSlice []*Set

func (SetSlice) ToJsonSlice added in v0.2.4

func (s SetSlice) ToJsonSlice() SetJsonSlice

Jump to

Keyboard shortcuts

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