[proto] update message names
This commit is contained in:
@@ -4,9 +4,14 @@ import ru.m.draw.Color;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
typedef CompleteRule = {
|
||||
@:optional var team:TeamId;
|
||||
}
|
||||
|
||||
typedef GameConfig = {
|
||||
var levels: Int;
|
||||
var friendlyFire:Bool;
|
||||
var complete:Array<CompleteRule>;
|
||||
}
|
||||
|
||||
typedef SpawnPoint = {
|
||||
|
||||
@@ -14,11 +14,15 @@ class Entity implements IKey {
|
||||
|
||||
public function new(rect:Rectangle) {
|
||||
this.id = ++idCounter;
|
||||
this.type = Type.getClassName(Type.getClass(this)).split('.').pop();
|
||||
this.type = Type.getClassName(Type.getClass(this)).split('.').pop().toLowerCase();
|
||||
this.rect = rect;
|
||||
}
|
||||
|
||||
private function get_key():String {
|
||||
return '$type:$id';
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package ru.m.tankz.game;
|
||||
|
||||
import ru.m.tankz.control.IControlFactory;
|
||||
import ru.m.tankz.game.GameSave.PlayerSave;
|
||||
import haxe.ds.Option;
|
||||
import haxe.Timer;
|
||||
import haxework.provider.Provider;
|
||||
@@ -13,6 +11,7 @@ import ru.m.tankz.bundle.IConfigBundle;
|
||||
import ru.m.tankz.bundle.ILevelBundle;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.control.Control;
|
||||
import ru.m.tankz.control.IControlFactory;
|
||||
import ru.m.tankz.core.Bonus;
|
||||
import ru.m.tankz.core.Eagle;
|
||||
import ru.m.tankz.core.Entity;
|
||||
@@ -232,6 +231,11 @@ class Game {
|
||||
}
|
||||
|
||||
public function next():Option<GameState> {
|
||||
for (rule in config.game.complete) {
|
||||
if (rule.team != null && rule.team == state.loser) {
|
||||
return Option.None;
|
||||
}
|
||||
}
|
||||
state.level++;
|
||||
if (state.level >= config.game.levels) state.level = 0;
|
||||
return Option.Some({type: state.type, presetId: preset.id, level: state.level});
|
||||
|
||||
26
src/common/haxe/ru/m/tankz/network/NetworkGame.hx
Normal file
26
src/common/haxe/ru/m/tankz/network/NetworkGame.hx
Normal file
@@ -0,0 +1,26 @@
|
||||
package ru.m.tankz.network;
|
||||
|
||||
import ru.m.tankz.proto.game.GameChangeProto;
|
||||
import ru.m.tankz.proto.core.GameProto;
|
||||
import ru.m.tankz.Type;
|
||||
import ru.m.tankz.game.Game;
|
||||
|
||||
|
||||
class NetworkGame extends Game {
|
||||
|
||||
public function new(type:GameType) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public function load(proto:GameProto):Void {
|
||||
// ToDo:
|
||||
}
|
||||
|
||||
public function update(changes:Array<GameChangeProto>):Void {
|
||||
|
||||
}
|
||||
|
||||
public function export():GameProto {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
package ru.m.tankz.game;
|
||||
package ru.m.tankz.preset;
|
||||
|
||||
import haxe.ds.Option;
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
class ClassicGame extends Game {
|
||||
class ClassicGame extends GamePreset {
|
||||
|
||||
public static var TYPE(default, never):GameType = 'classic';
|
||||
|
||||
@@ -17,13 +14,6 @@ class ClassicGame extends Game {
|
||||
public static var PLAYER2(default, never):PresetId = 'player2';
|
||||
|
||||
public function new() {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
override public function next():Option<GameState> {
|
||||
if (state.loser == HUMAN) {
|
||||
return Option.None;
|
||||
}
|
||||
return super.next();
|
||||
super(TYPE, [HUMAN, BOT], [PLAYER1, PLAYER2]);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package ru.m.tankz.game;
|
||||
package ru.m.tankz.preset;
|
||||
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
class DotaGame extends Game {
|
||||
class DotaGame extends GamePreset {
|
||||
|
||||
public static var TYPE(default, never):GameType = 'dota';
|
||||
|
||||
@@ -16,6 +15,6 @@ class DotaGame extends Game {
|
||||
public static var PLAYER2_VS(default, never):PresetId = 'player2_vs';
|
||||
|
||||
public function new() {
|
||||
super(TYPE);
|
||||
super(TYPE, [RADIANT, DIRE], [PLAYER1, PLAYER2_COOP, PLAYER2_VS]);
|
||||
}
|
||||
}
|
||||
17
src/common/haxe/ru/m/tankz/preset/GamePreset.hx
Normal file
17
src/common/haxe/ru/m/tankz/preset/GamePreset.hx
Normal file
@@ -0,0 +1,17 @@
|
||||
package ru.m.tankz.preset;
|
||||
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
class GamePreset {
|
||||
|
||||
public var type(default, null):GameType;
|
||||
public var teams(default, null):Array<TeamId>;
|
||||
public var presets(default, null):Array<PresetId>;
|
||||
|
||||
public function new(type:GameType, teams:Array<TeamId>, presets:Array<PresetId>) {
|
||||
this.type = type;
|
||||
this.teams = teams;
|
||||
this.presets = presets;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user