Skip to content

Commit

Permalink
galaxies
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielOliver committed May 26, 2023
1 parent a3e13de commit 06a9a92
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/core/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ const DefaultSetupInfo: SetupInfo = {
systems: SystemData,
};

export { FactionData, PlanetData, SystemData };
export { FactionData, PlanetData, SystemData, DefaultSetupInfo };
17 changes: 17 additions & 0 deletions packages/core/data/planets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,23 @@ const PlanetData: Planet[] = [
planetType: PlanetType.Legendary,
trait: Trait.Cultural,
},
{
systemId: -1,
planetId: 100,
name: "Mirage",
resources: 1,
influence: 2,
planetType: PlanetType.Legendary,
trait: Trait.Cultural,
},
{
systemId: -1,
planetId: 101,
name: "Custodia Vigilia",
resources: 2,
influence: 3,
planetType: PlanetType.Legendary,
},
];

export default PlanetData;
66 changes: 40 additions & 26 deletions packages/core/galaxy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { DefaultSetupInfo } from "./data";
import { SystemType, UniqueTile } from "./types/const";
import {
GalaxyCreationSimpleParameters,
GalaxyCreationSimpleSixPlayerParameters,
Expand All @@ -10,6 +12,7 @@ import {
SecretGalaxy,
UnitTechnologyI,
} from "./types/galaxy";
import { SetupInfo } from "./types/static";

const defaultReinforcements: Reinforcements = {
tokens: 8,
Expand Down Expand Up @@ -160,7 +163,6 @@ export function createSixPlayerGalaxy(
});
let map = ttsStringtoTilePositions(creation.ttsString);
if (players.some((x) => x.factionId === 7)) {
// TODO: make ghost placement nice.
map = map.concat({
position: { x: 1, y: 1 },
systemId: 51,
Expand All @@ -182,6 +184,8 @@ export function createGalaxy(creation: GalaxyCreationSimpleParameters): {
publicGalaxy: PublicGalaxy;
secretGalaxy: SecretGalaxy;
} {
const setupInfo: SetupInfo = DefaultSetupInfo;

const secretGalaxy: SecretGalaxy = {
actionCardDeckIds: [],
agendaDeckIds: [],
Expand Down Expand Up @@ -243,40 +247,50 @@ export function createGalaxy(creation: GalaxyCreationSimpleParameters): {
.sort((a, b) => a.speakerOrder - b.speakerOrder)
.map((x) => x.playerId);

// let systems = {};
// creation.map.forEach((x) => {
// systems[x.systemId] = {};
// });

let publicGalaxy: PublicGalaxy = {
activeLawIds: [],
forces: {},
initiativeOrder: [],
planets: {},
players: Object.fromEntries(players.map((x) => [x.playerId, x])),
speakerOrder: speakerOrder,
strategyCards: {},
systems: Object.fromEntries(
creation.map.map((x) => [
let systems = Object.fromEntries(
creation.map.map((x) => {
const system = setupInfo.systems.find((y) => y.systemId === x.systemId);
if (!system) return [];
const planets = setupInfo.planets.filter(
(y) => y.systemId === x.systemId
);
return [
x.systemId,
{
systemId: x.systemId,
position: x.position,
adjacencies: [],
neighbors: [],
adjacencyOverride: [],
canOccupy: true,
wormholes: [],
homeSystem: false,
legendary: false,
mecatolRex: false,
emptySystem: false,
anomalies: [],
planetIds: [],
wormholes: system.wormholes,
homeSystem:
!system.emptySystem && system.systemType === SystemType.Green,
legendary:
system.unique === UniqueTile.MalliceFlippedSide ||
system.unique === UniqueTile.MalliceStartingSide ||
system.unique === UniqueTile.HopesEnd ||
system.unique === UniqueTile.Mirage ||
system.unique === UniqueTile.Primor,
mecatolRex: system.unique === UniqueTile.MecatolRex,
emptySystem: system.emptySystem,
anomalies: system.anomaly ? [system.anomaly] : [],
planetIds: planets.map((y) => y.planetId),
tokens: [],
frontierToken: system.emptySystem,
},
])
),
];
})
);

let publicGalaxy: PublicGalaxy = {
activeLawIds: [],
forces: {},
initiativeOrder: [],
planets: {},
players: Object.fromEntries(players.map((x) => [x.playerId, x])),
speakerOrder: speakerOrder,
strategyCards: {},
systems: systems,
};

return {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/types/galaxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ export interface SystemI {
/** Virtual adjacencies are not supportable for movement purposes but support neighbors. */
neighbors: number[];
/** Some factions may do weird things, cough cough GHOSTS! */
adjacencyOverride: AdjacencyOverride[];
// adjacencyOverride: AdjacencyOverride[];
/** Default should be true */
canOccupy: boolean;
wormholes: Wormhole[];
frontierToken: boolean;
homeSystem: boolean;
legendary: boolean;
mecatolRex: boolean;
Expand Down

0 comments on commit 06a9a92

Please sign in to comment.