Doing Acheivement Dev

This commit is contained in:
Brian Buller 2015-11-09 20:10:37 -06:00
parent 23172a5115
commit 9fa3c1c6c9
4 changed files with 25 additions and 7 deletions

View File

@ -18,6 +18,7 @@ func (p *generalProcessor) GetName() string {
func (p *generalProcessor) GetHelp() string {
return ""
}
func (p *generalProcessor) Initialize() {}
func (p *generalProcessor) ProcessMessage(slack *Slack, m *Message) {}
func (p *generalProcessor) ProcessBotMessage(slack *Slack, m *Message) {}

View File

@ -18,6 +18,7 @@ func (p *levelUpStatProcessor) GetStatKeys() []string {
"levelup-*",
}
}
func (p *levelUpStatProcessor) Initialize() {}
func (p *levelUpStatProcessor) ProcessMessage(m *Message) {}
func (p *levelUpStatProcessor) ProcessAdminMessage(m *Message) {}

View File

@ -16,13 +16,28 @@ func (p *levelUpAchieveStatProcessor) GetStatKeys() []string {
}
}
type levelUpAchievement interface {
GetName() string
GetText() string
func (p *levelUpAcheiveStatProcessor) Initialize() {
// TODO: Set up achievements
p.Achievements = append(p.Achievements, levelUpAchievement{
GetName: func() string {
},
GetText: func() string {
},
DoesUserHave: func(uID string) bool {
},
ProcessMessage: func(m *Message) bool {
},
})
}
type levelUpAchievement struct {
GetName func() string
GetText func() string
// Returns whether the user already has this achievement
DoesUserHave(uID string) bool
DoesUserHave func(uID string) bool
// Processes the message, returns true if the achievement was triggered
ProcessMessage(m *Message) bool
ProcessMessage func(m *Message) bool
}
func (p *levelUpAchieveStatProcessor) ProcessMessage(m *Message) {
@ -42,7 +57,6 @@ func (p *levelUpAchieveStatProcessor) ProcessMessage(m *Message) {
userStat.Xp, _ = getUserStat(u.ID, "levelup-xp")
userStat.ChannelStats = getAllLevelUpChannelXp(u.ID)
userStat.OtherStats = getAllNonLevelUpStats(u.ID)
}
func (p *levelUpAchieveStatProcessor) ProcessAdminMessage(m *Message) {}
func (p *levelUpAchieveStatProcessor) ProcessBotMessage(m *Message) {}
@ -76,7 +90,7 @@ func (wm *levelUpAchieveWebModule) Register() {
}
func (wm *levelUpAchieveWebModule) GetMenuEntries() []menuItem {
var ret []menuItem
ret = append(ret, menuItem{Text: "Achieve GET!", Link: "/levelup/achieve"})
//ret = append(ret, menuItem{Text: "Achieve GET!", Link: "/levelup/achieve"})
return ret
}
func (wm *levelUpAchieveWebModule) GetBottomMenuEntries() []menuItem {

View File

@ -28,6 +28,7 @@ var messageProcessors []messageProcessor
type statProcessor interface {
GetName() string
GetStatKeys() []string
Initialize() []string
ProcessMessage(m *Message)
ProcessBotMessage(m *Message)
ProcessUserMessage(m *Message)
@ -191,6 +192,7 @@ func registerStatProcessor(b statProcessor) {
}
}
}
b.Initialize()
statProcessors = append(statProcessors, b)
}