@dreamboard-games/workspace-codegen 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +89 -0
- package/NOTICE +1 -0
- package/dist/hex-geometry.d.ts +2 -0
- package/dist/hex-geometry.js +49 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +22 -0
- package/dist/manifest-contract.d.ts +14 -0
- package/dist/manifest-contract.js +4897 -0
- package/dist/manifest-validation.d.ts +6 -0
- package/dist/manifest-validation.js +506 -0
- package/dist/ownership.d.ts +31 -0
- package/dist/ownership.js +86 -0
- package/dist/preset-card-sets.d.ts +5 -0
- package/dist/preset-card-sets.js +135 -0
- package/dist/seeds.d.ts +6 -0
- package/dist/seeds.js +766 -0
- package/ownership.json +51 -0
- package/package.json +46 -0
- package/src/__fixtures__/sdk-types/invalid-card-properties-extra-key.ts +62 -0
- package/src/__fixtures__/sdk-types/invalid-card-properties-missing-required.ts +60 -0
- package/src/__fixtures__/sdk-types/invalid-card-properties-wrong-enum.ts +61 -0
- package/src/__fixtures__/sdk-types/invalid-card-properties-wrong-nested.ts +61 -0
- package/src/__fixtures__/sdk-types/invalid-card-properties-wrong-scalar.ts +61 -0
- package/src/__fixtures__/sdk-types/invalid-card-visibility.ts +40 -0
- package/src/__fixtures__/sdk-types/invalid-container-card-set-manifest.ts +62 -0
- package/src/__fixtures__/sdk-types/invalid-die-fields-wrong-array-item.ts +43 -0
- package/src/__fixtures__/sdk-types/invalid-die-fields-wrong-player-id.ts +43 -0
- package/src/__fixtures__/sdk-types/invalid-die-fields-wrong-resource-id.ts +43 -0
- package/src/__fixtures__/sdk-types/invalid-die-home-per-player-zone-no-owner.ts +35 -0
- package/src/__fixtures__/sdk-types/invalid-die-seed-type-id.ts +31 -0
- package/src/__fixtures__/sdk-types/invalid-die-visibility.ts +28 -0
- package/src/__fixtures__/sdk-types/invalid-generic-board-edge-id.ts +38 -0
- package/src/__fixtures__/sdk-types/invalid-generic-board-nested-field.ts +45 -0
- package/src/__fixtures__/sdk-types/invalid-hex-edge-field-edge-id.ts +47 -0
- package/src/__fixtures__/sdk-types/invalid-hex-vertex-field-vertex-id.ts +47 -0
- package/src/__fixtures__/sdk-types/invalid-manifest.ts +143 -0
- package/src/__fixtures__/sdk-types/invalid-piece-fields-extra-key.ts +62 -0
- package/src/__fixtures__/sdk-types/invalid-piece-fields-wrong-card-id.ts +61 -0
- package/src/__fixtures__/sdk-types/invalid-piece-fields-wrong-enum.ts +61 -0
- package/src/__fixtures__/sdk-types/invalid-piece-fields-wrong-scalar.ts +61 -0
- package/src/__fixtures__/sdk-types/invalid-piece-fields-wrong-zone-id.ts +61 -0
- package/src/__fixtures__/sdk-types/invalid-piece-home-per-player-container-no-owner.ts +48 -0
- package/src/__fixtures__/sdk-types/invalid-piece-home-per-player-edge-no-owner.ts +47 -0
- package/src/__fixtures__/sdk-types/invalid-piece-home-per-player-space-no-owner.ts +42 -0
- package/src/__fixtures__/sdk-types/invalid-piece-home-per-player-vertex-no-owner.ts +49 -0
- package/src/__fixtures__/sdk-types/invalid-piece-seed-type-id.ts +30 -0
- package/src/__fixtures__/sdk-types/invalid-piece-visibility.ts +28 -0
- package/src/__fixtures__/sdk-types/invalid-slot-host-manifest.ts +47 -0
- package/src/__fixtures__/sdk-types/invalid-slot-id-manifest.ts +49 -0
- package/src/__fixtures__/sdk-types/invalid-square-board-edge-id.ts +47 -0
- package/src/__fixtures__/sdk-types/invalid-square-board-space-id.ts +47 -0
- package/src/__fixtures__/sdk-types/invalid-square-board-vertex-id.ts +49 -0
- package/src/__fixtures__/sdk-types/invalid-square-container-field-space-id.ts +59 -0
- package/src/__fixtures__/sdk-types/invalid-square-container-host-space-id.ts +49 -0
- package/src/__fixtures__/sdk-types/invalid-square-relation-field-scalar.ts +48 -0
- package/src/__fixtures__/sdk-types/invalid-square-relation-space-id.ts +48 -0
- package/src/__fixtures__/sdk-types/invalid-square-space-fields-enum.ts +44 -0
- package/src/__fixtures__/sdk-types/invalid-square-space-fields-extra-key.ts +45 -0
- package/src/__fixtures__/sdk-types/valid-die-type-omits-sides.ts +29 -0
- package/src/__fixtures__/sdk-types/valid-manifest-omits-board-templates.ts +19 -0
- package/src/__fixtures__/sdk-types/valid-manifest.ts +612 -0
- package/src/__fixtures__/sdk-types/valid-player-scoped-seed-homes.ts +59 -0
- package/src/authoring-benchmark.test.ts +362 -0
- package/src/hex-geometry.ts +69 -0
- package/src/index.ts +64 -0
- package/src/manifest-contract.test.ts +1764 -0
- package/src/manifest-contract.ts +6581 -0
- package/src/manifest-validation.test.ts +393 -0
- package/src/manifest-validation.ts +795 -0
- package/src/ownership.ts +127 -0
- package/src/preset-card-sets.ts +169 -0
- package/src/sdk-types-authoring.test.ts +361 -0
- package/src/seeds.ts +800 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const STANDARD_DECK_ID = "standard_52_deck";
|
|
2
|
+
function createEnumPropertySchema(enums, description) {
|
|
3
|
+
return {
|
|
4
|
+
type: "enum",
|
|
5
|
+
description,
|
|
6
|
+
enums,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function createStringPropertySchema(description) {
|
|
10
|
+
return {
|
|
11
|
+
type: "string",
|
|
12
|
+
description,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function createStandard52CardDeck() {
|
|
16
|
+
const suits = ["SPADES", "HEARTS", "CLUBS", "DIAMONDS"];
|
|
17
|
+
const ranks = [
|
|
18
|
+
"3",
|
|
19
|
+
"4",
|
|
20
|
+
"5",
|
|
21
|
+
"6",
|
|
22
|
+
"7",
|
|
23
|
+
"8",
|
|
24
|
+
"9",
|
|
25
|
+
"10",
|
|
26
|
+
"J",
|
|
27
|
+
"Q",
|
|
28
|
+
"K",
|
|
29
|
+
"A",
|
|
30
|
+
"2",
|
|
31
|
+
];
|
|
32
|
+
const cards = [];
|
|
33
|
+
for (const suit of suits) {
|
|
34
|
+
for (const rank of ranks) {
|
|
35
|
+
cards.push({
|
|
36
|
+
type: `${suit}_${rank}`,
|
|
37
|
+
name: `${rank} of ${suit}`,
|
|
38
|
+
imageUrl: `/cards/${suit.toLowerCase()}_${rank.toLowerCase()}.png`,
|
|
39
|
+
text: `A playing card: ${rank} of ${suit}. Value: ${getBigTwoCardValue(rank)}, Suit value: ${getSuitValue(suit)}`,
|
|
40
|
+
count: 1,
|
|
41
|
+
cardType: `${suit}_${rank}`,
|
|
42
|
+
properties: {
|
|
43
|
+
suit,
|
|
44
|
+
rank,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
id: STANDARD_DECK_ID,
|
|
51
|
+
name: "Standard 52-Card Deck",
|
|
52
|
+
type: "manual",
|
|
53
|
+
cards,
|
|
54
|
+
cardSchema: {
|
|
55
|
+
properties: {
|
|
56
|
+
suit: createEnumPropertySchema(["SPADES", "HEARTS", "CLUBS", "DIAMONDS"], "The suit of the card"),
|
|
57
|
+
rank: createStringPropertySchema("The rank of the card"),
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function addStandardDecksIfNeeded(manifest) {
|
|
63
|
+
return {
|
|
64
|
+
...manifest,
|
|
65
|
+
cardSets: manifest.cardSets.map((cardSet) => cardSet.type === "preset" && cardSet.presetId === STANDARD_DECK_ID
|
|
66
|
+
? {
|
|
67
|
+
...createStandard52CardDeck(),
|
|
68
|
+
id: cardSet.id,
|
|
69
|
+
name: cardSet.name,
|
|
70
|
+
}
|
|
71
|
+
: cardSet),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function materializePresetCardSet(presetCardSet) {
|
|
75
|
+
if (presetCardSet.presetId !== STANDARD_DECK_ID) {
|
|
76
|
+
throw new Error(`Unsupported preset deck: ${presetCardSet.presetId}`);
|
|
77
|
+
}
|
|
78
|
+
const standardDeck = createStandard52CardDeck();
|
|
79
|
+
return {
|
|
80
|
+
...standardDeck,
|
|
81
|
+
id: presetCardSet.id,
|
|
82
|
+
name: presetCardSet.name,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export function materializeCardSet(cardSet) {
|
|
86
|
+
return cardSet.type === "manual"
|
|
87
|
+
? cardSet
|
|
88
|
+
: materializePresetCardSet(cardSet);
|
|
89
|
+
}
|
|
90
|
+
function getBigTwoCardValue(rank) {
|
|
91
|
+
switch (rank) {
|
|
92
|
+
case "3":
|
|
93
|
+
return 3;
|
|
94
|
+
case "4":
|
|
95
|
+
return 4;
|
|
96
|
+
case "5":
|
|
97
|
+
return 5;
|
|
98
|
+
case "6":
|
|
99
|
+
return 6;
|
|
100
|
+
case "7":
|
|
101
|
+
return 7;
|
|
102
|
+
case "8":
|
|
103
|
+
return 8;
|
|
104
|
+
case "9":
|
|
105
|
+
return 9;
|
|
106
|
+
case "10":
|
|
107
|
+
return 10;
|
|
108
|
+
case "J":
|
|
109
|
+
return 11;
|
|
110
|
+
case "Q":
|
|
111
|
+
return 12;
|
|
112
|
+
case "K":
|
|
113
|
+
return 13;
|
|
114
|
+
case "A":
|
|
115
|
+
return 14;
|
|
116
|
+
case "2":
|
|
117
|
+
return 15;
|
|
118
|
+
default:
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function getSuitValue(suit) {
|
|
123
|
+
switch (suit) {
|
|
124
|
+
case "DIAMONDS":
|
|
125
|
+
return 1;
|
|
126
|
+
case "CLUBS":
|
|
127
|
+
return 2;
|
|
128
|
+
case "HEARTS":
|
|
129
|
+
return 3;
|
|
130
|
+
case "SPADES":
|
|
131
|
+
return 4;
|
|
132
|
+
default:
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
}
|
package/dist/seeds.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GameTopologyManifest } from "@dreamboard/sdk-types";
|
|
2
|
+
export declare const SETUP_PROFILES_SEED_MARKER = "Generated by dreamboard setup-profiles scaffold.";
|
|
3
|
+
export declare function isFrameworkOwnedSetupProfilesSeed(content: string | null | undefined): boolean;
|
|
4
|
+
export declare function generateSeedFiles(manifest: GameTopologyManifest): Record<string, string>;
|
|
5
|
+
export declare function generateAuthoritativeIndexFile(_manifest: GameTopologyManifest): string;
|
|
6
|
+
export declare function generateFrameworkFiles(manifest: GameTopologyManifest): Record<string, string>;
|