summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/fonts/woff2css242
-rw-r--r--tools/packreplay.sql8
-rw-r--r--tools/readgame.sh10
-rw-r--r--tools/showreplay.sh2
-rw-r--r--tools/undo.sh6
-rw-r--r--tools/writegame.sh7
6 files changed, 22 insertions, 53 deletions
diff --git a/tools/fonts/woff2css2 b/tools/fonts/woff2css2
deleted file mode 100755
index 8105524..0000000
--- a/tools/fonts/woff2css2
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/python3
-
-# Embed a woff2 font in a static CSS file.
-# Usage: woff2css in.woff2 out.css
-#
-# Limitations: takes weight and style information from the file name of the font.
-# This script will throw an unhelpful exception if weight and style cannot
-# be determined.
-
-# @font-face {
-# font-family: "Dinish";
-# font-weight: 700;
-# font-style: bold;
-# src: url(data:font/woff2;base64,d09GMgABAAAAACzcAA0AAAAAc/wAACyGAAIAxQAAAAAAAAAAAAAAAAAAAAAAAAAAGnYbnkIcg0IGYACDHAqBpT
-# }
-
-import os
-import re
-import sys
-
-if not re.search(r"\.woff2$", sys.argv[1]):
- print("Usage: woff2css *.woff2")
- sys.exit(1)
-
-for src in sys.argv[1:]:
- m = re.match(r"([\w-]+)-(\w+)\.", os.path.basename(src))
- if m:
- family = m.group(1)
- style = m.group(2)
- else:
- print("Font should be named Family-Style.woff2; could not determine font weight.")
- sys.exit(1)
-
- s = ("@font-face{")
- s += (f"font-family:'{family}';")
- if style == "Bold" or style == "BoldItalic":
- s += (f"font-weight:bold;")
- if style == "Italic" or style == "BoldItalic":
- s += (f"font-style:italic;")
- s += (f"src:url('{src}')format('woff2')")
- s += ("}")
- print(s)
diff --git a/tools/packreplay.sql b/tools/packreplay.sql
deleted file mode 100644
index 28cd11f..0000000
--- a/tools/packreplay.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-begin transaction;
-create temporary table replay_repack as
- select game_id,role,action,arguments
- from game_replay
- order by game_id,replay_id;
-delete from game_replay;
-insert into game_replay (game_id,role,action,arguments) select * from replay_repack;
-commit;
diff --git a/tools/readgame.sh b/tools/readgame.sh
new file mode 100644
index 0000000..4a8fdbd
--- /dev/null
+++ b/tools/readgame.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+if [ -n "$1" -a -n "$2" ]
+then
+ sqlite3 db "select writefile('$2',state) from game_state where game_id = $1"
+elif [ -n "$1" ]
+then
+ sqlite3 db "select state from game_state where game_id = $1"
+else
+ echo "usage: bash tools/readgame.sh GAME [ state.json ]"
+fi
diff --git a/tools/showreplay.sh b/tools/showreplay.sh
new file mode 100644
index 0000000..413e12f
--- /dev/null
+++ b/tools/showreplay.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+sqlite3 db "select * from game_replay where game_id=$1"
diff --git a/tools/undo.sh b/tools/undo.sh
index 3cd5b4a..716e88b 100644
--- a/tools/undo.sh
+++ b/tools/undo.sh
@@ -1,9 +1,9 @@
#!/bin/bash
if [ -n "$1" ]
then
- RID=$(sqlite3 db "select replay_id from game_replay where game_id=$1 order by replay_id desc limit 1")
- echo $RID
- sqlite3 db "delete from game_replay where game_id=$1 and replay_id=$RID"
+ COUNT=$(sqlite3 db "select count(1) from game_replay where game_id=$1")
+ echo Game has $COUNT actions.
+ sqlite3 db "delete from game_replay where game_id=$1 and replay_id=$COUNT"
node tools/patchgame.js $1
else
echo "usage: bash tools/undo.sh GAME"
diff --git a/tools/writegame.sh b/tools/writegame.sh
new file mode 100644
index 0000000..ea0f599
--- /dev/null
+++ b/tools/writegame.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+if [ -n "$1" -a -f "$2" ]
+then
+ sqlite3 db "update game_state set state=readfile('$2') where game_id = $1"
+else
+ echo "usage: bash tools/writegame.sh GAME state.json"
+fi