Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
move model to engine folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr authored May 7, 2024
1 parent 5322b77 commit 921c434
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ This is Jacob's list of cool tech tools that were shown off at some point in tea

- Classes get named in PascalCase like Java.
- Methods get named in camelCase also like Java.
- Single-export files _usually_ are named after said export exactly.
- Multi-export files are named in kebab-case after a generic group name that is inclusive of all the symbols.
- Single-export files _usually_ are named after said export exactly. `export default function App() { ... }` usually is called `App.tsx`
- Multi-export files are named in kebab-case after a generic group name that is inclusive of all the symbols. Like `game.ts`.
- In general, string literals are used for enums instead of number maps. For example it's `doThing("enum-value")` not `doThing(MyEnum.EnumValue)`.
- Use [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript) to find reference docs on JavaScript or Web API builtins.
- Don't try to put too much in a single file; break things up logically.
Expand All @@ -64,3 +64,4 @@ This is Jacob's list of cool tech tools that were shown off at some point in tea
- Avoid JSX UI logic in statements. Try to keep JSX focused on the big `return <>...</>` block. Prefer multiple micro-components.
- Avoid redundant JavaDoc-style comments. TypeScript does a lot of the work for you in documenting the important "this is a number" bits.
- When it makes sense it's OK to use a library. It's very easy to do: just `npm install <library>` and `import { ... } from "<library>"`.
- JavaScript does have getters and setters for properties. That means you can intercept `object.property` with a `get property() { return 42 }` function that will be called whenever the `property` field is accessed. [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get)
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Targeter,
LandscapeType,
BoardPos,
} from "./model";
} from "./engine/game";
//import { Creature, Building, Card } from "./engine/card";
import { Creature, Card, Landscape } from "./engine/card";
import { get, exportDecks } from "./engine/CardMap";
Expand Down
2 changes: 1 addition & 1 deletion src/decks/deck1.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card } from "../model";
import { Card } from "../engine/game";
import darkAngelPngUrl from "../assets/dark-angel.png";
// make sure you do this ^
export default [
Expand Down
2 changes: 1 addition & 1 deletion src/engine/CardMap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createVerify } from "crypto";
import { LandscapeType } from "../model.ts";
import { LandscapeType } from "./game.ts";
import { Card, Creature, Landscape } from "./card.ts";

var cardMap: Map<string, Card> = new Map<string, Card>();
Expand Down
2 changes: 1 addition & 1 deletion src/engine/card.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Game, BoardPos, CardType, Player, LandscapeType } from "../model.ts";
import { Game, BoardPos, CardType, Player, LandscapeType } from "./game.ts";
import { DisplayCardEvent } from "./event.ts";

export const GetCardTargetEvent: string = "getCardTarget";
Expand Down
2 changes: 1 addition & 1 deletion src/engine/event.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Card } from "./card.ts";
import { Targeter, BoardPos, Player } from "../model.ts";
import { Targeter, BoardPos, Player } from "./game.ts";

//Event name constants
export const PlayCardEventName: string = "playCard";
Expand Down
8 changes: 4 additions & 4 deletions src/model.test.ts → src/engine/game.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import {
BoardPos,
CardType,
Player,
} from "./model.ts";
} from "./game.ts";
import {
Card,
Creature,
Landscape,
GetCardTargetEvent,
} from "./engine/card.ts";
} from "./card.ts";
import {
get as getCardFromCardMap,
seeNonNullDecks,
} from "./engine/CardMap.ts";
import { GetBoardPosTargetEvent, PlayCardEventName } from "./engine/event.ts";
} from "./CardMap.ts";
import { GetBoardPosTargetEvent, PlayCardEventName } from "./event.ts";

test("new game works", () => {
assert(Game.getInstance() instanceof AbstractGame);
Expand Down
4 changes: 2 additions & 2 deletions src/model.ts → src/engine/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {
Creature,
Landscape,
GetCardTargetEvent,
} from "./engine/card.ts";
} from "./card.ts";
import {
GetBoardPosTargetEvent,
PlayCardEvent,
SwitchTurnsEvent,
SwitchTurnPhaseEvent,
DrawCardEvent,
DiscardCardEvent,
} from "./engine/event.ts";
} from "./event.ts";

//============================================================== Enums ==============================================================
export const TurnPhases = {
Expand Down
2 changes: 1 addition & 1 deletion src/examples.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import { Game } from "./model";
import { Game } from "./engine/game";

0 comments on commit 921c434

Please sign in to comment.