2015-11-06 01:36:09 +00:00
|
|
|
package main
|
|
|
|
|
2015-11-09 21:20:41 +00:00
|
|
|
import "net/http"
|
2015-11-06 01:36:09 +00:00
|
|
|
|
|
|
|
type levelUpAchieveStatProcessor struct {
|
|
|
|
Achievements []levelUpAchievement
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *levelUpAchieveStatProcessor) GetName() string {
|
|
|
|
return "LevelUp Achievements"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *levelUpAchieveStatProcessor) GetStatKeys() []string {
|
|
|
|
return []string{
|
|
|
|
"levelupachievement-*",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type levelUpAchievement interface {
|
|
|
|
GetName() string
|
|
|
|
GetText() string
|
|
|
|
// Returns whether the user already has this achievement
|
|
|
|
DoesUserHave(uID string) bool
|
|
|
|
// Processes the message, returns true if the achievement was triggered
|
|
|
|
ProcessMessage(m *Message) bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *levelUpAchieveStatProcessor) ProcessMessage(m *Message) {
|
|
|
|
type UserLevelUpStats struct {
|
|
|
|
Name string
|
|
|
|
Xp int
|
|
|
|
ChannelStats map[string]int
|
|
|
|
OtherStats map[string]int
|
|
|
|
}
|
|
|
|
var u *User
|
|
|
|
var err error
|
|
|
|
if u, err = getUserInfo(m.User); err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:20:41 +00:00
|
|
|
userStat := UserLevelUpStats{Name: u.Name}
|
|
|
|
userStat.Xp, _ = getUserStat(u.ID, "levelup-xp")
|
|
|
|
userStat.ChannelStats = getAllLevelUpChannelXp(u.ID)
|
|
|
|
userStat.OtherStats = getAllNonLevelUpStats(u.ID)
|
2015-11-06 01:36:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
func (p *levelUpAchieveStatProcessor) ProcessAdminMessage(m *Message) {}
|
|
|
|
func (p *levelUpAchieveStatProcessor) ProcessBotMessage(m *Message) {}
|
|
|
|
|
|
|
|
func (p *levelUpAchieveStatProcessor) ProcessUserMessage(m *Message) {}
|
|
|
|
func (p *levelUpAchieveStatProcessor) ProcessAdminUserMessage(m *Message) {}
|
|
|
|
func (p *levelUpAchieveStatProcessor) ProcessBotUserMessage(m *Message) {}
|
|
|
|
|
|
|
|
func (p *levelUpAchieveStatProcessor) ProcessChannelMessage(m *Message) {
|
|
|
|
}
|
|
|
|
func (p *levelUpAchieveStatProcessor) ProcessAdminChannelMessage(m *Message) {}
|
|
|
|
func (p *levelUpAchieveStatProcessor) ProcessBotChannelMessage(m *Message) {}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Web Site Module
|
|
|
|
*/
|
|
|
|
type levelUpAchieveWebModule struct{}
|
|
|
|
|
|
|
|
func (wm *levelUpAchieveWebModule) GetName() string {
|
|
|
|
return "LevelUp Achievement Web Module"
|
|
|
|
}
|
|
|
|
func (wm *levelUpAchieveWebModule) GetRoutes() map[string]func(http.ResponseWriter, *http.Request) {
|
|
|
|
ret := make(map[string]func(http.ResponseWriter, *http.Request))
|
|
|
|
ret["/levelup/achieve"] = wm.handleLevelUpAchieveGeneral
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
func (wm *levelUpAchieveWebModule) Register() {
|
|
|
|
for k, v := range wm.GetRoutes() {
|
|
|
|
r.HandleFunc(k, v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func (wm *levelUpAchieveWebModule) GetMenuEntries() []menuItem {
|
|
|
|
var ret []menuItem
|
|
|
|
ret = append(ret, menuItem{Text: "Achieve GET!", Link: "/levelup/achieve"})
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
func (wm *levelUpAchieveWebModule) GetBottomMenuEntries() []menuItem {
|
|
|
|
var ret []menuItem
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func (wm *levelUpAchieveWebModule) handleLevelUpAchieveGeneral(w http.ResponseWriter, req *http.Request) {
|
|
|
|
initRequest(w, req)
|
|
|
|
setMenuItemActive("Achieve GET!")
|
|
|
|
}
|