@p31/game-engine
v0.1.0-alpha.0
Published
Geodesic building game engine for the P31 assistive technology platform. Maxwell rigidity, 7 seed challenges, player progression.
Maintainers
Readme
@p31/game-engine
Geodesic building game engine for the P31 assistive technology platform.
Structural building from primitive polyhedra (tetrahedron, octahedron, icosahedron). Maxwell rigidity (E ≥ 3V - 6), 7 seed challenges from Genesis Resonance to Geodesic Dome, player progression (XP, levels, tiers, streaks, daily quests). Wires to @p31/node-zero (identity, bonds) and @p31/love-ledger (LOVE) via an optional LedgerAdapter — no direct dependency on either.
Built by P31 Labs, a Georgia 501(c)(3) nonprofit.
Install
npm install @p31/game-engineQuick Start
import { GameEngine } from "@p31/game-engine";
import { LedgerEngine } from "@p31/love-ledger";
const ledger = new LedgerEngine("my-node-id");
const game = new GameEngine("my-node-id", {
domeName: "Crystal Dome",
domeColor: "#4ade80",
ledger: {
blockPlaced: (meta) => ledger.blockPlaced(meta),
challengeComplete: (id, love) => { /* optional: ledger or custom */ },
},
});
game.on("PIECE_PLACED", (e) => console.log("Piece:", e.piece.type));
game.on("CHALLENGE_COMPLETE", (e) => console.log("Challenge:", e.challenge.id, "+" + e.rewardLove + " LOVE"));
game.place(game.dome.id, "tetrahedron", { x: 1, y: 0, z: 0 });
game.startChallenge("genesis_resonance");
game.completeActiveChallenge();Modules
- types — Primitives, structures, rigidity analysis, challenges, player progress, events, snapshot.
- geometry — Vec3, PRIMITIVES (tetra/octa/icosa/strut/hub),
maxwellAnalysis,analyzeStructure,findSnaps,canSnap. - structures —
createStructure,createGenesisDome,placePiece,undoLastPiece,connectPieces. - challenges —
SEED_CHALLENGES(7),getChallenge,canAttempt,isChallengeComplete,availableChallenges,freshChallenge. - player —
xpToLevel,xpToTier,updateStreak,generateDailyQuests,createPlayer,addXp. - engine —
GameEngine,LedgerAdapter,GameEngineConfig.
Stats
- 104 tests passing
- 0 runtime dependencies (peer optional for node-zero / love-ledger)
- ES2022 module output
License
MIT — P31 Labs.
