4 Commits

Author SHA1 Message Date
0b24c03068 style: format code 2026-07-13 22:41:32 +03:00
b24c71678e [proto] add game event proto messages 2026-07-13 22:20:37 +03:00
c34308ed7c build: use ruffle 2026-07-13 22:20:27 +03:00
a3be62eec7 docs: add screenshot 2026-05-04 16:24:41 +03:00
213 changed files with 15238 additions and 15322 deletions

View File

@@ -8,5 +8,6 @@ indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.yaml]
indent_size = 2
[*.md]
max_line_length = off
trim_trailing_whitespace = false

View File

@@ -19,3 +19,6 @@ DOCKER_PROJECTS=(
DOCKER_ARGS=(
"PROJECT_NAME=$PROJECT"
)
NEKO_SDK="$SDK_PATH/neko/2.2.0"
HAXE_SDK="$SDK_PATH/haxe/4.2.5"

View File

@@ -1,9 +1,11 @@
# Tankz
# Tank'z
![Tank'z](docs/Screenshot_2026-05-04_16-22-53.png "Tank'z")
## Play
https://shmyga.ru/tankz/html5/index.html
## Packages
## Releases
https://git.shmyga.ru/InfernalGames/-/packages/generic/tankz
https://git.shmyga.ru/InfernalGames/tankz/releases

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@@ -1,11 +1,13 @@
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 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");
Project.useRuffle();
if (packageInfo.haxe) {
Haxe.VERSION = packageInfo.haxe;
@@ -20,7 +22,7 @@ if (Config.BuildDir) {
}
exports.clean = function clean() {
return gulp.src('target/*', {read: false}).pipe(gulpClean());
return gulp.src("target/*", { read: false }).pipe(gulpClean());
};
exports.setup = function setup() {
@@ -49,32 +51,25 @@ exports.generate = function generate() {
*/
const config = new Project.Config({
meta: {
title: 'Tank\'z',
filename: 'tankz',
icon: 'src/client/resources/icon.png',
pack: 'ru.m.tankz',
author: 'shmyga <shmyga.z@gmail.com>',
company: 'MegaLoMania',
version: packageInfo.version + (Config.Develop ? '-SNAPSHOT' : ''),
title: "Tank'z",
filename: "tankz",
icon: "src/client/resources/icon.png",
pack: "ru.m.tankz",
author: "shmyga <shmyga.z@gmail.com>",
company: "MegaLoMania",
version: packageInfo.version + (Config.Develop ? "-SNAPSHOT" : ""),
},
key: Config.Key,
libs: packageInfo.haxeDependencies,
sources: [
'src/common/haxe',
'src-gen/haxe',
],
assets: [
'src/common/resources/config',
],
flags: [
'proto_debug',
],
sources: ["src/common/haxe", "src-gen/haxe"],
assets: ["src/common/resources/config"],
flags: ["proto_debug"],
macros: [
`CompilationOption.set('build','${dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss')}')`,
]
`CompilationOption.set('build','${dateformat(new Date(), "yyyy-mm-dd HH:MM:ss")}')`,
],
});
const host = argv.host || 'localhost';
const host = argv.host || "localhost";
const port = argv.port || 5000;
/**
@@ -90,16 +85,11 @@ const client = new Project(
Project.Platform.ANDROID,
],
config.branch({
name: 'client',
sources: [
'src/client/haxe',
],
main: 'ru.m.tankz.Client',
preloader: 'ru.m.tankz.Preloader',
assets: [
'src/common/resources/level',
'src/client/resources',
],
name: "client",
sources: ["src/client/haxe"],
main: "ru.m.tankz.Client",
preloader: "ru.m.tankz.Preloader",
assets: ["src/common/resources/level", "src/client/resources"],
meta: {
width: 1024,
height: 576,
@@ -113,7 +103,7 @@ const client = new Project(
macros: [
`CompilationOption.set('host','${host}')`,
`CompilationOption.set('port',${port})`,
]
],
}),
).bind(module, gulp);
@@ -122,33 +112,23 @@ const client = new Project(
*/
const editor = new Project(
Project.BuildSystem.OPENFL,
[
Project.Platform.FLASH,
Project.Platform.HTML5,
Project.Platform.LINUX,
],
[Project.Platform.FLASH, Project.Platform.HTML5, Project.Platform.LINUX],
config.branch({
name: 'editor',
sources: [
'src/client/haxe',
'src/editor/haxe',
],
main: 'ru.m.tankz.editor.Editor',
preloader: 'ru.m.tankz.Preloader',
assets: [
'src/client/resources',
'src/editor/resources',
],
name: "editor",
sources: ["src/client/haxe", "src/editor/haxe"],
main: "ru.m.tankz.editor.Editor",
preloader: "ru.m.tankz.Preloader",
assets: ["src/client/resources", "src/editor/resources"],
meta: {
filename: 'editor',
pack: 'ru.m.tankz.editor',
filename: "editor",
pack: "ru.m.tankz.editor",
width: 1024,
height: 768,
},
flags: [
//'dev_layout',
]
})
],
}),
).bind(module, gulp);
/**
@@ -158,19 +138,22 @@ const server = new Project(
Project.BuildSystem.HAXE,
Project.Platform.CPP,
config.branch({
name: 'server',
sources: ['src/server/haxe'],
main: 'ru.m.tankz.server.Server',
assets: [
'src/common/resources/level',
]
name: "server",
sources: ["src/server/haxe"],
main: "ru.m.tankz.server.Server",
assets: ["src/common/resources/level"],
}),
).bind(module, gulp);
/**
* publish
*/
module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.PublishDir, Config.PublishUrl);
module.exports.publish = publish(
packageInfo.name,
packageInfo.version,
Config.PublishDir,
Config.PublishUrl,
);
/**
* default
@@ -178,37 +161,35 @@ module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.P
const defaultSeries = [
exports.clean,
exports.generate,
module.exports['client:flash:build'],
module.exports['client:flash:html'],
module.exports['client:html5:build'],
module.exports["client:flash:build"],
module.exports["client:flash:html"],
module.exports["client:html5:build"],
module.exports['editor:flash:build'],
module.exports['editor:flash:html'],
module.exports['editor:html5:build'],
module.exports["editor:flash:build"],
module.exports["editor:flash:html"],
module.exports["editor:html5:build"],
module.exports['server:cpp:build'],
module.exports["server:cpp:build"],
];
if (System.isLinux) {
defaultSeries.push(
module.exports['client:linux:build'],
module.exports['client:linux:archive'],
module.exports['client:linux:deb'],
module.exports["client:linux:build"],
module.exports["client:linux:archive"],
module.exports["client:linux:deb"],
module.exports['client:android:build'],
module.exports["client:android:build"],
);
}
if (System.isWindows) {
defaultSeries.push(
module.exports['client:windows:build'],
module.exports['client:windows:archive'],
module.exports['client:windows:installer'],
module.exports["client:windows:build"],
module.exports["client:windows:archive"],
module.exports["client:windows:installer"],
);
}
defaultSeries.push(
exports.publish,
);
defaultSeries.push(exports.publish);
module.exports.default = gulp.series(defaultSeries);

View File

@@ -1,5 +1,8 @@
{
"indentation": {
"character": " "
},
"wrapping": {
"maxLineLength": 120
}
}

13
package-lock.json generated
View File

@@ -1,18 +1,18 @@
{
"name": "tankz",
"version": "0.17.6",
"version": "0.18.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tankz",
"version": "0.17.6",
"version": "0.18.0",
"devDependencies": {
"dateformat": "^3.0.3",
"gulp": "^4.0.0",
"gulp-add": "0.0.2",
"gulp-clean": "^0.4.0",
"gulp-haxetool": "^0.1.9",
"gulp-haxetool": "^0.2.1",
"yargs": "^13.2.4"
}
},
@@ -3296,10 +3296,11 @@
}
},
"node_modules/gulp-haxetool": {
"version": "0.1.9",
"resolved": "https://registry.npmjs.org/gulp-haxetool/-/gulp-haxetool-0.1.9.tgz",
"integrity": "sha512-ABS3nWVrGMA0iLnIoOHl06zp6OOB9BCE5Nda0cpuaKVX2LGMPnJMhxPJNDQXvMhYTDnX90z2EpyIFDH6Pyv37A==",
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/gulp-haxetool/-/gulp-haxetool-0.2.1.tgz",
"integrity": "sha512-+p38E66G67AxYY1V8ZHRGlNG08EnfdEJezteKhocjBFjnGIguJrwFc0paGvL/zlyWJV1vSyfiLWN8J5HYZLjYg==",
"dev": true,
"license": "ISC",
"dependencies": {
"ansi-colors": "^1.1.0",
"async": "^2.6.0",

View File

@@ -7,7 +7,7 @@
"gulp": "^4.0.0",
"gulp-add": "0.0.2",
"gulp-clean": "^0.4.0",
"gulp-haxetool": "^0.1.9",
"gulp-haxetool": "^0.2.1",
"yargs": "^13.2.4"
},
"haxeDependencies": {

View File

@@ -2,6 +2,7 @@
set -e
cd "$(dirname $(dirname "$0"))" || exit
source .env
source $NEKO_SDK/activate
source $HAXE_SDK/activate
haxelib install formatter

View File

@@ -2,6 +2,7 @@
set -e
cd "$(dirname $(dirname "$0"))" || exit
source .env
source $NEKO_SDK/activate
source $HAXE_SDK/activate
haxelib install formatter

View File

@@ -7,7 +7,6 @@ package ru.m;
}
class Device {
public static var platform(get, null):Platform;
private static function get_platform():Platform {
@@ -22,9 +21,8 @@ class Device {
#end
}
private static var MOBILES(default, never):Array<String> = [
"Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",
];
private static var MOBILES(default,
never):Array<String> = ["Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",];
public static function isMobile():Bool {
#if android

View File

@@ -10,7 +10,6 @@ typedef Frame = {
}
class Animate extends Bitmap {
public var playing(default, default):Bool;
public var frames(default, set):Array<Frame>;

View File

@@ -4,7 +4,6 @@ import promhx.Deferred;
import promhx.Promise;
class OnceAnimate extends Animate {
private var deferred:Deferred<Animate>;
public function play():Promise<Animate> {

View File

@@ -4,7 +4,6 @@ import hw.signal.Signal;
import ru.m.control.IControlBus;
class ControlBus implements IControlBus {
private static inline var TAG = "control";
public var devices(default, null):Array<IControlDevice>;
@@ -23,7 +22,7 @@ class ControlBus implements IControlBus {
public function connect(device:IControlDevice):Void {
var connector = function(action:DeviceAction, on:Bool):Void {
//L.d("TAG", '${device.type}, ${action}, ${on}');
// L.d("TAG", '${device.type}, ${action}, ${on}');
signal.emit(device.type, action, on);
}
connections.set(device.type, connector);

View File

@@ -7,7 +7,6 @@ import ru.m.control.DeviceType;
import ru.m.geom.Direction;
class JoystickDevice implements IControlDevice {
public var type(default, null):DeviceType;
public var signal(default, null):Signal2<DeviceAction, Bool>;

View File

@@ -6,7 +6,6 @@ import hw.signal.Signal;
import ru.m.control.DeviceAction;
class KeyboardDevice implements IControlDevice {
public var type(default, null):DeviceType;
public var signal(default, null):Signal2<DeviceAction, Bool>;

View File

@@ -4,7 +4,6 @@ import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
class DisplayObjectContainerExtender {
public static function childrenIterator():Iterator<DisplayObject> {
throw "Not implemented";
}

View File

@@ -9,7 +9,6 @@ using StringTools;
using hw.color.ColorUtil;
@:style class ButtonSVGSkin implements ISkin<ButtonView> {
@:style(null) private var svg:String;
@:style(0) private var color:Null<Color>;
@:style(false) private var solid:Null<Bool>;

View File

@@ -15,7 +15,6 @@ import ru.m.skin.ButtonSVGSkin;
using hw.color.ColorUtil;
class AppTheme extends Theme {
public static var COLORS(default, never):ThemeColors = {
light: 0x95937D,
dark: 0x777564,
@@ -29,17 +28,11 @@ class AppTheme extends Theme {
override private function reload():Void {
super.reload();
register(new Style("light", [
"skin.background.color" => colors.light,
]));
register(new Style("light", ["skin.background.color" => colors.light,]));
register(new Style("dark", [
"skin.background.color" => colors.dark,
]));
register(new Style("dark", ["skin.background.color" => colors.dark,]));
register(new Style("font", [
"_" => null,
], ["text"]));
register(new Style("font", ["_" => null,], ["text"]));
register(new Style("text.header", [
"font.size" => fontSize.big,
@@ -97,14 +90,10 @@ class AppTheme extends Theme {
"layout.vAlign" => VAlign.MIDDLE,
], ["light"]));
register(new Style("panel_button", [
"font.size" => fontSize.big,
"geometry.height" => SizeValue.fromString("100%"),
], ["button"]));
register(new Style("panel_button",
["font.size" => fontSize.big, "geometry.height" => SizeValue.fromString("100%"),], ["button"]));
register(new Style("window", [
"geometry.padding" => Box.fromFloat(2),
], ["dark", "border"]));
register(new Style("window", ["geometry.padding" => Box.fromFloat(2),], ["dark", "border"]));
register(new Style("line", [
"geometry.width" => SizeValue.fromString("100%"),
@@ -112,7 +101,8 @@ class AppTheme extends Theme {
], ["border"]));
register(new Style("window.close", [
"skin" => function() return new ButtonSVGSkin(Assets.getText("resources/image/icon/window-close-solid.svg"), colors.light),
"skin" => function() return new ButtonSVGSkin(Assets.getText("resources/image/icon/window-close-solid.svg"),
colors.light),
"geometry.width" => SizeValue.fromString("8h"),
"geometry.height" => SizeValue.fromString("8h"),
]));
@@ -137,14 +127,8 @@ class AppTheme extends Theme {
"skin.border.thickness" => 5,
"skin.round" => 10,
], ["light"]));
register(new Style("player.winner", [
"skin.background.alpha" => 0.2,
"skin.background.color" => green,
]));
register(new Style("player.loser", [
"skin.background.alpha" => 0.2,
"skin.background.color" => red,
]));
register(new Style("player.winner", ["skin.background.alpha" => 0.2, "skin.background.color" => green,]));
register(new Style("player.loser", ["skin.background.alpha" => 0.2, "skin.background.color" => red,]));
register(new Style("button.pack", [
"geometry.width" => SizeValue.fromString("35h"),
@@ -157,9 +141,7 @@ class AppTheme extends Theme {
"skin.round" => 15,
], ["border", "light"]));
register(new Style("button.menu", [
"geometry.padding" => Box.fromArray([20, 10]),
]));
register(new Style("button.menu", ["geometry.padding" => Box.fromArray([20, 10]),]));
registerButton("settings", "cog-solid.svg");
registerButton("close", "times-circle-solid.svg");
@@ -174,27 +156,23 @@ class AppTheme extends Theme {
registerButton("backspace", "backspace-light.svg", true);
registerButton("tablet-android-alt", "tablet-android-alt-light.svg", true);
register(new Style("gamepad", [
"skin.color" => colors.text,
"skin.activeColor" => colors.active,
]));
register(new Style("gamepad", ["skin.color" => colors.text, "skin.activeColor" => colors.active,]));
register(new Style("render", [
"skin.background.color" => colors.dark,
]));
register(new Style("render", ["skin.background.color" => colors.dark,]));
}
private function registerButton(name:String, resource:String, solid:Bool = false):Void {
register(new Style('button.$name', [
"geometry.width" => SizeValue.fromString("10h"),
"geometry.height" => SizeValue.fromString("10h"),
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light, solid),
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light,
solid),
]));
register(new Style('button.$name.small', [
"geometry.width" => SizeValue.fromString("7h"),
"geometry.height" => SizeValue.fromString("7h"),
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light, solid),
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light,
solid),
]));
}
}

View File

@@ -22,7 +22,7 @@ class Client {
L.push(new hw.log.JSLogger());
#end
#if debug
//L.push(new hw.log.SocketLogger());
// L.push(new hw.log.SocketLogger());
#end
// ToDo: fix @:provide macro
PopupManager;

View File

@@ -23,7 +23,6 @@ import ru.m.tankz.proto.pack.Response;
import ru.m.update.Updater;
class Init {
@:provide static var theme:ITheme;
@:provide static var levelBundle:ILevelBundle;
@:provide static var configBundle:IConfigBundle;
@@ -39,7 +38,8 @@ class Init {
#if flash
return new ru.m.connect.flash.FlashConnection<Request, Response>(host, port, Response);
#elseif html5
return new ru.m.connect.js.JsConnection<Request, Response>(host, port + (ru.m.connect.js.JsConnection.isSecured() ? 1 : 0), Response);
return new ru.m.connect.js.JsConnection<Request, Response>(host,
port + (ru.m.connect.js.JsConnection.isSecured() ? 1 : 0), Response);
#else
return new ru.m.connect.desktop.DesktopConnection<Request, Response>(host, port, Response);
#end

View File

@@ -7,7 +7,6 @@ import flash.Lib;
import openfl.Assets;
class LinuxIcon {
private static function prepareIcon(bitmap:BitmapData):BitmapData {
var matrix:Array<Float> = [];
matrix = matrix.concat([0, 0, 1, 0, 0]);

View File

@@ -9,7 +9,6 @@ import hw.view.geometry.Size;
import ru.m.tankz.AppTheme;
class Progress extends Sprite {
public var color(default, set):Int = 0;
public var backColor(default, set):Int = 0;
public var progress(default, set):Float = 0;
@@ -85,7 +84,7 @@ class Progress extends Sprite {
maskShape.graphics.moveTo(radius, radius);
var sides = 6;
var rotation = (-(Math.PI) / 2);
var r = radius / Math.cos(1/sides * Math.PI);
var r = radius / Math.cos(1 / sides * Math.PI);
var lineToRadians = function(rads:Float):Void {
maskShape.graphics.lineTo(Math.cos(rads) * r + radius, Math.sin(rads) * r + radius);
};
@@ -101,7 +100,6 @@ class Progress extends Sprite {
}
class Preloader extends Sprite {
private var progress:Progress;
public function new() {

View File

@@ -8,7 +8,6 @@ import ru.m.tankz.Type;
import ru.m.tankz.util.LevelUtil;
class ClientLevelSource implements ILevelSource {
public function new() {}
public function resolveMeta(id:PackId):LevelPackMeta {

View File

@@ -8,7 +8,6 @@ import yaml.Parser;
import yaml.Yaml;
class ConfigBundle implements IConfigBundle {
private var _cache:Map<GameType, Config> = new Map();
public function new() {}

View File

@@ -13,7 +13,6 @@ import ru.m.tankz.Type;
using haxe.EnumTools.EnumValueTools;
class HumanControl extends Control {
@:provide static var storage:SettingsStorage;
@:provide static var bus:IControlBus;
@@ -110,7 +109,7 @@ class HumanControl extends Control {
}
}
private function shooter(weapon:Int):Void -> Void {
private function shooter(weapon:Int):Void->Void {
return function():Void {
action(SHOT(weapon));
}

View File

@@ -6,7 +6,6 @@ import ru.m.tankz.control.HumanControl;
import ru.m.tankz.Type;
class LocalControlFactory extends BaseControlFactory {
override private function buildHuman(id:PlayerId, index:Int):Control {
return new HumanControl(id, index);
}

View File

@@ -8,7 +8,6 @@ import ru.m.tankz.storage.GameStorage;
import ru.m.tankz.Type;
class LocalGame extends GameRunner {
@:provide static var gameStorage:GameStorage;
public function new(start:Start) {

View File

@@ -5,10 +5,9 @@ import flash.events.Event;
import ru.m.tankz.engine.ICaller;
class StageCaller implements ICaller {
private var stage:Stage;
private var event:String;
private var calback:Void -> Void;
private var calback:Void->Void;
public function new(stage:Stage, ?event:String) {
this.stage = stage;
@@ -19,7 +18,7 @@ class StageCaller implements ICaller {
calback();
}
public function start(calback:Void -> Void):Void {
public function start(calback:Void->Void):Void {
this.calback = calback;
stage.addEventListener(event, onEvent);
}

View File

@@ -5,7 +5,6 @@ import ru.m.tankz.network.NetworkManager;
import ru.m.tankz.control.Control;
class NetworkControl extends HumanControl {
@:provide private var network:NetworkManager;
override public function action(action:TankAction):Void {

View File

@@ -5,7 +5,6 @@ import ru.m.tankz.control.Control;
import ru.m.tankz.Type;
class NetworkControlFactory extends BaseControlFactory {
override private function buildHuman(id:PlayerId, index:Int):Control {
return new NetworkControl(id, index);
}

View File

@@ -10,7 +10,6 @@ import ru.m.tankz.proto.pack.GameEventResponse;
import ru.m.tankz.proto.room.RoomSlotProto;
class NetworkGame extends Game {
private var network:NetworkManager;
public function new(network:NetworkManager) {
@@ -39,7 +38,8 @@ class NetworkGame extends Game {
}
override private function onStart(start:Start):Void {
var slot:RoomSlotProto = Lambda.find(network.room.slots, function(slot:RoomSlotProto) return slot.hasUser() && slot.user.uuid == network.user.uuid);
var slot:RoomSlotProto = Lambda.find(network.room.slots,
function(slot:RoomSlotProto) return slot.hasUser() && slot.user.uuid == network.user.uuid);
if (slot != null) {
start.state.controls.push({playerId: [slot.slot.team, slot.slot.index], controller: HUMAN(0)});
}

View File

@@ -37,7 +37,6 @@ enum ConnectionState {
}
@:provide class NetworkManager {
private static inline var TAG = "NetworkManager";
public var state(default, null):ConnectionState;
@@ -91,11 +90,7 @@ enum ConnectionState {
public function login(name:String, uuid:String = null):Void {
updateState(LOGIN);
connection.send(new Request().setLogin(
new LoginRequest()
.setUuid(uuid)
.setName(name)
));
connection.send(new Request().setLogin(new LoginRequest().setUuid(uuid).setName(name)));
}
public function logout():Void {
@@ -107,11 +102,13 @@ enum ConnectionState {
}
public function createGame(type:String, level:Int):Void {
connection.send(new Request().setRoom(new RoomRequest().setCreate(new CreateRequest().setType(type).setLevel(level))));
connection.send(new Request().setRoom(new RoomRequest().setCreate(new CreateRequest().setType(type)
.setLevel(level))));
}
public function joinGame(gameId:Int, restore:Bool = false):Void {
connection.send(new Request().setRoom(new RoomRequest().setJoin(new JoinRequest().setGameId(gameId).setRestore(restore))));
connection.send(new Request().setRoom(new RoomRequest().setJoin(new JoinRequest().setGameId(gameId)
.setRestore(restore))));
}
public function selectSlot(slot:SlotProto):Void {
@@ -127,11 +124,8 @@ enum ConnectionState {
}
public function action(tankId:Int, action:TankAction):Void {
connection.send(new Request().setGameEvent(new GameEventRequest().setEvent(
new GameEventProto().setTime(0).setEvent(
Serializer.run(GameEvent.ACTION(tankId, action))
)))
);
connection.send(new Request().setGameEvent(new GameEventRequest().setEvent(new GameEventProto().setTime(0)
.setEvent(Serializer.run(GameEvent.ACTION(tankId, action))))));
}
private function connect():Void {

View File

@@ -5,38 +5,35 @@ import ru.m.animate.Animate;
import ru.m.animate.OnceAnimate;
class AnimateBundle {
private static function buildAnimate(name:String, sequence:Array<Int>):OnceAnimate {
var template:String = 'resources/image/animate/${name}/%index%.png';
var frames = [for (i in sequence) ({
image: Assets.getBitmapData(StringTools.replace(template, '%index%', Std.string(i))),
length: 1
})];
var frames = [
for (i in sequence)
({
image:Assets.getBitmapData(StringTools.replace(template, '%index%', Std.string(i))), length:1
})
];
return new OnceAnimate(frames);
}
public static function tankSpawn():OnceAnimate {
return buildAnimate('appear', [
0, 1, 2, 3, 3, 4, 5, 5, 6
]);
return buildAnimate('appear', [0, 1, 2, 3, 3, 4, 5, 5, 6]);
}
public static function tankBoom():OnceAnimate {
return buildAnimate('boom', [
0, 1, 2, 3, 4, 4, 4, 1, 4, 4, 7, 7, 8, 9, 9
]);
return buildAnimate('boom', [0, 1, 2, 3, 4, 4, 4, 1, 4, 4, 7, 7, 8, 9, 9]);
}
public static function bulletBoom():OnceAnimate {
return buildAnimate('boom-sm', [
0, 1, 1, 0, 0, 1
]);
return buildAnimate('boom-sm', [0, 1, 1, 0, 0, 1]);
}
public static function tankProtect():Animate {
return new Animate([for (i in 0...2) ({
image: Assets.getBitmapData('resources/image/animate/protect/${i}.png'),
length: 5
})]);
return new Animate([
for (i in 0...2)
({
image:Assets.getBitmapData('resources/image/animate/protect/${i}.png'), length:5
})
]);
}
}

View File

@@ -23,10 +23,10 @@ import ru.m.tankz.render.item.EagleRenderItem;
import ru.m.tankz.render.item.IRenderItem;
import ru.m.tankz.render.item.TankRenderItem;
import ru.m.tankz.Type;
using ru.m.display.DisplayObjectContainerExtender;
class Render extends SpriteView implements IRender {
public var config(default, set):Config;
public var gridSize(default, set):GridSize;

View File

@@ -5,7 +5,6 @@ import openfl.Assets;
import ru.m.tankz.Type;
class RenderUtil {
public static function eagleImage(death:Bool = false):BitmapData {
var suffix = death ? '-death' : '';
return Assets.getBitmapData('resources/image/eagle/eagle${suffix}.png');

View File

@@ -4,8 +4,8 @@ import ru.m.geom.Rectangle;
import ru.m.tankz.Type;
class BonusRenderItem extends BitmapRenderItem {
public var type(default, set):BonusType;
private var d = -0.05;
private var alpha = 1.0;

View File

@@ -7,7 +7,6 @@ import ru.m.geom.Rectangle;
import ru.m.tankz.Type;
class BrickBitmapBundle {
private var data:Map<String, BitmapData>;
public function new() {
@@ -24,10 +23,7 @@ class BrickBitmapBundle {
var image = RenderUtil.brickImage(type, frame);
var result = new BitmapData(image.width, image.height, true, 0x00000000);
for (point in cells) {
var rect = new flash.geom.Rectangle(
point.x * image.width / 2,
point.y * image.height / 2,
image.width / 2,
var rect = new flash.geom.Rectangle(point.x * image.width / 2, point.y * image.height / 2, image.width / 2,
image.height / 2);
result.draw(image, null, null, null, rect);
}
@@ -45,7 +41,6 @@ class BrickBitmapBundle {
}
class BrickRenderItem extends BitmapRenderItem {
private static var bundle:BrickBitmapBundle = new BrickBitmapBundle();
public var type(default, set):BrickType;

View File

@@ -5,7 +5,6 @@ import ru.m.geom.Position;
import ru.m.geom.Rectangle;
class RenderItem implements IRenderItem {
public var view(get, null):DisplayObject;
public var content(get, null):DisplayObject;
@@ -30,12 +29,22 @@ class RenderItem implements IRenderItem {
rect.direction = position.direction;
if (content != null) {
content.rotation = rect.direction.angle;
content.x = - rect.width * (rect.direction.x + 1) / 2 + rect.width * (rect.direction.y + 1) / 2 + 0.5 * rect.width;
content.y = - rect.height * (rect.direction.x + 1) / 2 - rect.height * (rect.direction.y + 1) / 2 + 1.5 * rect.height;
content.x = -rect.width * (rect.direction.x + 1) / 2
+ rect.width * (rect.direction.y + 1) / 2
+ 0.5 * rect.width;
content.y = -rect.height * (rect.direction.x + 1) / 2
- rect.height * (rect.direction.y + 1) / 2
+ 1.5 * rect.height;
} else {
view.rotation = rect.direction.angle;
view.x = rect.x - rect.width * (rect.direction.x + 1) / 2 + rect.width * (rect.direction.y + 1) / 2 + 0.5 * rect.width;
view.y = rect.y - rect.height * (rect.direction.x + 1) / 2 - rect.height * (rect.direction.y + 1) / 2 + 1.5 * rect.height;
view.x = rect.x
- rect.width * (rect.direction.x + 1) / 2
+ rect.width * (rect.direction.y + 1) / 2
+ 0.5 * rect.width;
view.y = rect.y
- rect.height * (rect.direction.x + 1) / 2
- rect.height * (rect.direction.y + 1) / 2
+ 1.5 * rect.height;
}
}
}

View File

@@ -155,7 +155,7 @@ class TankRenderItem extends BitmapRenderItem {
name = value;
nameView.text = name;
nameView.x = (rect.width - nameView.width) / 2;
nameView.y = -nameView.height / 2; //(rect.height - nameView.height) / 2;
nameView.y = -nameView.height / 2; // (rect.height - nameView.height) / 2;
}
return name;
}

View File

@@ -58,7 +58,7 @@ import ru.m.tankz.game.IGame;
}
public function play(id:String):Void {
//L.d(TAG, 'play: ${id}');
// L.d(TAG, 'play: ${id}');
var sound:Sound = Assets.getSound('resources/sounds/${id}.${type}');
if (sound != null) {
var channel = sound.play(0, 0, transform);
@@ -105,7 +105,7 @@ import ru.m.tankz.game.IGame;
play("bullet_hit");
case HIT(CELL(_, _, shot)):
if (humanBullets.indexOf(shot.bulletId) > -1) {
//play("bullet_block");
// play("bullet_block");
}
case DESTROY(TANK(id, _)):
if (humanTanks.indexOf(id) > -1) {
@@ -116,7 +116,7 @@ import ru.m.tankz.game.IGame;
case DESTROY(EAGLE(_, _)):
play("boom_player");
case DESTROY(BONUS(id, _)):
play("bonus_get");
// play("bonus_get");
if (liveBonuses.indexOf(id) > -1) {
play("live");
} else {

View File

@@ -5,7 +5,6 @@ import ru.m.tankz.game.PackProgress;
import ru.m.tankz.Type;
@:provide class GameStorage extends SharedObjectStorage {
private static inline var VERSION = 1;
public function new() {

View File

@@ -3,7 +3,6 @@ package ru.m.tankz.storage;
import hw.storage.SharedObjectStorage;
@:provide class NetworkStorage extends SharedObjectStorage {
public var user(get, set):User;
public function new() {

View File

@@ -5,7 +5,6 @@ import hw.storage.SharedObjectStorage;
import ru.m.tankz.game.record.GameRecord;
@:provide class RecordStorage extends SharedObjectStorage {
private static inline var VERSION = 1;
public function new() {

View File

@@ -17,7 +17,6 @@ enum Setting {
}
@:provide class SettingsStorage extends SharedObjectStorage {
private static inline var VERSION = 4.1;
public var signal(default, null):Signal<Setting> = new Signal();
@@ -88,9 +87,7 @@ enum Setting {
];
}
private static var mobileDefaults:Map<Int, Binding> = [
0 => buildDeviceBinding(SCREEN),
];
private static var mobileDefaults:Map<Int, Binding> = [0 => buildDeviceBinding(SCREEN),];
private static var defaults:Map<Int, Binding> = [
0 => [

View File

@@ -17,6 +17,7 @@ import ru.m.tankz.sound.SoundManager;
@:provide var resources:IResources;
@:provide var switcher:FrameSwitcher;
@:provide var soundManager:SoundManager;
@:provide static var bus:IControlBus;
public function new():Void {

View File

@@ -19,7 +19,6 @@ import ru.m.update.Updater;
using ru.m.tankz.view.ViewUtil;
@:template class MenuFrame extends FrameView<Dynamic> {
public static var ID(default, never):String = "menu";
@:provide static var gameInit:GameInit;
@@ -59,7 +58,8 @@ using ru.m.tankz.view.ViewUtil;
private function onSettingChange(setting:Setting):Void {
switch setting {
case ENABLE_NETWORK(value): networkButton.visible = value;
case ENABLE_NETWORK(value):
networkButton.visible = value;
case _:
}
}

View File

@@ -7,7 +7,6 @@ import ru.m.tankz.game.record.GameRecord;
import ru.m.tankz.storage.RecordStorage;
@:template class RecordFrame extends FrameView<Dynamic> {
public static var ID(default, never):String = "record";
@:provide static var switcher:FrameSwitcher;

View File

@@ -22,6 +22,7 @@ using ru.m.tankz.view.ViewUtil;
@:view("next") var nextButton:ButtonView;
@:provide var frames:FrameSwitcher;
@:provide static var levelBundle:ILevelBundle;
@:provide static var gameStorage:GameStorage;
@@ -38,7 +39,8 @@ using ru.m.tankz.view.ViewUtil;
view.winner = view.data.id.team == data.winner;
}
levelLabel.text = data.level.toLevelLabel();
nextButton.disabled = !gameStorage.get(result.level.packId).isPresetAvailable(result.level.id + 1, result.state.presetId);
nextButton.disabled = !gameStorage.get(result.level.packId)
.isPresetAvailable(result.level.id + 1, result.state.presetId);
nextButton.text = 'Next #${result.level.id + 1}';
}

View File

@@ -31,8 +31,10 @@ import ru.m.tankz.storage.SettingsStorage;
private function onSettingChange(setting:Setting):Void {
switch setting {
case DISPLAY_FPS(value): fpsButton.on = value;
case ENABLE_NETWORK(value): networkButton.on = value;
case DISPLAY_FPS(value):
fpsButton.on = value;
case ENABLE_NETWORK(value):
networkButton.on = value;
case _:
}
}

View File

@@ -19,7 +19,6 @@ using haxe.EnumTools.EnumValueTools;
using ru.m.tankz.view.ViewUtil;
@:template class StartFrame extends FrameView<Start> {
public static var ID(default, never):String = "start";
@:provide static var switcher:FrameSwitcher;

View File

@@ -8,7 +8,6 @@ import ru.m.tankz.control.Binding;
import ru.m.tankz.control.Control;
class KeyboardMap {
private var data:Map<Int, String>;
public function new() {
@@ -20,19 +19,18 @@ class KeyboardMap {
this.data.set(Std.parseInt(arr[1]), arr[0]);
}
}
}
private static var instance:KeyboardMap;
public static function getName(key:Int):String {
if (instance == null) instance = new KeyboardMap();
if (instance == null)
instance = new KeyboardMap();
return key == -1 ? "(NONE)" : instance.data.exists(key) ? instance.data.get(key) : Std.string(key);
}
}
class ViewUtil {
public static function toLevelLabel(level:LevelConfig, oneline:Bool = false):String {
var result:Array<String> = ['${level.packId.type} #${level.id}'];
if (level.name != null) {
@@ -41,7 +39,7 @@ class ViewUtil {
return result.join(oneline ? " " : "\n");
}
public static function toPackLabel(packId:PackId, separator=" #"):String {
public static function toPackLabel(packId:PackId, separator = " #"):String {
return packId.name != PackId.DEFAULT ? '${packId.type}${separator}${packId.name}' : packId.type;
}

View File

@@ -9,7 +9,6 @@ import ru.m.tankz.network.NetworkManager;
import ru.m.tankz.view.popup.LoginPopup;
@:template class NetworkStateView extends HGroupView {
@:view("state") var stateView:SpriteView;
@:view("user") var userLabel:LabelView;
@:view("login") var loginButton:ButtonView;

View File

@@ -9,7 +9,6 @@ import ru.m.tankz.Type;
using ru.m.tankz.view.ViewUtil;
@:template class PackView extends VGroupView {
public var data(default, set):PackId;
@:view var label:LabelView;

View File

@@ -10,7 +10,6 @@ import ru.m.tankz.control.Controller;
import ru.m.tankz.control.PlayerControl;
@:template class SlotView extends HGroupView {
@:view("tank") public var tankView:ImageView;
@:view("slot") public var slotLabel:LabelView;
@:view("select") public var select:SelectView<Controller>;

View File

@@ -6,7 +6,6 @@ import ru.m.tankz.render.RenderUtil;
import ru.m.tankz.Type.TankInfo;
class TankView extends ImageView {
public var tank(null, set):TankInfo;
public function new() {

View File

@@ -7,7 +7,6 @@ import ru.m.tankz.Type;
import ru.m.tankz.view.common.TankView;
@:template class PlayerView extends VGroupView {
@:view("title") public var titleView:LabelView;
@:view("tank") public var tankView:TankView;
@:view("life") public var lifeLabel:LabelView;

View File

@@ -5,7 +5,6 @@ import ru.m.tankz.game.GameState;
import ru.m.tankz.Type;
class TeamView extends DataView<PlayerState, PlayerView> {
public var teamId(default, default):TeamId;
public var state(default, set):TeamState;

View File

@@ -5,38 +5,27 @@ import ru.m.geom.Direction;
import ru.m.geom.Rectangle;
class DefaultActionAreaBuilder implements IActionAreaBuilder {
public function new() {
}
public function new() {}
public function build(width:Float, height:Float):Array<IActionArea> {
var areas:Array<IActionArea> = [];
var size = Math.min(width, height) / 7;
var padding = size / 2;
// top
areas.push(new RectangleActionArea(
DIRECTION(Direction.TOP),
new Rectangle(padding + size, height - size * 3 - padding, size, size)
));
areas.push(new RectangleActionArea(DIRECTION(Direction.TOP),
new Rectangle(padding + size, height - size * 3 - padding, size, size)));
// left
areas.push(new RectangleActionArea(
DIRECTION(Direction.LEFT),
new Rectangle(padding, height - size * 2 - padding, size, size)
));
areas.push(new RectangleActionArea(DIRECTION(Direction.LEFT),
new Rectangle(padding, height - size * 2 - padding, size, size)));
// bottom
areas.push(new RectangleActionArea(
DIRECTION(Direction.BOTTOM),
new Rectangle(padding + size, height - size - padding, size, size)
));
areas.push(new RectangleActionArea(DIRECTION(Direction.BOTTOM),
new Rectangle(padding + size, height - size - padding, size, size)));
// right
areas.push(new RectangleActionArea(
DIRECTION(Direction.RIGHT),
new Rectangle(padding + size * 2, height - size * 2 - padding, size, size)
));
areas.push(new RectangleActionArea(DIRECTION(Direction.RIGHT),
new Rectangle(padding + size * 2, height - size * 2 - padding, size, size)));
// button
areas.push(new RectangleActionArea(
KEY(0),
new Rectangle(width - size * 1.5 - padding, height - size * 2 - padding, size, size)
));
areas.push(new RectangleActionArea(KEY(0),
new Rectangle(width - size * 1.5 - padding, height - size * 2 - padding, size, size)));
return areas;
}
}

View File

@@ -6,7 +6,6 @@ import hw.view.skin.ISkin;
import ru.m.control.DeviceAction;
@:style class GamepadSkin implements ISkin<GamepadView> {
@:style(0xffffff) public var color(default, default):Null<Color>;
@:style(0x00ff00) public var activeColor(default, default):Null<Color>;

View File

@@ -12,7 +12,6 @@ import ru.m.geom.Point;
import ru.m.tankz.config.Config;
class GamepadView extends SpriteView implements IControlDevice {
public var type(default, null):DeviceType;
public var signal(default, null):Signal2<DeviceAction, Bool>;

View File

@@ -7,43 +7,30 @@ import ru.m.geom.Direction;
import ru.m.geom.Rectangle;
class SmartActionAreaBuilder implements IActionAreaBuilder {
public function new() {
}
public function new() {}
public function build(width:Float, height:Float):Array<IActionArea> {
var areas:Array<IActionArea> = [];
var size = Math.min(width, height) / 5;
var padding = Box.fromArray([size / 4, size / 3]);
// top
areas.push(new RhombusActionArea(
DIRECTION(Direction.TOP),
new Rectangle(padding.left + size * 0.5, height - size * 2 - padding.bottom, size, size )
));
areas.push(new RhombusActionArea(DIRECTION(Direction.TOP),
new Rectangle(padding.left + size * 0.5, height - size * 2 - padding.bottom, size, size)));
// left
areas.push(new RhombusActionArea(
DIRECTION(Direction.LEFT),
new Rectangle(padding.left, height - size * 1.5 - padding.bottom, size, size)
));
areas.push(new RhombusActionArea(DIRECTION(Direction.LEFT),
new Rectangle(padding.left, height - size * 1.5 - padding.bottom, size, size)));
// bottom
areas.push(new RhombusActionArea(
DIRECTION(Direction.BOTTOM),
new Rectangle(padding.left + size * 0.5, height - size - padding.bottom, size, size)
));
areas.push(new RhombusActionArea(DIRECTION(Direction.BOTTOM),
new Rectangle(padding.left + size * 0.5, height - size - padding.bottom, size, size)));
// right
areas.push(new RhombusActionArea(
DIRECTION(Direction.RIGHT),
new Rectangle(padding.left + size, height - size * 1.5 - padding.bottom, size, size)
));
areas.push(new RhombusActionArea(DIRECTION(Direction.RIGHT),
new Rectangle(padding.left + size, height - size * 1.5 - padding.bottom, size, size)));
// key 0
areas.push(new CircleActionArea(
KEY(0),
new Circle(width - size * 0.5 - padding.right, height - size * 0.5 - padding.bottom, size / 2)
));
areas.push(new CircleActionArea(KEY(0),
new Circle(width - size * 0.5 - padding.right, height - size * 0.5 - padding.bottom, size / 2)));
// key 1
areas.push(new CircleActionArea(
KEY(1),
new Circle(width - size * 0.5 - padding.right, height - size * 1.5 - padding.bottom, size / 2)
));
areas.push(new CircleActionArea(KEY(1),
new Circle(width - size * 0.5 - padding.right, height - size * 1.5 - padding.bottom, size / 2)));
return areas;
}
}

View File

@@ -11,7 +11,6 @@ import ru.m.tankz.proto.room.RoomProto;
import ru.m.tankz.proto.room.RoomSlotProto;
@:template class RoomFrame extends FrameView<RoomProto> {
public static inline var ID = "room";
@:view var start:ButtonView;

View File

@@ -9,7 +9,6 @@ import hw.view.list.ListView;
import ru.m.tankz.proto.room.RoomProto;
@:template class RoomItemView extends HGroupView implements IListItemView<RoomProto> {
public var item_index(default, default):Int;
public var data(default, set):RoomProto;

View File

@@ -9,7 +9,6 @@ import ru.m.tankz.network.NetworkManager;
import ru.m.tankz.proto.room.RoomSlotProto;
@:template class SlotItemView extends HGroupView implements IListItemView<RoomSlotProto> {
public var item_index(default, default):Int;
public var data(default, set):RoomSlotProto;

View File

@@ -14,7 +14,6 @@ private typedef Result = {
}
@:template class CreateGamePopup extends PopupView<Result> {
@:view("type") var typeView:DataView<GameType, ToggleButtonView>;
@:view("level") var levelView:DataView<LevelConfig, ToggleButtonView>;
@@ -30,7 +29,7 @@ private typedef Result = {
}
private function submit():Void {
close({type:type, level:level});
close({type: type, level: level});
}
private function gameTypeViewFactory(index:Int, type:GameType):ToggleButtonView {

View File

@@ -7,7 +7,6 @@ import hw.view.text.TextView;
import ru.m.tankz.network.NetworkManager;
@:singleton @:template class LoginPopup extends PopupView<User> {
@:view var username:InputView;
@:view var password:InputView;
@:view var error:TextView;
@@ -26,9 +25,12 @@ import ru.m.tankz.network.NetworkManager;
private function onStateChange(state:ConnectionState):Void {
switch state {
case ONLINE(user): close(user);
case ERROR(error): this.error.text = LoggerUtil.printError(error);
case _: this.error.text = null;
case ONLINE(user):
close(user);
case ERROR(error):
this.error.text = LoggerUtil.printError(error);
case _:
this.error.text = null;
}
}

View File

@@ -7,6 +7,4 @@ enum Action {
EXIT;
}
@:singleton @:template class PausePopup extends PopupView<Action> {
}
@:singleton @:template class PausePopup extends PopupView<Action> {}

View File

@@ -7,7 +7,6 @@ import ru.m.tankz.render.RenderUtil;
import ru.m.tankz.view.common.TankView;
@:template class FragView extends HGroupView {
@:view("tank") var tankView:TankView;
@:view("title") var titleView:LabelView;
@:view("score") var scoreView:LabelView;

View File

@@ -8,7 +8,6 @@ import ru.m.tankz.game.GameState;
import ru.m.tankz.view.common.TankView;
@:template class ResultPlayerView extends VGroupView {
@:view("player") var playerView:HGroupView;
@:view("tank") var tankView:TankView;
@:view("title") var titleView:LabelView;

View File

@@ -14,7 +14,6 @@ typedef ActionItem = {
}
@:template class ActionView extends HGroupView implements IListItemView<ActionItem> {
public var item_index(default, default):Int;
public var data(default, set):ActionItem;

View File

@@ -14,7 +14,6 @@ import ru.m.tankz.storage.SettingsStorage;
import ru.m.tankz.view.settings.ActionView;
class BindEditor {
private var editViews:Array<ActionView>;
@:provide static var bus:IControlBus;
@@ -63,8 +62,7 @@ class BindEditor {
}
@:template class SettingsEditor extends VGroupView {
public var controlIndex(default, set): Int;
public var controlIndex(default, set):Int;
@:view var label:LabelView;
@:view var list:DataView<ActionItem, ActionView>;
@@ -74,12 +72,12 @@ class BindEditor {
@:provide static var bus:IControlBus;
private function refresh():Void {
label.text = 'Player ${controlIndex+1}';
label.text = 'Player ${controlIndex + 1}';
var binding = storage.getBinding(controlIndex);
list.data = bindingToArray(binding);
}
private function set_controlIndex(value: Int): Int {
private function set_controlIndex(value:Int):Int {
this.controlIndex = value;
refresh();
return this.controlIndex;

View File

@@ -30,7 +30,6 @@ typedef PackagesBundle = {
}
class Updater {
private static inline var TAG = "Update";
public var type(get, null):PackageType;
@@ -63,11 +62,9 @@ class Updater {
public function check():Promise<Bool> {
return resolveBundle().then(function(bundle:PackagesBundle):Bool {
this.bundle = bundle;
return Lambda.exists(bundle.packages, function(item) return (
item.platform == Device.platform &&
item.type == type &&
version < Version.fromString(item.version)
));
return Lambda.exists(bundle.packages,
function(item) return (item.platform == Device.platform && item.type == type
&& version < Version.fromString(item.version)));
});
}

View File

@@ -1,17 +1,12 @@
package ru.m.update;
abstract Version(Array<Int>) {
public function new(mayor:Int, minor:Int, patch:Int, snapshot:Bool = false) {
this = [
mayor,
minor,
patch,
snapshot ? -1 : 0,
];
this = [mayor, minor, patch, snapshot ? -1 : 0,];
}
@:arrayAccess public inline function get(key:Int) return this[key];
@:arrayAccess public inline function get(key:Int)
return this[key];
public function compare(other:Version):Int {
if (other == null) {
@@ -26,21 +21,20 @@ abstract Version(Array<Int>) {
return 0;
}
@:op(A > B) static function gt(a:Version, b:Version):Bool return a.compare(b) > 0;
@:op(A > B) static function gt(a:Version, b:Version):Bool
return a.compare(b) > 0;
@:op(A == B) static function eq(a:Version, b:Version):Bool return a.compare(b) == 0;
@:op(A == B) static function eq(a:Version, b:Version):Bool
return a.compare(b) == 0;
@:op(A < B) static function lt(a:Version, b:Version):Bool return a.compare(b) < 0;
@:op(A < B) static function lt(a:Version, b:Version):Bool
return a.compare(b) < 0;
@:from public static function fromString(value:String):Version {
var r = ~/(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/;
return if (r.match(value)) {
new Version(
Std.parseInt(r.matched(1)),
Std.parseInt(r.matched(2)),
Std.parseInt(r.matched(3)),
r.matched(4) != null
);
new Version(Std.parseInt(r.matched(1)), Std.parseInt(r.matched(2)), Std.parseInt(r.matched(3)),
r.matched(4) != null);
} else {
new Version(0, 0, 0);
}

View File

@@ -7,9 +7,7 @@ class Base64 {
private inline static var BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
private static var codec:BaseCode;
public function new() {
}
public function new() {}
static function getCodec():BaseCode {
if (codec == null) {
@@ -20,7 +18,7 @@ class Base64 {
}
public static function encodeBase64(content:haxe.io.Bytes):String {
var suffix = switch (content.length % 3){
var suffix = switch (content.length % 3) {
case 2: "=";
case 1: "==";
default: "";
@@ -45,5 +43,4 @@ class Base64 {
var bytes:Bytes = Bytes.ofString(removeNullbits(content));
return getCodec().decodeBytes(bytes);
}
}

View File

@@ -1,13 +1,11 @@
package ru.m;
#if neko
import haxe.Log;
import haxe.PosInfos;
import neko.vm.Thread;
class Timer {
private var sleep:Float;
private var stopped:Bool;
@@ -32,7 +30,7 @@ class Timer {
public dynamic function run() {}
public static function delay(f:Void -> Void, time_ms:Int) {
public static function delay(f:Void->Void, time_ms:Int) {
var t = new Timer(time_ms);
t.run = function() {
t.stop();
@@ -41,7 +39,7 @@ class Timer {
return t;
}
public static function measure<T>(f:Void -> T, ?pos:PosInfos):T {
public static function measure<T>(f:Void->T, ?pos:PosInfos):T {
var t0 = stamp();
var r = f();
Log.trace((stamp() - t0) + "s", pos);
@@ -52,9 +50,6 @@ class Timer {
return Sys.time();
}
}
#else
typedef Timer = haxe.Timer;
#end

View File

@@ -7,7 +7,6 @@ import haxe.io.BytesInput;
import protohx.Message;
class PacketQueue<P:Message> {
public var packetClass(default, null):Class<P>;
private var buffer:BytesBuffer;

View File

@@ -5,7 +5,6 @@ import haxe.io.BytesOutput;
import protohx.Message;
class PacketUtil {
public static function fromBytes<P:Message>(bytes:Bytes, factory:Class<P>):P {
var packet:P = Type.createInstance(factory, []);
packet.mergeFrom(bytes);

View File

@@ -3,15 +3,13 @@ package ru.m.connect;
import haxe.io.BytesOutput;
import protohx.Message;
class WebSocketTools {
public static function packet2string(packet:Message):String {
var b = new BytesOutput();
packet.writeTo(b);
var data = b.getBytes();
var res = new BytesOutput();
//res.writeUInt16(data.length);
// res.writeUInt16(data.length);
res.write(data);
return Base64.encodeBase64(res.getBytes());
}

View File

@@ -10,7 +10,6 @@ import sys.net.Host;
import sys.net.Socket;
class DesktopConnection<O:Message, I:Message> extends BaseConnection<O, I> {
private var host:String;
private var port:Int;
private var socket:Socket;

View File

@@ -5,7 +5,6 @@ import promhx.Promise;
import protohx.Message;
class FakeConnection<O:Message, I:Message> extends BaseConnection<O, I> {
override public function connect():Promise<IConnection<O, I>> {
handler.emit(ConnectionEvent.CONNECTED);
var promise:Promise<IConnection<O, I>> = cast Promise.promise(this);

View File

@@ -14,7 +14,6 @@ import protohx.Message;
import ru.m.connect.IConnection;
class FlashConnection<O:Message, I:Message> extends BaseConnection<O, I> {
private var host:String;
private var port:Int;
private var socket:Socket;

View File

@@ -10,7 +10,6 @@ import protohx.Message;
import ru.m.connect.IConnection;
class JsConnection<O:Message, I:Message> extends BaseConnection<O, I> {
private var host:String;
private var port:Int;
private var socket:WebSocket;

View File

@@ -4,7 +4,6 @@ import protohx.Message;
import sys.net.Socket;
class NekoConnection<O:Message, I:Message> extends BaseConnection<O, I> {
public var socket(default, null):Socket;
private var sendQueue:Array<O>;

View File

@@ -8,7 +8,6 @@ import protohx.Message;
import sys.net.Socket;
class NekoWSConnection<O:Message, I:Message> extends NekoConnection<O, I> {
private var opened:Bool;
public function new(socket:Socket, i:Class<I>) {
@@ -40,8 +39,7 @@ class NekoWSConnection<O:Message, I:Message> extends NekoConnection<O, I> {
}
private function encodeBase64(content:String):String {
var suffix = switch (content.length % 3)
{
var suffix = switch (content.length % 3) {
case 2: "=";
case 1: "==";
default: "";
@@ -60,11 +58,8 @@ class NekoWSConnection<O:Message, I:Message> extends NekoConnection<O, I> {
private function sendServerHandShake(socket:sys.net.Socket, inpKey:String) {
var outKey = encodeBase64(hex2data(Sha1.encode(StringTools.trim(inpKey) + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11")));
var s = "HTTP/1.1 101 Switching Protocols\r\n"
+ "Upgrade: websocket\r\n"
+ "Connection: Upgrade\r\n"
+ "Sec-WebSocket-Accept: " + outKey + "\r\n"
+ "\r\n";
var s = "HTTP/1.1 101 Switching Protocols\r\n" + "Upgrade: websocket\r\n" + "Connection: Upgrade\r\n"
+ "Sec-WebSocket-Accept: " + outKey + "\r\n" + "\r\n";
socket.output.writeString(s);
}
@@ -73,9 +68,12 @@ class NekoWSConnection<O:Message, I:Message> extends NekoConnection<O, I> {
socket.output.writeByte(130);
var len = 0;
if (data.length < 126) len = data.length;
else if (data.length < 65536) len = 126;
else len = 127;
if (data.length < 126)
len = data.length;
else if (data.length < 65536)
len = 126;
else
len = 127;
socket.output.writeByte(len | (!isServer ? 0x80 : 0x00));
@@ -83,8 +81,7 @@ class NekoWSConnection<O:Message, I:Message> extends NekoConnection<O, I> {
if (data.length < 65536) {
socket.output.writeByte((data.length >> 8) & 0xFF);
socket.output.writeByte(data.length & 0xFF);
}
else {
} else {
socket.output.writeByte((data.length >> 24) & 0xFF);
socket.output.writeByte((data.length >> 16) & 0xFF);
socket.output.writeByte((data.length >> 8) & 0xFF);
@@ -94,9 +91,8 @@ class NekoWSConnection<O:Message, I:Message> extends NekoConnection<O, I> {
if (isServer) {
socket.output.writeBytes(data, 0, data.length);
}
else {
var mask = [ Std.random(256), Std.random(256), Std.random(256), Std.random(256) ];
} else {
var mask = [Std.random(256), Std.random(256), Std.random(256), Std.random(256)];
socket.output.writeByte(mask[0]);
socket.output.writeByte(mask[1]);
socket.output.writeByte(mask[2]);
@@ -134,8 +130,7 @@ class NekoWSConnection<O:Message, I:Message> extends NekoConnection<O, I> {
var b2 = bytes.get(p++);
var b3 = bytes.get(p++);
len = (b2 << 8) + b3;
}
else if (len == 127) {
} else if (len == 127) {
var b2 = bytes.get(p++);
var b3 = bytes.get(p++);
var b4 = bytes.get(p++);
@@ -143,7 +138,7 @@ class NekoWSConnection<O:Message, I:Message> extends NekoConnection<O, I> {
len = (b2 << 24) + (b3 << 16) + (b4 << 8) + b5;
}
//Lib.println("len = " + len);
// Lib.println("len = " + len);
// direct array init not work corectly!
var mask = [];
@@ -152,14 +147,14 @@ class NekoWSConnection<O:Message, I:Message> extends NekoConnection<O, I> {
mask.push(bytes.get(p++));
mask.push(bytes.get(p++));
//Lib.println("mask = " + mask);
// Lib.println("mask = " + mask);
var data = new BytesBuffer();
for (i in 0...len) {
data.addByte(bytes.get(p++) ^ mask[i % 4]);
}
//Lib.println("readed = " + data.toString());
// Lib.println("readed = " + data.toString());
return data.getBytes();
} else {
throw "Expected masked data.";
@@ -167,7 +162,7 @@ class NekoWSConnection<O:Message, I:Message> extends NekoConnection<O, I> {
}
if (opcode == 136) {
//socket.close();
// socket.close();
opened = false;
return null;
} else {

View File

@@ -6,9 +6,7 @@ abstract Circle(Array<Float>) {
public var radius(get, set):Float;
public function new(x:Float = 0, y:Float = 0, radius:Float = 0) {
this = [
x, y, radius,
];
this = [x, y, radius,];
}
private inline function get_x():Float {

View File

@@ -16,9 +16,11 @@ abstract Direction(Array<Int>) {
this = value;
}
inline private function get_x():Int return this[0];
inline private function get_x():Int
return this[0];
inline private function get_y():Int return this[1];
inline private function get_y():Int
return this[1];
inline private function get_angle():Int {
return switch this {

View File

@@ -8,10 +8,17 @@ abstract GridPoint({x:Int, y:Int}) {
this = {x: x, y: y};
}
private inline function get_x():Int return this.x;
private inline function get_y():Int return this.y;
private inline function set_x(value:Int):Int return this.x = value;
private inline function set_y(value:Int):Int return this.y = value;
private inline function get_x():Int
return this.x;
private inline function get_y():Int
return this.y;
private inline function set_x(value:Int):Int
return this.x = value;
private inline function set_y(value:Int):Int
return this.y = value;
@:to inline public function toInt():Int {
return (this.x << 16) + this.y;

View File

@@ -1,7 +1,6 @@
package ru.m.geom;
class Line {
public var point1(default, null):Point;
public var point2(default, null):Point;
public var center(get, null):Point;
@@ -12,10 +11,7 @@ class Line {
}
private function get_center():Point {
return new Point(
point1.x + (point2.x - point1.x) / 2,
point1.y + (point2.y - point1.y) / 2
);
return new Point(point1.x + (point2.x - point1.x) / 2, point1.y + (point2.y - point1.y) / 2);
}
public function move(point:Point):Line {
@@ -28,10 +24,8 @@ class Line {
var height = point2.y - point1.y;
var kW = width > 0 ? (width + height) / width : 0;
var kH = height > 0 ? (width + height) / height : 0;
return new Line(
center.add(new Point(-kW * value / 2, -kH * value / 2)),
center.add(new Point(kW * value / 2, kH * value / 2))
);
return new Line(center.add(new Point(-kW * value / 2, -kH * value / 2)),
center.add(new Point(kW * value / 2, kH * value / 2)));
}
public function toString():String {

View File

@@ -8,10 +8,17 @@ abstract Point(Array<Float>) {
this = [x, y];
}
private inline function get_x():Float return this[0];
private inline function get_y():Float return this[1];
private inline function set_x(value:Float):Float return this[0] = value;
private inline function set_y(value:Float):Float return this[1] = value;
private inline function get_x():Float
return this[0];
private inline function get_y():Float
return this[1];
private inline function set_x(value:Float):Float
return this[0] = value;
private inline function set_y(value:Float):Float
return this[1] = value;
public function add(point:Point):Point {
return new Point(x + point.x, y + point.y);

View File

@@ -17,10 +17,7 @@ abstract Rectangle(Array<Float>) {
if (direction == null) {
direction = Direction.RIGHT;
}
this = [
x, y, width, height,
direction.x, direction.y,
];
this = [x, y, width, height, direction.x, direction.y,];
}
private inline function get_x():Float {
@@ -68,16 +65,10 @@ abstract Rectangle(Array<Float>) {
public function getSide(direction:Direction):Line {
if (direction.x != 0) {
var x = x + (direction.x * -1 + 1) / 2 * width;
return new Line(
new Point(x, y),
new Point(x, y + height)
);
return new Line(new Point(x, y), new Point(x, y + height));
} else if (direction.y != 0) {
var y = y + (direction.y * -1 + 1) / 2 * height;
return new Line(
new Point(x, y),
new Point(x + width, y)
);
return new Line(new Point(x, y), new Point(x + width, y));
} else {
return null;
}
@@ -106,10 +97,7 @@ abstract Rectangle(Array<Float>) {
}
public function intersection(rect:Rectangle):Bool {
return !(rect.left > right ||
rect.right < left ||
rect.top > bottom ||
rect.bottom < top);
return !(rect.left > right || rect.right < left || rect.top > bottom || rect.bottom < top);
}
public function intersection2(line:Line):Bool {
@@ -153,7 +141,7 @@ abstract Rectangle(Array<Float>) {
}
private function get_position():Position {
return {x:x, y:y, direction:direction};
return {x: x, y: y, direction: direction};
}
private function set_position(position:Position):Position {

View File

@@ -3,15 +3,10 @@ package ru.m.tankz;
import hw.color.Color;
typedef GameType = String;
typedef TeamId = String;
typedef BrickType = String;
typedef BrickIndex = Int;
typedef TankType = String;
typedef BonusType = String;
typedef TankInfo = {
@@ -32,9 +27,11 @@ abstract PlayerId(Array<Dynamic>) {
this = [team, index];
}
private inline function get_team():TeamId return this[0];
private inline function get_team():TeamId
return this[0];
private inline function get_index():Int return this[1];
private inline function get_index():Int
return this[1];
public function compare(other:PlayerId):Int {
if (other == null) {
@@ -73,9 +70,11 @@ abstract PackId({type:GameType, name:String}) {
this = {type: type, name: name};
}
private inline function get_type():GameType return this.type;
private inline function get_type():GameType
return this.type;
private inline function get_name():String return this.name;
private inline function get_name():String
return this.name;
@:from static public inline function fromArray(value:Array<Dynamic>):PackId {
return new PackId(value[0], value[1]);
@@ -95,12 +94,12 @@ abstract PackId({type:GameType, name:String}) {
}
typedef LevelId = Int;
typedef PresetId = Int;
abstract Score(Int) from Int to Int {
public function new(value:Int)
this = value;
public function new(value:Int) this = value;
public inline function format():String return '${this}$';
public inline function format():String
return '${this}$';
}

View File

@@ -11,15 +11,9 @@ import ru.m.tankz.Type;
using ru.m.tankz.game.GameUtil;
class ArmorEagleBonus extends BaseBonus {
public static inline var CLASS = "armor.eagle";
private static var brickMap(default, never) = [
[1, 1, 1, 1],
[1, 0, 0, 1],
[1, 0, 0, 1],
[1, 1, 1, 1],
];
private static var brickMap(default, never) = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1],];
override public function apply(playerId:PlayerId, game:IGame, engine:IEngine):Void {
for (team in game.teams) {

View File

@@ -8,7 +8,6 @@ import ru.m.tankz.Type;
using ru.m.tankz.game.GameUtil;
class BoatBonus extends BaseBonus {
public static inline var CLASS = "boat";
override public function apply(playerId:PlayerId, game:IGame, engine:IEngine):Void {

View File

@@ -3,7 +3,6 @@ package ru.m.tankz.bonus;
import ru.m.tankz.config.Config.BonusConfig;
class BonusFactory {
private var classes:Map<String, Class<IBonus>>;
public function new() {

View File

@@ -9,7 +9,6 @@ import ru.m.tankz.Type;
using ru.m.tankz.game.GameUtil;
class DestroyTeamBonus extends BaseBonus {
public static inline var CLASS = "destroy.team";
override public function apply(playerId:PlayerId, game:IGame, engine:IEngine):Void {

View File

@@ -7,7 +7,6 @@ import ru.m.tankz.Type;
using ru.m.tankz.game.GameUtil;
class FreezeTeamBonus extends BaseBonus {
public static inline var CLASS = "freeze.team";
override public function apply(playerId:PlayerId, game:IGame, engine:IEngine):Void {

View File

@@ -7,7 +7,6 @@ import ru.m.tankz.Type;
using ru.m.tankz.game.GameUtil;
class LifeBonus extends BaseBonus {
public static inline var CLASS = "life";
override public function apply(playerId:PlayerId, game:IGame, engine:IEngine):Void {

View File

@@ -9,7 +9,6 @@ import ru.m.tankz.Type;
using ru.m.tankz.game.GameUtil;
class ProtectEagleBonus extends BaseBonus {
public static inline var CLASS = "protect.eagle";
override public function apply(playerId:PlayerId, game:IGame, engine:IEngine):Void {

View File

@@ -8,7 +8,6 @@ import ru.m.tankz.Type;
using ru.m.tankz.game.GameUtil;
class ProtectTankBonus extends BaseBonus {
public static inline var CLASS = "protect.tank";
override public function apply(playerId:PlayerId, game:IGame, engine:IEngine):Void {

Some files were not shown because too many files have changed in this diff Show More