summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-01-03 09:59:33 +0300
committerGrail Finder <wohilas@gmail.com>2026-01-03 09:59:33 +0300
commitaeb2700d14c23c175376e2a5749295cd9a5d72c7 (patch)
treee34a5860da644b2d4747e4091f23805a63ede180 /extra
parent6b875a2782e77afe6595b47d069a217fa2702eb1 (diff)
Refactor: building binary with no extra
Diffstat (limited to 'extra')
-rw-r--r--extra/cluedo.go73
-rw-r--r--extra/cluedo_test.go50
-rw-r--r--extra/stt.go3
-rw-r--r--extra/tts.go3
-rw-r--r--extra/twentyq.go11
-rw-r--r--extra/vad.go1
-rw-r--r--extra/websearch.go13
-rw-r--r--extra/whisper_binary.go3
8 files changed, 9 insertions, 148 deletions
diff --git a/extra/cluedo.go b/extra/cluedo.go
deleted file mode 100644
index 1ef11cc..0000000
--- a/extra/cluedo.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package extra
-
-import (
- "math/rand"
- "strings"
-)
-
-var (
- rooms = []string{"HALL", "LOUNGE", "DINING ROOM", "KITCHEN", "BALLROOM", "CONSERVATORY", "BILLIARD ROOM", "LIBRARY", "STUDY"}
- weapons = []string{"CANDLESTICK", "DAGGER", "LEAD PIPE", "REVOLVER", "ROPE", "SPANNER"}
- people = []string{"Miss Scarlett", "Colonel Mustard", "Mrs. White", "Reverend Green", "Mrs. Peacock", "Professor Plum"}
-)
-
-type MurderTrifecta struct {
- Murderer string
- Weapon string
- Room string
-}
-
-type CluedoRoundInfo struct {
- Answer MurderTrifecta
- PlayersCards map[string][]string
-}
-
-func (c *CluedoRoundInfo) GetPlayerCards(player string) string {
- // maybe format it a little
- return "cards of " + player + "are " + strings.Join(c.PlayersCards[player], ",")
-}
-
-func CluedoPrepCards(playerOrder []string) *CluedoRoundInfo {
- res := &CluedoRoundInfo{}
- // Select murder components
- trifecta := MurderTrifecta{
- Murderer: people[rand.Intn(len(people))],
- Weapon: weapons[rand.Intn(len(weapons))],
- Room: rooms[rand.Intn(len(rooms))],
- }
- // Collect non-murder cards
- var notInvolved []string
- for _, room := range rooms {
- if room != trifecta.Room {
- notInvolved = append(notInvolved, room)
- }
- }
- for _, weapon := range weapons {
- if weapon != trifecta.Weapon {
- notInvolved = append(notInvolved, weapon)
- }
- }
- for _, person := range people {
- if person != trifecta.Murderer {
- notInvolved = append(notInvolved, person)
- }
- }
- // Shuffle and distribute cards
- rand.Shuffle(len(notInvolved), func(i, j int) {
- notInvolved[i], notInvolved[j] = notInvolved[j], notInvolved[i]
- })
- players := map[string][]string{}
- cardsPerPlayer := len(notInvolved) / len(playerOrder)
- // playerOrder := []string{"{{user}}", "{{char}}", "{{char2}}"}
- for i, player := range playerOrder {
- start := i * cardsPerPlayer
- end := (i + 1) * cardsPerPlayer
- if end > len(notInvolved) {
- end = len(notInvolved)
- }
- players[player] = notInvolved[start:end]
- }
- res.Answer = trifecta
- res.PlayersCards = players
- return res
-}
diff --git a/extra/cluedo_test.go b/extra/cluedo_test.go
deleted file mode 100644
index e7a53b1..0000000
--- a/extra/cluedo_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package extra
-
-import (
- "testing"
-)
-
-func TestPrepCards(t *testing.T) {
- // Run the function to get the murder combination and player cards
- roundInfo := CluedoPrepCards([]string{"{{user}}", "{{char}}", "{{char2}}"})
- // Create a map to track all distributed cards
- distributedCards := make(map[string]bool)
- // Check that the murder combination cards are not distributed to players
- murderCards := []string{roundInfo.Answer.Murderer, roundInfo.Answer.Weapon, roundInfo.Answer.Room}
- for _, card := range murderCards {
- if distributedCards[card] {
- t.Errorf("Murder card %s was distributed to a player", card)
- }
- }
- // Check each player's cards
- for player, cards := range roundInfo.PlayersCards {
- for _, card := range cards {
- // Ensure the card is not part of the murder combination
- for _, murderCard := range murderCards {
- if card == murderCard {
- t.Errorf("Player %s has a murder card: %s", player, card)
- }
- }
- // Ensure the card is unique and not already distributed
- if distributedCards[card] {
- t.Errorf("Card %s is duplicated in player %s's hand", card, player)
- }
- distributedCards[card] = true
- }
- }
- // Verify that all non-murder cards are distributed
- allCards := append(append([]string{}, rooms...), weapons...)
- allCards = append(allCards, people...)
- for _, card := range allCards {
- isMurderCard := false
- for _, murderCard := range murderCards {
- if card == murderCard {
- isMurderCard = true
- break
- }
- }
- if !isMurderCard && !distributedCards[card] {
- t.Errorf("Card %s was not distributed to any player", card)
- }
- }
-}
diff --git a/extra/stt.go b/extra/stt.go
index e33a94d..86fcf9c 100644
--- a/extra/stt.go
+++ b/extra/stt.go
@@ -1,3 +1,6 @@
+//go:build extra
+// +build extra
+
package extra
import (
diff --git a/extra/tts.go b/extra/tts.go
index c6f373a..c9ad59d 100644
--- a/extra/tts.go
+++ b/extra/tts.go
@@ -1,3 +1,6 @@
+//go:build extra
+// +build extra
+
package extra
import (
diff --git a/extra/twentyq.go b/extra/twentyq.go
deleted file mode 100644
index 30c08cc..0000000
--- a/extra/twentyq.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package extra
-
-import "math/rand"
-
-var (
- chars = []string{"Shrek", "Garfield", "Jack the Ripper"}
-)
-
-func GetRandomChar() string {
- return chars[rand.Intn(len(chars))]
-}
diff --git a/extra/vad.go b/extra/vad.go
deleted file mode 100644
index 2a9e238..0000000
--- a/extra/vad.go
+++ /dev/null
@@ -1 +0,0 @@
-package extra
diff --git a/extra/websearch.go b/extra/websearch.go
deleted file mode 100644
index 99bc1b6..0000000
--- a/extra/websearch.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package extra
-
-import "github.com/GrailFinder/searchagent/searcher"
-
-var WebSearcher searcher.WebSurfer
-
-func init() {
- sa, err := searcher.NewWebSurfer(searcher.SearcherTypeScraper, "")
- if err != nil {
- panic("failed to init seachagent; error: " + err.Error())
- }
- WebSearcher = sa
-}
diff --git a/extra/whisper_binary.go b/extra/whisper_binary.go
index 31c083c..6b7ddc8 100644
--- a/extra/whisper_binary.go
+++ b/extra/whisper_binary.go
@@ -1,3 +1,6 @@
+//go:build extra
+// +build extra
+
package extra
import (