[common] add BaseControlFactory

This commit is contained in:
2019-05-28 19:42:46 +03:00
parent 1d95de02e1
commit 31cb20bf85
6 changed files with 40 additions and 34 deletions

View File

@@ -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);
}
}