Add easter egg error message

This commit is contained in:
ekzyis 2024-09-26 01:00:41 +02:00
parent 4d7ab3484d
commit d6ffd8a57d
1 changed files with 10 additions and 0 deletions

10
main.go
View File

@ -1,8 +1,10 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"log" "log"
"math/rand"
"strings" "strings"
"time" "time"
@ -117,6 +119,10 @@ func handleGameStart(req *sn.Item) error {
// create board with initial move(s) // create board with initial move(s)
if b, err = chess.NewGame(move); err != nil { if b, err = chess.NewGame(move); err != nil {
if rand.Float32() > 0.99 {
// easter egg error message
return errors.New("Nice try, fed.")
}
return fmt.Errorf("failed to create new game from item %d: %v\n", req.Id, err) return fmt.Errorf("failed to create new game from item %d: %v\n", req.Id, err)
} }
@ -171,6 +177,10 @@ func handleGameProgress(req *sn.Item) error {
// parse and execute new move // parse and execute new move
if err = b.Parse(move); err != nil { if err = b.Parse(move); err != nil {
if rand.Float32() > 0.99 {
// easter egg error message
return errors.New("Nice try, fed.")
}
return fmt.Errorf("failed to parse move %s: %v\n", move, err) return fmt.Errorf("failed to parse move %s: %v\n", move, err)
} }