Skip to content

Commit

Permalink
fix calculation of active bloodmoonday
Browse files Browse the repository at this point in the history
  • Loading branch information
tlanfer committed Oct 16, 2020
1 parent 0e50219 commit a36bde6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ func (bot Bot) Start() {
func BloodMoonMessage(days, hours, minutes, bloodMoonFrequency, offset int) string {
msg := fmt.Sprintf("The next bloodmoon will be on day %v.",(((days-offset)/bloodMoonFrequency)+1)*bloodMoonFrequency+offset)

if (days % 7) == 0 {
if ((days-offset) % bloodMoonFrequency) == 0 {
msg = "The next bloodmoon will be today."

if hours >= 22 {
msg = "A bloodmoon is active!"
}
}

if (days % 7) == 1 {
if ((days-offset) % bloodMoonFrequency) == 1 {
if hours < 4 {
msg = "A bloodmoon is active!"
}
Expand Down
10 changes: 10 additions & 0 deletions bot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ func TestBloodMoonMessage(t *testing.T) {
},
"A bloodmoon is active!",
},
{
args{
616,
22,
16,
14,
595,
},
"The next bloodmoon will be on day 623.",
},
}
for _, tt := range tests {
t.Run(fmt.Sprintf("%+v", tt.args), func(t *testing.T) {
Expand Down

0 comments on commit a36bde6

Please sign in to comment.