create-vimp-game 0.1.13 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-vimp-game",
3
- "version": "0.1.13",
3
+ "version": "0.2.0",
4
4
  "description": "Scaffolder for VIMP game plugins",
5
5
  "keywords": [
6
6
  "vimp",
@@ -1,4 +1,4 @@
1
1
  {
2
- "engine": "0.14.4",
3
- "core": "0.8.3"
2
+ "engine": "0.16.0",
3
+ "core": "0.8.4"
4
4
  }
@@ -12,6 +12,7 @@ import { rangeToPattern } from './lib/rangeToPattern.js';
12
12
  // asset steps: it hashes what they produced.
13
13
  // Run: node scripts/build-game-manifest.js (build:manifest)
14
14
 
15
+ const packageJsonPath = fileURLToPath(new URL('../package.json', import.meta.url));
15
16
  const distPath = fileURLToPath(new URL('../dist/', import.meta.url));
16
17
  const assetsPath = path.join(distPath, 'assets');
17
18
  const mapsPath = path.join(distPath, 'maps');
@@ -54,6 +55,13 @@ const version = createHash('sha256')
54
55
  .digest('hex')
55
56
  .slice(0, 16);
56
57
 
58
+ // The npm version of this package. `version` above is a bundle hash — useful
59
+ // to the engine, meaningless to a player; this is what the engine shows in
60
+ // the #auth footer.
61
+ const { version: packageVersion } = JSON.parse(
62
+ fs.readFileSync(packageJsonPath, 'utf8'),
63
+ );
64
+
57
65
  const mapNames = fs
58
66
  .readdirSync(mapsPath)
59
67
  .filter(name => name.endsWith('.json'))
@@ -106,10 +114,14 @@ const roomValues = {
106
114
  map: gameConfig.currentMap,
107
115
  };
108
116
 
109
- // bounds of the numeric fields (v3 text controls know no min/max): the same
110
- // numbers the host clamps by, not an independent copy
117
+ // bounds of the numeric fields: the same numbers the host clamps by, not an
118
+ // independent copy. regExp remains the actual (native-shaped) constraint;
119
+ // min/max additionally travel to the client for the field-label hint and
120
+ // the custom range error (formBuilder.js collectFormErrors) — v3 text
121
+ // controls have no native min/max of their own
111
122
  const { roomTimeMin, roomTimeMax } = hostDefaults.timers;
112
123
  const roomTimeRegExp = rangeToPattern(roomTimeMin / 1000, roomTimeMax / 1000);
124
+ const roomTimeBounds = { min: roomTimeMin / 1000, max: roomTimeMax / 1000 };
113
125
 
114
126
  const fieldRegExp = {
115
127
  maxPlayers: rangeToPattern(1, gameConfig.roomDefaults.maxPlayers),
@@ -117,9 +129,15 @@ const fieldRegExp = {
117
129
  mapTime: roomTimeRegExp,
118
130
  };
119
131
 
132
+ const fieldBounds = {
133
+ maxPlayers: { min: 1, max: gameConfig.roomDefaults.maxPlayers },
134
+ roundTime: roomTimeBounds,
135
+ mapTime: roomTimeBounds,
136
+ };
137
+
120
138
  const roomForm = gameConfig.roomForm.map(field =>
121
139
  field.name in fieldRegExp
122
- ? { ...field, regExp: fieldRegExp[field.name] }
140
+ ? { ...field, regExp: fieldRegExp[field.name], ...fieldBounds[field.name] }
123
141
  : field,
124
142
  );
125
143
 
@@ -145,6 +163,7 @@ const manifest = {
145
163
  id: '{{GAME_ID}}',
146
164
  engineApi: ENGINE_API_VERSION,
147
165
  version,
166
+ packageVersion,
148
167
  title: '{{GAME_TITLE}}',
149
168
  entries: {
150
169
  client: `/games/{{GAME_ID}}/${clientFile}`,