map: Fixed location badge not updating
This commit is contained in:
parent
55d83b1649
commit
98e75c67c8
1
TODO.md
1
TODO.md
|
@ -21,7 +21,6 @@ Map/story
|
|||
* Forbid to end up with more than 5 ships in the fleet because of escorts
|
||||
* Fix problems when several dialogs are active at the same time
|
||||
* Handle case where cargo is full to give a reward (give money?)
|
||||
* Fix question mark not being cleared on no encounter
|
||||
|
||||
Character sheet
|
||||
---------------
|
||||
|
|
30
src/ui/map/StarSystemDisplay.spec.ts
Normal file
30
src/ui/map/StarSystemDisplay.spec.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
module TS.SpaceTac.UI.Specs {
|
||||
describe("StarSystemDisplay", function () {
|
||||
let testgame = setupMapview();
|
||||
|
||||
it("displays a badge with the current state for a star location", function () {
|
||||
let mapview = testgame.mapview;
|
||||
let location = nn(mapview.player.fleet.location);
|
||||
|
||||
let ssdisplay = nn(first(mapview.starsystems, ss => ss.starsystem == location.star));
|
||||
let l1display = nn(first(ssdisplay.locations, loc => loc[0] == location));
|
||||
expect(l1display[2].name).toEqual("map-status-dockyard");
|
||||
|
||||
let l2display = nn(first(ssdisplay.locations, loc => loc[0] != location));
|
||||
expect(l2display[2].name).toEqual("map-status-unvisited");
|
||||
|
||||
l2display[0].setupEncounter();
|
||||
ssdisplay.updateInfo(2, true);
|
||||
expect(l2display[2].name).toEqual("map-status-unvisited");
|
||||
|
||||
mapview.player.setVisited(l2display[0]);
|
||||
ssdisplay.updateInfo(2, true);
|
||||
expect(l2display[2].name).toEqual("map-status-enemy");
|
||||
|
||||
l2display[0].shop = null;
|
||||
l2display[0].clearEncounter();
|
||||
ssdisplay.updateInfo(2, true);
|
||||
expect(l2display[2].name).toEqual("map-status-clear");
|
||||
});
|
||||
});
|
||||
}
|
|
@ -60,8 +60,8 @@ module TS.SpaceTac.UI {
|
|||
});
|
||||
|
||||
if (location_sprite) {
|
||||
let frame = this.getBadgeFrame(location);
|
||||
let status_badge = this.addImage(location.x + 0.005, location.y + 0.005, `map-status-${frame}`);
|
||||
let status = this.getBadgeFrame(location);
|
||||
let status_badge = this.addImage(location.x + 0.005, location.y + 0.005, `map-status-${status}`);
|
||||
this.locations.push([location, location_sprite, status_badge]);
|
||||
}
|
||||
});
|
||||
|
@ -127,7 +127,8 @@ module TS.SpaceTac.UI {
|
|||
*/
|
||||
updateInfo(level: number, focus: boolean) {
|
||||
this.locations.forEach(info => {
|
||||
info[2].frame = this.getBadgeFrame(info[0]);
|
||||
let status = this.getBadgeFrame(info[0]);
|
||||
this.view.changeImage(info[2], `map-status-${status}`);
|
||||
});
|
||||
|
||||
// LOD
|
||||
|
|
Loading…
Reference in a new issue