Documentation ¶
Index ¶
- Constants
- Variables
- func GetRuleTextsForGame(g database.Turn) []string
- type FibonacciRule
- func (fr FibonacciRule) Description() string
- func (fr FibonacciRule) Id() int
- func (fr FibonacciRule) Name() string
- func (fr FibonacciRule) OnNewGame(db *gorm.DB, s *discordgo.Session, ng database.Turn, channelID string)
- func (fr FibonacciRule) Type() string
- func (fr FibonacciRule) Validate(db *gorm.DB, lastTurn database.Turn, msg discordgo.Message, guess int) bool
- func (fr FibonacciRule) Weight() int
- type GuessNormallyRule
- func (gnr GuessNormallyRule) Description() string
- func (gnr GuessNormallyRule) Id() int
- func (gnr GuessNormallyRule) Name() string
- func (gnr GuessNormallyRule) OnNewGame(_ *gorm.DB, _ *discordgo.Session, _ database.Turn, _ string)
- func (gnr GuessNormallyRule) PreValidate(db *gorm.DB, dg *discordgo.Session, msg discordgo.Message) (int, error)
- func (gnr GuessNormallyRule) Type() string
- func (gnr GuessNormallyRule) Weight() int
- type IncrementRule
- func (ir IncrementRule) Description() string
- func (ir IncrementRule) Id() int
- func (ir IncrementRule) Name() string
- func (ir IncrementRule) OnNewGame(_ *gorm.DB, _ *discordgo.Session, _ database.Turn, _ string)
- func (ir IncrementRule) Type() string
- func (ir IncrementRule) Validate(db *gorm.DB, lastTurn database.Turn, msg discordgo.Message, guess int) bool
- func (ir IncrementRule) Weight() int
- type JeopardyRule
- func (jr JeopardyRule) Description() string
- func (jr JeopardyRule) Id() int
- func (jr JeopardyRule) Name() string
- func (jr JeopardyRule) OnNewGame(_ *gorm.DB, _ *discordgo.Session, _ database.Turn, _ string)
- func (jr JeopardyRule) PreValidate(db *gorm.DB, dg *discordgo.Session, msg discordgo.Message) (int, error)
- func (jr JeopardyRule) Type() string
- func (jr JeopardyRule) Weight() int
- type NoValidateRule
- func (nvr NoValidateRule) Description() string
- func (nvr NoValidateRule) Id() int
- func (nvr NoValidateRule) Name() string
- func (nvr NoValidateRule) OnNewGame(_ *gorm.DB, _ *discordgo.Session, _ database.Turn, _ string)
- func (nvr NoValidateRule) Type() string
- func (nvr NoValidateRule) Validate(_ *gorm.DB, lastTurn database.Turn, _ discordgo.Message, _ int) bool
- func (nvr NoValidateRule) Weight() int
- type PreValidateRule
- type RomanNumeralRule
- func (rnr RomanNumeralRule) Description() string
- func (rnr RomanNumeralRule) Id() int
- func (rnr RomanNumeralRule) Name() string
- func (rnr RomanNumeralRule) OnNewGame(_ *gorm.DB, _ *discordgo.Session, _ database.Turn, _ string)
- func (rnr RomanNumeralRule) PreValidate(db *gorm.DB, dg *discordgo.Session, msg discordgo.Message) (int, error)
- func (rnr RomanNumeralRule) Type() string
- func (rnr RomanNumeralRule) Weight() int
- type Rule
- type RulesForTurn
- type TakeTurnsRule
- func (ttr TakeTurnsRule) Description() string
- func (ttr TakeTurnsRule) Id() int
- func (ttr TakeTurnsRule) Name() string
- func (ttr TakeTurnsRule) OnNewGame(_ *gorm.DB, _ *discordgo.Session, _ database.Turn, _ string)
- func (ttr TakeTurnsRule) Type() string
- func (ttr TakeTurnsRule) Validate(db *gorm.DB, lastTurn database.Turn, msg discordgo.Message, guess int) bool
- func (ttr TakeTurnsRule) Weight() int
- type ValidateRule
Constants ¶
View Source
const ( IncrementRule1Id = 1 << iota IncrementRule2Id = 1 << iota IncrementRule3Id = 1 << iota IncrementRule7Id = 1 << iota TakeTurnsRuleId = 1 << iota GuessNormallyRuleId = 1 << iota NoValidateRuleId = 1 << iota FibonacciRuleId = 1 << iota RomanNumeralRuleId = 1 << iota JeopardyRuleId = 1 << iota )
View Source
const ( PreValidateType = "PreValidate" CountType = "Count" ValidateType = "Validate" )
Variables ¶
View Source
var ( IncrementOne = createIncrementRule(1, IncrementRule1Id, 30) IncrementTwo = createIncrementRule(2, IncrementRule2Id, 30) IncrementThree = createIncrementRule(3, IncrementRule3Id, 20) IncrementSeven = createIncrementRule(7, IncrementRule7Id, 20) )
View Source
var ( AllRules = []Rule{} PreValidateRules = []Rule{} CountRules = []Rule{} ValidateRules = []Rule{} )
View Source
var ( Fibonacci = (func() ValidateRule { fr := FibonacciRule{ id: FibonacciRuleId, weight: 20, ruleType: CountType, } registerRule(fr) return fr })() )
View Source
var ( GuessNormally = (func() Rule { gnr := GuessNormallyRule{ id: GuessNormallyRuleId, weight: 100, ruleType: PreValidateType, } registerRule(gnr) return gnr })() )
View Source
var ( Jeopardy = (func() Rule { jr := JeopardyRule{ id: JeopardyRuleId, weight: 10, ruleType: PreValidateType, } registerRule(jr) return jr })() )
View Source
var ( NoValidate = (func() ValidateRule { nvr := NoValidateRule{ id: NoValidateRuleId, weight: 30, ruleType: ValidateType, } registerRule(nvr) return nvr })() )
View Source
var ( RomanNumeral = (func() Rule { rnr := RomanNumeralRule{ id: RomanNumeralRuleId, weight: 15, ruleType: PreValidateType, } registerRule(rnr) return rnr })() )
View Source
var ( TakeTurns = (func() Rule { ttr := TakeTurnsRule{ id: TakeTurnsRuleId, weight: 100, ruleType: ValidateType, } registerRule(ttr) return ttr })() )
Functions ¶
func GetRuleTextsForGame ¶
Types ¶
type FibonacciRule ¶
type FibonacciRule struct {
// contains filtered or unexported fields
}
func (FibonacciRule) Description ¶
func (fr FibonacciRule) Description() string
func (FibonacciRule) Id ¶
func (fr FibonacciRule) Id() int
func (FibonacciRule) Name ¶
func (fr FibonacciRule) Name() string
func (FibonacciRule) Type ¶
func (fr FibonacciRule) Type() string
func (FibonacciRule) Weight ¶
func (fr FibonacciRule) Weight() int
type GuessNormallyRule ¶
type GuessNormallyRule struct {
// contains filtered or unexported fields
}
func (GuessNormallyRule) Description ¶
func (gnr GuessNormallyRule) Description() string
func (GuessNormallyRule) Id ¶
func (gnr GuessNormallyRule) Id() int
func (GuessNormallyRule) Name ¶
func (gnr GuessNormallyRule) Name() string
func (GuessNormallyRule) PreValidate ¶
func (GuessNormallyRule) Type ¶
func (gnr GuessNormallyRule) Type() string
func (GuessNormallyRule) Weight ¶
func (gnr GuessNormallyRule) Weight() int
type IncrementRule ¶
type IncrementRule struct {
// contains filtered or unexported fields
}
func (IncrementRule) Description ¶
func (ir IncrementRule) Description() string
func (IncrementRule) Id ¶
func (ir IncrementRule) Id() int
func (IncrementRule) Name ¶
func (ir IncrementRule) Name() string
func (IncrementRule) Type ¶
func (ir IncrementRule) Type() string
func (IncrementRule) Weight ¶
func (ir IncrementRule) Weight() int
type JeopardyRule ¶
type JeopardyRule struct {
// contains filtered or unexported fields
}
func (JeopardyRule) Description ¶
func (jr JeopardyRule) Description() string
func (JeopardyRule) Id ¶
func (jr JeopardyRule) Id() int
func (JeopardyRule) Name ¶
func (jr JeopardyRule) Name() string
func (JeopardyRule) PreValidate ¶
func (JeopardyRule) Type ¶
func (jr JeopardyRule) Type() string
func (JeopardyRule) Weight ¶
func (jr JeopardyRule) Weight() int
type NoValidateRule ¶
type NoValidateRule struct {
// contains filtered or unexported fields
}
func (NoValidateRule) Description ¶
func (nvr NoValidateRule) Description() string
func (NoValidateRule) Id ¶
func (nvr NoValidateRule) Id() int
func (NoValidateRule) Name ¶
func (nvr NoValidateRule) Name() string
func (NoValidateRule) Type ¶
func (nvr NoValidateRule) Type() string
func (NoValidateRule) Weight ¶
func (nvr NoValidateRule) Weight() int
type PreValidateRule ¶
type PreValidateRule interface { Rule // PreValidate returns the guess as an int and an error if the guess is invalid PreValidate(db *gorm.DB, dg *discordgo.Session, msg discordgo.Message) (int, error) }
The purpose of a prevalidate rule is to take the message and extract the guess from it, and return the guess as an int
func GetRandomPreValidateRule ¶
func GetRandomPreValidateRule() PreValidateRule
type RomanNumeralRule ¶
type RomanNumeralRule struct {
// contains filtered or unexported fields
}
func (RomanNumeralRule) Description ¶
func (rnr RomanNumeralRule) Description() string
func (RomanNumeralRule) Id ¶
func (rnr RomanNumeralRule) Id() int
func (RomanNumeralRule) Name ¶
func (rnr RomanNumeralRule) Name() string
func (RomanNumeralRule) PreValidate ¶
func (RomanNumeralRule) Type ¶
func (rnr RomanNumeralRule) Type() string
func (RomanNumeralRule) Weight ¶
func (rnr RomanNumeralRule) Weight() int
type Rule ¶
type Rule interface { Id() int Name() string Weight() int Description() string Type() string // OnNewGame is called once when a new game is started OnNewGame(db *gorm.DB, dg *discordgo.Session, ng database.Turn, channelID string) }
func GetAllRulesForTurn ¶
type RulesForTurn ¶
type RulesForTurn struct { PreValidateRules []PreValidateRule ValidateRules []ValidateRule }
func GetRulesForTurn ¶
func GetRulesForTurn(g database.Turn) RulesForTurn
type TakeTurnsRule ¶
type TakeTurnsRule struct {
// contains filtered or unexported fields
}
func (TakeTurnsRule) Description ¶
func (ttr TakeTurnsRule) Description() string
func (TakeTurnsRule) Id ¶
func (ttr TakeTurnsRule) Id() int
func (TakeTurnsRule) Name ¶
func (ttr TakeTurnsRule) Name() string
func (TakeTurnsRule) Type ¶
func (ttr TakeTurnsRule) Type() string
func (TakeTurnsRule) Weight ¶
func (ttr TakeTurnsRule) Weight() int
type ValidateRule ¶
type ValidateRule interface { Rule // Validate returns true if the guess is correct Validate(db *gorm.DB, lt database.Turn, msg discordgo.Message, guess int) bool }
The purpose of a validate rule is to take the guess and validate that it meets the rule criteria, returning a bool
func GetRandomCountRule ¶
func GetRandomCountRule() ValidateRule
func GetRandomValidateRule ¶
func GetRandomValidateRule() ValidateRule
Click to show internal directories.
Click to hide internal directories.