1
0
Fork 0
spacetac/src/scripts/game/Universe.ts

33 lines
933 B
TypeScript
Raw Normal View History

2015-03-03 00:00:00 +00:00
/// <reference path="Serializable.ts"/>
2014-12-29 00:00:00 +00:00
module SpaceTac.Game {
2015-01-07 00:00:00 +00:00
"use strict";
2014-12-29 00:00:00 +00:00
// Main game universe
2015-03-03 00:00:00 +00:00
export class Universe extends Serializable {
2014-12-29 00:00:00 +00:00
// Current connected player
player: Player;
// Currently played battle
battle: Battle;
2015-03-03 00:00:00 +00:00
// Load a game state from a string
static loadFromString(serialized: string): Universe {
var serializer = new Serializer();
return <Universe>serializer.unserialize(serialized);
}
// Start a new "quick battle" game
startQuickBattle(with_ai: boolean = false): void {
this.battle = Game.Battle.newQuickRandom(with_ai);
2015-03-03 00:00:00 +00:00
this.player = this.battle.fleets[0].player;
}
// Serializes the game state to a string
saveToString(): string {
var serializer = new Serializer();
return serializer.serialize(this);
}
2014-12-29 00:00:00 +00:00
}
}