online multiplayer chess game (note server currently down)
Diffstat (limited to 'Utils.gd')
-rw-r--r--Utils.gd23
1 files changed, 19 insertions, 4 deletions
diff --git a/Utils.gd b/Utils.gd
index 70ac59b..ddac1ae 100644
--- a/Utils.gd
+++ b/Utils.gd
@@ -17,6 +17,10 @@ func expand_color(color: String) -> String:
return "white" if color == "w" else "black"
+func get_version() -> String:
+ return SaveLoad.load_string("res://version")
+
+
func _ready() -> void:
request() # check internet ok?
cli()
@@ -37,6 +41,16 @@ func cli() -> void:
parser.add_argument(
Arg.new(
{
+ triggers = ["--version", "-v", "-V"],
+ n_args = 0,
+ help = "show version and exit",
+ action = "store_true",
+ }
+ )
+ )
+ parser.add_argument(
+ Arg.new(
+ {
triggers = ["--host", "-h"],
n_args = 1,
default = "game_code",
@@ -82,9 +96,12 @@ func cli() -> void:
)
var args = parser.parse_arguments()
Debug.debug = str_bool(args["debug"]) if args.has("debug") else OS.is_debug_build()
- if args.has("help") and args["help"]:
+ if args.get("help", false):
print(parser.help("chess game"))
get_tree().quit() # dont wait
+ elif args.get("version", false):
+ print("chess %s" % get_version())
+ get_tree().quit() # dont wait
elif args.has("host") or args.has("join"):
if !internet:
printerr("No internet")
@@ -170,10 +187,8 @@ static func to_str(type: int) -> String:
return "PNBRQK"[type]
-# cant wait for 4.0 dict.merge(dict) :C
static func append_dict(dict: Dictionary, newdict: Dictionary) -> Dictionary:
- for key in newdict:
- dict[key] = newdict[key]
+ dict.merge(newdict)
return dict