Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
aghull committed Jan 9, 2024
0 parents commit a84d030
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules
/build
/.save-states
/package-lock.json
/yarn.lock
28 changes: 28 additions & 0 deletions esbuild.game.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as esbuild from 'esbuild'
import { sassPlugin } from 'esbuild-sass-plugin'

const env = process.env.NODE_ENV || "development"
const minify = env === "production"
const sourcemap = env === "production" ? false : "inline"

await esbuild.build({
format: 'iife',
globalName: 'game',
loader: {
'.jpg': 'file',
'.png': 'file',
'.svg': 'file',
'.webp': 'file',
'.scss': 'css',
'.ogg': 'dataurl',
},
sourcemap,
sourceRoot: "src/game",
keepNames: true,
sourcemap: 'inline',
outdir: 'build/game',
entryPoints: ['src/game/game-interface.ts'],
bundle: true,
minify,
plugins: [sassPlugin()]
})
28 changes: 28 additions & 0 deletions esbuild.ui.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as esbuild from 'esbuild'
import { sassPlugin } from 'esbuild-sass-plugin'

const env = process.env.NODE_ENV || "development"
const minify = env === "production"
const sourcemap = env === "production" ? false : "inline"

await esbuild.build({
format: 'iife',
assetNames: 'assets/[name]-[hash]',
loader: {
'.jpg': 'file',
'.png': 'file',
'.svg': 'file',
'.webp': 'file',
'.scss': 'css',
'.ogg': 'dataurl',
},
sourcemap,
sourceRoot: "src/ui",
keepNames: true,
sourcemap: 'inline',
outfile: 'build/ui/index.js',
entryPoints: ['./src/ui/'],
bundle: true,
minify,
plugins: [sassPlugin()]
})
27 changes: 27 additions & 0 deletions game.v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"minPlayers": 1,
"maxPlayers": 4,
"ui": {
"root": ".",
"build": {
"dev": "npm run build:ui",
"prod": "npm run build:ui:prod"
},
"watchPaths": [
"src/ui",
"src/game"
],
"outDir": "build/ui"
},
"game": {
"root": ".",
"build": {
"dev": "npm run build:game",
"prod": "npm run build:game:prod"
},
"watchPaths": [
"src/game"
],
"out": "build/game/game-interface.js"
}
}
3 changes: 3 additions & 0 deletions gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules
/.save-states
/build
Binary file added image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module "*.png";
declare module "*.ogg";
declare module "*.svg";
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "boardzilla-starter-game",
"version": "1.0.5",
"license": "MIT",
"type": "module",
"dependencies": {
"@boardzilla/core": "^0.0.59",
"@boardzilla/devtools": "^0.0.50",
"react": "^18.2",
"react-dom": "^18.2"
},
"devDependencies": {
"@types/node": "^20.8.7",
"@types/react": "^18.2.25",
"@types/react-dom": "^18.2.14",
"esbuild": "^0.19.2",
"esbuild-sass-plugin": "^2.15.0",
"typescript": "^5.2.2"
},
"scripts": {
"dev": "bz run -root .",
"info": "bz info -root .",
"submit": "bz submit -root .",
"build:ui": "npx node esbuild.ui.mjs",
"build:ui:prod": "NODE_ENV=production npx node esbuild.ui.mjs",
"build:game": "npx node esbuild.game.mjs",
"build:game:prod": "NODE_ENV=production npx node esbuild.game.mjs"
},
"private": true
}
5 changes: 5 additions & 0 deletions src/game/game-interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import setup from './index.js';
import { createInteface } from '@boardzilla/core';

const { initialState, processMove, getPlayerState } = createInteface(setup)
export { initialState, processMove, getPlayerState };
28 changes: 28 additions & 0 deletions src/game/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {
createGame,
createBoardClasses,
Player,
Board,
} from '@boardzilla/core';

export class MyGamePlayer extends Player<MyGamePlayer, MyGameBoard> {
};

class MyGameBoard extends Board<MyGamePlayer, MyGameBoard> {
}

const { Space, Piece } = createBoardClasses<MyGamePlayer, MyGameBoard>();

export default createGame(MyGamePlayer, MyGameBoard, game => {

const { board, action } = game;
const { playerActions, loop, eachPlayer } = game.flowCommands;

board.registerClasses();

game.defineActions({
});

game.defineFlow(
);
});
13 changes: 13 additions & 0 deletions src/ui/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { render } from '@boardzilla/core';
import { default as setup } from '../game/index.js';

import './style.scss';
import '@boardzilla/core/index.css';

render(setup, {
settings: {
},
layout: board => {
}
});
2 changes: 2 additions & 0 deletions src/ui/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#play-area {
}
14 changes: 14 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "es2020",
"module": "nodenext",
"esModuleInterop": true,
"sourceMap": true,
"noImplicitAny": true,
"strictNullChecks": true,
"jsx": "react",
"resolveJsonModule": true
},
"include": ["src", "./index.d.ts"],
"exclude": ["**/node_modules", "**/.*/"]
}

0 comments on commit a84d030

Please sign in to comment.