Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gaia-project/engine

Package Overview
Dependencies
Maintainers
2
Versions
272
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gaia-project/engine - npm Package Compare versions

Comparing version 4.8.33 to 4.8.34

1

dist/index.js

@@ -63,3 +63,2 @@ "use strict";

Object.defineProperty(exports, "BrainstoneWarning", { enumerable: true, get: function () { return types_1.BrainstoneWarning; } });
Object.defineProperty(exports, "MAX_SHIPS_PER_HEX", { enumerable: true, get: function () { return types_1.MAX_SHIPS_PER_HEX; } });
Object.defineProperty(exports, "ShipAction", { enumerable: true, get: function () { return types_1.ShipAction; } });

@@ -66,0 +65,0 @@ var engine_2 = require("./src/engine");

2

dist/package.json
{
"name": "@gaia-project/engine",
"version": "4.8.33",
"version": "4.8.34",
"description": "Javascript engine for project gaia",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.possibleShipMovements = exports.possibleShipActions = exports.possibleShips = exports.shipsInHex = void 0;
exports.possibleShipMovements = exports.possibleShipActions = exports.possibleShips = exports.shipsInHex = exports.TRADE_COST = void 0;
const enums_1 = require("../enums");

@@ -12,2 +12,5 @@ const reward_1 = __importDefault(require("../reward"));

const types_1 = require("./types");
const MAX_SHIPS_PER_HEX = 3;
const SHIP_ACTION_RANGE = 1;
exports.TRADE_COST = 3;
function shipsInHex(location, data) {

@@ -23,3 +26,3 @@ return data.players.flatMap((p) => p.data.ships).filter((s) => s.location === location);

for (const h of map.withinDistance(hex, 1)) {
if (!h.hasPlanet() && shipsInHex(h.toString(), engine).length < types_1.MAX_SHIPS_PER_HEX) {
if (!h.hasPlanet() && shipsInHex(h.toString(), engine).length < MAX_SHIPS_PER_HEX) {
buildings.push(buildings_1.newAvailableBuilding(ship, h, check, false));

@@ -35,3 +38,3 @@ }

if (!targets.find((t) => t.coordinates === hex) &&
(shipsInHex(hex, engine).length < types_1.MAX_SHIPS_PER_HEX || source === hex)) {
(shipsInHex(hex, engine).length < MAX_SHIPS_PER_HEX || source === hex)) {
targets.push({ coordinates: hex });

@@ -54,3 +57,3 @@ }

const locations = map
.withinDistance(map.getS(shipLocation), types_1.SHIP_ACTION_RANGE)
.withinDistance(map.getS(shipLocation), SHIP_ACTION_RANGE)
.flatMap((h) => locationFactory(h));

@@ -72,2 +75,5 @@ const actions = [];

}
function tradeCost(engine, player) {
return new reward_1.default(-engine.player(player).data.tradeCost(), enums_1.Resource.ChargePower);
}
function tradeUnits(engine, player, building) {

@@ -81,16 +87,23 @@ const p = engine.player(player);

}
function baseTradeReward(building) {
function isFurther(guest, host) {
return enums_1.ResearchField.values(enums_1.Expansion.All).filter((f) => host[f] > guest[f]).length;
}
function baseTradeReward(building, guest, host, engine) {
switch (building) {
//Own Mine
case enums_1.Building.Mine:
return new reward_1.default(1, enums_1.Resource.Ore);
return reward_1.default.parse("1o");
case enums_1.Building.TradingStation:
return new reward_1.default(5, enums_1.Resource.Credit);
return reward_1.default.parse("5c");
case enums_1.Building.ResearchLab:
return reward_1.default.parse("2k");
case enums_1.Building.Academy1:
case enums_1.Building.Academy2:
return new reward_1.default(2, enums_1.Resource.Knowledge);
return [
new reward_1.default(isFurther(engine.player(guest).data.research, engine.player(host).data.research), enums_1.Resource.Knowledge),
];
case enums_1.Building.PlanetaryInstitute:
return new reward_1.default(5, enums_1.Resource.ChargePower);
return reward_1.default.parse("1t,2pw");
case enums_1.Building.Colony:
return new reward_1.default(3, enums_1.Resource.VictoryPoint);
return reward_1.default.parse("3vp");
}

@@ -102,5 +115,6 @@ throw new Error("unknown trade bonus: " + building);

case enums_1.Building.Mine:
//foreign mine
return reward_1.default.parse("1c,1o");
case enums_1.Building.TradingStation:
return reward_1.default.parse("2c,1pw");
return reward_1.default.parse("3c,1pw");
case enums_1.Building.ResearchLab:

@@ -111,3 +125,3 @@ case enums_1.Building.Academy1:

case enums_1.Building.PlanetaryInstitute:
return reward_1.default.parse("3pw");
return reward_1.default.parse("4pw");
case enums_1.Building.Colony:

@@ -127,3 +141,3 @@ return reward_1.default.parse("2vp");

.canBuild(engine.map, h, h.data.planet, enums_1.Building.CustomsPost, engine.isLastRound, engine.replay, {
addedCost: reward_1.default.negative(tradeUnits(engine, player, building)),
addedCost: reward_1.default.negative(reward_1.default.merge(tradeUnits(engine, player, building)).concat(tradeCost(engine, player))),
});

@@ -138,3 +152,5 @@ if (check) {

coordinates: h.toString(),
rewards: reward_1.default.merge([baseTradeReward(building)].concat(tradeUnits(engine, player, building))).toString(),
rewards: reward_1.default.merge(baseTradeReward(building, player, host, engine)
.concat(tradeCost(engine, player))
.concat(tradeUnits(engine, player, building))).toString(),
},

@@ -148,3 +164,3 @@ ];

coordinates: h.toString(),
rewards: baseTradeReward(building).toString(),
rewards: baseTradeReward(building, player, host, engine).toString(),
},

@@ -151,0 +167,0 @@ ];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShipAction = exports.Offer = exports.BrainstoneWarning = exports.SHIP_ACTION_RANGE = exports.MAX_SHIPS_PER_HEX = exports.UPGRADE_RESEARCH_COST = exports.ISOLATED_DISTANCE = void 0;
exports.ShipAction = exports.Offer = exports.BrainstoneWarning = exports.UPGRADE_RESEARCH_COST = exports.ISOLATED_DISTANCE = void 0;
const enums_1 = require("../enums");
exports.ISOLATED_DISTANCE = 3;
exports.UPGRADE_RESEARCH_COST = "4k";
exports.MAX_SHIPS_PER_HEX = 3;
exports.SHIP_ACTION_RANGE = 1;
var BrainstoneWarning;

@@ -10,0 +8,0 @@ (function (BrainstoneWarning) {

@@ -88,4 +88,5 @@ "use strict";

Resource["Turn"] = "turn";
Resource["TradeBonus"] = "trade-bonus";
Resource["TradeShip"] = "trade-ship";
Resource["TradeBonus"] = "tradeBonus";
Resource["TradeDiscount"] = "tradeDiscount";
Resource["TradeShip"] = "tradeShip";
})(Resource = exports.Resource || (exports.Resource = {}));

@@ -96,2 +97,3 @@ function isResourceUsed(resource, expansion) {

case Resource.TradeBonus:
case Resource.TradeDiscount:
case Resource.TradeShip:

@@ -126,3 +128,3 @@ case Resource.UpgradeDiplomacy:

Condition["ResearchLab"] = "lab";
Condition["PlanetaryInstituteOrAcademy"] = "PA";
Condition["BigBuilding"] = "PA";
Condition["Federation"] = "fed";

@@ -145,2 +147,3 @@ // count only

Condition["GaiaFormer"] = "gf";
Condition["Trade"] = "trade";
})(Condition = exports.Condition || (exports.Condition = {}));

@@ -155,4 +158,7 @@ (function (Condition) {

return building === Building.Mine && planet === Planet.Gaia;
case Condition.PlanetaryInstituteOrAcademy:
return (building === Building.PlanetaryInstitute || building === Building.Academy1 || building === Building.Academy2);
case Condition.BigBuilding:
return (building === Building.PlanetaryInstitute ||
building === Building.Academy1 ||
building === Building.Academy2 ||
building === Building.Colony);
}

@@ -159,0 +165,0 @@ return false;

@@ -52,3 +52,4 @@ "use strict";

}
pl.receiveTriggerIncome(enums_1.Condition.Trade);
}
//# sourceMappingURL=ships.js.map

