Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b9c3655d1 |
+2
-2
@@ -1,5 +1,5 @@
|
||||
PROJECT=puzzlez
|
||||
VERSION=$(grep -m 1 'version' ./package.json | grep -oP '"version"\s*:\s*"\K\d+\.\d+.\d+')
|
||||
#VERSION=$(grep -m 1 'version' ./package.json | grep -oP '"version"\s*:\s*"\K\d+\.\d+.\d+')
|
||||
SDK_PATH=$HOME/sdk
|
||||
PUBLISH_PATH=$HOME/public/$PROJECT
|
||||
BUILD_PATH=./build
|
||||
@@ -8,7 +8,7 @@ KEY_STORE=<keystore.jks>
|
||||
KEY_PASS=<passphrase>
|
||||
|
||||
# publish
|
||||
REPO=https://git.shmyga.ru/api/packages/InfernalGames
|
||||
PUBLISH_REPO=https://git.shmyga.ru/api/packages/InfernalGames
|
||||
PUBLISH_USER=<username>
|
||||
PUBLISH_PASSWORD=<passphrase>
|
||||
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
/build/
|
||||
build/
|
||||
target/
|
||||
src-gen/
|
||||
out/
|
||||
@@ -10,8 +10,8 @@ out/
|
||||
.idea/
|
||||
.ideaDataSources/
|
||||
config.json
|
||||
/node_modules
|
||||
/log
|
||||
/ansible/*.retry
|
||||
node_modules
|
||||
log
|
||||
ansible/*.retry
|
||||
.npmrc
|
||||
.env
|
||||
@@ -0,0 +1,23 @@
|
||||
modules = ["."]
|
||||
|
||||
[presets.docker]
|
||||
variables.docker_target = "web"
|
||||
variables.docker_name = "{{ project_name }}-web"
|
||||
|
||||
[presets.docker.tasks.build.compose]
|
||||
priority = 1
|
||||
variables.sdk_path = "{{ 'SDK_PATH' | env('$HOME/sdk') }}"
|
||||
variables.publish_path = "{{ 'PUBLISH_PATH' | env('$HOME/public/' + project_name) }}"
|
||||
variables.build_path = "{{ 'BUILD_PATH' | env('./build') }}"
|
||||
variables.target_path = "{{ 'TARGET_PATH' | env('./target') }}"
|
||||
commands = [
|
||||
"mkdir -p \"{{ sdk_path }}\" \"{{ publish_path }}\" \"{{ build_path }}\" \"{{ target_path }}\" \"src-gen\"",
|
||||
"docker compose run --rm --user $(id -u):$(id -g) --build --remove-orphans builder",
|
||||
]
|
||||
|
||||
[presets.gitea]
|
||||
variables.publish_artefacts.debian = "target/app/debian/{{ project_name }}_{{ project_version }}_all.deb"
|
||||
variables.publish_artefacts.android = "target/app/android/{{ project_name }}_{{ project_version }}.apk"
|
||||
variables.publish_artefacts.archive_linux = "target/app/archive/{{ project_name }}_{{ project_version }}_linux.tar.gz"
|
||||
variables.publish_artefacts.archive_win = "target/app/archive/{{ project_name }}_{{ project_version }}_win.zip"
|
||||
variables.publish_artefacts.installer = "target/app/installer/{{ project_name }}_{{ project_version }}.exe"
|
||||
+2
-1
@@ -12,7 +12,8 @@ FROM base AS builder
|
||||
ENV GRADLE_USER_HOME=/sdk/gradle
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
RUN --mount=type=cache,target=/root/.npm \
|
||||
npm ci
|
||||
COPY gulpfile.js protohx.json ./
|
||||
COPY tasks ./tasks
|
||||
COPY config.example.json ./config.example.json
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
[defaults]
|
||||
hash_behaviour = merge
|
||||
host_key_checking = False
|
||||
#callback_whitelist = profile_tasks
|
||||
display_skipped_hosts = False
|
||||
stdout_callback = yaml
|
||||
bin_ansible_callbacks = True
|
||||
|
||||
[ssh_connection]
|
||||
pipelining = True
|
||||
ssh_args = -o ForwardAgent=yes
|
||||
@@ -1,11 +0,0 @@
|
||||
---
|
||||
- hosts: all
|
||||
vars:
|
||||
ansible_user: "{{ deploy_user }}"
|
||||
roles:
|
||||
- ansible-deploy
|
||||
- build
|
||||
post_tasks:
|
||||
- include_role:
|
||||
name: ansible-deploy
|
||||
tasks_from: complete.yml
|
||||
@@ -1,2 +0,0 @@
|
||||
all:
|
||||
hosts: localhost
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
project_name: puzzlez
|
||||
project_user: holop
|
||||
|
||||
deploy_user: "{{ project_user }}"
|
||||
deploy_project: "{{ project_name }}"
|
||||
deploy_repo_url: "git@bitbucket.org:infernalgames/{{ project_name }}.git"
|
||||
deploy_repo_version: master
|
||||
deploy_npm: yes
|
||||
@@ -1,4 +0,0 @@
|
||||
all:
|
||||
hosts: shmyga.ru
|
||||
vars:
|
||||
config_src: "/home/holop/puzzlez/config.json"
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
- name: ansible-deploy
|
||||
src: git@bitbucket.org:shmyga/ansible-deploy.git
|
||||
version: master
|
||||
scm: git
|
||||
@@ -1,2 +0,0 @@
|
||||
config_src: "{{ deploy_release_dir }}/config.{{ inventory_hostname }}.json"
|
||||
config_dest: "{{ deploy_release_dir }}/config.json"
|
||||
@@ -1,11 +0,0 @@
|
||||
---
|
||||
- name: "Copy config"
|
||||
copy:
|
||||
src: "{{ config_src }}"
|
||||
dest: "{{ config_dest }}"
|
||||
remote_src: true
|
||||
|
||||
- name: "Gulp build"
|
||||
command: "{{ deploy_release_dir }}/node_modules/.bin/gulp default"
|
||||
args:
|
||||
chdir: "{{ deploy_release_dir }}"
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"SdkDir": "C:\\sdk",
|
||||
"SdkDir": "$HOME/sdk",
|
||||
"BuildDir": null,
|
||||
"PublishDir": "",
|
||||
"PublishDir": "$HOME/public/puzzlez",
|
||||
"PublishUrl": "https://shmyga.ru/repo/puzzlez",
|
||||
"Develop": false,
|
||||
"Key": {
|
||||
|
||||
+6
-3
@@ -5,17 +5,20 @@ const packageInfo = require("./package.json");
|
||||
const { System, Sdk, Haxe, Project } = require("gulp-haxetool");
|
||||
const dateformat = require("dateformat");
|
||||
const publish = require("./tasks/gulp-publish");
|
||||
const os = require("os");
|
||||
|
||||
const resolvePath = (path) => path.replace("$HOME", os.homedir());
|
||||
|
||||
if (packageInfo.haxe) {
|
||||
Haxe.VERSION = packageInfo.haxe;
|
||||
}
|
||||
|
||||
if (Config.SdkDir) {
|
||||
Sdk.dir = Config.SdkDir;
|
||||
Sdk.dir = resolvePath(Config.SdkDir);
|
||||
}
|
||||
|
||||
if (Config.BuildDir) {
|
||||
Haxe.buildDir = Config.BuildDir;
|
||||
Haxe.buildDir = resolvePath(Config.BuildDir);
|
||||
}
|
||||
|
||||
exports.clean = function clean() {
|
||||
@@ -104,7 +107,7 @@ const server = new Project(
|
||||
module.exports.publish = publish(
|
||||
packageInfo.name,
|
||||
packageInfo.version,
|
||||
Config.PublishDir,
|
||||
resolvePath(Config.PublishDir),
|
||||
Config.PublishUrl,
|
||||
);
|
||||
|
||||
|
||||
+5
-3
@@ -1,7 +1,10 @@
|
||||
{
|
||||
"name": "puzzlez",
|
||||
"version": "0.6.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "gulp",
|
||||
"dev": "gulp app:flash:test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dateformat": "^3.0.3",
|
||||
"fs-extra": "^10.0.0",
|
||||
@@ -20,8 +23,7 @@
|
||||
"svg": "1.1.3",
|
||||
"protohx": "0.4.6",
|
||||
"yield": "3.2.2",
|
||||
"formatter": "1.16.0",
|
||||
"hxWebSockets": "1.4.0"
|
||||
"formatter": "1.16.0"
|
||||
},
|
||||
"haxe": "4.2.5"
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ import hw.app.App;
|
||||
import hw.app.Const;
|
||||
import hw.log.TraceLogger;
|
||||
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.settings.Settings;
|
||||
import ru.m.puzzlez.source.AssetImageSource;
|
||||
@@ -20,15 +18,12 @@ import ru.m.update.Updater;
|
||||
class PuzzlezApp {
|
||||
@:provide static var updater:Updater;
|
||||
@:provide static var sourceBundle:ImageSourceBundle;
|
||||
@:provide static var network:Network;
|
||||
|
||||
public static function main() {
|
||||
// ToDo: fix @:provide macro
|
||||
Settings;
|
||||
IPartBuilder;
|
||||
GameStorage;
|
||||
Network;
|
||||
NetworkSource;
|
||||
sourceBundle.register(new AssetImageSource());
|
||||
sourceBundle.register(new FileImageSource());
|
||||
sourceBundle.register(new PixabayImageSource(CompilationOption.get("PIXABAY_KEY")));
|
||||
@@ -41,6 +36,5 @@ class PuzzlezApp {
|
||||
app.icon = openfl.Assets.getBitmapData("resources/icon.png");
|
||||
app.view = new PuzzlezAppView();
|
||||
L.d("Puzzlez", "started");
|
||||
network.auth();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import hw.connect.IConnection;
|
||||
import hw.signal.Signal;
|
||||
import hw.storage.SharedObjectStorage;
|
||||
import promhx.Promise;
|
||||
import ru.m.data.IDataSource;
|
||||
import ru.m.puzzlez.proto.core.User;
|
||||
import ru.m.puzzlez.proto.event.GameAction;
|
||||
import ru.m.puzzlez.proto.event.GameEvent;
|
||||
@@ -12,7 +13,6 @@ import ru.m.puzzlez.proto.game.GamePreset;
|
||||
import ru.m.puzzlez.proto.game.GameState;
|
||||
import ru.m.puzzlez.proto.pack.AuthRequest;
|
||||
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.GameLeaveRequest;
|
||||
import ru.m.puzzlez.proto.pack.GameListRequest;
|
||||
@@ -21,26 +21,21 @@ import ru.m.puzzlez.proto.pack.NotificationResponse;
|
||||
import ru.m.puzzlez.proto.pack.Request;
|
||||
import ru.m.puzzlez.proto.pack.Response;
|
||||
|
||||
using ru.m.SignalUtil;
|
||||
|
||||
@:provide class Network {
|
||||
@:provide class Network implements IDataSource<String, GameState> {
|
||||
public var userSignal:Signal<User> = new Signal();
|
||||
public var notificationSignal:Signal<NotificationResponse> = new Signal();
|
||||
public var listSignal:Signal<GameListResponse> = new Signal();
|
||||
public var joinSignal:Signal<GameState> = 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 static var USER_KEY = "user";
|
||||
|
||||
public function new() {
|
||||
storage = new SharedObjectStorage("network/2");
|
||||
var host:String = CompilationOption.get("host");
|
||||
var port:Int = cast(CompilationOption.get("port"), Int);
|
||||
connection = ConnectionFactory.buildClientConnection(host, port, Response);
|
||||
connection = ConnectionFactory.buildClientConnection("127.0.0.1", 5000, Response);
|
||||
connection.handler.connect(onConnectionChange);
|
||||
connection.receiveHandler.connect(onReceivePacket);
|
||||
connection.connect().catchError(_ -> {});
|
||||
@@ -50,23 +45,17 @@ using ru.m.SignalUtil;
|
||||
if (storage.exists(USER_KEY)) {
|
||||
return storage.read(USER_KEY);
|
||||
} else {
|
||||
var uuid = IdUtil.generate();
|
||||
return new User().setUuid(uuid).setName('Anonimus #${uuid}');
|
||||
return new User().setName('Anonimus #${IdUtil.generate()}');
|
||||
}
|
||||
}
|
||||
|
||||
public function auth():Promise<User> {
|
||||
try {
|
||||
connection.send(new Request().setAuth(new AuthRequest().setUser(restoreUser())));
|
||||
return userSignal.next();
|
||||
} catch (error:Dynamic) {
|
||||
L.w("network", "auth", error);
|
||||
return Promise.promise(null);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -110,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 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.GameEvent;
|
||||
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 {
|
||||
public var state(default, null):GameState;
|
||||
@@ -21,12 +19,8 @@ class NetworkGame implements IGame {
|
||||
}
|
||||
|
||||
public function action(action:GameAction):Void {
|
||||
if (action.action == Action.MOVE) {
|
||||
events.emit(EventUtil.action(action));
|
||||
} else {
|
||||
network.sendGameAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
public function start():Void {
|
||||
events.emit(new GameEvent().setStart(new GameStart().setState(state)));
|
||||
|
||||
@@ -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 ru.m.puzzlez.game.Game;
|
||||
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.GameEvent;
|
||||
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}');
|
||||
onHide();
|
||||
if (state.online) {
|
||||
game = new NetworkGame(state);
|
||||
// game = new NetworkGame(state);
|
||||
} else {
|
||||
game = new Game(state);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import hw.view.form.ToggleButtonView;
|
||||
import hw.view.frame.FrameSwitcher;
|
||||
import hw.view.frame.FrameView;
|
||||
import ru.m.puzzlez.game.GameUtil;
|
||||
import ru.m.puzzlez.net.Network;
|
||||
import ru.m.puzzlez.proto.game.ImageId;
|
||||
import ru.m.puzzlez.view.common.PresetView;
|
||||
|
||||
@@ -18,7 +17,7 @@ import ru.m.puzzlez.view.common.PresetView;
|
||||
|
||||
@:provide var switcher:FrameSwitcher;
|
||||
|
||||
@:provide var network:Network;
|
||||
// @:provide var network:Network;
|
||||
private var imageId:ImageId;
|
||||
|
||||
public function new() {
|
||||
@@ -56,7 +55,7 @@ import ru.m.puzzlez.view.common.PresetView;
|
||||
|
||||
private function start(online:Bool = false):Void {
|
||||
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 {
|
||||
switcher.change(GameFrame.ID, imageView.state);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ views:
|
||||
geometry.margin.left: 15
|
||||
text: Network
|
||||
+onPress: ~start(true)
|
||||
visible: true
|
||||
visible: false
|
||||
- id: image
|
||||
$type: ru.m.puzzlez.view.common.PresetView
|
||||
geometry.stretch: true
|
||||
|
||||
@@ -6,7 +6,6 @@ import hw.view.frame.FrameSwitcher;
|
||||
import hw.view.frame.FrameView;
|
||||
import ru.m.puzzlez.FileUtil;
|
||||
import ru.m.puzzlez.image.ImageSourceBundle;
|
||||
import ru.m.puzzlez.net.NetworkSource;
|
||||
import ru.m.puzzlez.proto.game.GameStatus;
|
||||
import ru.m.puzzlez.storage.FileStorage;
|
||||
import ru.m.puzzlez.storage.GameStorage;
|
||||
@@ -29,7 +28,6 @@ import ru.m.update.Updater;
|
||||
@:provide var fileStorage:FileStorage;
|
||||
@:provide var gameStorage:GameStorage;
|
||||
@:provide var sourceBundle:ImageSourceBundle;
|
||||
@:provide var networkSource:NetworkSource;
|
||||
|
||||
private var fileSource:ImageListConfig = {title: "Files", sourceId: "file"};
|
||||
private var startedGames:GameListConfig = {
|
||||
@@ -42,10 +40,6 @@ import ru.m.update.Updater;
|
||||
source: gameStorage,
|
||||
filter: ["status" => GameStatus.COMPLETE]
|
||||
};
|
||||
private var networkGames:GameListConfig = {
|
||||
title: "Network",
|
||||
source: networkSource
|
||||
};
|
||||
|
||||
public function new() {
|
||||
super(ID);
|
||||
|
||||
@@ -39,10 +39,6 @@ views:
|
||||
$type: hw.view.form.ButtonView
|
||||
text: Completed
|
||||
+onPress: ~showGames(completedGames)
|
||||
- id: networkButton
|
||||
$type: hw.view.form.ButtonView
|
||||
text: Network
|
||||
+onPress: ~showGames(networkGames)
|
||||
- $type: hw.view.form.ButtonView
|
||||
text: Upload
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ import ru.m.puzzlez.proto.pack.GameListResponse;
|
||||
import ru.m.puzzlez.proto.pack.GameListRequest;
|
||||
import hw.connect.session.ProtoSession;
|
||||
import hw.log.BaseLogger.LoggerUtil;
|
||||
import ru.m.puzzlez.game.Game;
|
||||
import ru.m.puzzlez.game.GameUtil;
|
||||
import ru.m.puzzlez.image.Game;
|
||||
import ru.m.puzzlez.image.GameUtil;
|
||||
import ru.m.puzzlez.proto.core.User;
|
||||
import ru.m.puzzlez.proto.event.GameAction;
|
||||
import ru.m.puzzlez.proto.event.GameEvent;
|
||||
|
||||
Reference in New Issue
Block a user