diff --git a/TODO.md b/TODO.md index 5abd114..55f29b7 100644 --- a/TODO.md +++ b/TODO.md @@ -30,7 +30,6 @@ Character sheet * When transferring to another ship, if the item can't be equipped (unmatched requirements), the transfer is cancelled instead of trying cargo * Effective skill is sometimes not updated when upgrading base skill * Add merged cargo display for the whole fleet -* Fix player's ship name not updating with level Battle ------ diff --git a/src/core/Equipment.ts b/src/core/Equipment.ts index 1d41012..0546dda 100644 --- a/src/core/Equipment.ts +++ b/src/core/Equipment.ts @@ -59,7 +59,7 @@ module TS.SpaceTac { } jasmineToString() { - return this.attached_to ? `${this.attached_to.ship.name} - ${this.name}` : this.name; + return this.attached_to ? `${this.attached_to.ship.getFullName()} - ${this.name}` : this.name; } /** diff --git a/src/core/Fleet.ts b/src/core/Fleet.ts index 0197cc2..ad6ea6a 100644 --- a/src/core/Fleet.ts +++ b/src/core/Fleet.ts @@ -26,7 +26,7 @@ module TS.SpaceTac { } jasmineToString(): string { - return `${this.player.name}'s fleet [${this.ships.map(ship => ship.name).join(",")}]`; + return `${this.player.name}'s fleet [${this.ships.map(ship => ship.getFullName()).join(",")}]`; } /** diff --git a/src/core/FleetGenerator.ts b/src/core/FleetGenerator.ts index 120b695..2308314 100644 --- a/src/core/FleetGenerator.ts +++ b/src/core/FleetGenerator.ts @@ -19,7 +19,7 @@ module TS.SpaceTac { range(ship_count).forEach(i => { var ship = ship_generator.generate(level, models[i] || null, upgrade, i < ship_count * 0.6); - ship.name = `${fleet.player.name}'s Level ${ship.level.get()} ${ship.model.name}`; + ship.name = ship.model.name; fleet.addShip(ship); }); diff --git a/src/core/Ship.spec.ts b/src/core/Ship.spec.ts index 282da2a..6c1c763 100644 --- a/src/core/Ship.spec.ts +++ b/src/core/Ship.spec.ts @@ -1,5 +1,19 @@ module TS.SpaceTac.Specs { describe("Ship", function () { + it("creates a full name", function () { + let ship = new Ship(); + expect(ship.getFullName(false)).toEqual("Level 1 unnamed"); + + ship.name = "Titan"; + expect(ship.getFullName(false)).toEqual("Level 1 Titan"); + + ship.level.forceLevel(3); + expect(ship.getFullName(false)).toEqual("Level 3 Titan"); + + ship.fleet.player.name = "Emperor"; + expect(ship.getFullName(true)).toEqual("Emperor's Level 3 Titan"); + }); + it("moves and computes facing angle", function () { var ship = new Ship(null, "Test"); ship.setArenaFacingAngle(0); diff --git a/src/core/Ship.ts b/src/core/Ship.ts index ebc0e93..f7605ec 100644 --- a/src/core/Ship.ts +++ b/src/core/Ship.ts @@ -77,6 +77,14 @@ module TS.SpaceTac { return new ArenaLocationAngle(this.arena_x, this.arena_y, this.arena_angle); } + /** + * Returns the full name of this ship + */ + getFullName(owner = true): string { + let result = `Level ${this.level.get()} ${this.name}`; + return owner ? `${this.fleet.player.name}'s ${result}` : result; + } + // Returns true if the ship is able to play // If *check_ap* is true, ap_current=0 will make this function return false isAbleToPlay(check_ap: boolean = true): boolean { diff --git a/src/ui/battle/ShipTooltip.spec.ts b/src/ui/battle/ShipTooltip.spec.ts index 0b5165e..aa343be 100644 --- a/src/ui/battle/ShipTooltip.spec.ts +++ b/src/ui/battle/ShipTooltip.spec.ts @@ -5,6 +5,7 @@ module TS.SpaceTac.UI.Specs { it("fills ship details", function () { let tooltip = new ShipTooltip(testgame.battleview); let ship = testgame.battleview.battle.play_order[2]; + ship.fleet.player.name = "Phil"; ship.name = "Fury"; ship.model = new ShipModel("fake", "Fury"); ship.listEquipment(SlotType.Weapon).forEach(equ => equ.detach()); @@ -22,7 +23,7 @@ module TS.SpaceTac.UI.Specs { let content = (tooltip).container.content; expect(content.children[0].name).toBe("ship-fake-portrait"); - expect(content.children[1].text).toBe("Fury"); + expect(content.children[1].text).toBe("Phil's Level 1 Fury"); expect(content.children[2].text).toBe("Plays in 2 turns"); expect(content.children[3].text).toBe("Hull\n58"); expect(content.children[4].text).toBe("Shield\n140"); diff --git a/src/ui/battle/ShipTooltip.ts b/src/ui/battle/ShipTooltip.ts index 592971f..a12e8be 100644 --- a/src/ui/battle/ShipTooltip.ts +++ b/src/ui/battle/ShipTooltip.ts @@ -27,7 +27,7 @@ module TS.SpaceTac.UI { filler.addImageA(0, 0, `ship-${ship.model.code}-portrait`, 0.5); let enemy = ship.getPlayer() != this.battleview.player; - filler.addText(140, 0, ship.name, enemy ? "#cc0d00" : "#ffffff", 22, false, true); + filler.addText(140, 0, ship.getFullName(), enemy ? "#cc0d00" : "#ffffff", 22, false, true); if (ship.alive) { let turns = this.battleview.battle.getTurnsBefore(ship); diff --git a/src/ui/character/CharacterFleetMember.ts b/src/ui/character/CharacterFleetMember.ts index 284e98b..9a851c7 100644 --- a/src/ui/character/CharacterFleetMember.ts +++ b/src/ui/character/CharacterFleetMember.ts @@ -25,7 +25,7 @@ module TS.SpaceTac.UI { this.levelup.visible = this.ship.getAvailableUpgradePoints() > 0; this.addChild(this.levelup); - sheet.view.tooltip.bindDynamicText(this, () => ship.name); + sheet.view.tooltip.bindDynamicText(this, () => ship.getFullName()); } /** diff --git a/src/ui/character/CharacterSheet.spec.ts b/src/ui/character/CharacterSheet.spec.ts index 52cdf4e..d92c5b7 100644 --- a/src/ui/character/CharacterSheet.spec.ts +++ b/src/ui/character/CharacterSheet.spec.ts @@ -28,14 +28,14 @@ module TS.SpaceTac.UI.Specs { expect(sheet.x).toEqual(0); expect(sheet.portraits.length).toBe(2); - expect(sheet.ship_name.text).toEqual("Ship 1"); + expect(sheet.ship_name.text).toEqual("Player's Level 1 Ship 1"); expect(sheet.ship_slots.length).toBe(4); expect(sheet.ship_cargo.length).toBe(3); let portrait = sheet.portraits.getChildAt(1); portrait.onInputUp.dispatch(); - expect(sheet.ship_name.text).toEqual("Ship 2"); + expect(sheet.ship_name.text).toEqual("Player's Level 1 Ship 2"); expect(sheet.ship_slots.length).toBe(1); expect(sheet.ship_cargo.length).toBe(2); }); diff --git a/src/ui/character/CharacterSheet.ts b/src/ui/character/CharacterSheet.ts index 89edca3..2b75be5 100644 --- a/src/ui/character/CharacterSheet.ts +++ b/src/ui/character/CharacterSheet.ts @@ -229,11 +229,11 @@ module TS.SpaceTac.UI { let upgrade_points = ship.getAvailableUpgradePoints(); - this.ship_name.setText(ship.name); + this.ship_name.setText(ship.getFullName()); this.ship_level.setText(ship.level.get().toString()); this.ship_experience.setValue(ship.level.getExperience(), ship.level.getNextGoal()); this.ship_upgrade_points.setText(upgrade_points.toString()); - this.ship_upgrades.visible = upgrade_points > 0; + this.ship_upgrades.visible = !ship.critical && upgrade_points > 0; iteritems(ship.attributes, (key, value: ShipAttribute) => { let text = this.attributes[key];