aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--go/Makefile11
-rw-r--r--go/assets/retrieve.go3
-rw-r--r--go/assets/sources_local.go9
-rw-r--r--go/assets/sources_release.go9
-rw-r--r--go/game/card.go3
-rw-r--r--go/game/map.go9
-rw-r--r--go/game/set.go3
8 files changed, 34 insertions, 14 deletions
diff --git a/README.md b/README.md
index e99c0670..69d664c9 100644
--- a/README.md
+++ b/README.md
@@ -123,5 +123,4 @@ Things that should be done eventually:
- [ ] finish AIs
- [ ] tyrant
- [ ] finish error handling for remote PlayerControls
-- [ ] add build flavors to retrieve card data from muhq.space
- [ ] support big card grids (for sealed)
diff --git a/go/Makefile b/go/Makefile
index 20ef58e9..cac5071e 100644
--- a/go/Makefile
+++ b/go/Makefile
@@ -8,9 +8,14 @@ WASM := client/client.wasm webtools/webtools.wasm dummy-ui/dummy-ui.wasm
GOFMT ?= gofumpt -l -w .
-.PHONY: all fmt test check $(OBJS) $(WASM)
+GO_BUILDTAGS ?=
+
+.PHONY: all release fmt test check $(OBJS) $(WASM)
all: $(OBJS) $(WASM)
+release:
+ $(MAKE) GO_BUILDTAGS="-tags release" all
+
.PHONY: client server dummy-ui
client: client/client
server: server/server
@@ -18,11 +23,11 @@ dummy-ui: dummy-ui/dummy-ui
$(OBJS):
@echo Building $(@F)
- @pushd $(@D) >/dev/null && go build && popd >/dev/null
+ @pushd $(@D) >/dev/null && go build $(GO_BUILDTAGS) && popd >/dev/null
$(WASM):
@echo Building $(@F) ...
- @pushd $(@D) >/dev/null && env GOOS=js GOARCH=wasm go build -o $(@F) && popd >/dev/null
+ @pushd $(@D) >/dev/null && env GOOS=js GOARCH=wasm go build $(GO_BUILDTAGS) -o $(@F) && popd >/dev/null
fmt:
@set -e; for package in $(PACKAGES) webtools; do \
diff --git a/go/assets/retrieve.go b/go/assets/retrieve.go
index 3ef0cb3d..6791ceaf 100644
--- a/go/assets/retrieve.go
+++ b/go/assets/retrieve.go
@@ -15,9 +15,6 @@ import (
)
const (
- PROTOCOL string = "https://"
- // BASE_URL string = "localhost:8000/"
- BASE_URL string = "muhq.space/muhqs-game"
IMAGE_URL_PART string = "html/build/latex-build"
TILE_URL_PART string = "assets/tiles"
SYMBOL_URL_PART string = "assets/symbols/40x40"
diff --git a/go/assets/sources_local.go b/go/assets/sources_local.go
new file mode 100644
index 00000000..dd4725fc
--- /dev/null
+++ b/go/assets/sources_local.go
@@ -0,0 +1,9 @@
+//go:build !release
+// +build !release
+
+package assets
+
+const (
+ PROTOCOL string = "http://"
+ BASE_URL string = "localhost:8000/"
+)
diff --git a/go/assets/sources_release.go b/go/assets/sources_release.go
new file mode 100644
index 00000000..cb5d9f61
--- /dev/null
+++ b/go/assets/sources_release.go
@@ -0,0 +1,9 @@
+//go:build release
+// +build release
+
+package assets
+
+const (
+ PROTOCOL string = "https://"
+ BASE_URL string = "muhq.space/muhqs-game"
+)
diff --git a/go/game/card.go b/go/game/card.go
index 06a04f1b..438fb384 100644
--- a/go/game/card.go
+++ b/go/game/card.go
@@ -11,6 +11,7 @@ import (
"golang.org/x/exp/slices"
"gopkg.in/yaml.v3"
+ "muhq.space/muhqs-game/go/assets"
)
type CardType int
@@ -196,7 +197,7 @@ func getCardDefinition(set, cardName string) ([]byte, error) {
var ErrUnknownCardPath = errors.New("unknown card path")
func retrieveCardDefinition(cardPath string) ([]byte, error) {
- url := PROTOCOL + path.Join(BASE_URL, CARD_DATA_URL, cardPath+".yml")
+ url := assets.PROTOCOL + path.Join(assets.BASE_URL, CARD_DATA_URL, cardPath+".yml")
log.Printf("loading card from %s\n", url)
resp, err := http.Get(url)
if err != nil {
diff --git a/go/game/map.go b/go/game/map.go
index 9a07e308..48ec8be3 100644
--- a/go/game/map.go
+++ b/go/game/map.go
@@ -13,12 +13,11 @@ import (
"golang.org/x/exp/slices"
"gopkg.in/yaml.v3"
+
+ "muhq.space/muhqs-game/go/assets"
)
const (
- PROTOCOL string = "https://"
- // BASE_URL string = "localhost:8000/"
- BASE_URL string = "muhq.space/muhqs-game"
MAP_URL_PART string = "html/build/maps"
DEFAULT_RESOURCE_GAIN int = 5
@@ -195,9 +194,9 @@ func (m *Map) FindFortificationConnections(x int, y int) (connections int, left,
// GetMap creates a new map from the definition retrieved for the map's name.
func GetMap(name string) (*Map, error) {
- url := path.Join(BASE_URL, MAP_URL_PART, name+".yml")
+ url := path.Join(assets.BASE_URL, MAP_URL_PART, name+".yml")
log.Printf("loading map from %s\n", url)
- resp, err := http.Get(PROTOCOL + url)
+ resp, err := http.Get(assets.PROTOCOL + url)
if err != nil {
log.Fatal(err)
}
diff --git a/go/game/set.go b/go/game/set.go
index 3690e839..e4a08f3b 100644
--- a/go/game/set.go
+++ b/go/game/set.go
@@ -8,6 +8,7 @@ import (
"strings"
"golang.org/x/net/html"
+ "muhq.space/muhqs-game/go/assets"
)
type SetIdentifier int
@@ -86,7 +87,7 @@ var SetNames = map[string]SetIdentifier{
}
func (set SetIdentifier) CardPaths() []string {
- url := PROTOCOL + path.Join(BASE_URL, CARD_DATA_URL, set.String())
+ url := assets.PROTOCOL + path.Join(assets.BASE_URL, CARD_DATA_URL, set.String())
log.Printf("loading set from %s\n", url)
resp, err := http.Get(url)
if err != nil {