powergrid-viewer 1.11.4 → 1.11.6

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": "powergrid-viewer",
3
- "version": "1.11.4",
3
+ "version": "1.11.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/boardgamers/powergrid.git",
@@ -18,7 +18,7 @@
18
18
  "vue": "^2.6.11",
19
19
  "vue-class-component": "^7.2.3",
20
20
  "vue-property-decorator": "^8.4.2",
21
- "powergrid-engine": "1.15.4"
21
+ "powergrid-engine": "1.15.6"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/assert": "^1.4.7",
@@ -55,9 +55,11 @@
55
55
  :connections="G.map.connections"
56
56
  :polygons="G.map.polygons"
57
57
  :buildableCities="getBuildableCities()"
58
+ :pickableRegions="getPickableRegions()"
58
59
  :devBackdrop="G.map.devBackdrop"
59
60
  :mapRotation="G.map.mapRotation || 0"
60
61
  @build="build($event)"
62
+ @pickRegion="pickRegion($event)"
61
63
  />
62
64
 
63
65
  <!-- Japan: Free Jump indicator -->
@@ -1114,6 +1116,19 @@ export default class Game extends Vue {
1114
1116
  return availableMoves[MoveName.Build] && availableMoves[MoveName.Build]!.map((c) => c.name) || [];
1115
1117
  }
1116
1118
 
1119
+ getPickableRegions(): string[] {
1120
+ if (!this.canMove()) return [];
1121
+
1122
+ const currentPlayer = this.G!.players[this.player!];
1123
+ const availableMoves = currentPlayer.availableMoves!;
1124
+
1125
+ return availableMoves[MoveName.ChooseRegion] || [];
1126
+ }
1127
+
1128
+ pickRegion(region: string) {
1129
+ this.sendMove({ name: MoveName.ChooseRegion, data: region });
1130
+ }
1131
+
1117
1132
  playerHasUsedFreeJump(playerIndex: number): boolean {
1118
1133
  const player = this.G?.players[playerIndex];
1119
1134
  if (!player) return false;
@@ -1222,6 +1237,20 @@ export default class Game extends Vue {
1222
1237
  }
1223
1238
 
1224
1239
  getStatusMessage() {
1240
+ // Region draft (chooseRegions): show the pick prompt to the current picker
1241
+ // even on the very first turn, before any moves are in the log.
1242
+ if (
1243
+ this.G &&
1244
+ this.G.phase == Phase.RegionSelection &&
1245
+ this.player !== undefined &&
1246
+ this.G.currentPlayers.includes(this.player)
1247
+ ) {
1248
+ const draft = this.G.regionDraft;
1249
+ return draft
1250
+ ? `Choose a region to play in (${draft.picked.length + 1} of ${draft.regionsNeeded}).`
1251
+ : 'Choose a region to play in.';
1252
+ }
1253
+
1225
1254
  if (!this.G || this.G.log.length == 1) {
1226
1255
  return 'Game Start!';
1227
1256
  } else if (this.G.currentPlayers == []) {
@@ -94,7 +94,7 @@
94
94
  <template v-for="city in cities">
95
95
  <g v-if="city.connectionCost != null" :key="city.name + '_tile'">
96
96
  <rect
97
- :class="[{ canClick: canBuild(city) }]"
97
+ :class="[{ canClick: canBuild(city) || canPickRegion(city) }]"
98
98
  :x="city.x - 23"
99
99
  :y="city.y - 23"
100
100
  width="46"
@@ -104,7 +104,7 @@
104
104
  :stroke="city.region"
105
105
  stroke-width="4"
106
106
  :transform="`rotate(45, ${city.x}, ${city.y})`"
107
- @click="canBuild(city) && build(city)"
107
+ @click="onCityClick(city)"
108
108
  >
109
109
  <title>{{ city.name }} — connect for {{ city.connectionCost }} (entry) + house</title>
110
110
  </rect>
@@ -148,12 +148,12 @@
148
148
  <circle
149
149
  v-if="city.connectionCost == null"
150
150
  :key="city.name + '_circle2'"
151
- :class="[{ canClick: canBuild(city) }]"
151
+ :class="[{ canClick: canBuild(city) || canPickRegion(city) }]"
152
152
  r="20"
153
153
  :cx="city.x"
154
154
  :cy="city.y"
155
155
  fill="gray"
156
- @click="canBuild(city) && build(city)"
156
+ @click="onCityClick(city)"
157
157
  >
158
158
  <title>{{ city.name }}</title>
159
159
  </circle>
@@ -317,6 +317,25 @@
317
317
  />
318
318
  </template>
319
319
  </template>
320
+
321
+ <!-- chooseRegions draft: outline every city in a pickable region so the
322
+ current player can see and click the regions they may draft. Shown
323
+ regardless of the help preference since the draft can't proceed
324
+ without it. -->
325
+ <template v-for="city in cities">
326
+ <circle
327
+ v-if="canPickRegion(city)"
328
+ :key="city.name + '_pickRegion'"
329
+ class="canClick"
330
+ r="18"
331
+ :cx="city.x"
332
+ :cy="city.y"
333
+ fill="none"
334
+ stroke="gold"
335
+ stroke-width="5px"
336
+ @click="onCityClick(city)"
337
+ />
338
+ </template>
320
339
  </g>
321
340
  </template>
322
341
 
@@ -338,6 +357,8 @@ export default class Map extends Vue {
338
357
  @Prop() connections?: Connection[];
339
358
  @Prop() playerColors?: string[];
340
359
  @Prop() buildableCities?: string[];
360
+ // chooseRegions draft: region names the current player may pick this turn.
361
+ @Prop() pickableRegions?: string[];
341
362
  @Prop() devBackdrop?: { src: string; width: number; height: number; opacity?: number };
342
363
  @Prop({ default: 0 }) mapRotation!: number;
343
364
 
@@ -426,6 +447,23 @@ export default class Map extends Vue {
426
447
  this.$emit('build', city);
427
448
  }
428
449
 
450
+ canPickRegion(city: City) {
451
+ return !!this.pickableRegions && this.pickableRegions.includes(city.region);
452
+ }
453
+
454
+ pickRegion(city: City) {
455
+ this.$emit('pickRegion', city.region);
456
+ }
457
+
458
+ // During the region draft a city click picks its region; otherwise it builds.
459
+ onCityClick(city: City) {
460
+ if (this.canBuild(city)) {
461
+ this.build(city);
462
+ } else if (this.canPickRegion(city)) {
463
+ this.pickRegion(city);
464
+ }
465
+ }
466
+
429
467
  onPickCoord(e: MouseEvent) {
430
468
  if (!this.devBackdrop) return;
431
469
  const g = e.currentTarget as SVGGElement;