diff --git a/WORK.md b/WORK.md index f1a7a02..0384e46 100644 --- a/WORK.md +++ b/WORK.md @@ -4,15 +4,15 @@ * tanks and bullets speed balancing * game series * network series - * save human state in classic game * map packs * create in editor * import in game * save imported in local storage * database + * cache * improve bots * A star -* game config macro +* game config validate * additional weapon * mine * display count diff --git a/gulpfile.js b/gulpfile.js index c669612..e89975b 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -40,9 +40,7 @@ exports.levels = function levels() { }; /** - * ToDo: - * windows target - * window exe package (innosetup) + * base config */ const config = new Project.Config({ meta: { diff --git a/package.json b/package.json index 07102ab..f85fd79 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tankz", - "version": "0.16.10", + "version": "0.16.11", "private": true, "devDependencies": { "dateformat": "^3.0.3", diff --git a/src/client/haxe/ru/m/Device.hx b/src/client/haxe/ru/m/Device.hx index 13f8d22..3298d2c 100644 --- a/src/client/haxe/ru/m/Device.hx +++ b/src/client/haxe/ru/m/Device.hx @@ -1,7 +1,27 @@ package ru.m; +@:enum abstract Platform(String) from String to String { + var ANDROID = "android"; + var LINUX = "linux"; + var WINDOWS = "windows"; +} + class Device { + public static var platform(get, null):Platform; + + private static function get_platform():Platform { + #if android + return ANDROID; + #elseif linux + return LINUX; + #elseif windows + return WINDOWS; + #else + return null; + #end + } + private static var MOBILES(default, never):Array = [ "Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone", ]; diff --git a/src/client/haxe/ru/m/Updater.hx b/src/client/haxe/ru/m/Updater.hx index 1912b06..9e63caf 100644 --- a/src/client/haxe/ru/m/Updater.hx +++ b/src/client/haxe/ru/m/Updater.hx @@ -4,9 +4,18 @@ import haxework.net.JsonLoader; import openfl.Lib; import openfl.net.URLRequest; import promhx.Promise; +import ru.m.Device; + +@:enum abstract PackageType(String) from String to String { + var APK = "apk"; + var DEB = "deb"; + var EXE = "exe"; + var ARCHIVE = "archive"; +} typedef PackageInfo = { - var type:String; + var platform:Platform; + var type:PackageType; var path:String; var filename:String; var url:String; @@ -22,7 +31,7 @@ class Updater { private static inline var TAG = "Update"; - public var type(get, null):String; + public var type(get, null):PackageType; public var bundle(default, null):PackagesBundle; private var url:String; @@ -33,14 +42,13 @@ class Updater { this.version = version; } - private function get_type():String { - #if android - return "android"; - #elseif linux - return "debian"; - #else - return null; - #end + private function get_type():PackageType { + return switch Device.platform { + case ANDROID: APK; + case LINUX: DEB; + case WINDOWS: EXE; + case _: null; + } } private function resolveBundle():Promise { @@ -53,14 +61,16 @@ class Updater { public function check():Promise { return resolveBundle().then(function(bundle:PackagesBundle):Bool { this.bundle = bundle; - return bundle.version != version && Lambda.exists(bundle.packages, function(item) return item.type == type); + return bundle.version != version && Lambda.exists(bundle.packages, function(item) { + return item.platform == Device.platform && item.type == type; + }); }); } public function download():Promise { return resolveBundle().then(function(bundle:PackagesBundle) { for (item in bundle.packages) { - if (item.type == type) { + if (item.platform == Device.platform && item.type == type) { L.i(TAG, 'download: ${item.url}'); Lib.getURL(new URLRequest(item.url)); return true; diff --git a/tasks/gulp-publish.js b/tasks/gulp-publish.js index fb84830..a702561 100755 --- a/tasks/gulp-publish.js +++ b/tasks/gulp-publish.js @@ -19,7 +19,7 @@ class Package { static getPlatform(filename) { for (const [platform, r] of [ ['android', /^.*?\.apk$/], - ['debian', /^.*?\.deb$/], + ['linux', /^.*?\.deb$/], ['linux', /^.*?linux\.tar\.gz$/], ['windows', /^.*?win\.zip$/], ['windows', /^.*?\.exe$/], @@ -37,7 +37,7 @@ class Package { ['deb', /^.*?\.deb$/], ['archive', /^.*?\.tar\.gz$/], ['archive', /^.*?\.zip$/], - ['installer', /^.*?\.exe$/], + ['exe', /^.*?\.exe$/], ]) { if (r.test(filename)) { return type;