Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
charredUtensil committed Nov 10, 2024
1 parent e5c59cd commit 194b67f
Show file tree
Hide file tree
Showing 21 changed files with 330 additions and 237 deletions.
42 changes: 21 additions & 21 deletions src/core/architects/blackout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const MIN_AIR = 500;
const RESET_SECONDS = 120;
const RESET_END = 999;

const METADATA = {tag:'blackout'} as const satisfies BaseMetadata;
const METADATA = { tag: "blackout" } as const satisfies BaseMetadata;

const BASE: PartialArchitect<typeof METADATA> = {
...DefaultSpawnArchitect,
Expand All @@ -21,22 +21,22 @@ const BASE: PartialArchitect<typeof METADATA> = {
const context = inferContextDefaults({
caveHasRechargeSeamChance: 0.15,
hallHasRechargeSeamChance: 0.15,
...cavern.initialContext
})
return {...cavern, context}
...cavern.initialContext,
});
return { ...cavern, context };
},
script({cavern, plan, sh}) {
script({ cavern, plan, sh }) {
const v = mkVars(`p${plan.id}Bo`, [
'crystalBank',
'doReset',
'loop',
'ms',
'msgStart',
'msgEnd',
'needCrystals',
'reset',
'tc',
'trips',
"crystalBank",
"doReset",
"loop",
"ms",
"msgStart",
"msgEnd",
"needCrystals",
"reset",
"tc",
"trips",
]);
const rng = cavern.dice.script(plan.id);
return scriptFragment(
Expand All @@ -58,12 +58,12 @@ const BASE: PartialArchitect<typeof METADATA> = {
`when(crystals>=${v.needCrystals})[${v.trips}+=1]`,
sh.trigger(
`when(${v.trips}==1)`,
'wait:random(5)(30);',
"wait:random(5)(30);",
`${v.needCrystals}=crystals+${CRYSTALS_INCREMENT_TO_RESET};`,
'disable:lights;',
"disable:lights;",
`${v.reset}=0;`,
`${v.loop};`,
'wait:1;',
"wait:1;",
`${v.ms}=1;`,
),
`if(${v.ms}==1)[msg:${v.msgStart}]`,
Expand All @@ -85,15 +85,15 @@ const BASE: PartialArchitect<typeof METADATA> = {
`crystals+=${v.crystalBank};`,
`${v.needCrystals}=${v.crystalBank}+${CRYSTALS_INCREMENT_TO_RETRIGGER};`,
`${v.crystalBank}=0;`,
'wait:1;',
'enable:lights;',
"wait:1;",
"enable:lights;",
`${v.trips}=0;`,
`wait:1;`,
`${v.ms}=2;`,
),
`if(${v.ms}==2)[msg:${v.msgEnd}]`,
);
}
},
};

const BLACKOUT = [
Expand Down
2 changes: 1 addition & 1 deletion src/core/architects/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ export const DefaultSpawnArchitect: PartialArchitect<any> = {
};
},
maxSlope: 15,
};
};
4 changes: 2 additions & 2 deletions src/core/architects/established_hq/lost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const LOST = [
!plan.fluid &&
plan.pearlRadius > 5 &&
hops.length <= MAX_HOPS &&
plans[cavern.anchor]?.metadata?.tag !== 'mobFarm' &&
plans[cavern.anchor]?.metadata?.tag !== "mobFarm" &&
!hops.some((id) => plans[id].fluid) &&
!plans.some((p) => p.metadata?.tag === "hq") &&
0.5,
Expand All @@ -95,7 +95,7 @@ const LOST = [
!plan.fluid &&
plan.pearlRadius > 6 &&
hops.length <= MAX_HOPS &&
plans[cavern.anchor]?.metadata?.tag !== 'mobFarm' &&
plans[cavern.anchor]?.metadata?.tag !== "mobFarm" &&
!plans.some((p) => p.metadata?.tag === "hq") &&
(plans[hops[0]].metadata?.tag === "nomads" ? 5 : 0.5),
},
Expand Down
2 changes: 1 addition & 1 deletion src/core/architects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type AnyMetadata =
| LostMinersMetadata
| NomadsMetadata
| MobFarmMetadata
| { tag: 'blackout' | "seismic" | "slugNest" | "treasure" };
| { tag: "blackout" | "seismic" | "slugNest" | "treasure" };

export const ARCHITECTS = [
...BLACKOUT,
Expand Down
41 changes: 23 additions & 18 deletions src/core/architects/lost_miners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ function getBreadcrumbPoint(
// Choose the neighboring plan which is closest to spawn (fewest hops).
const neighborPlan = cavern.plans[plan.hops[plan.hops.length - 1]];

const result = closestTo(minersPos, neighborPlan.innerPearl
.flatMap((layer) => layer)
// Find all the points in the inner pearl that are not walls and are in a
// different discovery zone from the miners.
.filter(([x, y]) => {
const dz = cavern.discoveryZones.get(x, y);
return dz && dz !== minersDz;
}));
const result = closestTo(
minersPos,
neighborPlan.innerPearl
.flatMap((layer) => layer)
// Find all the points in the inner pearl that are not walls and are in a
// different discovery zone from the miners.
.filter(([x, y]) => {
const dz = cavern.discoveryZones.get(x, y);
return dz && dz !== minersDz;
}),
);

// If such a point exists, return it.
if (result) {
Expand All @@ -105,16 +108,18 @@ function placeBreadcrumbVehicles(
): Vehicle[] {
const tile = cavern.tiles.get(x, y);
const fluid = tile === Tile.LAVA || tile === Tile.WATER ? tile : null;
const isMobFarm = cavern.plans[cavern.anchor].metadata?.tag === 'mobFarm';
const template = rng.weightedChoice<VehicleTemplate | null>(filterTruthy([
!fluid && !isMobFarm && { item: HOVER_SCOUT, bid: 2 },
!fluid && { item: SMALL_DIGGER, bid: 0.5 },
!fluid && { item: SMALL_TRANSPORT_TRUCK, bid: 0.75 },
!fluid && { item: SMLC, bid: 0.05},
!isMobFarm && fluid === Tile.WATER && { item: RAPID_RIDER, bid: 1 },
!isMobFarm && { item: TUNNEL_SCOUT, bid: 0.25 },
{ item: null, bid: 0.0025 },
]));
const isMobFarm = cavern.plans[cavern.anchor].metadata?.tag === "mobFarm";
const template = rng.weightedChoice<VehicleTemplate | null>(
filterTruthy([
!fluid && !isMobFarm && { item: HOVER_SCOUT, bid: 2 },
!fluid && { item: SMALL_DIGGER, bid: 0.5 },
!fluid && { item: SMALL_TRANSPORT_TRUCK, bid: 0.75 },
!fluid && { item: SMLC, bid: 0.05 },
!isMobFarm && fluid === Tile.WATER && { item: RAPID_RIDER, bid: 1 },
!isMobFarm && { item: TUNNEL_SCOUT, bid: 0.25 },
{ item: null, bid: 0.0025 },
]),
);
if (template) {
return [
vehicleFactory.create({
Expand Down
Loading

0 comments on commit 194b67f

Please sign in to comment.