@@ -9,2 +9,3 @@ "use strict";

const lodash_1 = require("lodash");
const ships_1 = require("./available/ships");
const types_1 = require("./available/types");

@@ -77,2 +78,3 @@ const enums_1 = require("./enums");

this.tradeBonus = 0;
this.tradeDiscount = 0;
this.tradeShips = 0;

@@ -125,2 +127,3 @@ this.tiles = {

tradeBonus: this.tradeBonus,
tradeDiscount: this.tradeDiscount,
tradeShips: this.tradeShips,

@@ -241,2 +244,5 @@ };

break;
case enums_1.Resource.TradeDiscount:
this.tradeDiscount += count;
break;
case enums_1.Resource.TradeShip:

@@ -511,2 +517,5 @@ this.tradeShips += count;

}
tradeCost() {
return ships_1.TRADE_COST - this.tradeDiscount;
}
/**

@@ -513,0 +522,0 @@ * Convert all resources into knowledge / ore / credits,

@@ -571,5 +571,2 @@ "use strict";

}
if (events.flatMap((e) => e.rewards).some((r) => r.type === enums_1.Resource.TradeBonus)) {
this.data.tradeBonus--;
}
}

@@ -746,6 +743,7 @@ incomeSelection(additionalEvents) {

return this.data.buildings[enums_1.Building.ResearchLab];
case enums_1.Condition.PlanetaryInstituteOrAcademy:
case enums_1.Condition.BigBuilding:
return (this.data.buildings[enums_1.Building.Academy1] +
this.data.buildings[enums_1.Building.Academy2] +
this.data.buildings[enums_1.Building.PlanetaryInstitute]);
this.data.buildings[enums_1.Building.PlanetaryInstitute] +
this.data.buildings[enums_1.Building.Colony]);
case enums_1.Condition.Federation:

@@ -752,0 +750,0 @@ return this.data.tiles.federations.length;

@@ -15,14 +15,14 @@ "use strict";

[],
["+pw", "trade-bonus"],
["+2pw", "q"],
["+3pw", "trade-bonus", "3pw"],
["+4pw", "trade-bonus"],
["+6pw", "trade-bonus"],
["+pw", "tradeDiscount"],
["+2pw", "tradeBonus"],
["+3pw", "tradeDiscount", "3pw"],
["+4pw", "tradeBonus"],
["+6pw", "tradeBonus", "tradeDiscount"],
],
};
const frontiersEco = [
[">trade-ship"],
["+2c", ">trade-ship"],
["tradeShip"],
["+2c", "tradeShip"],
["+2c,1o,1pw"],
["+3c,1o,1pw", "3pw", ">trade-ship"],
["+3c,1o,1pw", "3pw", "tradeShip"],
["+4c,2o,2pw"],

@@ -29,0 +29,0 @@ ["6c,3o,6pw"],

@@ -15,3 +15,3 @@ "use strict";

[enums_1.TechTile.Tech9]: ["=> 4pw"],
[enums_1.TechTile.TechFrontiers1]: ["trade-bonus"],
[enums_1.TechTile.TechFrontiers1]: ["trade >> 2c"],
[enums_1.AdvTechTile.AdvTech1]: ["fed | 3vp"],

@@ -18,0 +18,0 @@ [enums_1.AdvTechTile.AdvTech2]: ["a >> 2vp"],

@@ -31,3 +31,2 @@ import { finalRankings, gainFinalScoringVictoryPoints } from "./src/algorithms/scoring";

ChooseTechTile,
MAX_SHIPS_PER_HEX,
ShipAction,

@@ -34,0 +33,0 @@ } from "./src/available/types";

{
"name": "@gaia-project/engine",
"version": "4.8.33",
"version": "4.8.34",
"description": "Javascript engine for project gaia",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import Engine from "../engine";
import { Building, Command, Planet, Player, Resource, Ship } from "../enums";
import { Building, Command, Expansion, Planet, Player, ResearchField, Resource, Ship } from "../enums";
import { GaiaHex } from "../gaia-hex";
import SpaceMap from "../map";
import PlayerObject from "../player";
import { ResearchProgress } from "../player-data";
import Reward from "../reward";

@@ -13,9 +14,11 @@ import { newAvailableBuilding } from "./buildings";

AvailableShipAction,
MAX_SHIPS_PER_HEX,
ShipAction,
ShipActionLocation,
SHIP_ACTION_RANGE,
TradingLocation,
} from "./types";
const MAX_SHIPS_PER_HEX = 3;
const SHIP_ACTION_RANGE = 1;
export const TRADE_COST = 3;
export function shipsInHex(location: string, data): Ship[] {

@@ -94,2 +97,6 @@ return data.players.flatMap((p) => p.data.ships).filter((s) => s.location === location);

function tradeCost(engine: Engine, player: Player): Reward {
return new Reward(-engine.player(player).data.tradeCost(), Resource.ChargePower);
}
function tradeUnits(engine: Engine, player: Player, building: Building): Reward[] {

@@ -105,16 +112,27 @@ const p = engine.player(player);

function baseTradeReward(building: Building): Reward {
function isFurther(guest: ResearchProgress, host: ResearchProgress): number {
return ResearchField.values(Expansion.All).filter((f) => host[f] > guest[f]).length;
}
function baseTradeReward(building: Building, guest: Player, host: Player, engine: Engine): Reward[] {
switch (building) {
//Own Mine
case Building.Mine:
return new Reward(1, Resource.Ore);
return Reward.parse("1o");
case Building.TradingStation:
return new Reward(5, Resource.Credit);
return Reward.parse("5c");
case Building.ResearchLab:
return Reward.parse("2k");
case Building.Academy1:
case Building.Academy2:
return new Reward(2, Resource.Knowledge);
return [
new Reward(
isFurther(engine.player(guest).data.research, engine.player(host).data.research),
Resource.Knowledge
),
];
case Building.PlanetaryInstitute:
return new Reward(5, Resource.ChargePower);
return Reward.parse("1t,2pw");
case Building.Colony:
return new Reward(3, Resource.VictoryPoint);
return Reward.parse("3vp");
}

@@ -127,5 +145,6 @@ throw new Error("unknown trade bonus: " + building);

case Building.Mine:
//foreign mine
return Reward.parse("1c,1o");
case Building.TradingStation:
return Reward.parse("2c,1pw");
return Reward.parse("3c,1pw");
case Building.ResearchLab:

@@ -136,3 +155,3 @@ case Building.Academy1:

case Building.PlanetaryInstitute:
return Reward.parse("3pw");
return Reward.parse("4pw");
case Building.Colony:

@@ -153,3 +172,5 @@ return Reward.parse("2vp");

.canBuild(engine.map, h, h.data.planet, Building.CustomsPost, engine.isLastRound, engine.replay, {
addedCost: Reward.negative(tradeUnits(engine, player, building)),
addedCost: Reward.negative(
Reward.merge(tradeUnits(engine, player, building)).concat(tradeCost(engine, player))
),
});

@@ -163,3 +184,7 @@ if (check) {

coordinates: h.toString(),
rewards: Reward.merge([baseTradeReward(building)].concat(tradeUnits(engine, player, building))).toString(),
rewards: Reward.merge(
baseTradeReward(building, player, host, engine)
.concat(tradeCost(engine, player))
.concat(tradeUnits(engine, player, building))
).toString(),
} as TradingLocation,

@@ -172,3 +197,3 @@ ];

coordinates: h.toString(),
rewards: baseTradeReward(building).toString(),
rewards: baseTradeReward(building, player, host, engine).toString(),
} as TradingLocation,

@@ -175,0 +200,0 @@ ];

@@ -22,4 +22,2 @@ import {

export const UPGRADE_RESEARCH_COST = "4k";
export const MAX_SHIPS_PER_HEX = 3;
export const SHIP_ACTION_RANGE = 1;

@@ -26,0 +24,0 @@ export enum BrainstoneWarning {

@@ -86,4 +86,5 @@ export enum Planet {

Turn = "turn",
TradeBonus = "trade-bonus",
TradeShip = "trade-ship",
TradeBonus = "tradeBonus",
TradeDiscount = "tradeDiscount",
TradeShip = "tradeShip",
}

@@ -95,2 +96,3 @@

case Resource.TradeBonus:
case Resource.TradeDiscount:
case Resource.TradeShip:

@@ -125,3 +127,3 @@ case Resource.UpgradeDiplomacy:

ResearchLab = "lab",
PlanetaryInstituteOrAcademy = "PA",
BigBuilding = "PA",
Federation = "fed",

@@ -146,2 +148,3 @@

GaiaFormer = "gf",
Trade = "trade",
}

@@ -157,5 +160,8 @@

return building === Building.Mine && planet === Planet.Gaia;
case Condition.PlanetaryInstituteOrAcademy:
case Condition.BigBuilding:
return (
building === Building.PlanetaryInstitute || building === Building.Academy1 || building === Building.Academy2
building === Building.PlanetaryInstitute ||
building === Building.Academy1 ||
building === Building.Academy2 ||
building === Building.Colony
);

@@ -162,0 +168,0 @@ }

import assert from "assert";
import { AvailableBuilding, AvailableCommand, ShipAction, TradingLocation } from "../available/types";
import Engine from "../engine";
import { Building, Command, Player as PlayerEnum } from "../enums";
import { Building, Command, Condition, Player as PlayerEnum } from "../enums";
import Player from "../player";

@@ -67,2 +67,3 @@ import Reward from "../reward";

}
pl.receiveTriggerIncome(Condition.Trade);
}
import { EventEmitter } from "eventemitter3";
import { cloneDeep, fromPairs } from "lodash";
import { TRADE_COST } from "./available/ships";
import { BrainstoneActionData, BrainstoneWarning } from "./available/types";

@@ -55,2 +56,5 @@ import {

export type MaxLeech = { value: number; victoryPoints: number; charge: number };
export type ResearchProgress = {
[key in ResearchField]: number;
};
export default class PlayerData extends EventEmitter {

@@ -83,5 +87,3 @@ victoryPoints = 10;

satellites = 0;
research: {
[key in ResearchField]: number;
} = {
research: ResearchProgress = {
terra: 0,

@@ -103,2 +105,3 @@ nav: 0,

tradeBonus = 0;
tradeDiscount = 0;
tradeShips = 0;

@@ -162,2 +165,3 @@

tradeBonus: this.tradeBonus,
tradeDiscount: this.tradeDiscount,
tradeShips: this.tradeShips,

@@ -294,2 +298,5 @@ };

break;
case Resource.TradeDiscount:
this.tradeDiscount += count;
break;
case Resource.TradeShip:

@@ -605,2 +612,6 @@ this.tradeShips += count;

tradeCost(): number {
return TRADE_COST - this.tradeDiscount;
}
/**

@@ -607,0 +618,0 @@ * Convert all resources into knowledge / ore / credits,

@@ -709,5 +709,2 @@ import assert from "assert";

}
if (events.flatMap((e) => e.rewards).some((r) => r.type === Resource.TradeBonus)) {
this.data.tradeBonus--;
}
}

@@ -932,7 +929,8 @@

return this.data.buildings[Building.ResearchLab];
case Condition.PlanetaryInstituteOrAcademy:
case Condition.BigBuilding:
return (
this.data.buildings[Building.Academy1] +
this.data.buildings[Building.Academy2] +
this.data.buildings[Building.PlanetaryInstitute]
this.data.buildings[Building.PlanetaryInstitute] +
this.data.buildings[Building.Colony]
);

@@ -939,0 +937,0 @@ case Condition.Federation:

@@ -13,7 +13,7 @@ import { Event, Expansion } from "../index";

[],
["+pw", "trade-bonus"],
["+2pw", "q"],
["+3pw", "trade-bonus", "3pw"],
["+4pw", "trade-bonus"],
["+6pw", "trade-bonus"],
["+pw", "tradeDiscount"],
["+2pw", "tradeBonus"],
["+3pw", "tradeDiscount", "3pw"],
["+4pw", "tradeBonus"],
["+6pw", "tradeBonus", "tradeDiscount"],
],

@@ -23,6 +23,6 @@ };

const frontiersEco: string[][] = [
[">trade-ship"],
["+2c", ">trade-ship"],
["tradeShip"],
["+2c", "tradeShip"],
["+2c,1o,1pw"],
["+3c,1o,1pw", "3pw", ">trade-ship"],
["+3c,1o,1pw", "3pw", "tradeShip"],
["+4c,2o,2pw"],

@@ -29,0 +29,0 @@ ["6c,3o,6pw"],

@@ -13,3 +13,3 @@ import { AdvTechTile, AdvTechTilePos, Operator, TechTile, TechTilePos } from "../enums";

[TechTile.Tech9]: ["=> 4pw"],
[TechTile.TechFrontiers1]: ["trade-bonus"],
[TechTile.TechFrontiers1]: ["trade >> 2c"],
[AdvTechTile.AdvTech1]: ["fed | 3vp"],

@@ -16,0 +16,0 @@ [AdvTechTile.AdvTech2]: ["a >> 2vp"],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc