Compare commits
3 Commits
af32320ec4
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e67513897 | |||
| e41d461ba6 | |||
| acf0706bef |
10
README.md
10
README.md
@@ -1,9 +1,13 @@
|
||||
# Puzzlez
|
||||
# Puzzle'z
|
||||
|
||||
Puzzle game
|
||||
|
||||

|
||||
|
||||
## Play
|
||||
|
||||
https://shmyga.ru/puzzlez/html5/index.html
|
||||
|
||||
## Packages
|
||||
## Releases
|
||||
|
||||
https://git.shmyga.ru/InfernalGames/-/packages/generic/puzzlez
|
||||
https://git.shmyga.ru/InfernalGames/puzzlez/releases
|
||||
|
||||
BIN
docs/Screenshot_2026-05-04_15-42-42.jpg
Normal file
BIN
docs/Screenshot_2026-05-04_15-42-42.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 357 KiB |
10
gulpfile.js
10
gulpfile.js
@@ -4,8 +4,11 @@ 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");
|
||||
|
||||
Project.useRuffle();
|
||||
|
||||
if (packageInfo.haxe) {
|
||||
Haxe.VERSION = packageInfo.haxe;
|
||||
}
|
||||
@@ -63,6 +66,9 @@ const config = new Project.Config({
|
||||
flags: ["proto_debug"],
|
||||
});
|
||||
|
||||
const host = argv.host || "localhost";
|
||||
const port = argv.port || 5000;
|
||||
|
||||
const app = new Project(
|
||||
Project.BuildSystem.OPENFL,
|
||||
[
|
||||
@@ -87,6 +93,10 @@ const app = new Project(
|
||||
width: 1280,
|
||||
height: 768,
|
||||
},
|
||||
macros: [
|
||||
`CompilationOption.set('host','${host}')`,
|
||||
`CompilationOption.set('port',${port})`,
|
||||
],
|
||||
flags: ["app"],
|
||||
}),
|
||||
).bind(module, gulp);
|
||||
|
||||
475
package-lock.json
generated
475
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@
|
||||
"gulp-add": "0.0.2",
|
||||
"gulp-clean": "^0.4.0",
|
||||
"gulp-cli": "^2.2.0",
|
||||
"gulp-haxetool": "^0.1.9",
|
||||
"gulp-haxetool": "^0.2.1",
|
||||
"yargs": "^13.2.4"
|
||||
},
|
||||
"haxeDependencies": {
|
||||
@@ -20,8 +20,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,7 +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.render.part.IPartBuilder;
|
||||
import ru.m.puzzlez.settings.Settings;
|
||||
import ru.m.puzzlez.source.AssetImageSource;
|
||||
@@ -19,14 +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;
|
||||
sourceBundle.register(new AssetImageSource());
|
||||
sourceBundle.register(new FileImageSource());
|
||||
sourceBundle.register(new PixabayImageSource(CompilationOption.get("PIXABAY_KEY")));
|
||||
@@ -39,6 +36,5 @@ class PuzzlezApp {
|
||||
app.icon = openfl.Assets.getBitmapData("resources/icon.png");
|
||||
app.view = new PuzzlezAppView();
|
||||
L.d("Puzzlez", "started");
|
||||
network.auth();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ import hw.connect.ConnectionFactory;
|
||||
import hw.connect.IConnection;
|
||||
import hw.signal.Signal;
|
||||
import hw.storage.SharedObjectStorage;
|
||||
import promhx.Deferred;
|
||||
import promhx.Promise;
|
||||
import ru.m.data.DataSource;
|
||||
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;
|
||||
@@ -14,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;
|
||||
@@ -23,20 +21,7 @@ import ru.m.puzzlez.proto.pack.NotificationResponse;
|
||||
import ru.m.puzzlez.proto.pack.Request;
|
||||
import ru.m.puzzlez.proto.pack.Response;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@:provide class Network implements DataSource<GameState> {
|
||||
@: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();
|
||||
@@ -66,17 +51,17 @@ class SignalUtil {
|
||||
|
||||
public function auth():Promise<User> {
|
||||
connection.send(new Request().setAuth(new AuthRequest().setUser(restoreUser())));
|
||||
return SignalUtil.next(userSignal);
|
||||
return userSignal.next();
|
||||
}
|
||||
|
||||
public function createGame(preset:GamePreset):Promise<GameState> {
|
||||
connection.send(new Request().setCreate(new GameCreateRequest().setPreset(preset)));
|
||||
return SignalUtil.next(joinSignal);
|
||||
connection.send(new Request().setJoin(new GameJoinRequest().setPreset(preset)));
|
||||
return joinSignal.next();
|
||||
}
|
||||
|
||||
public function joinGame(gameId:String):Promise<GameState> {
|
||||
connection.send(new Request().setJoin(new GameJoinRequest().setGameId(gameId)));
|
||||
return SignalUtil.next(joinSignal);
|
||||
return joinSignal.next();
|
||||
}
|
||||
|
||||
public function leaveGame():Void {
|
||||
@@ -117,7 +102,7 @@ class SignalUtil {
|
||||
|
||||
public function getPage(page:Page):Promise<DataPage<GameState>> {
|
||||
connection.send(new Request().setList(new GameListRequest().setCount(page.count).setPage(page.index)));
|
||||
return SignalUtil.next(listSignal).then((list:GameListResponse) -> ({
|
||||
return listSignal.next().then((list:GameListResponse) -> ({
|
||||
page: {
|
||||
index: list.page,
|
||||
count: list.count,
|
||||
@@ -128,4 +113,8 @@ class SignalUtil {
|
||||
data: list.games,
|
||||
}));
|
||||
}
|
||||
|
||||
public function get(id:String):GameState {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ 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;
|
||||
|
||||
@@ -25,6 +25,7 @@ class NginxImageSource implements ImageSource {
|
||||
public var id(default, never):String = "nginx";
|
||||
|
||||
private var baseUrl:String;
|
||||
private var cache:Map<String, Promise<NginxResponse>> = new Map();
|
||||
|
||||
public function new(baseUrl:String) {
|
||||
this.baseUrl = baseUrl;
|
||||
@@ -36,8 +37,11 @@ class NginxImageSource implements ImageSource {
|
||||
|
||||
public function getPage(page:Page):Promise<DataPage<ImageId>> {
|
||||
var category = page.filter.get("category");
|
||||
return new JsonLoader<NginxResponse>().GET(category != null ? this.baseUrl + category + "/" : this.baseUrl)
|
||||
.then((response:NginxResponse) -> {
|
||||
var url = category != null ? this.baseUrl + category + "/" : this.baseUrl;
|
||||
if (!this.cache.exists(url)) {
|
||||
this.cache.set(url, new JsonLoader<NginxResponse>().GET(url));
|
||||
}
|
||||
return this.cache.get(url).then((response:NginxResponse) -> {
|
||||
var data:Array<ImageId> = [];
|
||||
for (item in response) {
|
||||
if (item.type == NginxResponseItemType.FILE) {
|
||||
@@ -45,6 +49,7 @@ class NginxImageSource implements ImageSource {
|
||||
data.push(new ImageId().setSource(id).setId(itemId));
|
||||
}
|
||||
}
|
||||
data = data.slice(page.index * page.count, (page.index + 1) * page.count);
|
||||
return {
|
||||
page: page,
|
||||
data: data,
|
||||
@@ -55,12 +60,12 @@ class NginxImageSource implements ImageSource {
|
||||
|
||||
public function load(id:String, thumb:Bool = false):Promise<ImageValue> {
|
||||
var url = this.baseUrl + StringTools.replace(id, "@", "/");
|
||||
if (thumb) {
|
||||
// TODO: default size by screen width?
|
||||
var width = thumb ? 360 : 1920;
|
||||
var parts = url.split(".");
|
||||
var index = parts.length - 2;
|
||||
parts[index] = parts[index] + "-thumbnail";
|
||||
parts[index] = parts[index] + '-w${width}';
|
||||
url = parts.join(".");
|
||||
}
|
||||
return Promise.promise(ImageValue.URL(url));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.m.puzzlez.view;
|
||||
|
||||
import ru.m.puzzlez.net.Network;
|
||||
import hw.view.data.DataView;
|
||||
import hw.view.form.ButtonView;
|
||||
import hw.view.frame.FrameSwitcher;
|
||||
@@ -29,7 +28,6 @@ import ru.m.update.Updater;
|
||||
@:provide var fileStorage:FileStorage;
|
||||
@:provide var gameStorage:GameStorage;
|
||||
@:provide var sourceBundle:ImageSourceBundle;
|
||||
@:provide var network:Network;
|
||||
|
||||
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: network
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
@@ -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