[common] add PackId
This commit is contained in:
@@ -39,5 +39,33 @@ abstract PlayerId(Array<Dynamic>) {
|
||||
}
|
||||
}
|
||||
|
||||
abstract PackId(Array<Dynamic>) {
|
||||
public static inline var DEFAULT = "standard";
|
||||
|
||||
public var type(get, never):GameType;
|
||||
public var name(get, never):String;
|
||||
|
||||
public function new(type:GameType, name:String = DEFAULT) {
|
||||
this = [type, name];
|
||||
}
|
||||
|
||||
private inline function get_type():GameType return this[0];
|
||||
|
||||
private inline function get_name():String return this[1];
|
||||
|
||||
@:from static public inline function fromArray(value:Array<Dynamic>):PackId {
|
||||
return new PackId(value[0], value[1]);
|
||||
}
|
||||
|
||||
@:to public inline function toString():String {
|
||||
return '${type}_${name}';
|
||||
}
|
||||
|
||||
@:op(X == Y) static public inline function equals(x:PackId, y:PackId):Bool {
|
||||
return x.type == y.type && x.name == y.name;
|
||||
}
|
||||
}
|
||||
|
||||
typedef LevelId = Int;
|
||||
|
||||
typedef PresetId = Int;
|
||||
|
||||
@@ -4,5 +4,5 @@ import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
interface ILevelBundle {
|
||||
public function get(type:GameType, name:String):LevelPack;
|
||||
public function get(id:PackId):LevelPack;
|
||||
}
|
||||
|
||||
@@ -115,8 +115,7 @@ typedef LevelConfig = {
|
||||
}
|
||||
|
||||
typedef LevelPack = {
|
||||
var type:GameType;
|
||||
var name:String;
|
||||
var id:PackId;
|
||||
var data:Array<LevelConfig>;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ interface IGame extends GameListener {
|
||||
public var config(default, null):Config;
|
||||
public var winner(default, null):Null<TeamId>;
|
||||
public var state(default, null):GameState;
|
||||
public var level(default, null):LevelConfig;
|
||||
public var controlFactory(default, null):IControlFactory;
|
||||
public var pause(default, set):Bool;
|
||||
public var controls(default, null):Map<String, Control>;
|
||||
|
||||
@@ -11,13 +11,14 @@ typedef LevelProgress = {
|
||||
var presets:Map<Int, LevelResult>;
|
||||
}
|
||||
|
||||
class GameProgress {
|
||||
class PackProgress {
|
||||
|
||||
public var id(default, null):PackId;
|
||||
|
||||
public var type(default, null):GameType;
|
||||
private var completed(default, null):Map<Int, LevelProgress>;
|
||||
|
||||
public function new(type:GameType) {
|
||||
this.type = type;
|
||||
public function new(id:PackId) {
|
||||
this.id = id;
|
||||
this.completed = new Map();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user