Fixed a rare failure case of universe generation
This commit is contained in:
parent
d0f475c0e4
commit
ab8d9b4729
1
TODO
1
TODO
|
@ -40,6 +40,7 @@
|
|||
* Mobile: think UI layout so that fingers do not block the view (right and left handed)
|
||||
* Mobile: display tooltips larger and on the side of screen where the finger is not
|
||||
* Mobile: targetting in two times, using a draggable target indicator
|
||||
* AI: use a first batch of producers, and only if no "good" move has been found, go on with some infinite producers
|
||||
* AI: apply safety distances to move actions
|
||||
* AI: do not always move first, they are defenders
|
||||
* AI: add combination of random small move and actual maneuver, as producer
|
||||
|
|
|
@ -86,5 +86,13 @@ module TS.SpaceTac.Specs {
|
|||
expect(start_location.encounter).toBeNull();
|
||||
expect(start_location.encounter_gen).toBe(true);
|
||||
});
|
||||
|
||||
it("can generate lots of new games", function () {
|
||||
range(100).forEach(() => {
|
||||
let session = new GameSession();
|
||||
session.startNewGame();
|
||||
expect(session.universe.stars.length).toBe(50);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,10 +17,12 @@ module TS.SpaceTac {
|
|||
|
||||
// Generates a universe, with star systems and such
|
||||
generate(starcount = 50): void {
|
||||
this.stars = this.generateStars(starcount);
|
||||
while (this.stars.length == 0 || any(this.stars, star => star.getLinks().length == 0)) {
|
||||
this.stars = this.generateStars(starcount);
|
||||
|
||||
var links = this.getPotentialLinks();
|
||||
this.starlinks = this.filterCrossingLinks(links);
|
||||
let links = this.getPotentialLinks();
|
||||
this.starlinks = this.filterCrossingLinks(links);
|
||||
}
|
||||
|
||||
this.generateWarpLocations();
|
||||
|
||||
|
|
Loading…
Reference in a new issue