diff --git a/src/client/haxe/ru/m/tankz/control/ClientControlFactory.hx b/src/client/haxe/ru/m/tankz/control/ClientControlFactory.hx index 9dcec88..37c4ece 100644 --- a/src/client/haxe/ru/m/tankz/control/ClientControlFactory.hx +++ b/src/client/haxe/ru/m/tankz/control/ClientControlFactory.hx @@ -1,22 +1,10 @@ package ru.m.tankz.control; -import ru.m.tankz.bot.StupidBotControl; -import ru.m.tankz.bot.HardBotControl; import ru.m.tankz.Type; -class ClientControlFactory implements IControlFactory { +class ClientControlFactory extends BaseControlFactory { - public function new() {} - - public function build(id:PlayerId, controller:Controller):Control { - return switch controller { - case HUMAN(index): new HumanControl(id, index); - case BOT(type): switch type { - case StupidBotControl.BOT_TYPE: new StupidBotControl(id); - case HardBotControl.BOT_TYPE: new HardBotControl(id); - case _: null; - } - case NONE: null; - } + override private function buildHuman(id:PlayerId, index:Int):Control { + return new HumanControl(id, index); } } diff --git a/src/common/haxe/ru/m/tankz/control/BaseControlFactory.hx b/src/common/haxe/ru/m/tankz/control/BaseControlFactory.hx new file mode 100644 index 0000000..4cb9b3f --- /dev/null +++ b/src/common/haxe/ru/m/tankz/control/BaseControlFactory.hx @@ -0,0 +1,30 @@ +package ru.m.tankz.control; + +import ru.m.tankz.bot.HardBotControl; +import ru.m.tankz.bot.StupidBotControl; +import ru.m.tankz.Type; + +class BaseControlFactory implements IControlFactory { + + public function new() {} + + public function build(id:PlayerId, controller:Controller):Control { + return switch controller { + case Controller.HUMAN(index): buildHuman(id, index); + case Controller.BOT(type): buildBot(id, type); + case Controller.NONE: null; + } + } + + private function buildHuman(id:PlayerId, index:Int):Control { + return null; + } + + private function buildBot(id:PlayerId, type:String):Control { + return switch type { + case StupidBotControl.BOT_TYPE: new StupidBotControl(id); + case HardBotControl.BOT_TYPE: new HardBotControl(id); + case _: null; + } + } +} diff --git a/src/common/haxe/ru/m/tankz/game/EntityBuilder.hx b/src/common/haxe/ru/m/tankz/game/EntityBuilder.hx index 18b1c5a..817e4c0 100644 --- a/src/common/haxe/ru/m/tankz/game/EntityBuilder.hx +++ b/src/common/haxe/ru/m/tankz/game/EntityBuilder.hx @@ -23,7 +23,7 @@ class EntityBuilder { public function new(config:Config) { this.config = config; - this.entityId = 0; + this.entityId = 1; } public function buildRect(point:EntityPoint, width:Float, height:Float):Rectangle { diff --git a/src/common/haxe/ru/m/tankz/game/GameRunner.hx b/src/common/haxe/ru/m/tankz/game/GameRunner.hx index 15668c9..ed11e8d 100644 --- a/src/common/haxe/ru/m/tankz/game/GameRunner.hx +++ b/src/common/haxe/ru/m/tankz/game/GameRunner.hx @@ -306,7 +306,7 @@ class GameRunner extends Game implements EngineListener { super.onGameEvent(event); switch event { case GameEvent.START(_): - timer = new Timer(10); + timer = new Timer(30); timer.run = update; case GameEvent.COMPLETE(_, _): if (timer != null) { diff --git a/src/server/haxe/ru/m/tankz/server/control/ServerControlFactory.hx b/src/server/haxe/ru/m/tankz/server/control/ServerControlFactory.hx index 16f95c0..0efb997 100644 --- a/src/server/haxe/ru/m/tankz/server/control/ServerControlFactory.hx +++ b/src/server/haxe/ru/m/tankz/server/control/ServerControlFactory.hx @@ -1,25 +1,13 @@ package ru.m.tankz.server.control; import ru.m.tankz.bot.HardBotControl; -import ru.m.tankz.bot.StupidBotControl; +import ru.m.tankz.control.BaseControlFactory; import ru.m.tankz.control.Control; -import ru.m.tankz.control.Controller; -import ru.m.tankz.control.IControlFactory; import ru.m.tankz.Type.PlayerId; -class ServerControlFactory implements IControlFactory { +class ServerControlFactory extends BaseControlFactory { - public function new() {} - - public function build(id:PlayerId, controller:Controller):Control { - return switch controller { - case HUMAN(index): new HardBotControl(id); // ToDo: - case BOT(type): switch type { - case StupidBotControl.BOT_TYPE: new StupidBotControl(id); - case HardBotControl.BOT_TYPE: new HardBotControl(id); - case _: null; - } - case NONE: null; - } + override private function buildHuman(id:PlayerId, index:Int):Control { + return new HardBotControl(id); // ToDo: } } diff --git a/src/server/haxe/ru/m/tankz/server/game/GameManager.hx b/src/server/haxe/ru/m/tankz/server/game/GameManager.hx index ab2dcd3..f2bd359 100644 --- a/src/server/haxe/ru/m/tankz/server/game/GameManager.hx +++ b/src/server/haxe/ru/m/tankz/server/game/GameManager.hx @@ -21,8 +21,8 @@ class _GameListener implements GameListener { dispatcher.dispatchEvent(game, event); switch event { case COMPLETE(_, _): - dispose(); dispatcher.delete(game.proto.id); + dispose(); case _: } }