Fixed ship naming
This commit is contained in:
parent
5700e7c16a
commit
ff233bd164
1
TODO.md
1
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
|
||||
------
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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(",")}]`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 = (<any>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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 = <Phaser.Button>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);
|
||||
});
|
||||
|
|
|
@ -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(<any>ship.attributes, (key, value: ShipAttribute) => {
|
||||
let text = this.attributes[key];
|
||||
|
|
Loading…
Reference in a new issue