diff --git a/TODO b/TODO index 00ec993..ffb282c 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,9 @@ * Restore serialization * Drones: add tooltip * Drones: add hull points and take area damage +* Drones: change the sprite angle for deploy animation +* Better display of effects over ship sprite (repairs, sticky effects...) +* Add a battle log display * Organize arena objects and information in layers * Allow to cancel last moves * Add more visual effects to weapons, hits and explosions diff --git a/out/index.html b/out/index.html index d2dfdbf..18e88cf 100644 --- a/out/index.html +++ b/out/index.html @@ -31,7 +31,7 @@ diff --git a/src/GameUI.ts b/src/MainUI.ts similarity index 65% rename from src/GameUI.ts rename to src/MainUI.ts index e10ddc3..63b7fec 100644 --- a/src/GameUI.ts +++ b/src/MainUI.ts @@ -6,30 +6,30 @@ if (typeof window != "undefined") { module TS.SpaceTac { // Router between game views - export class GameUI extends Phaser.Game { + export class MainUI extends Phaser.Game { // Current game session - session: Game.GameSession; + session: GameSession; // Current focused star system - star: Game.Star; + star: Star; // Audio manager - audio: View.Audio; + audio: UI.Audio; constructor(headless: boolean = false) { super(1920, 1080, headless ? Phaser.HEADLESS : Phaser.AUTO, '-space-tac'); - this.audio = new View.Audio(this); + this.audio = new UI.Audio(this); - this.session = new Game.GameSession(); + this.session = new GameSession(); this.star = null; - this.state.add('boot', View.Boot); - this.state.add('preload', View.Preload); - this.state.add('mainmenu', View.MainMenu); - this.state.add('router', View.Router); - this.state.add('battle', View.BattleView); - this.state.add('universe', View.UniverseMapView); + this.state.add('boot', UI.Boot); + this.state.add('preload', UI.Preload); + this.state.add('mainmenu', UI.MainMenu); + this.state.add('router', UI.Router); + this.state.add('battle', UI.BattleView); + this.state.add('universe', UI.UniverseMapView); this.state.start('boot'); } @@ -38,10 +38,10 @@ module TS.SpaceTac { saveGame(): boolean { if (typeof (Storage) !== "undefined") { localStorage.setItem("spacetac-savegame", this.session.saveToString()); - (this.state.getCurrentState()).messages.addMessage("Game saved"); + (this.state.getCurrentState()).messages.addMessage("Game saved"); return true; } else { - (this.state.getCurrentState()).messages.addMessage("Your browser does not support saving"); + (this.state.getCurrentState()).messages.addMessage("Your browser does not support saving"); return false; } } @@ -51,7 +51,7 @@ module TS.SpaceTac { if (typeof (Storage) !== "undefined") { var loaded = localStorage.getItem("spacetac-savegame"); if (loaded) { - this.session = Game.GameSession.loadFromString(loaded); + this.session = GameSession.loadFromString(loaded); console.log("Game loaded"); return true; } else { @@ -65,7 +65,7 @@ module TS.SpaceTac { } // Get the focuses star system - getFocusedStar(): Game.Star { + getFocusedStar(): Star { if (this.star && this.star.universe === this.session.universe) { return this.star; } else { diff --git a/src/common b/src/common index 6d16fc0..7952670 160000 --- a/src/common +++ b/src/common @@ -1 +1 @@ -Subproject commit 6d16fc0a5b50aa53c68c09fda2d0d3c5ec22b02d +Subproject commit 795267025bbe1f67c33645af12096dd57a8f1109 diff --git a/src/game/Battle.spec.ts b/src/core/Battle.spec.ts similarity index 99% rename from src/game/Battle.spec.ts rename to src/core/Battle.spec.ts index d283ad8..b8a5ce4 100644 --- a/src/game/Battle.spec.ts +++ b/src/core/Battle.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { describe("Battle", function () { it("defines play order by initiative throws", function () { var fleet1 = new Fleet(null); diff --git a/src/game/Battle.ts b/src/core/Battle.ts similarity index 99% rename from src/game/Battle.ts rename to src/core/Battle.ts index 4cb3926..9e97ca9 100644 --- a/src/game/Battle.ts +++ b/src/core/Battle.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // A turn-based battle between fleets export class Battle { // Flag indicating if the battle is ended diff --git a/src/game/BattleLog.spec.ts b/src/core/BattleLog.spec.ts similarity index 99% rename from src/game/BattleLog.spec.ts rename to src/core/BattleLog.spec.ts index 54ae478..56cc1c0 100644 --- a/src/game/BattleLog.spec.ts +++ b/src/core/BattleLog.spec.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Check a single game log event function checkEvent(got: BaseLogEvent, ship: Ship, code: string, target_ship: Ship = null, target_x: number = null, target_y: number = null): void { diff --git a/src/game/BattleLog.ts b/src/core/BattleLog.ts similarity index 98% rename from src/game/BattleLog.ts rename to src/core/BattleLog.ts index 6c1b6d2..27c53b2 100644 --- a/src/game/BattleLog.ts +++ b/src/core/BattleLog.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Log of a battle // This keeps track of all events in a battle // It also allows to register a callback to receive these events diff --git a/src/game/BattleOutcome.spec.ts b/src/core/BattleOutcome.spec.ts similarity index 99% rename from src/game/BattleOutcome.spec.ts rename to src/core/BattleOutcome.spec.ts index 5c3d5f6..2fd7df4 100644 --- a/src/game/BattleOutcome.spec.ts +++ b/src/core/BattleOutcome.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("BattleOutcome", () => { it("generates loot from dead ships, for the winner to take", () => { var fleet1 = new Fleet(); diff --git a/src/game/BattleOutcome.ts b/src/core/BattleOutcome.ts similarity index 99% rename from src/game/BattleOutcome.ts rename to src/core/BattleOutcome.ts index 6a5634d..a941ba2 100644 --- a/src/game/BattleOutcome.ts +++ b/src/core/BattleOutcome.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Result of an ended battle export class BattleOutcome { // Indicates if the battle is a draw (no winner) diff --git a/src/game/Drone.spec.ts b/src/core/Drone.spec.ts similarity index 99% rename from src/game/Drone.spec.ts rename to src/core/Drone.spec.ts index 553baf1..593b27c 100644 --- a/src/game/Drone.spec.ts +++ b/src/core/Drone.spec.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * Fake effect to capture apply requests */ diff --git a/src/game/Drone.ts b/src/core/Drone.ts similarity index 99% rename from src/game/Drone.ts rename to src/core/Drone.ts index 512d97d..19e11e3 100644 --- a/src/game/Drone.ts +++ b/src/core/Drone.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * Drones are static objects that apply effects in a circular zone around themselves. */ diff --git a/src/game/EffectTemplate.spec.ts b/src/core/EffectTemplate.spec.ts similarity index 96% rename from src/game/EffectTemplate.spec.ts rename to src/core/EffectTemplate.spec.ts index 66bde8e..d032f18 100644 --- a/src/game/EffectTemplate.spec.ts +++ b/src/core/EffectTemplate.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("EffectTemplate", () => { it("interpolates between weak and strong effects", () => { var base_effect = new AttributeEffect("hull_capacity", 6); diff --git a/src/game/EffectTemplate.ts b/src/core/EffectTemplate.ts similarity index 97% rename from src/game/EffectTemplate.ts rename to src/core/EffectTemplate.ts index 14a26bd..2f63ac6 100644 --- a/src/game/EffectTemplate.ts +++ b/src/core/EffectTemplate.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Modifier for a value of a BaseEffect subclass export class EffectTemplateModifier { // Value name diff --git a/src/game/Equipment.spec.ts b/src/core/Equipment.spec.ts similarity index 98% rename from src/game/Equipment.spec.ts rename to src/core/Equipment.spec.ts index 49f4918..76a3118 100644 --- a/src/game/Equipment.spec.ts +++ b/src/core/Equipment.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("Equipment", () => { it("checks capabilities requirements", function () { var equipment = new Equipment(); diff --git a/src/game/Equipment.ts b/src/core/Equipment.ts similarity index 99% rename from src/game/Equipment.ts rename to src/core/Equipment.ts index 7a578b3..116b040 100644 --- a/src/game/Equipment.ts +++ b/src/core/Equipment.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Piece of equipment to attach in slots export class Equipment { // Actual slot this equipment is attached to diff --git a/src/game/Fleet.spec.ts b/src/core/Fleet.spec.ts similarity index 94% rename from src/game/Fleet.spec.ts rename to src/core/Fleet.spec.ts index 7aad1c8..904c628 100644 --- a/src/game/Fleet.spec.ts +++ b/src/core/Fleet.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { describe("Fleet", function () { it("get average level", function () { var fleet = new Fleet(); diff --git a/src/game/Fleet.ts b/src/core/Fleet.ts similarity index 98% rename from src/game/Fleet.ts rename to src/core/Fleet.ts index 296df77..ed5208b 100644 --- a/src/game/Fleet.ts +++ b/src/core/Fleet.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // A fleet of ships export class Fleet { // Fleet owner diff --git a/src/game/FleetGenerator.ts b/src/core/FleetGenerator.ts similarity index 96% rename from src/game/FleetGenerator.ts rename to src/core/FleetGenerator.ts index 85427fc..512309d 100644 --- a/src/game/FleetGenerator.ts +++ b/src/core/FleetGenerator.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Generator of balanced ships to form a fleet export class FleetGenerator { // Random generator to use diff --git a/src/game/GameSession.spec.ts b/src/core/GameSession.spec.ts similarity index 97% rename from src/game/GameSession.spec.ts rename to src/core/GameSession.spec.ts index 56cc85e..9e490a0 100644 --- a/src/game/GameSession.spec.ts +++ b/src/core/GameSession.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { function applyGameSteps(session: GameSession): void { var battle = session.getBattle(); battle.advanceToNextShip(); diff --git a/src/game/GameSession.ts b/src/core/GameSession.ts similarity index 87% rename from src/game/GameSession.ts rename to src/core/GameSession.ts index edc49fd..eeb2029 100644 --- a/src/game/GameSession.ts +++ b/src/core/GameSession.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // A game session, binding a universe and a player export class GameSession { // Game universe @@ -14,13 +14,13 @@ module TS.SpaceTac.Game { // Load a game state from a string static loadFromString(serialized: string): GameSession { - var serializer = new Serializer(); + var serializer = new Serializer(TS.SpaceTac); return serializer.unserialize(serialized); } // Serializes the game state to a string saveToString(): string { - var serializer = new Serializer(); + var serializer = new Serializer(TS.SpaceTac); return serializer.serialize(this); } @@ -35,14 +35,14 @@ module TS.SpaceTac.Game { start_location.encounter_gen = true; start_location.encounter = null; - this.player = new Game.Player(this.universe); + this.player = new Player(this.universe); this.player.fleet = fleet_generator.generate(1, this.player); this.player.fleet.setLocation(start_location); } // Start a new "quick battle" game startQuickBattle(with_ai: boolean = false): void { - var battle = Game.Battle.newQuickRandom(with_ai); + var battle = Battle.newQuickRandom(with_ai); this.player = battle.fleets[0].player; this.player.setBattle(battle); } diff --git a/src/game/LootGenerator.spec.ts b/src/core/LootGenerator.spec.ts similarity index 96% rename from src/game/LootGenerator.spec.ts rename to src/core/LootGenerator.spec.ts index 2d5bd1c..03bf898 100644 --- a/src/game/LootGenerator.spec.ts +++ b/src/core/LootGenerator.spec.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { class TestTemplate extends LootTemplate { constructor() { super(SlotType.Shield, "Hexagrid Shield"); diff --git a/src/game/LootGenerator.ts b/src/core/LootGenerator.ts similarity index 92% rename from src/game/LootGenerator.ts rename to src/core/LootGenerator.ts index b381610..c854ff4 100644 --- a/src/game/LootGenerator.ts +++ b/src/core/LootGenerator.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Equipment generator from loot templates export class LootGenerator { // List of available templates @@ -21,9 +21,9 @@ module TS.SpaceTac.Game { // Fill the list of templates populate(): void { var templates: LootTemplate[] = []; - for (var template_name in TS.SpaceTac.Game.Equipments) { + for (var template_name in TS.SpaceTac.Equipments) { if (template_name && template_name.indexOf("Abstract") != 0) { - var template_class = TS.SpaceTac.Game.Equipments[template_name]; + var template_class = TS.SpaceTac.Equipments[template_name]; var template: LootTemplate = new template_class(); templates.push(template); } diff --git a/src/game/LootTemplate.spec.ts b/src/core/LootTemplate.spec.ts similarity index 99% rename from src/game/LootTemplate.spec.ts rename to src/core/LootTemplate.spec.ts index 96062bd..26ce884 100644 --- a/src/game/LootTemplate.spec.ts +++ b/src/core/LootTemplate.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("LootTemplate", () => { it("interpolates between weak and strong loot", () => { var template = new LootTemplate(SlotType.Weapon, "Bulletator"); diff --git a/src/game/LootTemplate.ts b/src/core/LootTemplate.ts similarity index 99% rename from src/game/LootTemplate.ts rename to src/core/LootTemplate.ts index af77416..378fd9a 100644 --- a/src/game/LootTemplate.ts +++ b/src/core/LootTemplate.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Template used to generate a loot equipment export class LootTemplate { // Type of slot this equipment will fit in diff --git a/src/game/MoveFireSimulator.spec.ts b/src/core/MoveFireSimulator.spec.ts similarity index 99% rename from src/game/MoveFireSimulator.spec.ts rename to src/core/MoveFireSimulator.spec.ts index 4d69736..3531a2a 100644 --- a/src/game/MoveFireSimulator.spec.ts +++ b/src/core/MoveFireSimulator.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("MoveFireSimulator", function () { function simpleWeaponCase(distance = 10, ship_ap = 5, weapon_ap = 3, engine_distance = 5): [Ship, MoveFireSimulator, BaseAction] { diff --git a/src/game/MoveFireSimulator.ts b/src/core/MoveFireSimulator.ts similarity index 99% rename from src/game/MoveFireSimulator.ts rename to src/core/MoveFireSimulator.ts index 2fa28fa..a955aa5 100644 --- a/src/game/MoveFireSimulator.ts +++ b/src/core/MoveFireSimulator.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * A single action in the sequence result from the simulator diff --git a/src/game/NameGenerator.spec.ts b/src/core/NameGenerator.spec.ts similarity index 92% rename from src/game/NameGenerator.spec.ts rename to src/core/NameGenerator.spec.ts index 1fdf9a1..8f3e20d 100644 --- a/src/game/NameGenerator.spec.ts +++ b/src/core/NameGenerator.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("NameGenerator", () => { it("generates unique names", () => { var random = new RandomGenerator(0.48, 0.9, 0.1); diff --git a/src/game/NameGenerator.ts b/src/core/NameGenerator.ts similarity index 96% rename from src/game/NameGenerator.ts rename to src/core/NameGenerator.ts index 8d328bb..156ecf9 100644 --- a/src/game/NameGenerator.ts +++ b/src/core/NameGenerator.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // A unique name generator export class NameGenerator { // List of available choices diff --git a/src/game/Player.spec.ts b/src/core/Player.spec.ts similarity index 98% rename from src/game/Player.spec.ts rename to src/core/Player.spec.ts index 9ab2ef2..d7858bc 100644 --- a/src/game/Player.spec.ts +++ b/src/core/Player.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { describe("Player", function () { it("keeps track of visited locations", function () { let player = new Player(); diff --git a/src/game/Player.ts b/src/core/Player.ts similarity index 98% rename from src/game/Player.ts rename to src/core/Player.ts index 5e0c2df..bc6911c 100644 --- a/src/game/Player.ts +++ b/src/core/Player.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // One player (human or IA) export class Player { // Universe in which we are playing diff --git a/src/game/RandomGenerator.ts b/src/core/RandomGenerator.ts similarity index 98% rename from src/game/RandomGenerator.ts rename to src/core/RandomGenerator.ts index a27048e..dbe978c 100644 --- a/src/game/RandomGenerator.ts +++ b/src/core/RandomGenerator.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Random generator, used in all throws export class RandomGenerator { // Array of next values, empty for a correct generator diff --git a/src/game/Range.spec.ts b/src/core/Range.spec.ts similarity index 98% rename from src/game/Range.spec.ts rename to src/core/Range.spec.ts index 44965cf..65b63d4 100644 --- a/src/game/Range.spec.ts +++ b/src/core/Range.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { function checkProportional(range: Range, value1: number, value2: number) { expect(range.getProportional(value1)).toEqual(value2); expect(range.getReverseProportional(value2)).toEqual(value1); diff --git a/src/game/Range.ts b/src/core/Range.ts similarity index 99% rename from src/game/Range.ts rename to src/core/Range.ts index e74961c..45f7b8b 100644 --- a/src/game/Range.ts +++ b/src/core/Range.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Range of number values export class Range { // Minimal value diff --git a/src/game/Ship.spec.ts b/src/core/Ship.spec.ts similarity index 99% rename from src/game/Ship.spec.ts rename to src/core/Ship.spec.ts index 38bcd22..1b88d80 100644 --- a/src/game/Ship.spec.ts +++ b/src/core/Ship.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("Ship", function () { it("moves and computes facing angle", function () { var ship = new Ship(null, "Test"); diff --git a/src/game/Ship.ts b/src/core/Ship.ts similarity index 99% rename from src/game/Ship.ts rename to src/core/Ship.ts index 59513bd..0ac82e3 100644 --- a/src/game/Ship.ts +++ b/src/core/Ship.ts @@ -1,7 +1,7 @@ /// /// -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * Set of ShipAttribute for a ship diff --git a/src/game/ShipAttribute.ts b/src/core/ShipAttribute.ts similarity index 94% rename from src/game/ShipAttribute.ts rename to src/core/ShipAttribute.ts index d8234dc..f5e241c 100644 --- a/src/game/ShipAttribute.ts +++ b/src/core/ShipAttribute.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * A ship attribute is a value computed by a sum of contributions from equipments and sticky effects. * diff --git a/src/game/ShipGenerator.spec.ts b/src/core/ShipGenerator.spec.ts similarity index 94% rename from src/game/ShipGenerator.spec.ts rename to src/core/ShipGenerator.spec.ts index 6187efa..7da28bc 100644 --- a/src/game/ShipGenerator.spec.ts +++ b/src/core/ShipGenerator.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("ShipGenerator", function () { it("can use ship model", function () { var gen = new ShipGenerator(); diff --git a/src/game/ShipGenerator.ts b/src/core/ShipGenerator.ts similarity index 97% rename from src/game/ShipGenerator.ts rename to src/core/ShipGenerator.ts index 157fcd2..b35fd4e 100644 --- a/src/game/ShipGenerator.ts +++ b/src/core/ShipGenerator.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Generator of random ship export class ShipGenerator { // Random number generator used diff --git a/src/game/ShipModel.ts b/src/core/ShipModel.ts similarity index 98% rename from src/game/ShipModel.ts rename to src/core/ShipModel.ts index a2d2280..7d278a5 100644 --- a/src/game/ShipModel.ts +++ b/src/core/ShipModel.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // A model of ship // It defines the ship looks, and available slots for equipment export class ShipModel { diff --git a/src/game/ShipValue.spec.ts b/src/core/ShipValue.spec.ts similarity index 98% rename from src/game/ShipValue.spec.ts rename to src/core/ShipValue.spec.ts index c385d73..a8e7872 100644 --- a/src/game/ShipValue.spec.ts +++ b/src/core/ShipValue.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { describe("ShipValue", function () { it("is initially not limited", function () { var attr = new ShipValue("test"); diff --git a/src/game/ShipValue.ts b/src/core/ShipValue.ts similarity index 98% rename from src/game/ShipValue.ts rename to src/core/ShipValue.ts index cc60fea..bf46f33 100644 --- a/src/game/ShipValue.ts +++ b/src/core/ShipValue.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * A ship value is a number that may vary and be constrained in a given range. */ diff --git a/src/game/Slot.spec.ts b/src/core/Slot.spec.ts similarity index 97% rename from src/game/Slot.spec.ts rename to src/core/Slot.spec.ts index 3b6f4f0..ccb9737 100644 --- a/src/game/Slot.spec.ts +++ b/src/core/Slot.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("Slot", () => { it("checks equipment type", () => { var ship = new Ship(); diff --git a/src/game/Slot.ts b/src/core/Slot.ts similarity index 97% rename from src/game/Slot.ts rename to src/core/Slot.ts index 9c66190..59780bf 100644 --- a/src/game/Slot.ts +++ b/src/core/Slot.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Types of slots export enum SlotType { Armor, diff --git a/src/game/Star.spec.ts b/src/core/Star.spec.ts similarity index 98% rename from src/game/Star.spec.ts rename to src/core/Star.spec.ts index 841a7b4..d8129cf 100644 --- a/src/game/Star.spec.ts +++ b/src/core/Star.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("Star", () => { it("lists links to other stars", () => { var universe = new Universe(); diff --git a/src/game/Star.ts b/src/core/Star.ts similarity index 99% rename from src/game/Star.ts rename to src/core/Star.ts index fc81406..58db5d4 100644 --- a/src/game/Star.ts +++ b/src/core/Star.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // A star system export class Star { diff --git a/src/game/StarLink.spec.ts b/src/core/StarLink.spec.ts similarity index 98% rename from src/game/StarLink.spec.ts rename to src/core/StarLink.spec.ts index 17bfc8b..662ab0c 100644 --- a/src/game/StarLink.spec.ts +++ b/src/core/StarLink.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("StarLink", () => { it("checks link intersection", () => { var star1 = new Star(null, 0, 0); diff --git a/src/game/StarLink.ts b/src/core/StarLink.ts similarity index 98% rename from src/game/StarLink.ts rename to src/core/StarLink.ts index 762efc6..829a816 100644 --- a/src/game/StarLink.ts +++ b/src/core/StarLink.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // An hyperspace link between two star systems export class StarLink { // Stars diff --git a/src/game/StarLocation.spec.ts b/src/core/StarLocation.spec.ts similarity index 97% rename from src/game/StarLocation.spec.ts rename to src/core/StarLocation.spec.ts index 3f2bf71..5ce4061 100644 --- a/src/game/StarLocation.spec.ts +++ b/src/core/StarLocation.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("StarLocation", () => { it("removes generated encounters that lose", function () { var location = new StarLocation(null, StarLocationType.PLANET, 0, 0); diff --git a/src/game/StarLocation.ts b/src/core/StarLocation.ts similarity index 99% rename from src/game/StarLocation.ts rename to src/core/StarLocation.ts index 2de6472..1b1e113 100644 --- a/src/game/StarLocation.ts +++ b/src/core/StarLocation.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { export enum StarLocationType { STAR, WARP, diff --git a/src/game/Target.spec.ts b/src/core/Target.spec.ts similarity index 98% rename from src/game/Target.spec.ts rename to src/core/Target.spec.ts index 778b679..f12296f 100644 --- a/src/game/Target.spec.ts +++ b/src/core/Target.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("Target", () => { it("initializes from ship or location", () => { var target: Target; diff --git a/src/game/Target.ts b/src/core/Target.ts similarity index 99% rename from src/game/Target.ts rename to src/core/Target.ts index de4ffed..71e7074 100644 --- a/src/game/Target.ts +++ b/src/core/Target.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Find the nearest intersection between a line and a circle // Circle is supposed to be centered at (0,0) // Nearest intersection to (x1,y1) is returned diff --git a/src/game/TestTools.ts b/src/core/TestTools.ts similarity index 99% rename from src/game/TestTools.ts rename to src/core/TestTools.ts index 40459bf..48e49b3 100644 --- a/src/game/TestTools.ts +++ b/src/core/TestTools.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // unit testing utilities export class TestTools { diff --git a/src/game/Universe.spec.ts b/src/core/Universe.spec.ts similarity index 99% rename from src/game/Universe.spec.ts rename to src/core/Universe.spec.ts index 92bb0e8..892a9f1 100644 --- a/src/game/Universe.spec.ts +++ b/src/core/Universe.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("Universe", () => { it("generates star systems", () => { var universe = new Universe(); diff --git a/src/game/Universe.ts b/src/core/Universe.ts similarity index 99% rename from src/game/Universe.ts rename to src/core/Universe.ts index 22d4ee5..6720847 100644 --- a/src/game/Universe.ts +++ b/src/core/Universe.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Main game universe export class Universe { // List of star systems diff --git a/src/game/actions/BaseAction.spec.ts b/src/core/actions/BaseAction.spec.ts similarity index 97% rename from src/game/actions/BaseAction.spec.ts rename to src/core/actions/BaseAction.spec.ts index 34e3bf0..e0c8d04 100644 --- a/src/game/actions/BaseAction.spec.ts +++ b/src/core/actions/BaseAction.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { describe("BaseAction", function () { it("check if equipment can be used with remaining AP", function () { var equipment = new Equipment(SlotType.Armor); diff --git a/src/game/actions/BaseAction.ts b/src/core/actions/BaseAction.ts similarity index 99% rename from src/game/actions/BaseAction.ts rename to src/core/actions/BaseAction.ts index 6ec90bc..8539a96 100644 --- a/src/game/actions/BaseAction.ts +++ b/src/core/actions/BaseAction.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Base class for action definitions export class BaseAction { // Identifier code for the type of action diff --git a/src/game/actions/DeployDroneAction.spec.ts b/src/core/actions/DeployDroneAction.spec.ts similarity index 98% rename from src/game/actions/DeployDroneAction.spec.ts rename to src/core/actions/DeployDroneAction.spec.ts index c9804e4..bc93ec2 100644 --- a/src/game/actions/DeployDroneAction.spec.ts +++ b/src/core/actions/DeployDroneAction.spec.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { describe("DeployDroneAction", function () { it("stores useful information", function () { let equipment = new Equipment(SlotType.Weapon, "testdrone"); diff --git a/src/game/actions/DeployDroneAction.ts b/src/core/actions/DeployDroneAction.ts similarity index 97% rename from src/game/actions/DeployDroneAction.ts rename to src/core/actions/DeployDroneAction.ts index c8bf626..81bf3c2 100644 --- a/src/game/actions/DeployDroneAction.ts +++ b/src/core/actions/DeployDroneAction.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * Action to deploy a drone in space */ diff --git a/src/game/actions/EndTurnAction.spec.ts b/src/core/actions/EndTurnAction.spec.ts similarity index 96% rename from src/game/actions/EndTurnAction.spec.ts rename to src/core/actions/EndTurnAction.spec.ts index c0a5902..a69b7d5 100644 --- a/src/game/actions/EndTurnAction.spec.ts +++ b/src/core/actions/EndTurnAction.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("EndTurnAction", () => { it("can't be applied to non-playing ship", () => { var battle = Battle.newQuickRandom(); diff --git a/src/game/actions/EndTurnAction.ts b/src/core/actions/EndTurnAction.ts similarity index 93% rename from src/game/actions/EndTurnAction.ts rename to src/core/actions/EndTurnAction.ts index 828bdf3..970bf88 100644 --- a/src/game/actions/EndTurnAction.ts +++ b/src/core/actions/EndTurnAction.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Action to end the ship's turn export class EndTurnAction extends BaseAction { constructor() { diff --git a/src/game/actions/FireWeaponAction.ts b/src/core/actions/FireWeaponAction.ts similarity index 98% rename from src/game/actions/FireWeaponAction.ts rename to src/core/actions/FireWeaponAction.ts index ba83d33..6cf62ff 100644 --- a/src/game/actions/FireWeaponAction.ts +++ b/src/core/actions/FireWeaponAction.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Action to fire a weapon on another ship, or in space export class FireWeaponAction extends BaseAction { // Boolean set to true if the weapon can target space diff --git a/src/game/actions/MoveAction.spec.ts b/src/core/actions/MoveAction.spec.ts similarity index 99% rename from src/game/actions/MoveAction.spec.ts rename to src/core/actions/MoveAction.spec.ts index 4f7ad63..3b58a56 100644 --- a/src/game/actions/MoveAction.spec.ts +++ b/src/core/actions/MoveAction.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { describe("MoveAction", function () { it("checks movement against remaining AP", function () { var ship = new Ship(); diff --git a/src/game/actions/MoveAction.ts b/src/core/actions/MoveAction.ts similarity index 98% rename from src/game/actions/MoveAction.ts rename to src/core/actions/MoveAction.ts index 843a33e..c5f79f5 100644 --- a/src/game/actions/MoveAction.ts +++ b/src/core/actions/MoveAction.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Action to move to a given location export class MoveAction extends BaseAction { diff --git a/src/game/ai/AbstractAI.ts b/src/core/ai/AbstractAI.ts similarity index 99% rename from src/game/ai/AbstractAI.ts rename to src/core/ai/AbstractAI.ts index f811889..1c92e78 100644 --- a/src/game/ai/AbstractAI.ts +++ b/src/core/ai/AbstractAI.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.AI { +module TS.SpaceTac.AI { // Base class for all Artificial Intelligence interaction export class AbstractAI { // The fleet controlled by this AI diff --git a/src/game/ai/BullyAI.spec.ts b/src/core/ai/BullyAI.spec.ts similarity index 99% rename from src/game/ai/BullyAI.spec.ts rename to src/core/ai/BullyAI.spec.ts index dcde737..1920f07 100644 --- a/src/game/ai/BullyAI.spec.ts +++ b/src/core/ai/BullyAI.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.AI.Specs { +module TS.SpaceTac.AI.Specs { describe("BullyAI", function () { it("lists enemies", function () { var battle = new Battle(); diff --git a/src/game/ai/BullyAI.ts b/src/core/ai/BullyAI.ts similarity index 99% rename from src/game/ai/BullyAI.ts rename to src/core/ai/BullyAI.ts index f4f030f..f4e1b44 100644 --- a/src/game/ai/BullyAI.ts +++ b/src/core/ai/BullyAI.ts @@ -1,5 +1,5 @@ /// -module TS.SpaceTac.Game.AI { +module TS.SpaceTac.AI { // Combination of a move action and a fire action export class BullyManeuver { // Move action to position the ship before firing diff --git a/src/game/ai/Maneuver.ts b/src/core/ai/Maneuver.ts similarity index 95% rename from src/game/ai/Maneuver.ts rename to src/core/ai/Maneuver.ts index e607934..4d64724 100644 --- a/src/game/ai/Maneuver.ts +++ b/src/core/ai/Maneuver.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.AI { +module TS.SpaceTac.AI { // Ship maneuver for an artifical intelligence // A maneuver is like a human player action, choosing an equipment and using it export class Maneuver { diff --git a/src/game/ai/ManeuverSequence.ts b/src/core/ai/ManeuverSequence.ts similarity index 92% rename from src/game/ai/ManeuverSequence.ts rename to src/core/ai/ManeuverSequence.ts index 67b5436..1acdc52 100644 --- a/src/game/ai/ManeuverSequence.ts +++ b/src/core/ai/ManeuverSequence.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.AI { +module TS.SpaceTac.AI { // A chain of Maneuver to execute sequentially export class ManeuverSequence { // Concerned ship diff --git a/src/game/effects/AttributeEffect.spec.ts b/src/core/effects/AttributeEffect.spec.ts similarity index 100% rename from src/game/effects/AttributeEffect.spec.ts rename to src/core/effects/AttributeEffect.spec.ts diff --git a/src/game/effects/AttributeEffect.ts b/src/core/effects/AttributeEffect.ts similarity index 97% rename from src/game/effects/AttributeEffect.ts rename to src/core/effects/AttributeEffect.ts index 4dc2f62..9b25a7c 100644 --- a/src/game/effects/AttributeEffect.ts +++ b/src/core/effects/AttributeEffect.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * Effect to modify an attribute. * diff --git a/src/game/effects/AttributeLimitEffect.ts b/src/core/effects/AttributeLimitEffect.ts similarity index 97% rename from src/game/effects/AttributeLimitEffect.ts rename to src/core/effects/AttributeLimitEffect.ts index 1da7f49..f41f537 100644 --- a/src/game/effects/AttributeLimitEffect.ts +++ b/src/core/effects/AttributeLimitEffect.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * Enforce a limitation on ship attribute final value * diff --git a/src/game/effects/BaseEffect.ts b/src/core/effects/BaseEffect.ts similarity index 98% rename from src/game/effects/BaseEffect.ts rename to src/core/effects/BaseEffect.ts index 477a2bd..0181782 100644 --- a/src/game/effects/BaseEffect.ts +++ b/src/core/effects/BaseEffect.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Base class for effects of actions // Effects are typically one shot, but sticky effects can be used to apply effects over a period export class BaseEffect { diff --git a/src/game/effects/DamageEffect.ts b/src/core/effects/DamageEffect.ts similarity index 97% rename from src/game/effects/DamageEffect.ts rename to src/core/effects/DamageEffect.ts index 0ccce93..8d159ed 100644 --- a/src/game/effects/DamageEffect.ts +++ b/src/core/effects/DamageEffect.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * Apply damage on a ship. * diff --git a/src/game/effects/StickyEffect.ts b/src/core/effects/StickyEffect.ts similarity index 99% rename from src/game/effects/StickyEffect.ts rename to src/core/effects/StickyEffect.ts index 61f614f..0b48252 100644 --- a/src/game/effects/StickyEffect.ts +++ b/src/core/effects/StickyEffect.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * Wrapper around another effect, to make it stick to a ship. * diff --git a/src/game/effects/ValueEffect.spec.ts b/src/core/effects/ValueEffect.spec.ts similarity index 97% rename from src/game/effects/ValueEffect.spec.ts rename to src/core/effects/ValueEffect.spec.ts index b8ffd35..2e0b186 100644 --- a/src/game/effects/ValueEffect.spec.ts +++ b/src/core/effects/ValueEffect.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { describe("ValueEffect", function () { it("adds an amount to a ship value", function () { let effect = new ValueEffect("shield", 20); diff --git a/src/game/effects/ValueEffect.ts b/src/core/effects/ValueEffect.ts similarity index 97% rename from src/game/effects/ValueEffect.ts rename to src/core/effects/ValueEffect.ts index e97adc7..b087296 100644 --- a/src/game/effects/ValueEffect.ts +++ b/src/core/effects/ValueEffect.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { /** * Effect to add (or subtract if negative) an amount to a ship value. * diff --git a/src/game/equipments/AbstractDrone.spec.ts b/src/core/equipments/AbstractDrone.spec.ts similarity index 98% rename from src/game/equipments/AbstractDrone.spec.ts rename to src/core/equipments/AbstractDrone.spec.ts index 0cbc1e7..2a3cb58 100644 --- a/src/game/equipments/AbstractDrone.spec.ts +++ b/src/core/equipments/AbstractDrone.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { describe("AbstractDrone", function () { it("can be configured", function () { let template = new AbstractDrone("test"); diff --git a/src/game/equipments/AbstractDrone.ts b/src/core/equipments/AbstractDrone.ts similarity index 97% rename from src/game/equipments/AbstractDrone.ts rename to src/core/equipments/AbstractDrone.ts index 609d674..d460344 100644 --- a/src/game/equipments/AbstractDrone.ts +++ b/src/core/equipments/AbstractDrone.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { /** * Base class for all weapon equipment that deploys a drone. */ diff --git a/src/game/equipments/AbstractWeapon.spec.ts b/src/core/equipments/AbstractWeapon.spec.ts similarity index 99% rename from src/game/equipments/AbstractWeapon.spec.ts rename to src/core/equipments/AbstractWeapon.spec.ts index 94a53c5..fdb5b0f 100644 --- a/src/game/equipments/AbstractWeapon.spec.ts +++ b/src/core/equipments/AbstractWeapon.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("AbstractWeapon", function () { it("has fire action, and damage effects on target", function () { var weapon = new Equipments.AbstractWeapon("Super Fire Weapon", 50, 60); diff --git a/src/game/equipments/AbstractWeapon.ts b/src/core/equipments/AbstractWeapon.ts similarity index 97% rename from src/game/equipments/AbstractWeapon.ts rename to src/core/equipments/AbstractWeapon.ts index 039888c..fe0c020 100644 --- a/src/game/equipments/AbstractWeapon.ts +++ b/src/core/equipments/AbstractWeapon.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { // Base convenience class for weapons export class AbstractWeapon extends LootTemplate { // Boolean set to true if the weapon can target space diff --git a/src/game/equipments/BasicForceField.ts b/src/core/equipments/BasicForceField.ts similarity index 89% rename from src/game/equipments/BasicForceField.ts rename to src/core/equipments/BasicForceField.ts index 50ca467..0d94fe7 100644 --- a/src/game/equipments/BasicForceField.ts +++ b/src/core/equipments/BasicForceField.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { export class BasicForceField extends LootTemplate { constructor() { super(SlotType.Shield, "Basic Force Field"); diff --git a/src/game/equipments/BasicPowerCore.ts b/src/core/equipments/BasicPowerCore.ts similarity index 92% rename from src/game/equipments/BasicPowerCore.ts rename to src/core/equipments/BasicPowerCore.ts index 10616d4..a90f410 100644 --- a/src/game/equipments/BasicPowerCore.ts +++ b/src/core/equipments/BasicPowerCore.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { export class BasicPowerCore extends LootTemplate { constructor() { super(SlotType.Power, "Basic Power Core"); diff --git a/src/game/equipments/ConventionalEngine.ts b/src/core/equipments/ConventionalEngine.ts similarity index 94% rename from src/game/equipments/ConventionalEngine.ts rename to src/core/equipments/ConventionalEngine.ts index 91ad3ce..4b173d7 100644 --- a/src/game/equipments/ConventionalEngine.ts +++ b/src/core/equipments/ConventionalEngine.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { // Equipment: Conventional Engine export class ConventionalEngine extends LootTemplate { constructor() { diff --git a/src/game/equipments/GatlingGun.ts b/src/core/equipments/GatlingGun.ts similarity index 89% rename from src/game/equipments/GatlingGun.ts rename to src/core/equipments/GatlingGun.ts index 30ff8a3..25c01db 100644 --- a/src/game/equipments/GatlingGun.ts +++ b/src/core/equipments/GatlingGun.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { export class GatlingGun extends AbstractWeapon { constructor() { super("Gatling Gun", 50, 100); diff --git a/src/game/equipments/IronHull.ts b/src/core/equipments/IronHull.ts similarity index 89% rename from src/game/equipments/IronHull.ts rename to src/core/equipments/IronHull.ts index 576c64a..efd2f85 100644 --- a/src/game/equipments/IronHull.ts +++ b/src/core/equipments/IronHull.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { export class IronHull extends LootTemplate { constructor() { super(SlotType.Armor, "IronHull"); diff --git a/src/game/equipments/PowerDepleter.spec.ts b/src/core/equipments/PowerDepleter.spec.ts similarity index 97% rename from src/game/equipments/PowerDepleter.spec.ts rename to src/core/equipments/PowerDepleter.spec.ts index 33e30ce..6f60c91 100644 --- a/src/game/equipments/PowerDepleter.spec.ts +++ b/src/core/equipments/PowerDepleter.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("PowerDepleter", () => { it("limits target's AP", () => { var template = new Equipments.PowerDepleter(); diff --git a/src/game/equipments/PowerDepleter.ts b/src/core/equipments/PowerDepleter.ts similarity index 91% rename from src/game/equipments/PowerDepleter.ts rename to src/core/equipments/PowerDepleter.ts index 299f920..a0bc5ec 100644 --- a/src/game/equipments/PowerDepleter.ts +++ b/src/core/equipments/PowerDepleter.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { export class PowerDepleter extends AbstractWeapon { constructor() { super("Power Depleter"); diff --git a/src/game/equipments/RepairDrone.spec.ts b/src/core/equipments/RepairDrone.spec.ts similarity index 96% rename from src/game/equipments/RepairDrone.spec.ts rename to src/core/equipments/RepairDrone.spec.ts index bf9930e..e1d76c0 100644 --- a/src/game/equipments/RepairDrone.spec.ts +++ b/src/core/equipments/RepairDrone.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { describe("RepairDrone", function () { it("generates a drone that may repair ships hull", function () { let template = new RepairDrone(); diff --git a/src/game/equipments/RepairDrone.ts b/src/core/equipments/RepairDrone.ts similarity index 93% rename from src/game/equipments/RepairDrone.ts rename to src/core/equipments/RepairDrone.ts index bf011e9..154c91f 100644 --- a/src/game/equipments/RepairDrone.ts +++ b/src/core/equipments/RepairDrone.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { /** * Drone that repairs damage done to the hull. */ diff --git a/src/game/equipments/SubMunitionMissile.spec.ts b/src/core/equipments/SubMunitionMissile.spec.ts similarity index 98% rename from src/game/equipments/SubMunitionMissile.spec.ts rename to src/core/equipments/SubMunitionMissile.spec.ts index 249ac21..9e03cb2 100644 --- a/src/game/equipments/SubMunitionMissile.spec.ts +++ b/src/core/equipments/SubMunitionMissile.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game.Specs { +module TS.SpaceTac.Specs { describe("SubMunitionMissile", () => { it("hits several targets in circle", () => { var battle = TestTools.createBattle(1, 2); diff --git a/src/game/equipments/SubMunitionMissile.ts b/src/core/equipments/SubMunitionMissile.ts similarity index 91% rename from src/game/equipments/SubMunitionMissile.ts rename to src/core/equipments/SubMunitionMissile.ts index b216579..a0fd21c 100644 --- a/src/game/equipments/SubMunitionMissile.ts +++ b/src/core/equipments/SubMunitionMissile.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game.Equipments { +module TS.SpaceTac.Equipments { export class SubMunitionMissile extends AbstractWeapon { constructor() { super("SubMunition Missile", 30, 50); diff --git a/src/game/events/BaseLogEvent.ts b/src/core/events/BaseLogEvent.ts similarity index 94% rename from src/game/events/BaseLogEvent.ts rename to src/core/events/BaseLogEvent.ts index ab4532c..7929b8d 100644 --- a/src/game/events/BaseLogEvent.ts +++ b/src/core/events/BaseLogEvent.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.Game { +module TS.SpaceTac { // Base class for a BattleLog event export class BaseLogEvent { // Code of the event (its type) diff --git a/src/game/events/DamageEvent.ts b/src/core/events/DamageEvent.ts similarity index 94% rename from src/game/events/DamageEvent.ts rename to src/core/events/DamageEvent.ts index 2e4b3d1..1bfa38f 100644 --- a/src/game/events/DamageEvent.ts +++ b/src/core/events/DamageEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when a ship takes damage export class DamageEvent extends BaseLogEvent { // Damage to hull diff --git a/src/game/events/DeathEvent.ts b/src/core/events/DeathEvent.ts similarity index 89% rename from src/game/events/DeathEvent.ts rename to src/core/events/DeathEvent.ts index c08f75b..d7efb00 100644 --- a/src/game/events/DeathEvent.ts +++ b/src/core/events/DeathEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when a ship is dead export class DeathEvent extends BaseLogEvent { constructor(ship: Ship) { diff --git a/src/game/events/DroneDeployedEvent.ts b/src/core/events/DroneDeployedEvent.ts similarity index 92% rename from src/game/events/DroneDeployedEvent.ts rename to src/core/events/DroneDeployedEvent.ts index 3f256be..28c9964 100644 --- a/src/game/events/DroneDeployedEvent.ts +++ b/src/core/events/DroneDeployedEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when a drone is deployed by a ship export class DroneDeployedEvent extends BaseLogEvent { // Pointer to the drone diff --git a/src/game/events/DroneDestroyedEvent.ts b/src/core/events/DroneDestroyedEvent.ts similarity index 92% rename from src/game/events/DroneDestroyedEvent.ts rename to src/core/events/DroneDestroyedEvent.ts index 022561a..04ab313 100644 --- a/src/game/events/DroneDestroyedEvent.ts +++ b/src/core/events/DroneDestroyedEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when a drone is destroyed export class DroneDestroyedEvent extends BaseLogEvent { // Pointer to the drone diff --git a/src/game/events/EffectAddedEvent.ts b/src/core/events/EffectAddedEvent.ts similarity index 93% rename from src/game/events/EffectAddedEvent.ts rename to src/core/events/EffectAddedEvent.ts index be8d9ff..7afd2c9 100644 --- a/src/game/events/EffectAddedEvent.ts +++ b/src/core/events/EffectAddedEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when a sticky effect is added to a ship export class EffectAddedEvent extends BaseLogEvent { // Pointer to the effect diff --git a/src/game/events/EffectDurationChangedEvent.ts b/src/core/events/EffectDurationChangedEvent.ts similarity index 95% rename from src/game/events/EffectDurationChangedEvent.ts rename to src/core/events/EffectDurationChangedEvent.ts index a8e8b79..a0e2bd7 100644 --- a/src/game/events/EffectDurationChangedEvent.ts +++ b/src/core/events/EffectDurationChangedEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when a sticky effect is added to a ship export class EffectDurationChangedEvent extends BaseLogEvent { // Pointer to the effect diff --git a/src/game/events/EffectRemovedEvent.ts b/src/core/events/EffectRemovedEvent.ts similarity index 93% rename from src/game/events/EffectRemovedEvent.ts rename to src/core/events/EffectRemovedEvent.ts index 915f8b5..37bbe52 100644 --- a/src/game/events/EffectRemovedEvent.ts +++ b/src/core/events/EffectRemovedEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when a sticky effect is removed from a ship export class EffectRemovedEvent extends BaseLogEvent { // Pointer to the effect diff --git a/src/game/events/EndBattleEvent.ts b/src/core/events/EndBattleEvent.ts similarity index 93% rename from src/game/events/EndBattleEvent.ts rename to src/core/events/EndBattleEvent.ts index 98e2d81..ff9c89f 100644 --- a/src/game/events/EndBattleEvent.ts +++ b/src/core/events/EndBattleEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when the battle ended // This is always the last event of a battle log export class EndBattleEvent extends BaseLogEvent { diff --git a/src/game/events/FireEvent.ts b/src/core/events/FireEvent.ts similarity index 93% rename from src/game/events/FireEvent.ts rename to src/core/events/FireEvent.ts index 081d92f..3ded308 100644 --- a/src/game/events/FireEvent.ts +++ b/src/core/events/FireEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when a weapon is used on a target export class FireEvent extends BaseLogEvent { // Weapon used diff --git a/src/game/events/MoveEvent.ts b/src/core/events/MoveEvent.ts similarity index 93% rename from src/game/events/MoveEvent.ts rename to src/core/events/MoveEvent.ts index 71bcd70..dfee8cc 100644 --- a/src/game/events/MoveEvent.ts +++ b/src/core/events/MoveEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when a ship moves export class MoveEvent extends BaseLogEvent { // New facing angle, in radians diff --git a/src/game/events/ShipChangeEvent.ts b/src/core/events/ShipChangeEvent.ts similarity index 92% rename from src/game/events/ShipChangeEvent.ts rename to src/core/events/ShipChangeEvent.ts index 2950a4e..5df7973 100644 --- a/src/game/events/ShipChangeEvent.ts +++ b/src/core/events/ShipChangeEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Battle event, when a ship turn ended, and advanced to a new one export class ShipChangeEvent extends BaseLogEvent { constructor(ship: Ship, new_ship: Ship) { diff --git a/src/game/events/ValueChangeEvent.ts b/src/core/events/ValueChangeEvent.ts similarity index 93% rename from src/game/events/ValueChangeEvent.ts rename to src/core/events/ValueChangeEvent.ts index 00954eb..d70fab4 100644 --- a/src/game/events/ValueChangeEvent.ts +++ b/src/core/events/ValueChangeEvent.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.Game { +module TS.SpaceTac { // Event logged when a ship value or attribute changed export class ValueChangeEvent extends BaseLogEvent { // Saved version of the value diff --git a/src/view/BaseView.ts b/src/ui/BaseView.ts similarity index 93% rename from src/view/BaseView.ts rename to src/ui/BaseView.ts index ed8ea2d..64dd692 100644 --- a/src/view/BaseView.ts +++ b/src/ui/BaseView.ts @@ -1,8 +1,8 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Base class for all game views export class BaseView extends Phaser.State { // Link to the root UI - gameui: GameUI; + gameui: MainUI; // Message notifications messages: Messages; @@ -26,7 +26,7 @@ module TS.SpaceTac.View { // Init the view init(...args: any[]) { - this.gameui = this.game; + this.gameui = this.game; } // Create view graphics diff --git a/src/view/Boot.ts b/src/ui/Boot.ts similarity index 95% rename from src/view/Boot.ts rename to src/ui/Boot.ts index 5d0da2a..f55770d 100644 --- a/src/view/Boot.ts +++ b/src/ui/Boot.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { export class Boot extends Phaser.State { preload() { this.load.image("preload-background", "assets/images/preload/bar-background.png"); diff --git a/src/view/MainMenu.ts b/src/ui/MainMenu.ts similarity index 95% rename from src/view/MainMenu.ts rename to src/ui/MainMenu.ts index 9c4e0de..9506221 100644 --- a/src/view/MainMenu.ts +++ b/src/ui/MainMenu.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.View { +module TS.SpaceTac.UI { export class MainMenu extends BaseView { group: Phaser.Group; button_new_game: Phaser.Button; @@ -60,7 +60,7 @@ module TS.SpaceTac.View { // Called when "New Game" is clicked onNewGame(): void { - var gameui = this.game; + var gameui = this.game; gameui.session.startNewGame(); @@ -69,7 +69,7 @@ module TS.SpaceTac.View { // Called when "Quick Battle" is clicked onQuickBattle(): void { - var gameui = this.game; + var gameui = this.game; gameui.session.startQuickBattle(true); @@ -78,7 +78,7 @@ module TS.SpaceTac.View { // Called when "Load Game" is clicked onLoadGame(): void { - var gameui = this.game; + var gameui = this.game; if (gameui.loadGame()) { this.game.state.start("router"); diff --git a/src/view/Preload.ts b/src/ui/Preload.ts similarity index 99% rename from src/view/Preload.ts rename to src/ui/Preload.ts index bbc2e85..f301a83 100644 --- a/src/view/Preload.ts +++ b/src/ui/Preload.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.View { +module TS.SpaceTac.UI { export class Preload extends BaseView { private preloadBar: Phaser.Image; diff --git a/src/view/Router.ts b/src/ui/Router.ts similarity index 93% rename from src/view/Router.ts rename to src/ui/Router.ts index 0d567b7..d10c03c 100644 --- a/src/view/Router.ts +++ b/src/ui/Router.ts @@ -1,8 +1,8 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Router to other states export class Router extends Phaser.State { create() { - var ui = this.game; + var ui = this.game; var session = ui.session; if (!session) { diff --git a/src/view/TestGame.ts b/src/ui/TestGame.ts similarity index 91% rename from src/view/TestGame.ts rename to src/ui/TestGame.ts index f215f5d..138ab2b 100644 --- a/src/view/TestGame.ts +++ b/src/ui/TestGame.ts @@ -1,7 +1,7 @@ /// /// -module TS.SpaceTac.View.Specs { +module TS.SpaceTac.UI.Specs { // Test game wrapper (use instead of jasmine 'it') export function ingame_it(desc: string, func: (game: Phaser.Game, state: Phaser.State) => void, state: Phaser.State = null, ...stateargs: any[]) { @@ -9,7 +9,7 @@ module TS.SpaceTac.View.Specs { spyOn(console, "log").and.stub(); spyOn(console, "warn").and.stub(); - var game = new GameUI(true); + var game = new MainUI(true); if (!state) { state = new Phaser.State(); @@ -37,7 +37,7 @@ module TS.SpaceTac.View.Specs { // Test game wrapper, with a battleview initialized on a random battle export function inbattleview_it(desc: string, func: (battleview: BattleView) => void) { var battleview = new BattleView(); - var battle = Game.Battle.newQuickRandom(); + var battle = Battle.newQuickRandom(); var player = battle.playing_ship.getPlayer(); ingame_it(desc, (game: Phaser.Game, state: Phaser.State) => { func(battleview); @@ -47,7 +47,7 @@ module TS.SpaceTac.View.Specs { // Test game wrapper, with a map initialized on a random universe export function inmapview_it(desc: string, func: (mapview: UniverseMapView) => void) { var mapview = new UniverseMapView(); - var session = new Game.GameSession(); + var session = new GameSession(); session.startNewGame(); ingame_it(desc, (game: Phaser.Game, state: Phaser.State) => { func(mapview); diff --git a/src/view/battle/ActionBar.spec.ts b/src/ui/battle/ActionBar.spec.ts similarity index 75% rename from src/view/battle/ActionBar.spec.ts rename to src/ui/battle/ActionBar.spec.ts index b009bc0..16ba480 100644 --- a/src/view/battle/ActionBar.spec.ts +++ b/src/ui/battle/ActionBar.spec.ts @@ -1,12 +1,12 @@ /// -module TS.SpaceTac.View.Specs { +module TS.SpaceTac.UI.Specs { describe("ActionBar", () => { inbattleview_it("lists available actions for selected ship", (battleview: BattleView) => { var bar = battleview.action_bar; // Ship not owned by current battleview player - var ship = new Game.Ship(); + var ship = new Ship(); bar.setShip(ship); expect(bar.actions.length).toBe(0); @@ -17,13 +17,13 @@ module TS.SpaceTac.View.Specs { expect(bar.actions[0].action.code).toEqual("endturn"); // Add an engine, with move action - ship.addSlot(Game.SlotType.Engine).attach((new Game.Equipments.ConventionalEngine()).generate()); + ship.addSlot(SlotType.Engine).attach((new Equipments.ConventionalEngine()).generate()); bar.setShip(ship); expect(bar.actions.length).toBe(2); expect(bar.actions[0].action.code).toEqual("move"); // Add a weapon, with fire action - ship.addSlot(Game.SlotType.Weapon).attach((new Game.Equipments.GatlingGun()).generate()); + ship.addSlot(SlotType.Weapon).attach((new Equipments.GatlingGun()).generate()); bar.setShip(ship); expect(bar.actions.length).toBe(3); expect(bar.actions[1].action.code).toEqual("fire-gatlinggun"); @@ -31,19 +31,19 @@ module TS.SpaceTac.View.Specs { inbattleview_it("mark actions that would become unavailable after use", (battleview: BattleView) => { var bar = battleview.action_bar; - var ship = new Game.Ship(); + var ship = new Ship(); ship.arena_x = 1; ship.arena_y = 8; - var engine = (new Game.Equipments.ConventionalEngine()).generate(); + var engine = (new Equipments.ConventionalEngine()).generate(); engine.ap_usage = 8; engine.distance = 4; - ship.addSlot(Game.SlotType.Engine).attach(engine); - var weapon1 = (new Game.Equipments.GatlingGun()).generate(); + ship.addSlot(SlotType.Engine).attach(engine); + var weapon1 = (new Equipments.GatlingGun()).generate(); weapon1.ap_usage = 3; - ship.addSlot(Game.SlotType.Weapon).attach(weapon1); - var weapon2 = (new Game.Equipments.GatlingGun()).generate(); + ship.addSlot(SlotType.Weapon).attach(weapon1); + var weapon2 = (new Equipments.GatlingGun()).generate(); weapon2.ap_usage = 5; - ship.addSlot(Game.SlotType.Weapon).attach(weapon2); + ship.addSlot(SlotType.Weapon).attach(weapon2); battleview.battle.playing_ship = ship; battleview.player = ship.getPlayer(); @@ -90,13 +90,13 @@ module TS.SpaceTac.View.Specs { ship.setValue("power", 6); bar.actions[0].processClick(); checkFading([], [0, 1, 2, 3]); - bar.actions[0].processHover(Game.Target.newFromLocation(2, 8)); + bar.actions[0].processHover(Target.newFromLocation(2, 8)); checkFading([2], [0, 1, 3]); - bar.actions[0].processHover(Game.Target.newFromLocation(3, 8)); + bar.actions[0].processHover(Target.newFromLocation(3, 8)); checkFading([1, 2], [0, 3]); - bar.actions[0].processHover(Game.Target.newFromLocation(4, 8)); + bar.actions[0].processHover(Target.newFromLocation(4, 8)); checkFading([0, 1, 2], [3]); - bar.actions[0].processHover(Game.Target.newFromLocation(5, 8)); + bar.actions[0].processHover(Target.newFromLocation(5, 8)); checkFading([0, 1, 2], [3]); bar.actionEnded(); }); diff --git a/src/view/battle/ActionBar.ts b/src/ui/battle/ActionBar.ts similarity index 94% rename from src/view/battle/ActionBar.ts rename to src/ui/battle/ActionBar.ts index 974ce62..c3fcb19 100644 --- a/src/view/battle/ActionBar.ts +++ b/src/ui/battle/ActionBar.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Bar with all available action icons displayed export class ActionBar extends Phaser.Group { // Link to the parent battleview @@ -15,7 +15,7 @@ module TS.SpaceTac.View { tooltip: ActionTooltip; // Current ship, whose actions are displayed - ship: Game.Ship; + ship: Ship; // Create an empty action bar constructor(battleview: BattleView) { @@ -53,7 +53,7 @@ module TS.SpaceTac.View { } // Add an action icon - addAction(ship: Game.Ship, action: Game.BaseAction): ActionIcon { + addAction(ship: Ship, action: BaseAction): ActionIcon { var icon = new ActionIcon(this, 192 + this.actions.length * 88, 8, ship, action); this.actions.push(icon); @@ -90,12 +90,12 @@ module TS.SpaceTac.View { } // Set action icons from selected ship - setShip(ship: Game.Ship): void { + setShip(ship: Ship): void { this.clearAll(); if (ship.getPlayer() === this.battleview.player) { var actions = ship.getAvailableActions(); - actions.forEach((action: Game.BaseAction) => { + actions.forEach((action: BaseAction) => { this.addAction(ship, action); }); diff --git a/src/view/battle/ActionIcon.ts b/src/ui/battle/ActionIcon.ts similarity index 95% rename from src/view/battle/ActionIcon.ts rename to src/ui/battle/ActionIcon.ts index 454f8fc..3645427 100644 --- a/src/view/battle/ActionIcon.ts +++ b/src/ui/battle/ActionIcon.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Icon to activate a ship capability (move, fire...) export class ActionIcon extends Phaser.Button { // Link to the parent bar @@ -8,10 +8,10 @@ module TS.SpaceTac.View { battleview: BattleView; // Related ship - ship: Game.Ship; + ship: Ship; // Related game action - action: Game.BaseAction; + action: BaseAction; // True if the action can be used active: boolean; @@ -35,7 +35,7 @@ module TS.SpaceTac.View { private layer_selected: Phaser.Image; // Create an icon for a single ship action - constructor(bar: ActionBar, x: number, y: number, ship: Game.Ship, action: Game.BaseAction) { + constructor(bar: ActionBar, x: number, y: number, ship: Ship, action: BaseAction) { super(bar.game, x, y, "battle-action-inactive"); this.bar = bar; @@ -112,7 +112,7 @@ module TS.SpaceTac.View { this.targetting.setSource(this.battleview.arena.findShipSprite(this.ship)); this.targetting.targetSelected.add(this.processSelection, this); this.targetting.targetHovered.add(this.processHover, this); - if (this.action instanceof Game.MoveAction) { + if (this.action instanceof MoveAction) { this.targetting.setApIndicatorsInterval(this.action.getDistanceByActionPoint(this.ship)); } } else { @@ -123,14 +123,14 @@ module TS.SpaceTac.View { // Called when a target is hovered // This will check the target against current action and adjust it if needed - processHover(target: Game.Target): void { + processHover(target: Target): void { target = this.action.checkTarget(this.battleview.battle, this.ship, target); this.targetting.setTarget(target, false, this.action.getBlastRadius(this.ship)); this.bar.updateFadings(this.action.getActionPointsUsage(this.battleview.battle, this.ship, target)); } // Called when a target is selected - processSelection(target: Game.Target): void { + processSelection(target: Target): void { if (this.action.apply(this.battleview.battle, this.ship, target)) { this.bar.actionEnded(); } diff --git a/src/view/battle/ActionTooltip.ts b/src/ui/battle/ActionTooltip.ts similarity index 96% rename from src/view/battle/ActionTooltip.ts rename to src/ui/battle/ActionTooltip.ts index 5366993..30d62e7 100644 --- a/src/view/battle/ActionTooltip.ts +++ b/src/ui/battle/ActionTooltip.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Tooltip to display action information export class ActionTooltip extends Phaser.Sprite { icon: Phaser.Image | null; @@ -46,7 +46,7 @@ module TS.SpaceTac.View { this.main_title.setText(action.action.equipment ? action.action.equipment.name : action.action.name); this.sub_title.setText(action.action.equipment ? action.action.name : ""); let cost = action.action.equipment ? `Cost: ${action.action.equipment.ap_usage} power` : ""; - if (action.action instanceof Game.MoveAction) { + if (action.action instanceof MoveAction) { cost += ` per ${action.action.equipment.distance}km`; } this.cost.setText(cost); diff --git a/src/view/battle/Arena.ts b/src/ui/battle/Arena.ts similarity index 91% rename from src/view/battle/Arena.ts rename to src/ui/battle/Arena.ts index 7c4a920..143f3ff 100644 --- a/src/view/battle/Arena.ts +++ b/src/ui/battle/Arena.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Graphical representation of a battle // This is the area in the BattleView that will display ships with their real positions export class Arena extends Phaser.Group { @@ -75,20 +75,20 @@ module TS.SpaceTac.View { // Initialize state (create sprites) init(): void { // Add ship sprites - this.battleview.battle.play_order.forEach((ship: Game.Ship) => { + this.battleview.battle.play_order.forEach((ship: Ship) => { var sprite = new ArenaShip(this.battleview, ship); this.addChild(sprite); this.ship_sprites.push(sprite); }); } - // Get the current GameUI instance - getGame(): GameUI { + // Get the current MainUI instance + getGame(): MainUI { return this.battleview.gameui; } // Remove a ship sprite - markAsDead(ship: Game.Ship): void { + markAsDead(ship: Ship): void { var sprite = this.findShipSprite(ship); if (sprite) { sprite.alpha = 0.5; @@ -96,7 +96,7 @@ module TS.SpaceTac.View { } // Find the sprite for a ship - findShipSprite(ship: Game.Ship): ArenaShip { + findShipSprite(ship: Ship): ArenaShip { var result: ArenaShip = null; this.ship_sprites.forEach((sprite: ArenaShip) => { if (sprite.ship === ship) { @@ -107,7 +107,7 @@ module TS.SpaceTac.View { } // Set the hovered state on a ship sprite - setShipHovered(ship: Game.Ship): void { + setShipHovered(ship: Ship): void { if (this.hovered) { this.hovered.setHovered(false); } @@ -119,7 +119,7 @@ module TS.SpaceTac.View { } // Set the playing state on a ship sprite - setShipPlaying(ship: Game.Ship): void { + setShipPlaying(ship: Ship): void { if (this.playing) { this.playing.setPlaying(false); } @@ -133,7 +133,7 @@ module TS.SpaceTac.View { } // Spawn a new drone - addDrone(drone: Game.Drone): void { + addDrone(drone: Drone): void { if (!any(this.drone_sprites, sprite => sprite.drone == drone)) { let sprite = new ArenaDrone(this.battleview, drone); this.addChild(sprite); @@ -147,7 +147,7 @@ module TS.SpaceTac.View { } // Remove a destroyed drone - removeDrone(drone: Game.Drone): void { + removeDrone(drone: Drone): void { let sprite = first(this.drone_sprites, sprite => sprite.drone == drone); if (sprite) { remove(this.drone_sprites, sprite); diff --git a/src/view/battle/ArenaDrone.ts b/src/ui/battle/ArenaDrone.ts similarity index 87% rename from src/view/battle/ArenaDrone.ts rename to src/ui/battle/ArenaDrone.ts index ed243d2..51ccf6b 100644 --- a/src/view/battle/ArenaDrone.ts +++ b/src/ui/battle/ArenaDrone.ts @@ -1,10 +1,10 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { /** * Drone sprite in the arena */ export class ArenaDrone extends Phaser.Group { // Link to displayed drone - drone: Game.Drone; + drone: Drone; // Sprite sprite: Phaser.Button; @@ -12,7 +12,7 @@ module TS.SpaceTac.View { // Radius radius: Phaser.Graphics; - constructor(battleview: BattleView, drone: Game.Drone) { + constructor(battleview: BattleView, drone: Drone) { super(battleview.game); this.drone = drone; diff --git a/src/view/battle/ArenaShip.ts b/src/ui/battle/ArenaShip.ts similarity index 97% rename from src/view/battle/ArenaShip.ts rename to src/ui/battle/ArenaShip.ts index de0a841..e9c628e 100644 --- a/src/view/battle/ArenaShip.ts +++ b/src/ui/battle/ArenaShip.ts @@ -1,8 +1,8 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Ship sprite in the arena (BattleView) export class ArenaShip extends Phaser.Group { // Link to displayed ship - ship: Game.Ship; + ship: Ship; // Boolean to indicate if it is an enemy ship enemy: boolean; @@ -17,7 +17,7 @@ module TS.SpaceTac.View { frame: Phaser.Image; // Create a ship sprite usable in the Arena - constructor(battleview: BattleView, ship: Game.Ship) { + constructor(battleview: BattleView, ship: Ship) { super(battleview.game); this.ship = ship; diff --git a/src/view/battle/BattleView.spec.ts b/src/ui/battle/BattleView.spec.ts similarity index 79% rename from src/view/battle/BattleView.spec.ts rename to src/ui/battle/BattleView.spec.ts index 5442650..1d787dd 100644 --- a/src/view/battle/BattleView.spec.ts +++ b/src/ui/battle/BattleView.spec.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.View.Specs { +module TS.SpaceTac.UI.Specs { describe("BattleView", () => { inbattleview_it("forwards events in targetting mode", (battleview: BattleView) => { expect(battleview.targetting).toBeNull(); @@ -16,12 +16,12 @@ module TS.SpaceTac.View.Specs { expect(result).toBe(battleview.targetting); // Collect targetting events - var hovered: Game.Target[] = []; - var clicked: Game.Target[] = []; - result.targetHovered.add((target: Game.Target) => { + var hovered: Target[] = []; + var clicked: Target[] = []; + result.targetHovered.add((target: Target) => { hovered.push(target); }); - result.targetSelected.add((target: Game.Target) => { + result.targetSelected.add((target: Target) => { clicked.push(target); }); @@ -29,7 +29,7 @@ module TS.SpaceTac.View.Specs { battleview.cursorInSpace(8, 4); expect(battleview.ship_hovered).toBeNull(); - expect(battleview.targetting.target_corrected).toEqual(Game.Target.newFromLocation(8, 4)); + expect(battleview.targetting.target_corrected).toEqual(Target.newFromLocation(8, 4)); // Process a click on space battleview.cursorClicked(); @@ -38,19 +38,19 @@ module TS.SpaceTac.View.Specs { battleview.cursorOnShip(battleview.battle.play_order[0]); expect(battleview.ship_hovered).toEqual(battleview.battle.playing_ship); - expect(battleview.targetting.target_corrected).toEqual(Game.Target.newFromShip(battleview.battle.playing_ship)); + expect(battleview.targetting.target_corrected).toEqual(Target.newFromShip(battleview.battle.playing_ship)); // Don't leave a ship we're not hovering battleview.cursorOffShip(battleview.battle.play_order[1]); expect(battleview.ship_hovered).toEqual(battleview.battle.playing_ship); - expect(battleview.targetting.target_corrected).toEqual(Game.Target.newFromShip(battleview.battle.playing_ship)); + expect(battleview.targetting.target_corrected).toEqual(Target.newFromShip(battleview.battle.playing_ship)); // Don't move in space while on ship battleview.cursorInSpace(1, 3); expect(battleview.ship_hovered).toEqual(battleview.battle.playing_ship); - expect(battleview.targetting.target_corrected).toEqual(Game.Target.newFromShip(battleview.battle.playing_ship)); + expect(battleview.targetting.target_corrected).toEqual(Target.newFromShip(battleview.battle.playing_ship)); // Process a click on ship battleview.cursorClicked(); @@ -77,13 +77,13 @@ module TS.SpaceTac.View.Specs { // Check collected targetting events expect(hovered).toEqual([ - Game.Target.newFromLocation(8, 4), - Game.Target.newFromShip(battleview.battle.playing_ship), + Target.newFromLocation(8, 4), + Target.newFromShip(battleview.battle.playing_ship), null ]); expect(clicked).toEqual([ - Game.Target.newFromLocation(8, 4), - Game.Target.newFromShip(battleview.battle.playing_ship), + Target.newFromLocation(8, 4), + Target.newFromShip(battleview.battle.playing_ship), ]); }); }); diff --git a/src/view/battle/BattleView.ts b/src/ui/battle/BattleView.ts similarity index 95% rename from src/view/battle/BattleView.ts rename to src/ui/battle/BattleView.ts index a11af03..78fa6d4 100644 --- a/src/view/battle/BattleView.ts +++ b/src/ui/battle/BattleView.ts @@ -1,14 +1,14 @@ /// -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Interactive view of a Battle export class BattleView extends BaseView { // Displayed battle - battle: Game.Battle; + battle: Battle; // Interacting player - player: Game.Player; + player: Player; // UI container ui: Phaser.Group; @@ -29,7 +29,7 @@ module TS.SpaceTac.View { action_bar: ActionBar; // Currently hovered ship - ship_hovered: Game.Ship; + ship_hovered: Ship; // Ship tooltip ship_tooltip: ShipTooltip; @@ -44,7 +44,7 @@ module TS.SpaceTac.View { icon_waiting: Phaser.Image; // Init the view, binding it to a specific battle - init(player: Game.Player, battle: Game.Battle) { + init(player: Player, battle: Battle) { super.init(); this.player = player; @@ -146,12 +146,12 @@ module TS.SpaceTac.View { } // Method called when cursor starts hovering over a ship (or its icon) - cursorOnShip(ship: Game.Ship): void { + cursorOnShip(ship: Ship): void { this.setShipHovered(ship); } // Method called when cursor stops hovering over a ship (or its icon) - cursorOffShip(ship: Game.Ship): void { + cursorOffShip(ship: Ship): void { if (this.ship_hovered === ship) { this.setShipHovered(null); } @@ -174,7 +174,7 @@ module TS.SpaceTac.View { } // Set the currently hovered ship - setShipHovered(ship: Game.Ship): void { + setShipHovered(ship: Ship): void { this.ship_hovered = ship; this.arena.setShipHovered(ship); this.ship_list.setHovered(ship); diff --git a/src/view/battle/LogProcessor.ts b/src/ui/battle/LogProcessor.ts similarity index 73% rename from src/view/battle/LogProcessor.ts rename to src/ui/battle/LogProcessor.ts index 7273104..1d90259 100644 --- a/src/view/battle/LogProcessor.ts +++ b/src/ui/battle/LogProcessor.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Processor of battle log events // This will process incoming battle events, and update the battleview accordingly export class LogProcessor { @@ -6,10 +6,10 @@ module TS.SpaceTac.View { private view: BattleView; // Link to the battle - private battle: Game.Battle; + private battle: Battle; // Link to the battle log - private log: Game.BattleLog; + private log: BattleLog; // Subscription identifier private subscription: any; @@ -20,33 +20,33 @@ module TS.SpaceTac.View { this.battle = view.battle; this.log = view.battle.log; - this.subscription = this.log.subscribe((event: Game.BaseLogEvent) => { + this.subscription = this.log.subscribe((event: BaseLogEvent) => { this.processBattleEvent(event); }); this.battle.injectInitialEvents(); } // Process a BaseLogEvent - processBattleEvent(event: Game.BaseLogEvent) { + processBattleEvent(event: BaseLogEvent) { console.log("Battle event", event); - if (event instanceof Game.ShipChangeEvent) { + if (event instanceof ShipChangeEvent) { this.processShipChangeEvent(event); - } else if (event instanceof Game.MoveEvent) { + } else if (event instanceof MoveEvent) { this.processMoveEvent(event); - } else if (event instanceof Game.ValueChangeEvent) { + } else if (event instanceof ValueChangeEvent) { this.processValueChangedEvent(event); - } else if (event instanceof Game.DeathEvent) { + } else if (event instanceof DeathEvent) { this.processDeathEvent(event); - } else if (event instanceof Game.FireEvent) { + } else if (event instanceof FireEvent) { this.processFireEvent(event); - } else if (event instanceof Game.DamageEvent) { + } else if (event instanceof DamageEvent) { this.processDamageEvent(event); - } else if (event instanceof Game.EndBattleEvent) { + } else if (event instanceof EndBattleEvent) { this.processEndBattleEvent(event); - } else if (event instanceof Game.DroneDeployedEvent) { + } else if (event instanceof DroneDeployedEvent) { this.processDroneDeployedEvent(event); - } else if (event instanceof Game.DroneDestroyedEvent) { + } else if (event instanceof DroneDestroyedEvent) { this.processDroneDestroyedEvent(event); } else if (event.code == "effectadd" || event.code == "effectduration" || event.code == "effectdel") { this.processEffectEvent(event); @@ -62,7 +62,7 @@ module TS.SpaceTac.View { } // Playing ship changed - private processShipChangeEvent(event: Game.ShipChangeEvent): void { + private processShipChangeEvent(event: ShipChangeEvent): void { this.view.arena.setShipPlaying(event.target.ship); this.view.ship_list.setPlaying(event.target.ship); this.view.action_bar.setShip(event.target.ship); @@ -71,7 +71,7 @@ module TS.SpaceTac.View { } // Damage to ship - private processDamageEvent(event: Game.DamageEvent): void { + private processDamageEvent(event: DamageEvent): void { var sprite = this.view.arena.findShipSprite(event.ship); if (sprite) { sprite.displayDamage(event.hull, event.shield); @@ -83,7 +83,7 @@ module TS.SpaceTac.View { } // Ship moved - private processMoveEvent(event: Game.MoveEvent): void { + private processMoveEvent(event: MoveEvent): void { var sprite = this.view.arena.findShipSprite(event.ship); if (sprite) { sprite.moveTo(event.target.x, event.target.y, event.facing_angle, true); @@ -91,7 +91,7 @@ module TS.SpaceTac.View { } // Ship value changed - private processValueChangedEvent(event: Game.ValueChangeEvent): void { + private processValueChangedEvent(event: ValueChangeEvent): void { var item = this.view.ship_list.findItem(event.ship); if (item) { item.updateAttributes(); @@ -100,7 +100,7 @@ module TS.SpaceTac.View { } // A ship died - private processDeathEvent(event: Game.DeathEvent): void { + private processDeathEvent(event: DeathEvent): void { if (this.view.ship_hovered === event.ship) { this.view.setShipHovered(null); } @@ -109,8 +109,8 @@ module TS.SpaceTac.View { } // Weapon used - private processFireEvent(event: Game.FireEvent): void { - var source = Game.Target.newFromShip(event.ship); + private processFireEvent(event: FireEvent): void { + var source = Target.newFromShip(event.ship); var destination = event.target; // Face the target @@ -123,7 +123,7 @@ module TS.SpaceTac.View { } // Battle ended (victory or defeat) - private processEndBattleEvent(event: Game.EndBattleEvent): void { + private processEndBattleEvent(event: EndBattleEvent): void { this.view.setInteractionEnabled(false); if (event.outcome.winner.player === this.view.player) { @@ -137,7 +137,7 @@ module TS.SpaceTac.View { } // Sticky effect on ship added, changed or removed - private processEffectEvent(event: Game.BaseLogEvent): void { + private processEffectEvent(event: BaseLogEvent): void { var item = this.view.ship_list.findItem(event.ship); if (item) { item.updateEffects(); @@ -145,12 +145,12 @@ module TS.SpaceTac.View { } // New drone deployed - private processDroneDeployedEvent(event: Game.DroneDeployedEvent): void { + private processDroneDeployedEvent(event: DroneDeployedEvent): void { this.view.arena.addDrone(event.drone); } // Drone destroyed - private processDroneDestroyedEvent(event: Game.DroneDestroyedEvent): void { + private processDroneDestroyedEvent(event: DroneDestroyedEvent): void { this.view.arena.removeDrone(event.drone); } } diff --git a/src/view/battle/RangeHint.ts b/src/ui/battle/RangeHint.ts similarity index 92% rename from src/view/battle/RangeHint.ts rename to src/ui/battle/RangeHint.ts index 4d7d807..e208a0e 100644 --- a/src/view/battle/RangeHint.ts +++ b/src/ui/battle/RangeHint.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Graphical hints for movement and weapon range export class RangeHint extends Phaser.Group { // Link to the arena @@ -37,7 +37,7 @@ module TS.SpaceTac.View { } // Set currently selected action - setPrimary(ship: Game.Ship, action: Game.BaseAction): void { + setPrimary(ship: Ship, action: BaseAction): void { var radius = action.getRangeRadius(ship); if (radius) { this.primary = new Phaser.Circle(ship.arena_x, ship.arena_y, radius * 2); @@ -48,7 +48,7 @@ module TS.SpaceTac.View { } // Set currently hovered action - setSecondary(ship: Game.Ship, action: Game.BaseAction): void { + setSecondary(ship: Ship, action: BaseAction): void { var radius = action.getRangeRadius(ship); if (radius) { this.draw(new Phaser.Circle(ship.arena_x, ship.arena_y, radius * 2)); diff --git a/src/view/battle/ShipList.spec.ts b/src/ui/battle/ShipList.spec.ts similarity index 96% rename from src/view/battle/ShipList.spec.ts rename to src/ui/battle/ShipList.spec.ts index 8a79d13..3b89937 100644 --- a/src/view/battle/ShipList.spec.ts +++ b/src/ui/battle/ShipList.spec.ts @@ -1,6 +1,6 @@ /// -module TS.SpaceTac.View.Specs { +module TS.SpaceTac.UI.Specs { describe("ShipList", () => { inbattleview_it("handles play position of ships", (battleview: BattleView) => { var list = battleview.ship_list; diff --git a/src/view/battle/ShipList.ts b/src/ui/battle/ShipList.ts similarity index 88% rename from src/view/battle/ShipList.ts rename to src/ui/battle/ShipList.ts index 0cb3be8..21cf508 100644 --- a/src/view/battle/ShipList.ts +++ b/src/ui/battle/ShipList.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Bar with all playing ships, by play order export class ShipList extends Phaser.Image { // Link to the parent battleview @@ -38,16 +38,16 @@ module TS.SpaceTac.View { } // Set the ship list from a battle - setShipsFromBattle(battle: Game.Battle): void { + setShipsFromBattle(battle: Battle): void { this.clearAll(); - battle.play_order.forEach((ship: Game.Ship) => { + battle.play_order.forEach((ship: Ship) => { this.addShip(ship); }, this); this.updateItemsLocation(); } // Add a ship icon - addShip(ship: Game.Ship): ShipListItem { + addShip(ship: Ship): ShipListItem { var owned = ship.getPlayer() === this.battleview.player; var result = new ShipListItem(this, -200, 0, ship, owned); this.ships.push(result); @@ -57,7 +57,7 @@ module TS.SpaceTac.View { // Find an item for a ship // Returns null if not found - findItem(ship: Game.Ship): ShipListItem { + findItem(ship: Ship): ShipListItem { var found: ShipListItem = null; this.ships.forEach((item: ShipListItem) => { if (item.ship === ship) { @@ -68,7 +68,7 @@ module TS.SpaceTac.View { } // Find the play position in play_order for a given ship (0 is currently playing) - findPlayPosition(ship: Game.Ship): number { + findPlayPosition(ship: Ship): number { var battle = this.battleview.battle; var idx = battle.play_order.indexOf(ship); var diff = idx - battle.playing_ship_index; @@ -92,7 +92,7 @@ module TS.SpaceTac.View { } // Remove a ship from the list - markAsDead(ship: Game.Ship): void { + markAsDead(ship: Ship): void { var item = this.findItem(ship); if (item) { item.alpha = 0.5; @@ -100,13 +100,13 @@ module TS.SpaceTac.View { } // Set the currently playing ship - setPlaying(ship: Game.Ship): void { + setPlaying(ship: Ship): void { this.playing = this.findItem(ship); this.updateItemsLocation(); } // Set the currently hovered ship - setHovered(ship: Game.Ship): void { + setHovered(ship: Ship): void { if (this.hovered) { this.hovered.setHovered(false); } diff --git a/src/view/battle/ShipListItem.ts b/src/ui/battle/ShipListItem.ts similarity index 98% rename from src/view/battle/ShipListItem.ts rename to src/ui/battle/ShipListItem.ts index a9f1eb6..cd09520 100644 --- a/src/view/battle/ShipListItem.ts +++ b/src/ui/battle/ShipListItem.ts @@ -1,8 +1,8 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // One item in a ship list (used in BattleView) export class ShipListItem extends Phaser.Button { // Reference to the ship game object - ship: Game.Ship; + ship: Ship; // Hull display hull: ValueBar; @@ -26,7 +26,7 @@ module TS.SpaceTac.View { active_effects: Phaser.Group; // Create a ship button for the battle ship list - constructor(list: ShipList, x: number, y: number, ship: Game.Ship, owned: boolean) { + constructor(list: ShipList, x: number, y: number, ship: Ship, owned: boolean) { super(list.battleview.game, x, y, owned ? "battle-shiplist-own" : "battle-shiplist-enemy"); this.ship = ship; diff --git a/src/view/battle/ShipTooltip.ts b/src/ui/battle/ShipTooltip.ts similarity index 95% rename from src/view/battle/ShipTooltip.ts rename to src/ui/battle/ShipTooltip.ts index 4538022..6413822 100644 --- a/src/view/battle/ShipTooltip.ts +++ b/src/ui/battle/ShipTooltip.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Tooltip to display ship information export class ShipTooltip extends Phaser.Sprite { battleview: BattleView; @@ -66,7 +66,7 @@ module TS.SpaceTac.View { } // Set current ship to display, null to hide - setShip(ship: Game.Ship | null): void { + setShip(ship: Ship | null): void { if (ship) { var enemy = ship.getPlayer() != this.battleview.player; this.loadTexture(`battle-ship-tooltip-${enemy ? "enemy" : "own"}`); @@ -105,7 +105,7 @@ module TS.SpaceTac.View { ship.sticky_effects.forEach((effect, index) => { this.addEffect(effect, index); }); - ship.listEquipment(Game.SlotType.Weapon).forEach((equipment, index) => { + ship.listEquipment(SlotType.Weapon).forEach((equipment, index) => { this.addEquipment(equipment, ship.sticky_effects.length + index); }); @@ -118,11 +118,11 @@ module TS.SpaceTac.View { /** * Add a sticky effect display */ - addEffect(effect: Game.StickyEffect, index = 0) { + addEffect(effect: StickyEffect, index = 0) { let effect_group = new Phaser.Image(this.game, 27, 243 + 60 * index, "battle-ship-tooltip-effect"); this.active_effects.addChild(effect_group); - if (effect.base instanceof Game.AttributeLimitEffect) { + if (effect.base instanceof AttributeLimitEffect) { let attr_name = effect.base.attrcode.replace('_', ''); let attr_icon = new Phaser.Image(this.game, 30, effect_group.height / 2, `battle-attributes-${attr_name}`); attr_icon.anchor.set(0.5, 0.5); @@ -145,7 +145,7 @@ module TS.SpaceTac.View { /** * Add an equipment action display */ - addEquipment(equipment: Game.Equipment, index = 0) { + addEquipment(equipment: Equipment, index = 0) { let effect_group = new Phaser.Image(this.game, 27, 243 + 60 * index, "battle-ship-tooltip-effect"); this.active_effects.addChild(effect_group); diff --git a/src/view/battle/Targetting.spec.ts b/src/ui/battle/Targetting.spec.ts similarity index 83% rename from src/view/battle/Targetting.spec.ts rename to src/ui/battle/Targetting.spec.ts index 6a888b1..a8a0e49 100644 --- a/src/view/battle/Targetting.spec.ts +++ b/src/ui/battle/Targetting.spec.ts @@ -1,24 +1,24 @@ -module TS.SpaceTac.View.Specs { +module TS.SpaceTac.UI.Specs { describe("Targetting", () => { it("broadcasts hovering and selection events", () => { var targetting = new Targetting(null); - var hovered: Game.Target[] = []; - var selected: Game.Target[] = []; - targetting.targetHovered.add((target: Game.Target) => { + var hovered: Target[] = []; + var selected: Target[] = []; + targetting.targetHovered.add((target: Target) => { hovered.push(target); }); - targetting.targetSelected.add((target: Game.Target) => { + targetting.targetSelected.add((target: Target) => { selected.push(target); }); targetting.setTargetSpace(1, 2); - expect(hovered).toEqual([Game.Target.newFromLocation(1, 2)]); + expect(hovered).toEqual([Target.newFromLocation(1, 2)]); expect(selected).toEqual([]); targetting.validate(); - expect(hovered).toEqual([Game.Target.newFromLocation(1, 2)]); - expect(selected).toEqual([Game.Target.newFromLocation(1, 2)]); + expect(hovered).toEqual([Target.newFromLocation(1, 2)]); + expect(selected).toEqual([Target.newFromLocation(1, 2)]); }); inbattleview_it("displays action point indicators", (battleview) => { diff --git a/src/view/battle/Targetting.ts b/src/ui/battle/Targetting.ts similarity index 92% rename from src/view/battle/Targetting.ts rename to src/ui/battle/Targetting.ts index 879d8c5..9dc1e3b 100644 --- a/src/view/battle/Targetting.ts +++ b/src/ui/battle/Targetting.ts @@ -1,13 +1,13 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Targetting system // Allows to pick a target for an action export class Targetting { // Initial target (as pointed by the user) - target_initial: Game.Target; + target_initial: Target; line_initial: Phaser.Graphics; // Corrected target (applying action rules) - target_corrected: Game.Target; + target_corrected: Target; line_corrected: Phaser.Graphics; // Circle for effect radius @@ -120,7 +120,7 @@ module TS.SpaceTac.View { let count = 0; let distance = 0; if (this.line_corrected.visible && this.ap_interval > 0) { - distance = this.target_corrected.getDistanceTo(Game.Target.newFromLocation(this.source.x, this.source.y)) - 0.00001; + distance = this.target_corrected.getDistanceTo(Target.newFromLocation(this.source.x, this.source.y)) - 0.00001; count = Math.ceil(distance / this.ap_interval); } @@ -153,7 +153,7 @@ module TS.SpaceTac.View { } // Set a target from a target object - setTarget(target: Game.Target, dispatch: boolean = true, blast_radius: number = 0): void { + setTarget(target: Target, dispatch: boolean = true, blast_radius: number = 0): void { this.target_corrected = target; this.blast_radius = blast_radius; if (dispatch) { @@ -169,13 +169,13 @@ module TS.SpaceTac.View { } // Set the current target ship (when hovered) - setTargetShip(ship: Game.Ship, dispatch: boolean = true): void { - this.setTarget(Game.Target.newFromShip(ship), dispatch); + setTargetShip(ship: Ship, dispatch: boolean = true): void { + this.setTarget(Target.newFromShip(ship), dispatch); } // Set the current target in space (when hovered) setTargetSpace(x: number, y: number, dispatch: boolean = true): void { - this.setTarget(Game.Target.newFromLocation(x, y)); + this.setTarget(Target.newFromLocation(x, y)); } // Validate the current target (when clicked) diff --git a/src/view/battle/WeaponEffect.ts b/src/ui/battle/WeaponEffect.ts similarity index 91% rename from src/view/battle/WeaponEffect.ts rename to src/ui/battle/WeaponEffect.ts index 60321ca..7ec2e31 100644 --- a/src/view/battle/WeaponEffect.ts +++ b/src/ui/battle/WeaponEffect.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Particle that is rotated to always face its ongoing direction class BulletParticle extends Phaser.Particle { update(): void { @@ -13,10 +13,10 @@ module TS.SpaceTac.View { private arena: Arena; // Firing ship - private source: Game.Target; + private source: Target; // Targetted ship - private destination: Game.Target; + private destination: Target; // Weapon class code (e.g. GatlingGun, ...) private weapon: string; @@ -24,7 +24,7 @@ module TS.SpaceTac.View { // Effect in use private effect: Function; - constructor(arena: Arena, source: Game.Target, destination: Game.Target, weapon: string) { + constructor(arena: Arena, source: Target, destination: Target, weapon: string) { this.arena = arena; this.source = source; this.destination = destination; @@ -58,7 +58,7 @@ module TS.SpaceTac.View { this.arena.addChild(missile); var tween = this.arena.game.tweens.create(missile); - tween.to({x: this.destination.x, y: this.destination.y}, 1000); + tween.to({ x: this.destination.x, y: this.destination.y }, 1000); tween.onComplete.addOnce(() => { missile.destroy(); }); diff --git a/src/view/common/Animation.ts b/src/ui/common/Animation.ts similarity index 97% rename from src/view/common/Animation.ts rename to src/ui/common/Animation.ts index 7a35af2..2388e8a 100644 --- a/src/view/common/Animation.ts +++ b/src/ui/common/Animation.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Utility functions for animation export class Animation { diff --git a/src/view/common/Audio.ts b/src/ui/common/Audio.ts similarity index 98% rename from src/view/common/Audio.ts rename to src/ui/common/Audio.ts index 183d0bb..29dac7f 100644 --- a/src/view/common/Audio.ts +++ b/src/ui/common/Audio.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Utility functions for sounds export class Audio { diff --git a/src/view/common/InputManager.ts b/src/ui/common/InputManager.ts similarity index 96% rename from src/view/common/InputManager.ts rename to src/ui/common/InputManager.ts index 12209a9..76729a4 100644 --- a/src/view/common/InputManager.ts +++ b/src/ui/common/InputManager.ts @@ -1,11 +1,11 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Manager for keyboard input / bindings // Action callbacks will receive the view as 'this' context export class InputManager { private view: BaseView; - private game: GameUI; + private game: MainUI; private input: Phaser.Input; diff --git a/src/view/common/Messages.ts b/src/ui/common/Messages.ts similarity index 89% rename from src/view/common/Messages.ts rename to src/ui/common/Messages.ts index 40d5820..a6eeedd 100644 --- a/src/view/common/Messages.ts +++ b/src/ui/common/Messages.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // A single displayed message class Message extends Phaser.Group { text: Phaser.Text; @@ -7,7 +7,7 @@ module TS.SpaceTac.View { super(parent.game); this.text = new Phaser.Text(parent.game, 0, 0, text, - {font: "bold 14px Arial", fill: "#90FEE3"}); + { font: "bold 14px Arial", fill: "#90FEE3" }); this.addChild(this.text); setTimeout(() => { @@ -18,7 +18,7 @@ module TS.SpaceTac.View { // Hide the message hide() { var tween = this.game.tweens.create(this); - tween.to({y: this.y + 50, alpha: 0}, 400, Phaser.Easing.Circular.In); + tween.to({ y: this.y + 50, alpha: 0 }, 400, Phaser.Easing.Circular.In); tween.onComplete.addOnce(() => { this.destroy(); }); diff --git a/src/view/common/Tools.spec.ts b/src/ui/common/Tools.spec.ts similarity index 98% rename from src/view/common/Tools.spec.ts rename to src/ui/common/Tools.spec.ts index 8bbccbd..483f3c1 100644 --- a/src/view/common/Tools.spec.ts +++ b/src/ui/common/Tools.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View.Specs { +module TS.SpaceTac.UI.Specs { describe("Tools", () => { it("normalizes angles", function () { expect(Tools.normalizeAngle(0)).toEqual(0); diff --git a/src/view/common/Tools.ts b/src/ui/common/Tools.ts similarity index 99% rename from src/view/common/Tools.ts rename to src/ui/common/Tools.ts index 7cfbc6d..a192e03 100644 --- a/src/view/common/Tools.ts +++ b/src/ui/common/Tools.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Common UI tools functions export class Tools { diff --git a/src/view/common/ValueBar.spec.ts b/src/ui/common/ValueBar.spec.ts similarity index 94% rename from src/view/common/ValueBar.spec.ts rename to src/ui/common/ValueBar.spec.ts index d43df52..76f4feb 100644 --- a/src/view/common/ValueBar.spec.ts +++ b/src/ui/common/ValueBar.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View.Specs { +module TS.SpaceTac.UI.Specs { describe("ValueBar", () => { ingame_it("computes proportional value", (game: Phaser.Game) => { var bar = ValueBar.newStandard(game, 0, 0); diff --git a/src/view/common/ValueBar.ts b/src/ui/common/ValueBar.ts similarity index 99% rename from src/view/common/ValueBar.ts rename to src/ui/common/ValueBar.ts index 2ea1510..4bbd016 100644 --- a/src/view/common/ValueBar.ts +++ b/src/ui/common/ValueBar.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Bar to display a value (like a progress bar) export class ValueBar extends Phaser.Sprite { // Vertical orientation diff --git a/src/view/map/FleetDisplay.spec.ts b/src/ui/map/FleetDisplay.spec.ts similarity index 95% rename from src/view/map/FleetDisplay.spec.ts rename to src/ui/map/FleetDisplay.spec.ts index bf78b6d..7e55f7c 100644 --- a/src/view/map/FleetDisplay.spec.ts +++ b/src/ui/map/FleetDisplay.spec.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View.Specs { +module TS.SpaceTac.UI.Specs { describe("FleetDisplay", () => { inmapview_it("orbits the fleet around its current location", mapview => { let fleet = mapview.player_fleet; diff --git a/src/view/map/FleetDisplay.ts b/src/ui/map/FleetDisplay.ts similarity index 94% rename from src/view/map/FleetDisplay.ts rename to src/ui/map/FleetDisplay.ts index 01aa414..f705735 100644 --- a/src/view/map/FleetDisplay.ts +++ b/src/ui/map/FleetDisplay.ts @@ -1,4 +1,4 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { const SCALING = 0.00005; const LOCATIONS: [number, number][] = [ [80, 0], @@ -14,10 +14,10 @@ module TS.SpaceTac.View { */ export class FleetDisplay extends Phaser.Group { private map: UniverseMapView; - private fleet: Game.Fleet; + private fleet: Fleet; private tween: Phaser.Tween; - constructor(parent: UniverseMapView, fleet: Game.Fleet) { + constructor(parent: UniverseMapView, fleet: Fleet) { super(parent.game); this.map = parent; @@ -67,7 +67,7 @@ module TS.SpaceTac.View { /** * Make the fleet move to another location in the same system */ - moveToLocation(location: Game.StarLocation) { + moveToLocation(location: StarLocation) { if (location != this.fleet.location) { let dx = location.x - this.fleet.location.x; let dy = location.y - this.fleet.location.y; diff --git a/src/view/map/StarSystemDisplay.ts b/src/ui/map/StarSystemDisplay.ts similarity index 85% rename from src/view/map/StarSystemDisplay.ts rename to src/ui/map/StarSystemDisplay.ts index 2d24865..0f918f7 100644 --- a/src/view/map/StarSystemDisplay.ts +++ b/src/ui/map/StarSystemDisplay.ts @@ -1,12 +1,12 @@ -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Group to display a star system export class StarSystemDisplay extends Phaser.Image { - starsystem: Game.Star; - player: Game.Player; + starsystem: Star; + player: Player; fleet_display: FleetDisplay; - locations: [Game.StarLocation, Phaser.Image, Phaser.Image][] = []; + locations: [StarLocation, Phaser.Image, Phaser.Image][] = []; - constructor(parent: UniverseMapView, starsystem: Game.Star) { + constructor(parent: UniverseMapView, starsystem: Star) { super(parent.game, starsystem.x, starsystem.y, "map-starsystem-background"); this.anchor.set(0.5, 0.5); @@ -26,13 +26,13 @@ module TS.SpaceTac.View { let location_sprite: Phaser.Image | null = null; let fleet_move = () => this.fleet_display.moveToLocation(location); - if (location.type == Game.StarLocationType.STAR) { + if (location.type == StarLocationType.STAR) { location_sprite = this.addImage(location.x, location.y, "map-location-star", fleet_move); - } else if (location.type == Game.StarLocationType.PLANET) { + } else if (location.type == StarLocationType.PLANET) { location_sprite = this.addImage(location.x, location.y, "map-location-planet", fleet_move); location_sprite.rotation = Math.atan2(location.y, location.x); this.addCircle(Math.sqrt(location.x * location.x + location.y * location.y), 1); - } else if (location.type == Game.StarLocationType.WARP) { + } else if (location.type == StarLocationType.WARP) { location_sprite = this.addImage(location.x, location.y, "map-location-warp", fleet_move); } @@ -64,7 +64,7 @@ module TS.SpaceTac.View { /** * Return the sprite code to use for visited status. */ - getVisitedKey(location: Game.StarLocation) { + getVisitedKey(location: StarLocation) { return this.player.hasVisitedLocation(location) ? (location.encounter ? "map-state-enemy" : "map-state-clear") : "map-state-unknown"; } diff --git a/src/view/map/UniverseMapView.ts b/src/ui/map/UniverseMapView.ts similarity index 96% rename from src/view/map/UniverseMapView.ts rename to src/ui/map/UniverseMapView.ts index e18286f..3f3d3c7 100644 --- a/src/view/map/UniverseMapView.ts +++ b/src/ui/map/UniverseMapView.ts @@ -1,13 +1,13 @@ /// -module TS.SpaceTac.View { +module TS.SpaceTac.UI { // Interactive map of the universe export class UniverseMapView extends BaseView { // Displayed universe - universe: Game.Universe; + universe: Universe; // Interacting player - player: Game.Player; + player: Player; // Star systems group: Phaser.Group; @@ -21,7 +21,7 @@ module TS.SpaceTac.View { zoom = 0; // Init the view, binding it to a universe - init(universe: Game.Universe, player: Game.Player) { + init(universe: Universe, player: Player) { super.init(); this.universe = universe;