Compare commits
2
Commits
online
..
eeee6e1f18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eeee6e1f18 | ||
|
|
1d64087e40 |
+1
-2
@@ -14,8 +14,7 @@ WORKDIR /app
|
|||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN --mount=type=cache,target=/root/.npm \
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
npm ci
|
npm ci
|
||||||
COPY gulpfile.js protohx.json ./
|
COPY gulpfile.ts protohx.json ./
|
||||||
COPY tasks ./tasks
|
|
||||||
COPY config.example.json ./config.example.json
|
COPY config.example.json ./config.example.json
|
||||||
RUN --mount=type=secret,id=KEY_STORE \
|
RUN --mount=type=secret,id=KEY_STORE \
|
||||||
cat /run/secrets/KEY_STORE > ./key.jks
|
cat /run/secrets/KEY_STORE > ./key.jks
|
||||||
|
|||||||
+1
-3
@@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"SdkDir": "$HOME/sdk",
|
"SdkDir": "$HOME/sdk",
|
||||||
"BuildDir": null,
|
|
||||||
"PublishDir": "$HOME/public/puzzlez",
|
|
||||||
"PublishUrl": "https://shmyga.ru/repo/puzzlez",
|
|
||||||
"Develop": false,
|
"Develop": false,
|
||||||
|
"UseRuffle": true,
|
||||||
"Key": {
|
"Key": {
|
||||||
"store": "keystore.jks",
|
"store": "keystore.jks",
|
||||||
"pass": null
|
"pass": null
|
||||||
|
|||||||
Vendored
+22
@@ -0,0 +1,22 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
google()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:::ANDROID_GRADLE_PLUGIN::'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace "ru.m.android"
|
||||||
|
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
|
||||||
|
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation project(':deps:extension-api')
|
||||||
|
}
|
||||||
Vendored
-11
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project name="android" default="help">
|
|
||||||
<property environment="env" />
|
|
||||||
<property name="sdk.dir" value="${env.ANDROID_SDK}" />
|
|
||||||
|
|
||||||
<property file="local.properties" />
|
|
||||||
<property file="ant.properties" />
|
|
||||||
<property file="project.properties" />
|
|
||||||
|
|
||||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
|
||||||
</project>
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
android.library=true
|
|
||||||
android.library.reference.1=../extension-api
|
|
||||||
target=android-::ANDROID_TARGET_SDK_VERSION::
|
|
||||||
Vendored
+1
-2
@@ -1,3 +1,2 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ru.m.android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ru.m.android" />
|
||||||
</manifest>
|
|
||||||
-152
@@ -1,152 +0,0 @@
|
|||||||
const gulp = require("gulp");
|
|
||||||
const gulpClean = require("gulp-clean");
|
|
||||||
const Config = require("./config.json");
|
|
||||||
const packageInfo = require("./package.json");
|
|
||||||
const { System, Sdk, Haxe, Project } = require("gulp-haxetool");
|
|
||||||
const dateformat = require("dateformat");
|
|
||||||
const argv = require("yargs").argv;
|
|
||||||
const publish = require("./tasks/gulp-publish");
|
|
||||||
const os = require("os");
|
|
||||||
|
|
||||||
const resolvePath = (path) => path.replace("$HOME", os.homedir());
|
|
||||||
|
|
||||||
Project.useRuffle();
|
|
||||||
|
|
||||||
if (packageInfo.haxe) {
|
|
||||||
Haxe.VERSION = packageInfo.haxe;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.SdkDir) {
|
|
||||||
Sdk.dir = resolvePath(Config.SdkDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.BuildDir) {
|
|
||||||
Haxe.buildDir = resolvePath(Config.BuildDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.clean = function clean() {
|
|
||||||
return gulp.src("target/*", { read: false }).pipe(gulpClean());
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.setup = function setup() {
|
|
||||||
const builder = Project.Builder.new(
|
|
||||||
app.config,
|
|
||||||
Project.Platform.ANDROID,
|
|
||||||
app.buildSystem,
|
|
||||||
);
|
|
||||||
return builder.prepare();
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.generate = function generate() {
|
|
||||||
return exports.setup().then(() =>
|
|
||||||
new Haxe()
|
|
||||||
.haxelib(["run", "protohx", "generate", "protohx.json"])
|
|
||||||
.then(({ stdout }) => {
|
|
||||||
if (stdout.indexOf("FAIL") > -1) {
|
|
||||||
throw stdout;
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const config = new Project.Config({
|
|
||||||
meta: {
|
|
||||||
title: "Puzzle'z",
|
|
||||||
filename: "puzzlez",
|
|
||||||
icon: "src/app/resources/icon.png",
|
|
||||||
pack: "ru.m.puzzlez",
|
|
||||||
author: "shmyga <shmyga.z@gmail.com>",
|
|
||||||
company: "MegaLoMania",
|
|
||||||
version: packageInfo.version + (Config.Develop ? "-SNAPSHOT" : ""),
|
|
||||||
},
|
|
||||||
key: Config.Key,
|
|
||||||
libs: packageInfo.haxeDependencies,
|
|
||||||
macros: [
|
|
||||||
`CompilationOption.set('build','${dateformat(new Date(), "yyyy-mm-dd HH:MM:ss")}')`,
|
|
||||||
`CompilationOption.set('UNSPLASH_KEY','${Config.UnsplashKey}')`,
|
|
||||||
`CompilationOption.set('PIXABAY_KEY','${Config.PixabayKey}')`,
|
|
||||||
],
|
|
||||||
flags: ["proto_debug"],
|
|
||||||
});
|
|
||||||
|
|
||||||
const host = argv.host || "localhost";
|
|
||||||
const port = argv.port || 5000;
|
|
||||||
|
|
||||||
const app = new Project(
|
|
||||||
Project.BuildSystem.OPENFL,
|
|
||||||
[
|
|
||||||
Project.Platform.FLASH,
|
|
||||||
Project.Platform.HTML5,
|
|
||||||
Project.Platform.LINUX,
|
|
||||||
Project.Platform.WINDOWS,
|
|
||||||
Project.Platform.ANDROID,
|
|
||||||
],
|
|
||||||
config.branch({
|
|
||||||
name: "app",
|
|
||||||
sources: ["src-gen/haxe", "src/common/haxe", "src/app/haxe"],
|
|
||||||
android: [
|
|
||||||
{
|
|
||||||
path: "dependencies/android",
|
|
||||||
extensions: ["ru.m.android.FileUtil"],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
assets: ["src/app/resources"],
|
|
||||||
main: "ru.m.puzzlez.PuzzlezApp",
|
|
||||||
meta: {
|
|
||||||
width: 1280,
|
|
||||||
height: 768,
|
|
||||||
},
|
|
||||||
macros: [
|
|
||||||
`CompilationOption.set('host','${host}')`,
|
|
||||||
`CompilationOption.set('port',${port})`,
|
|
||||||
],
|
|
||||||
flags: ["app"],
|
|
||||||
}),
|
|
||||||
).bind(module, gulp);
|
|
||||||
|
|
||||||
const server = new Project(
|
|
||||||
Project.BuildSystem.HAXE,
|
|
||||||
[Project.Platform.NEKO, Project.Platform.CPP],
|
|
||||||
config.branch({
|
|
||||||
name: "server",
|
|
||||||
sources: ["src-gen/haxe", "src/common/haxe", "src/server/haxe"],
|
|
||||||
main: "ru.m.puzzlez.PuzzlezServer",
|
|
||||||
}),
|
|
||||||
).bind(module, gulp);
|
|
||||||
|
|
||||||
module.exports.publish = publish(
|
|
||||||
packageInfo.name,
|
|
||||||
packageInfo.version,
|
|
||||||
resolvePath(Config.PublishDir),
|
|
||||||
Config.PublishUrl,
|
|
||||||
);
|
|
||||||
|
|
||||||
const defaultSeries = [
|
|
||||||
exports.clean,
|
|
||||||
exports.generate,
|
|
||||||
module.exports["app:flash:build"],
|
|
||||||
module.exports["app:flash:html"],
|
|
||||||
module.exports["app:html5:build"],
|
|
||||||
];
|
|
||||||
|
|
||||||
if (System.isLinux) {
|
|
||||||
defaultSeries.push(
|
|
||||||
module.exports["app:linux:build"],
|
|
||||||
module.exports["app:linux:archive"],
|
|
||||||
module.exports["app:linux:deb"],
|
|
||||||
|
|
||||||
module.exports["app:android:build"],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (System.isWindows) {
|
|
||||||
defaultSeries.push(
|
|
||||||
module.exports["app:windows:build"],
|
|
||||||
module.exports["app:windows:archive"],
|
|
||||||
module.exports["app:windows:installer"],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultSeries.push(exports.publish);
|
|
||||||
|
|
||||||
module.exports.default = gulp.series(defaultSeries);
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import gulp from "gulp";
|
||||||
|
import { Preset } from "gulp-haxetool";
|
||||||
|
import config from "./config.json" with { type: "json" };
|
||||||
|
import presetData from "./haxetool.json" with { type: "json" };
|
||||||
|
import packageInfo from "./package.json" with { type: "json" };
|
||||||
|
|
||||||
|
const preset = new Preset(presetData, config, packageInfo);
|
||||||
|
export default preset.register(gulp);
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"default": {
|
||||||
|
"meta": {
|
||||||
|
"title": "Puzzle'z",
|
||||||
|
"filename": "puzzlez",
|
||||||
|
"icon": "src/app/resources/icon.png",
|
||||||
|
"pack": "ru.m.puzzlez",
|
||||||
|
"author": "shmyga <shmyga.z@gmail.com>",
|
||||||
|
"company": "MegaLoMania",
|
||||||
|
"version": "<%=package.version%>"
|
||||||
|
},
|
||||||
|
"sources": ["src-gen/haxe", "src/common/haxe"],
|
||||||
|
"libs": {
|
||||||
|
"haxework": "2.1.0",
|
||||||
|
"lime": "8.3.2",
|
||||||
|
"openfl": "9.5.2",
|
||||||
|
"hxcpp": "4.2.1",
|
||||||
|
"svg": "1.1.3",
|
||||||
|
"protohx": "0.4.6",
|
||||||
|
"yield": "3.2.2",
|
||||||
|
"formatter": "1.16.0"
|
||||||
|
},
|
||||||
|
"key": {
|
||||||
|
"store": "<%=config.Key.store%>",
|
||||||
|
"pass": "<%=config.Key.pass%>"
|
||||||
|
},
|
||||||
|
"macros": [
|
||||||
|
"CompilationOption.set('build','<%=dateformat(Date.now(), 'yyyy-mm-dd HH:MM:ss')%>')",
|
||||||
|
"CompilationOption.set('UNSPLASH_KEY','<%=config.UnsplashKey%>')",
|
||||||
|
"CompilationOption.set('PIXABAY_KEY','<%=config.PixabayKey%>')"
|
||||||
|
],
|
||||||
|
"flags": ["proto_debug"]
|
||||||
|
},
|
||||||
|
"app": {
|
||||||
|
"buildSystem": "openfl",
|
||||||
|
"platforms": ["flash", "html5", "linux", "windows", "android"],
|
||||||
|
"sources": ["src/app/haxe"],
|
||||||
|
"android": [
|
||||||
|
{
|
||||||
|
"path": "dependencies/android",
|
||||||
|
"extensions": ["ru.m.android.FileUtil"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"assets": ["src/app/resources"],
|
||||||
|
"main": "ru.m.puzzlez.PuzzlezApp",
|
||||||
|
"meta": {
|
||||||
|
"width": 1280,
|
||||||
|
"height": 768
|
||||||
|
},
|
||||||
|
"macros": [
|
||||||
|
"CompilationOption.set('host','<%=env.HOST || '0.0.0.0'%>')",
|
||||||
|
"CompilationOption.set('port',<%=env.PORT || '5000'%>)"
|
||||||
|
],
|
||||||
|
"flags": ["app"]
|
||||||
|
},
|
||||||
|
"server": {
|
||||||
|
"buildSystem": "haxe",
|
||||||
|
"platforms": ["cpp"],
|
||||||
|
"sources": ["src/server/haxe"],
|
||||||
|
"main": "ru.m.puzzlez.PuzzlezServer"
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+5066
-11656
File diff suppressed because it is too large
Load Diff
+5
-23
@@ -1,30 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "puzzlez",
|
"name": "puzzlez",
|
||||||
|
"type": "module",
|
||||||
"version": "0.6.2",
|
"version": "0.6.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gulp",
|
"build": "hxt default",
|
||||||
"dev": "gulp app:flash:test"
|
"dev": "hxt app:flash:test"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dateformat": "^3.0.3",
|
"gulp-haxetool": "^2.0.3"
|
||||||
"fs-extra": "^10.1.0",
|
}
|
||||||
"gulp": "^4.0.0",
|
|
||||||
"gulp-add": "0.0.2",
|
|
||||||
"gulp-clean": "^0.4.0",
|
|
||||||
"gulp-cli": "^2.2.0",
|
|
||||||
"gulp-haxetool": "^0.2.2",
|
|
||||||
"yargs": "^13.2.4"
|
|
||||||
},
|
|
||||||
"haxeDependencies": {
|
|
||||||
"haxework": "2.1.0",
|
|
||||||
"lime": "8.0.0",
|
|
||||||
"openfl": "9.2.0",
|
|
||||||
"hxcpp": "4.2.1",
|
|
||||||
"svg": "1.1.3",
|
|
||||||
"protohx": "0.4.6",
|
|
||||||
"yield": "3.2.2",
|
|
||||||
"formatter": "1.16.0",
|
|
||||||
"hxWebSockets": "1.4.0"
|
|
||||||
},
|
|
||||||
"haxe": "4.2.5"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import hw.app.App;
|
|||||||
import hw.app.Const;
|
import hw.app.Const;
|
||||||
import hw.log.TraceLogger;
|
import hw.log.TraceLogger;
|
||||||
import ru.m.puzzlez.image.ImageSourceBundle;
|
import ru.m.puzzlez.image.ImageSourceBundle;
|
||||||
import ru.m.puzzlez.net.Network;
|
|
||||||
import ru.m.puzzlez.net.NetworkSource;
|
|
||||||
import ru.m.puzzlez.render.part.IPartBuilder;
|
import ru.m.puzzlez.render.part.IPartBuilder;
|
||||||
import ru.m.puzzlez.settings.Settings;
|
import ru.m.puzzlez.settings.Settings;
|
||||||
import ru.m.puzzlez.source.AssetImageSource;
|
import ru.m.puzzlez.source.AssetImageSource;
|
||||||
@@ -20,15 +18,12 @@ import ru.m.update.Updater;
|
|||||||
class PuzzlezApp {
|
class PuzzlezApp {
|
||||||
@:provide static var updater:Updater;
|
@:provide static var updater:Updater;
|
||||||
@:provide static var sourceBundle:ImageSourceBundle;
|
@:provide static var sourceBundle:ImageSourceBundle;
|
||||||
@:provide static var network:Network;
|
|
||||||
|
|
||||||
public static function main() {
|
public static function main() {
|
||||||
// ToDo: fix @:provide macro
|
// ToDo: fix @:provide macro
|
||||||
Settings;
|
Settings;
|
||||||
IPartBuilder;
|
IPartBuilder;
|
||||||
GameStorage;
|
GameStorage;
|
||||||
Network;
|
|
||||||
NetworkSource;
|
|
||||||
sourceBundle.register(new AssetImageSource());
|
sourceBundle.register(new AssetImageSource());
|
||||||
sourceBundle.register(new FileImageSource());
|
sourceBundle.register(new FileImageSource());
|
||||||
sourceBundle.register(new PixabayImageSource(CompilationOption.get("PIXABAY_KEY")));
|
sourceBundle.register(new PixabayImageSource(CompilationOption.get("PIXABAY_KEY")));
|
||||||
@@ -41,6 +36,5 @@ class PuzzlezApp {
|
|||||||
app.icon = openfl.Assets.getBitmapData("resources/icon.png");
|
app.icon = openfl.Assets.getBitmapData("resources/icon.png");
|
||||||
app.view = new PuzzlezAppView();
|
app.view = new PuzzlezAppView();
|
||||||
L.d("Puzzlez", "started");
|
L.d("Puzzlez", "started");
|
||||||
network.auth();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import hw.connect.IConnection;
|
|||||||
import hw.signal.Signal;
|
import hw.signal.Signal;
|
||||||
import hw.storage.SharedObjectStorage;
|
import hw.storage.SharedObjectStorage;
|
||||||
import promhx.Promise;
|
import promhx.Promise;
|
||||||
|
import ru.m.data.IDataSource;
|
||||||
import ru.m.puzzlez.proto.core.User;
|
import ru.m.puzzlez.proto.core.User;
|
||||||
import ru.m.puzzlez.proto.event.GameAction;
|
import ru.m.puzzlez.proto.event.GameAction;
|
||||||
import ru.m.puzzlez.proto.event.GameEvent;
|
import ru.m.puzzlez.proto.event.GameEvent;
|
||||||
@@ -12,34 +13,29 @@ import ru.m.puzzlez.proto.game.GamePreset;
|
|||||||
import ru.m.puzzlez.proto.game.GameState;
|
import ru.m.puzzlez.proto.game.GameState;
|
||||||
import ru.m.puzzlez.proto.pack.AuthRequest;
|
import ru.m.puzzlez.proto.pack.AuthRequest;
|
||||||
import ru.m.puzzlez.proto.pack.GameActionRequest;
|
import ru.m.puzzlez.proto.pack.GameActionRequest;
|
||||||
import ru.m.puzzlez.proto.pack.GameCreateRequest;
|
|
||||||
import ru.m.puzzlez.proto.pack.GameJoinRequest;
|
import ru.m.puzzlez.proto.pack.GameJoinRequest;
|
||||||
import ru.m.puzzlez.proto.pack.GameLeaveRequest;
|
import ru.m.puzzlez.proto.pack.GameLeaveRequest;
|
||||||
|
import ru.m.puzzlez.proto.pack.GameListRequest;
|
||||||
import ru.m.puzzlez.proto.pack.GameListResponse;
|
import ru.m.puzzlez.proto.pack.GameListResponse;
|
||||||
import ru.m.puzzlez.proto.pack.NotificationResponse;
|
import ru.m.puzzlez.proto.pack.NotificationResponse;
|
||||||
import ru.m.puzzlez.proto.pack.Request;
|
import ru.m.puzzlez.proto.pack.Request;
|
||||||
import ru.m.puzzlez.proto.pack.Response;
|
import ru.m.puzzlez.proto.pack.Response;
|
||||||
|
|
||||||
using ru.m.SignalUtil;
|
@:provide class Network implements IDataSource<String, GameState> {
|
||||||
|
|
||||||
@:provide class Network {
|
|
||||||
public var userSignal:Signal<User> = new Signal();
|
public var userSignal:Signal<User> = new Signal();
|
||||||
public var notificationSignal:Signal<NotificationResponse> = new Signal();
|
public var notificationSignal:Signal<NotificationResponse> = new Signal();
|
||||||
public var listSignal:Signal<GameListResponse> = new Signal();
|
public var listSignal:Signal<GameListResponse> = new Signal();
|
||||||
public var joinSignal:Signal<GameState> = new Signal();
|
public var joinSignal:Signal<GameState> = new Signal();
|
||||||
public var gameEventSignal:Signal<GameEvent> = new Signal();
|
public var gameEventSignal:Signal<GameEvent> = new Signal();
|
||||||
|
|
||||||
public var connection:IConnection<Request, Response>;
|
private var connection:IConnection<Request, Response>;
|
||||||
|
|
||||||
private var storage:SharedObjectStorage;
|
private var storage:SharedObjectStorage;
|
||||||
|
|
||||||
private static var USER_KEY = "user";
|
private static var USER_KEY = "user";
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
storage = new SharedObjectStorage("network/2");
|
storage = new SharedObjectStorage("network/2");
|
||||||
var host:String = CompilationOption.get("host");
|
connection = ConnectionFactory.buildClientConnection("127.0.0.1", 5000, Response);
|
||||||
var port:Int = cast(CompilationOption.get("port"), Int);
|
|
||||||
connection = ConnectionFactory.buildClientConnection(host, port, Response);
|
|
||||||
connection.handler.connect(onConnectionChange);
|
connection.handler.connect(onConnectionChange);
|
||||||
connection.receiveHandler.connect(onReceivePacket);
|
connection.receiveHandler.connect(onReceivePacket);
|
||||||
connection.connect().catchError(_ -> {});
|
connection.connect().catchError(_ -> {});
|
||||||
@@ -49,23 +45,17 @@ using ru.m.SignalUtil;
|
|||||||
if (storage.exists(USER_KEY)) {
|
if (storage.exists(USER_KEY)) {
|
||||||
return storage.read(USER_KEY);
|
return storage.read(USER_KEY);
|
||||||
} else {
|
} else {
|
||||||
var uuid = IdUtil.generate();
|
return new User().setName('Anonimus #${IdUtil.generate()}');
|
||||||
return new User().setUuid(uuid).setName('Anonimus #${uuid}');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth():Promise<User> {
|
public function auth():Promise<User> {
|
||||||
try {
|
connection.send(new Request().setAuth(new AuthRequest().setUser(restoreUser())));
|
||||||
connection.send(new Request().setAuth(new AuthRequest().setUser(restoreUser())));
|
return userSignal.next();
|
||||||
return userSignal.next();
|
|
||||||
} catch (error:Dynamic) {
|
|
||||||
L.w("network", "auth", error);
|
|
||||||
return Promise.promise(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createGame(preset:GamePreset):Promise<GameState> {
|
public function createGame(preset:GamePreset):Promise<GameState> {
|
||||||
connection.send(new Request().setCreate(new GameCreateRequest().setPreset(preset)));
|
connection.send(new Request().setJoin(new GameJoinRequest().setPreset(preset)));
|
||||||
return joinSignal.next();
|
return joinSignal.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,4 +99,22 @@ using ru.m.SignalUtil;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPage(page:Page):Promise<DataPage<GameState>> {
|
||||||
|
connection.send(new Request().setList(new GameListRequest().setCount(page.count).setPage(page.index)));
|
||||||
|
return listSignal.next().then((list:GameListResponse) -> ({
|
||||||
|
page: {
|
||||||
|
index: list.page,
|
||||||
|
count: list.count,
|
||||||
|
filter: null,
|
||||||
|
order: null,
|
||||||
|
},
|
||||||
|
total: list.total,
|
||||||
|
data: list.games,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(id:String):GameState {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ package ru.m.puzzlez.net;
|
|||||||
|
|
||||||
import ru.m.puzzlez.proto.event.GameStart;
|
import ru.m.puzzlez.proto.event.GameStart;
|
||||||
import hw.signal.Signal;
|
import hw.signal.Signal;
|
||||||
import ru.m.puzzlez.game.IGame;
|
import ru.m.puzzlez.image.IGame;
|
||||||
import ru.m.puzzlez.proto.event.GameAction;
|
import ru.m.puzzlez.proto.event.GameAction;
|
||||||
import ru.m.puzzlez.proto.event.GameEvent;
|
import ru.m.puzzlez.proto.event.GameEvent;
|
||||||
import ru.m.puzzlez.proto.game.GameState;
|
import ru.m.puzzlez.proto.game.GameState;
|
||||||
import ru.m.puzzlez.proto.event.gameaction.Action;
|
|
||||||
import ru.m.puzzlez.game.EventUtil;
|
|
||||||
|
|
||||||
class NetworkGame implements IGame {
|
class NetworkGame implements IGame {
|
||||||
public var state(default, null):GameState;
|
public var state(default, null):GameState;
|
||||||
@@ -21,11 +19,7 @@ class NetworkGame implements IGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function action(action:GameAction):Void {
|
public function action(action:GameAction):Void {
|
||||||
if (action.action == Action.MOVE) {
|
network.sendGameAction(action);
|
||||||
events.emit(EventUtil.action(action));
|
|
||||||
} else {
|
|
||||||
network.sendGameAction(action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function start():Void {
|
public function start():Void {
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
package ru.m.puzzlez.net;
|
|
||||||
|
|
||||||
import hw.connect.IConnection;
|
|
||||||
import hw.signal.Signal;
|
|
||||||
import promhx.Deferred;
|
|
||||||
import promhx.Promise;
|
|
||||||
|
|
||||||
enum NetworkState {
|
|
||||||
CONNECT;
|
|
||||||
ACTIVE;
|
|
||||||
DISCONNECT;
|
|
||||||
ERROR(error:Dynamic);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ReconnectTimer {
|
|
||||||
private var interval:Float;
|
|
||||||
private var lastConnected:Float;
|
|
||||||
private var lastActivity:Float;
|
|
||||||
private var lastError:Float;
|
|
||||||
private var next:Float;
|
|
||||||
|
|
||||||
public function new(interval:Float) {
|
|
||||||
this.interval = interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function connect():Promise<Void> {
|
|
||||||
d = new Deferred();
|
|
||||||
d.resolve();
|
|
||||||
return d.promise();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onActivity() {}
|
|
||||||
|
|
||||||
public function onError() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class NetworkManager {
|
|
||||||
public var state(default, null):Signal<NetworkState>;
|
|
||||||
|
|
||||||
private var reconnectTimer:ReconnectTimer;
|
|
||||||
|
|
||||||
public function new(connection:IConnection<Dynamic, Dynamic>) {
|
|
||||||
this.reconnectTimer = new ReconnectTimer(5.0);
|
|
||||||
connection.handler.connect(onConnectionChange);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function reconnect() {
|
|
||||||
return this.reconnectTimer.connect().then(() => {
|
|
||||||
state.emit(CONNECT);
|
|
||||||
connection.connect();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private function onConnectionChange(event:ConnectionEvent):Void {
|
|
||||||
switch event {
|
|
||||||
case CONNECTED:
|
|
||||||
state.emit(ACTIVE);
|
|
||||||
case DISCONNECTED:
|
|
||||||
state.emit(DISCONNECT);
|
|
||||||
case ERROR(error):
|
|
||||||
state.emit(ERROR(error));
|
|
||||||
this.reconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package ru.m.puzzlez.net;
|
|
||||||
|
|
||||||
import promhx.Promise;
|
|
||||||
import ru.m.data.DataSource;
|
|
||||||
import ru.m.puzzlez.proto.game.GameState;
|
|
||||||
import ru.m.puzzlez.proto.pack.GameListRequest;
|
|
||||||
import ru.m.puzzlez.proto.pack.GameListResponse;
|
|
||||||
import ru.m.puzzlez.proto.pack.Request;
|
|
||||||
|
|
||||||
using ru.m.SignalUtil;
|
|
||||||
|
|
||||||
@:provide class NetworkSource implements DataSource<GameState> {
|
|
||||||
@:provide private var network:Network;
|
|
||||||
|
|
||||||
public function getPage(page:Page):Promise<DataPage<GameState>> {
|
|
||||||
network.connection.send(new Request().setList(new GameListRequest().setCount(page.count).setPage(page.index)));
|
|
||||||
return network.listSignal.next().then((list:GameListResponse) -> ({
|
|
||||||
page: {
|
|
||||||
index: list.page,
|
|
||||||
count: list.count,
|
|
||||||
filter: null,
|
|
||||||
order: null,
|
|
||||||
},
|
|
||||||
total: list.total,
|
|
||||||
data: list.games,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,6 @@ import hw.view.popup.ConfirmView;
|
|||||||
import promhx.Promise;
|
import promhx.Promise;
|
||||||
import ru.m.puzzlez.game.Game;
|
import ru.m.puzzlez.game.Game;
|
||||||
import ru.m.puzzlez.game.IGame;
|
import ru.m.puzzlez.game.IGame;
|
||||||
import ru.m.puzzlez.net.NetworkGame;
|
|
||||||
import ru.m.puzzlez.proto.event.GameAction;
|
import ru.m.puzzlez.proto.event.GameAction;
|
||||||
import ru.m.puzzlez.proto.event.GameEvent;
|
import ru.m.puzzlez.proto.event.GameEvent;
|
||||||
import ru.m.puzzlez.proto.event.gameaction.Action;
|
import ru.m.puzzlez.proto.event.gameaction.Action;
|
||||||
@@ -38,7 +37,7 @@ import ru.m.puzzlez.view.popup.PreviewPopup;
|
|||||||
L.d("Frame", '$ID: ${state.preset.image.source}:${state.preset.image.id}');
|
L.d("Frame", '$ID: ${state.preset.image.source}:${state.preset.image.id}');
|
||||||
onHide();
|
onHide();
|
||||||
if (state.online) {
|
if (state.online) {
|
||||||
game = new NetworkGame(state);
|
// game = new NetworkGame(state);
|
||||||
} else {
|
} else {
|
||||||
game = new Game(state);
|
game = new Game(state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import hw.view.form.ToggleButtonView;
|
|||||||
import hw.view.frame.FrameSwitcher;
|
import hw.view.frame.FrameSwitcher;
|
||||||
import hw.view.frame.FrameView;
|
import hw.view.frame.FrameView;
|
||||||
import ru.m.puzzlez.game.GameUtil;
|
import ru.m.puzzlez.game.GameUtil;
|
||||||
import ru.m.puzzlez.net.Network;
|
|
||||||
import ru.m.puzzlez.proto.game.ImageId;
|
import ru.m.puzzlez.proto.game.ImageId;
|
||||||
import ru.m.puzzlez.view.common.PresetView;
|
import ru.m.puzzlez.view.common.PresetView;
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ import ru.m.puzzlez.view.common.PresetView;
|
|||||||
|
|
||||||
@:provide var switcher:FrameSwitcher;
|
@:provide var switcher:FrameSwitcher;
|
||||||
|
|
||||||
@:provide var network:Network;
|
// @:provide var network:Network;
|
||||||
private var imageId:ImageId;
|
private var imageId:ImageId;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
@@ -56,7 +55,7 @@ import ru.m.puzzlez.view.common.PresetView;
|
|||||||
|
|
||||||
private function start(online:Bool = false):Void {
|
private function start(online:Bool = false):Void {
|
||||||
if (online) {
|
if (online) {
|
||||||
network.createGame(imageView.state.preset).then(state -> switcher.change(GameFrame.ID, state));
|
// network.createGame(imageView.state.preset).then(state -> switcher.change(GameFrame.ID, state));
|
||||||
} else {
|
} else {
|
||||||
switcher.change(GameFrame.ID, imageView.state);
|
switcher.change(GameFrame.ID, imageView.state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ views:
|
|||||||
geometry.margin.left: 15
|
geometry.margin.left: 15
|
||||||
text: Network
|
text: Network
|
||||||
+onPress: ~start(true)
|
+onPress: ~start(true)
|
||||||
visible: true
|
visible: false
|
||||||
- id: image
|
- id: image
|
||||||
$type: ru.m.puzzlez.view.common.PresetView
|
$type: ru.m.puzzlez.view.common.PresetView
|
||||||
geometry.stretch: true
|
geometry.stretch: true
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import hw.view.frame.FrameSwitcher;
|
|||||||
import hw.view.frame.FrameView;
|
import hw.view.frame.FrameView;
|
||||||
import ru.m.puzzlez.FileUtil;
|
import ru.m.puzzlez.FileUtil;
|
||||||
import ru.m.puzzlez.image.ImageSourceBundle;
|
import ru.m.puzzlez.image.ImageSourceBundle;
|
||||||
import ru.m.puzzlez.net.NetworkSource;
|
|
||||||
import ru.m.puzzlez.proto.game.GameStatus;
|
import ru.m.puzzlez.proto.game.GameStatus;
|
||||||
import ru.m.puzzlez.storage.FileStorage;
|
import ru.m.puzzlez.storage.FileStorage;
|
||||||
import ru.m.puzzlez.storage.GameStorage;
|
import ru.m.puzzlez.storage.GameStorage;
|
||||||
@@ -29,7 +28,6 @@ import ru.m.update.Updater;
|
|||||||
@:provide var fileStorage:FileStorage;
|
@:provide var fileStorage:FileStorage;
|
||||||
@:provide var gameStorage:GameStorage;
|
@:provide var gameStorage:GameStorage;
|
||||||
@:provide var sourceBundle:ImageSourceBundle;
|
@:provide var sourceBundle:ImageSourceBundle;
|
||||||
@:provide var networkSource:NetworkSource;
|
|
||||||
|
|
||||||
private var fileSource:ImageListConfig = {title: "Files", sourceId: "file"};
|
private var fileSource:ImageListConfig = {title: "Files", sourceId: "file"};
|
||||||
private var startedGames:GameListConfig = {
|
private var startedGames:GameListConfig = {
|
||||||
@@ -42,10 +40,6 @@ import ru.m.update.Updater;
|
|||||||
source: gameStorage,
|
source: gameStorage,
|
||||||
filter: ["status" => GameStatus.COMPLETE]
|
filter: ["status" => GameStatus.COMPLETE]
|
||||||
};
|
};
|
||||||
private var networkGames:GameListConfig = {
|
|
||||||
title: "Network",
|
|
||||||
source: networkSource
|
|
||||||
};
|
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super(ID);
|
super(ID);
|
||||||
|
|||||||
@@ -39,10 +39,6 @@ views:
|
|||||||
$type: hw.view.form.ButtonView
|
$type: hw.view.form.ButtonView
|
||||||
text: Completed
|
text: Completed
|
||||||
+onPress: ~showGames(completedGames)
|
+onPress: ~showGames(completedGames)
|
||||||
- id: networkButton
|
|
||||||
$type: hw.view.form.ButtonView
|
|
||||||
text: Network
|
|
||||||
+onPress: ~showGames(networkGames)
|
|
||||||
- $type: hw.view.form.ButtonView
|
- $type: hw.view.form.ButtonView
|
||||||
text: Upload
|
text: Upload
|
||||||
geometry.margin.left: 30
|
geometry.margin.left: 30
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package ru.m;
|
|
||||||
|
|
||||||
import hw.signal.Signal;
|
|
||||||
import promhx.Deferred;
|
|
||||||
import promhx.Promise;
|
|
||||||
|
|
||||||
class SignalUtil {
|
|
||||||
public static function next<T>(signal:Signal<T>):Promise<T> {
|
|
||||||
var d:Deferred<T> = new Deferred<T>();
|
|
||||||
var receiver:T->Void;
|
|
||||||
receiver = (value:T) -> {
|
|
||||||
signal.disconnect(receiver);
|
|
||||||
d.resolve(value);
|
|
||||||
};
|
|
||||||
signal.connect(receiver);
|
|
||||||
return d.promise();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
const gulp = require("gulp");
|
|
||||||
const fs = require("fs");
|
|
||||||
const fse = require("fs-extra");
|
|
||||||
const path = require("path");
|
|
||||||
const through = require("through2");
|
|
||||||
|
|
||||||
class Package {
|
|
||||||
constructor(platform, type, version, versionInt) {
|
|
||||||
this.platform = platform;
|
|
||||||
this.type = type;
|
|
||||||
this.version = version;
|
|
||||||
this.versionInt = versionInt;
|
|
||||||
}
|
|
||||||
|
|
||||||
get key() {
|
|
||||||
return [this.platform, this.type].join(":");
|
|
||||||
}
|
|
||||||
|
|
||||||
static getPlatform(filename) {
|
|
||||||
for (const [platform, r] of [
|
|
||||||
["android", /^.*?\.apk$/],
|
|
||||||
["linux", /^.*?\.deb$/],
|
|
||||||
["linux", /^.*?linux\.tar\.gz$/],
|
|
||||||
["windows", /^.*?win\.zip$/],
|
|
||||||
["windows", /^.*?\.exe$/],
|
|
||||||
]) {
|
|
||||||
if (r.test(filename)) {
|
|
||||||
return platform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static getType(filename) {
|
|
||||||
for (const [type, r] of [
|
|
||||||
["apk", /^.*?\.apk$/],
|
|
||||||
["deb", /^.*?\.deb$/],
|
|
||||||
["archive", /^.*?\.tar\.gz$/],
|
|
||||||
["archive", /^.*?\.zip$/],
|
|
||||||
["exe", /^.*?\.exe$/],
|
|
||||||
]) {
|
|
||||||
if (r.test(filename)) {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static getVersion(filename) {
|
|
||||||
const m = /(\d+)\.(\d+)\.(\d+)/.exec(filename);
|
|
||||||
if (m) {
|
|
||||||
return [
|
|
||||||
m[0],
|
|
||||||
parseInt(m[1]) * 10000 + parseInt(m[2]) * 100 + parseInt(m[3]),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static parseFilename(filename) {
|
|
||||||
const platform = this.getPlatform(filename);
|
|
||||||
const type = this.getType(filename);
|
|
||||||
const version = this.getVersion(filename);
|
|
||||||
if (platform && type && version) {
|
|
||||||
return new Package(platform, type, version[0], version[1]);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = (name, version, publishDir, publishUrl) =>
|
|
||||||
function publish(cb) {
|
|
||||||
const packages = {};
|
|
||||||
fse.ensureDirSync(publishDir);
|
|
||||||
return gulp.series([
|
|
||||||
function copy() {
|
|
||||||
return gulp
|
|
||||||
.src("target/app/@(android|archive|debian|installer)/*")
|
|
||||||
.pipe(
|
|
||||||
through.obj(function (file, enc, cb) {
|
|
||||||
const pack = Package.parseFilename(file.path);
|
|
||||||
if (pack) {
|
|
||||||
this.push(file);
|
|
||||||
}
|
|
||||||
cb(null);
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.pipe(gulp.dest(publishDir));
|
|
||||||
},
|
|
||||||
function generate() {
|
|
||||||
return gulp
|
|
||||||
.src(`${publishDir}/*/*`)
|
|
||||||
.pipe(
|
|
||||||
through.obj(function (file, enc, cb) {
|
|
||||||
const basepath = file.path.replace(file.base + path.sep, "");
|
|
||||||
const pack = Package.parseFilename(file.path);
|
|
||||||
if (pack) {
|
|
||||||
if (
|
|
||||||
!packages[pack.key] ||
|
|
||||||
packages[pack.key].versionInt < pack.versionInt
|
|
||||||
) {
|
|
||||||
packages[pack.key] = {
|
|
||||||
platform: pack.platform,
|
|
||||||
type: pack.type,
|
|
||||||
version: pack.version,
|
|
||||||
versionInt: pack.versionInt,
|
|
||||||
path: basepath,
|
|
||||||
filename: basepath.split(path.sep).pop(),
|
|
||||||
url: `${publishUrl}/${basepath.replace(path.sep, "/")}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cb(null);
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.on("end", function () {
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(publishDir, "packages.json"),
|
|
||||||
JSON.stringify(
|
|
||||||
{
|
|
||||||
name: name,
|
|
||||||
version: version,
|
|
||||||
packages: Object.values(packages),
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
4
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
])(cb);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.Package = Package;
|
|
||||||
Reference in New Issue
Block a user