Cleaning up
This commit is contained in:
87
main.go
87
main.go
@ -23,6 +23,7 @@ var (
|
|||||||
ghostWritingEmoji = "📖"
|
ghostWritingEmoji = "📖"
|
||||||
emf5Emoji = "🚥"
|
emf5Emoji = "🚥"
|
||||||
ghostOrbsEmoji = "⚪"
|
ghostOrbsEmoji = "⚪"
|
||||||
|
deleteEmoji = "❌"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -61,10 +62,17 @@ func ready(s *discordgo.Session, event *discordgo.Ready) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readReactions(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
|
func readReactions(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
|
||||||
if _, ok := games[m.ChannelID]; !ok {
|
if m.UserID == s.State.User.ID {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if m.UserID == s.State.User.ID {
|
if m.Emoji.Name == deleteEmoji {
|
||||||
|
msg, _ := s.ChannelMessage(m.ChannelID, m.MessageID)
|
||||||
|
if msg.Author.ID == s.State.User.ID {
|
||||||
|
s.ChannelMessageDelete(m.ChannelID, m.MessageID)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if _, ok := games[m.ChannelID]; !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("Checking reaction from ", m.UserID)
|
fmt.Println("Checking reaction from ", m.UserID)
|
||||||
@ -109,7 +117,9 @@ func readReactions(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
|
|||||||
}
|
}
|
||||||
if len(g.Evidence) == 3 {
|
if len(g.Evidence) == 3 {
|
||||||
s.GuildMemberNickname(m.GuildID, "@me", "")
|
s.GuildMemberNickname(m.GuildID, "@me", "")
|
||||||
s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v was a %+v", g.Ghost.GhostName, g.PossibleGhosts[0].GhostType))
|
msg, _ := s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v was a %+v", g.Ghost.GhostName, g.PossibleGhosts[0].GhostType))
|
||||||
|
s.MessageReactionAdd(m.ChannelID, g.PostID, deleteEmoji)
|
||||||
|
s.MessageReactionAdd(m.ChannelID, msg.ID, deleteEmoji)
|
||||||
}
|
}
|
||||||
|
|
||||||
games[m.ChannelID] = g
|
games[m.ChannelID] = g
|
||||||
@ -128,18 +138,19 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
}
|
}
|
||||||
g := games[m.ChannelID]
|
g := games[m.ChannelID]
|
||||||
parts := strings.Split(m.Content, " ")
|
parts := strings.Split(m.Content, " ")
|
||||||
if strings.HasPrefix(m.Content, "!map") {
|
|
||||||
g.MapName = parts[1]
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(m.Content, "!name") {
|
if strings.HasPrefix(m.Content, "!name") {
|
||||||
g.Ghost.GhostName = strings.Join(parts[1:], " ")
|
g.Ghost.GhostName = strings.Join(parts[1:], " ")
|
||||||
s.GuildMemberNickname(m.GuildID, "@me", g.Ghost.GhostName)
|
s.GuildMemberNickname(m.GuildID, "@me", g.Ghost.GhostName)
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(m.Content, "!difficulty") {
|
|
||||||
g.Difficulty = parts[1]
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(m.Content, "!room") {
|
if strings.HasPrefix(m.Content, "!room") {
|
||||||
g.RoomID = parts[1]
|
if len(parts) == 2 {
|
||||||
|
g.RoomID = parts[1]
|
||||||
|
} else {
|
||||||
|
if g.RoomID != "" {
|
||||||
|
msg, _ := s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("The room code is `%+v`", g.RoomID))
|
||||||
|
s.MessageReactionAdd(m.ChannelID, msg.ID, deleteEmoji)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(m.Content, "!o") {
|
if strings.HasPrefix(m.Content, "!o") {
|
||||||
if strings.Contains(m.Content, "emf") {
|
if strings.Contains(m.Content, "emf") {
|
||||||
@ -179,7 +190,45 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
g.Objective = append(g.Objective, NoDeaths)
|
g.Objective = append(g.Objective, NoDeaths)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(g.Objective) == 3 {
|
if strings.HasPrefix(m.Content, "!c") {
|
||||||
|
if strings.Contains(m.Content, "emf") {
|
||||||
|
g.CompleteObjective(EMF)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "photo") {
|
||||||
|
g.CompleteObjective(Photo)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "event") {
|
||||||
|
g.CompleteObjective(Event)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "crucifix") {
|
||||||
|
g.CompleteObjective(Crucifix)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "motion") {
|
||||||
|
g.CompleteObjective(Motion)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "clean") {
|
||||||
|
g.CompleteObjective(SmudgeCleanse)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "hunt") {
|
||||||
|
g.CompleteObjective(SmudgeHunt)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "salt") {
|
||||||
|
g.CompleteObjective(Salt)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "candle") {
|
||||||
|
g.CompleteObjective(Candle)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "sanity") {
|
||||||
|
g.CompleteObjective(LowSanity)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "escape") {
|
||||||
|
g.CompleteObjective(MemberEscape)
|
||||||
|
}
|
||||||
|
if strings.Contains(m.Content, "death") {
|
||||||
|
g.CompleteObjective(NoDeaths)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(g.Objective) == 3 && g.PostID == "" {
|
||||||
post, _ := s.ChannelMessageSend(m.ChannelID, "The investigation begins! Click below to log evidence.")
|
post, _ := s.ChannelMessageSend(m.ChannelID, "The investigation begins! Click below to log evidence.")
|
||||||
g.PossibleGhosts = append(g.PossibleGhosts, ghostTypes...)
|
g.PossibleGhosts = append(g.PossibleGhosts, ghostTypes...)
|
||||||
g.PostID = post.ID
|
g.PostID = post.ID
|
||||||
@ -193,3 +242,19 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
|
|
||||||
games[m.ChannelID] = g
|
games[m.ChannelID] = g
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Game) CompleteObjective(objective int) {
|
||||||
|
var tasks []int
|
||||||
|
ret := "Current objectives: ```"
|
||||||
|
for _, v := range g.Objective {
|
||||||
|
if v != objective {
|
||||||
|
tasks = append(tasks, v)
|
||||||
|
ret += fmt.Sprintf("%+v\n", objectiveToStr(v))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret += "```"
|
||||||
|
msg, _ := dg.ChannelMessageSend(g.Identifier, ret)
|
||||||
|
dg.MessageReactionAdd(g.Identifier, msg.ID, deleteEmoji)
|
||||||
|
g.Objective = tasks
|
||||||
|
games[g.Identifier] = *g
|
||||||
|
}
|
||||||
|
|||||||
52
types.go
52
types.go
@ -10,6 +10,25 @@ const (
|
|||||||
GhostOrbs // 5
|
GhostOrbs // 5
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func evidenceToStr(tag int) string {
|
||||||
|
switch tag {
|
||||||
|
case 0:
|
||||||
|
return "EMF5"
|
||||||
|
case 1:
|
||||||
|
return "Freezing Temps"
|
||||||
|
case 2:
|
||||||
|
return "Spirit Box"
|
||||||
|
case 3:
|
||||||
|
return "Ghost Writing"
|
||||||
|
case 4:
|
||||||
|
return "Fingerprints"
|
||||||
|
case 5:
|
||||||
|
return "Ghost Orbs"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bonus Objectives
|
// Bonus Objectives
|
||||||
const (
|
const (
|
||||||
Photo = iota
|
Photo = iota
|
||||||
@ -26,15 +45,44 @@ const (
|
|||||||
NoDeaths
|
NoDeaths
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func objectiveToStr(tag int) string {
|
||||||
|
switch tag {
|
||||||
|
case 0:
|
||||||
|
return "Capture a photo of the ghost."
|
||||||
|
case 1:
|
||||||
|
return "Witness a ghost event."
|
||||||
|
case 2:
|
||||||
|
return "Get the ghost to walk through a motion sensor."
|
||||||
|
case 3:
|
||||||
|
return "Stop a hunt with a crucifix."
|
||||||
|
case 4:
|
||||||
|
return "Get an EMF reading."
|
||||||
|
case 5:
|
||||||
|
return "Cleanse the area around the ghost with a Smudge stick."
|
||||||
|
case 6:
|
||||||
|
return "Smudge the ghost during a hunt."
|
||||||
|
case 7:
|
||||||
|
return "Get the ghost to walk through salt."
|
||||||
|
case 8:
|
||||||
|
return "Get the ghost to blow out a candle."
|
||||||
|
case 9:
|
||||||
|
return "Get an average sanity of below 25%."
|
||||||
|
case 10:
|
||||||
|
return "Have a mamber of your team escape a ghost hunt."
|
||||||
|
case 11:
|
||||||
|
return "Complete the investigation with no deaths."
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Game for Phasbot
|
// Game for Phasbot
|
||||||
type Game struct {
|
type Game struct {
|
||||||
Identifier string
|
Identifier string
|
||||||
PostID string
|
PostID string
|
||||||
MapName string
|
|
||||||
Ghost Spookster
|
Ghost Spookster
|
||||||
PossibleGhosts []Spookster
|
PossibleGhosts []Spookster
|
||||||
PossibleEvidence []int
|
PossibleEvidence []int
|
||||||
Difficulty string
|
|
||||||
RoomID string
|
RoomID string
|
||||||
Evidence []int
|
Evidence []int
|
||||||
Objective []int
|
Objective []int
|
||||||
|
|||||||
Reference in New Issue
Block a user