@gaia-project/engine
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -8,15 +8,15 @@ "use strict"; | ||
// Data: from outer ring to inside ring, starting from a corner | ||
const s1 = "eeeeemevoeed,sereee,e".replace(/,/g, ""); | ||
const s2 = "evteedemeoee,eeiees,e".replace(/,/g, ""); | ||
const s3 = "eemeeteedree,geeiee,e".replace(/,/g, ""); | ||
const s4 = "eeteeereeeei,eoesev,e".replace(/,/g, ""); | ||
const s5 = "eeiemoeedvee,geeeee,e".replace(/,/g, ""); | ||
const s5b = "eeiemoeeevee,geeeee,e".replace(/,/g, ""); | ||
const s6 = "eeemeedmeeee,serege,e".replace(/,/g, ""); | ||
const s6b = "eeemeedmeeee,eerege,e".replace(/,/g, ""); | ||
const s7 = "meeseeeeteee,eoegeg,e".replace(/,/g, ""); | ||
const s7b = "meeeeeeeteee,egeseg,e".replace(/,/g, ""); | ||
const s8 = "eeremeeeemee,eietev,e".replace(/,/g, ""); | ||
const s9 = "evemieeeeese,eeeget,e".replace(/,/g, ""); | ||
const s10 = "eeemmeeeeore,deegee,e".replace(/,/g, ""); | ||
const s1 = { name: "s1", map: "eeeeemevoeed,sereee,e".replace(/,/g, "") }; | ||
const s2 = { name: "s2", map: "evteedemeoee,eeiees,e".replace(/,/g, "") }; | ||
const s3 = { name: "s3", map: "eemeeteedree,geeiee,e".replace(/,/g, "") }; | ||
const s4 = { name: "s4", map: "eeteeereeeei,eoesev,e".replace(/,/g, "") }; | ||
const s5 = { name: "s5", map: "eeiemoeedvee,geeeee,e".replace(/,/g, "") }; | ||
const s5b = { name: "s5b", map: "eeiemoeeevee,geeeee,e".replace(/,/g, "") }; | ||
const s6 = { name: "s6", map: "eeemeedmeeee,serege,e".replace(/,/g, "") }; | ||
const s6b = { name: "s6b", map: "eeemeedmeeee,eerege,e".replace(/,/g, "") }; | ||
const s7 = { name: "s7", map: "meeseeeeteee,eoegeg,e".replace(/,/g, "") }; | ||
const s7b = { name: "s7b", map: "meeeeeeeteee,egeseg,e".replace(/,/g, "") }; | ||
const s8 = { name: "s8", map: "eeremeeeemee,eietev,e".replace(/,/g, "") }; | ||
const s9 = { name: "s9", map: "evemieeeeese,eeeget,e".replace(/,/g, "") }; | ||
const s10 = { name: "s10", map: "eeemmeeeeore,deegee,e".replace(/,/g, "") }; | ||
const smallConfiguration = { | ||
@@ -67,3 +67,3 @@ sectors: [s1, s2, s3, s4, s5b, s6b, s7b], | ||
const centers = this.configuration().centers; | ||
const [hexagon, ...hexagons] = definitions.map((side, index) => sector_1.default.create(side, index, centers[index]).rotateLeft(Math.floor(this.rng() * 6), centers[index])); | ||
const [hexagon, ...hexagons] = definitions.map((side, index) => sector_1.default.create(side.map, side.name, centers[index]).rotateLeft(Math.floor(this.rng() * 6), centers[index])); | ||
this.grid = hexagon.merge(...hexagons); | ||
@@ -70,0 +70,0 @@ } |
@@ -12,4 +12,4 @@ "use strict"; | ||
*/ | ||
static create(definition, id, center = { q: 0, r: 0, s: 0 }) { | ||
const GaiaHex = hexagrid_1.Hex.extend({ planet: enums_1.Planet.Empty, sector: id }); | ||
static create(definition, name, center = { q: 0, r: 0, s: 0 }) { | ||
const GaiaHex = hexagrid_1.Hex.extend({ planet: enums_1.Planet.Empty, sector: name }); | ||
// Converts a string like eee,dsee,eeere,eeem,ove into an array of array of planets | ||
@@ -21,3 +21,3 @@ if (typeof definition === "string") { | ||
const planetArray = [].concat(...definition); | ||
const dataArray = planetArray.map(planet => ({ planet, sector: id })); | ||
const dataArray = planetArray.map(planet => ({ planet, sector: name })); | ||
const grid = new hexagrid_1.Grid(...GaiaHex.hexagon(2, { center, data: dataArray })); | ||
@@ -24,0 +24,0 @@ return grid; |
{ | ||
"name": "@gaia-project/engine", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Javascript engine for project gaia", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,15 +7,15 @@ import {Grid, Hex, CubeCoordinates} from "hexagrid"; | ||
// Data: from outer ring to inside ring, starting from a corner | ||
const s1 = "eeeeemevoeed,sereee,e".replace(/,/g, ""); | ||
const s2 = "evteedemeoee,eeiees,e".replace(/,/g, ""); | ||
const s3 = "eemeeteedree,geeiee,e".replace(/,/g, ""); | ||
const s4 = "eeteeereeeei,eoesev,e".replace(/,/g, ""); | ||
const s5 = "eeiemoeedvee,geeeee,e".replace(/,/g, ""); | ||
const s5b = "eeiemoeeevee,geeeee,e".replace(/,/g, ""); | ||
const s6 = "eeemeedmeeee,serege,e".replace(/,/g, ""); | ||
const s6b = "eeemeedmeeee,eerege,e".replace(/,/g, ""); | ||
const s7 = "meeseeeeteee,eoegeg,e".replace(/,/g, ""); | ||
const s7b = "meeeeeeeteee,egeseg,e".replace(/,/g, ""); | ||
const s8 = "eeremeeeemee,eietev,e".replace(/,/g, ""); | ||
const s9 = "evemieeeeese,eeeget,e".replace(/,/g, ""); | ||
const s10 = "eeemmeeeeore,deegee,e".replace(/,/g, ""); | ||
const s1 = {name: "s1", map: "eeeeemevoeed,sereee,e".replace(/,/g, "")}; | ||
const s2 = {name: "s2", map: "evteedemeoee,eeiees,e".replace(/,/g, "")}; | ||
const s3 = {name: "s3", map: "eemeeteedree,geeiee,e".replace(/,/g, "")}; | ||
const s4 = {name: "s4", map: "eeteeereeeei,eoesev,e".replace(/,/g, "")}; | ||
const s5 = {name: "s5", map: "eeiemoeedvee,geeeee,e".replace(/,/g, "")}; | ||
const s5b = {name: "s5b", map: "eeiemoeeevee,geeeee,e".replace(/,/g, "")}; | ||
const s6 = {name: "s6", map: "eeemeedmeeee,serege,e".replace(/,/g, "")}; | ||
const s6b = {name: "s6b", map: "eeemeedmeeee,eerege,e".replace(/,/g, "")}; | ||
const s7 = {name: "s7", map: "meeseeeeteee,eoegeg,e".replace(/,/g, "")}; | ||
const s7b = {name: "s7b", map: "meeeeeeeteee,egeseg,e".replace(/,/g, "")}; | ||
const s8 = {name: "s8", map: "eeremeeeemee,eietev,e".replace(/,/g, "")}; | ||
const s9 = {name: "s9", map: "evemieeeeese,eeeget,e".replace(/,/g, "")}; | ||
const s10 = {name: "s10", map: "eeemmeeeeore,deegee,e".replace(/,/g, "")}; | ||
@@ -81,3 +81,3 @@ const smallConfiguration = { | ||
const [hexagon, ...hexagons] = definitions.map((side, index) => Sector.create(side, index, centers[index]).rotateLeft(Math.floor(this.rng()*6), centers[index])); | ||
const [hexagon, ...hexagons] = definitions.map((side, index) => Sector.create(side.map, side.name, centers[index]).rotateLeft(Math.floor(this.rng()*6), centers[index])); | ||
@@ -87,3 +87,3 @@ this.grid = hexagon.merge(...hexagons); | ||
chooseSides() : string[] { | ||
chooseSides() : Array<{map: string, name: string}> { | ||
const definitions = this.configuration().sectors; | ||
@@ -90,0 +90,0 @@ // Random sort of the chosen sectors, sliced |
@@ -6,3 +6,3 @@ import {Hex, Grid} from "hexagrid"; | ||
planet: Planet, | ||
sector: number | ||
sector: string | ||
} | ||
@@ -17,4 +17,4 @@ | ||
*/ | ||
public static create(definition: Planet[] | string, id: number, center = {q:0, r:0, s: 0}): Grid<GaiaHexData> { | ||
const GaiaHex = Hex.extend<GaiaHexData>({planet: Planet.Empty, sector: id}); | ||
public static create(definition: Planet[] | string, name: string, center = {q:0, r:0, s: 0}): Grid<GaiaHexData> { | ||
const GaiaHex = Hex.extend<GaiaHexData>({planet: Planet.Empty, sector: name}); | ||
@@ -28,3 +28,3 @@ // Converts a string like eee,dsee,eeere,eeem,ove into an array of array of planets | ||
const planetArray: Planet[] = [].concat(...definition); | ||
const dataArray = planetArray.map(planet => ({planet, sector: id})); | ||
const dataArray = planetArray.map(planet => ({planet, sector: name})); | ||
const grid = new Grid<GaiaHexData>(...GaiaHex.hexagon(2, {center, data: dataArray})); | ||
@@ -31,0 +31,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
50361
0