✨ (all) Add Germany map, update map structure

This commit is contained in:
Lucas Mello 2021-10-27 22:49:46 -03:00
commit 59c19cf1a7
9 changed files with 570 additions and 349 deletions

View file

@ -29,6 +29,6 @@ module.exports = {
'no-return-assign': 'off',
// 'no-fallthrough': 'off',
'no-empty': 'off',
quotes: 'off',
quotes: ['error', 'single'],
},
};

View file

@ -1,3 +1,16 @@
{
"editor.formatOnSave": true
"editor.tabSize": 4,
"editor.acceptSuggestionOnCommitCharacter": false,
"editor.formatOnSave": true,
"editor.suggestSelection": "first",
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"vetur.format.options.tabSize": 4,
"vetur.format.defaultFormatter.js": "vscode-typescript",
"prettier.tabWidth": 4,
"files.trimTrailingWhitespace": true,
"vetur.format.defaultFormatter.html": "none",
"eslint.validate": ["javascript", "typescript", "vue"]
}

View file

@ -295,13 +295,10 @@ function dijkstra(G: GameState, player: Player): { name: string; price: number }
currentNode.price = 0;
while (nodes.some((n) => !n.visited)) {
const currentConnections = G.map.connections.filter(
(c) => c.to == currentNode.name || c.from == currentNode.name
);
const currentConnections = G.map.connections.filter((c) => c.nodes.includes(currentNode.name));
currentConnections.forEach((connection) => {
const otherNode = nodes.find((n) =>
connection.to == currentNode.name ? n.name == connection.from : n.name == connection.to
)!;
const otherName = connection.nodes.filter((n) => n != currentNode.name)[0];
const otherNode = nodes.find((n) => n.name == otherName)!;
const price = player.cities.find((c) => c.name == otherNode.name) ? 0 : currentNode.price + connection.cost;
if (!otherNode.visited && otherNode.price > price) {
otherNode.price = price;

View file

@ -4,7 +4,7 @@ import seedrandom from 'seedrandom';
import { availableMoves } from './available-moves';
import { GameOptions, GameState, Phase, Player, PowerPlant, PowerPlantType, ResourceType } from './gamestate';
import { LogItem } from './log';
import map from './map';
import maps from './maps';
import { Move, MoveName, Moves } from './move';
import powerPlants from './powerPlants';
import prices from './prices';
@ -45,7 +45,7 @@ const citiesToEndGame = [21, 17, 17, 15, 14];
const cityIncome = [10, 22, 33, 44, 54, 65, 73, 82, 90, 98, 105, 112, 118, 124, 129, 134, 138, 142, 145, 148, 150, 150];
const regionsInPlay = [3, 3, 4, 5, 5];
export function setup(numPlayers: number, { fastBid = false }: GameOptions, seed?: string): GameState {
export function setup(numPlayers: number, { fastBid = false, map = 'USA' }: GameOptions, seed?: string): GameState {
seed = seed ?? Math.random().toString();
const rng = seedrandom(seed);
@ -94,23 +94,20 @@ export function setup(numPlayers: number, { fastBid = false }: GameOptions, seed
const playerOrder = range(numPlayers);
const startingPlayer = playerOrder[0];
const regions = map.cities
.filter((c, i) => map.cities.findIndex((cc) => cc.region == c.region) == i)
const chosenMap = maps.find((m) => m.name == map)!;
const regions = chosenMap.cities
.filter((c, i) => chosenMap.cities.findIndex((cc) => cc.region == c.region) == i)
.map((c) => c.region);
const regionConnections = regions.map((region) =>
regions.filter(
(area2) =>
region != area2 &&
(map.connections.some(
(con) =>
map.cities.find((city) => city.name == con.from)!.region == region &&
map.cities.find((city) => city.name == con.to)!.region == area2
) ||
map.connections.some(
(con) =>
map.cities.find((city) => city.name == con.to)!.region == region &&
map.cities.find((city) => city.name == con.from)!.region == area2
))
chosenMap.connections.some((con) =>
con.nodes
.map((n) => chosenMap.cities.find((city) => city.name == n)!.region)
.every((r) => [region, area2].includes(r))
)
)
);
@ -122,12 +119,10 @@ export function setup(numPlayers: number, { fastBid = false }: GameOptions, seed
}
}
const filteredMap = cloneDeep(map);
const filteredMap = cloneDeep(chosenMap);
filteredMap.cities = filteredMap.cities.filter((city) => playRegions.has(city.region));
filteredMap.connections = filteredMap.connections.filter(
(con) =>
playRegions.has(map.cities.find((city) => city.name == con.from)!.region) &&
playRegions.has(map.cities.find((city) => city.name == con.to)!.region)
filteredMap.connections = filteredMap.connections.filter((con) =>
con.nodes.map((n) => chosenMap.cities.find((city) => city.name == n)!.region).every((r) => playRegions.has(r))
);
const p = players.length - 2;
@ -365,7 +360,7 @@ export function move(G: GameState, move: Move, playerNumber: number): GameState
if (maxCities >= G.citiesToStep2) {
G.actualMarket.shift();
addPowerPlant(G);
G.log.push({ type: 'event', event: `Starting Step 2` });
G.log.push({ type: 'event', event: 'Starting Step 2' });
G.step = 2;
}
}
@ -374,7 +369,7 @@ export function move(G: GameState, move: Move, playerNumber: number): GameState
G.phase = Phase.GameEnd;
G.currentPlayers = [];
calculateCitiesPowered(G);
G.log.push({ type: 'event', event: `Game Ended!` });
G.log.push({ type: 'event', event: 'Game Ended!' });
} else {
G.players.forEach((p) => {
p.passed = false;
@ -911,7 +906,7 @@ function addPowerPlant(G: GameState) {
G.powerPlantsDeck = shuffle(G.powerPlantsDeck, G.seed);
if (G.phase != Phase.Auction) {
G.log.push({ type: 'event', event: `Starting Step 3` });
G.log.push({ type: 'event', event: 'Starting Step 3' });
G.step = 3;
G.actualMarket.shift();
}
@ -1053,7 +1048,7 @@ function toResourcesPhase(G: GameState) {
G.currentPlayers = [G.playerOrder[G.players.length - 1]];
if (G.futureMarket.find((pp) => pp.number == 99)) {
G.log.push({ type: 'event', event: `Starting Step 3` });
G.log.push({ type: 'event', event: 'Starting Step 3' });
G.step = 3;
G.actualMarket.shift();
G.futureMarket.pop();

View file

@ -1,21 +1,22 @@
import { AvailableMoves } from './available-moves';
import { LogItem } from './log';
import { Cities, Regions } from './maps';
import { Move } from './move';
export interface GameOptions {
fastBid?: boolean;
map?: 'USA' | 'Germany';
}
export interface City {
name: string;
region: string;
name: Cities;
region: Regions;
x: number;
y: number;
}
export interface Connection {
from: string;
to: string;
nodes: Cities[];
cost: number;
}

View file

@ -1,140 +0,0 @@
import { Map } from './gamestate';
const map: Map = {
name: 'USA',
cities: [
{ name: 'Seattle', region: 'purple', x: 74, y: 129 },
{ name: 'Portland', region: 'purple', x: 45, y: 197 },
{ name: 'Boise', region: 'purple', x: 180, y: 250 },
{ name: 'Billings', region: 'purple', x: 345, y: 210 },
{ name: 'Cheyenne', region: 'purple', x: 410, y: 310 },
{ name: 'Denver', region: 'purple', x: 400, y: 363 },
{ name: 'Omaha', region: 'purple', x: 566, y: 323 },
{ name: 'San Francisco', region: 'cyan', x: 48, y: 401 },
{ name: 'Los Angeles', region: 'cyan', x: 116, y: 490 },
{ name: 'San Diego', region: 'cyan', x: 157, y: 537 },
{ name: 'Las Vegas', region: 'cyan', x: 200, y: 440 },
{ name: 'Saltlake City', region: 'cyan', x: 266, y: 341 },
{ name: 'Phoenix', region: 'cyan', x: 260, y: 516 },
{ name: 'Santa Fe', region: 'cyan', x: 371, y: 465 },
{ name: 'Kansas City', region: 'red', x: 587, y: 386 },
{ name: 'Oklahoma City', region: 'red', x: 550, y: 467 },
{ name: 'Dallas', region: 'red', x: 560, y: 534 },
{ name: 'Houston', region: 'red', x: 569, y: 601 },
{ name: 'Menphis', region: 'red', x: 678, y: 479 },
{ name: 'Birmingham', region: 'red', x: 739, y: 516 },
{ name: 'New Orleans', region: 'red', x: 674, y: 600 },
{ name: 'Fargo', region: 'yellow', x: 551, y: 182 },
{ name: 'Duluth', region: 'yellow', x: 637, y: 163 },
{ name: 'Minneapolis', region: 'yellow', x: 621, y: 220 },
{ name: 'Chicago', region: 'yellow', x: 716, y: 311 },
{ name: 'St. Louis', region: 'yellow', x: 678, y: 392 },
{ name: 'Cincinnati', region: 'yellow', x: 795, y: 378 },
{ name: 'Knoxvile', region: 'yellow', x: 796, y: 452 },
{ name: 'Detroit', region: 'brown', x: 803, y: 292 },
{ name: 'Buffalo', region: 'brown', x: 913, y: 281 },
{ name: 'Pittsburgh', region: 'brown', x: 884, y: 346 },
{ name: 'Boston', region: 'brown', x: 1052, y: 282 },
{ name: 'New York', region: 'brown', x: 1010, y: 320 },
{ name: 'Philadelphia', region: 'brown', x: 985, y: 360 },
{ name: 'Washington', region: 'brown', x: 934, y: 387 },
{ name: 'Horecin', region: 'green', x: 969, y: 435 },
{ name: 'Raleigh', region: 'green', x: 915, y: 467 },
{ name: 'Atlanta', region: 'green', x: 801, y: 517 },
{ name: 'Savannah', region: 'green', x: 867, y: 537 },
{ name: 'Jacksonvile', region: 'green', x: 861, y: 589 },
{ name: 'Tampa', region: 'green', x: 819, y: 651 },
{ name: 'Miami', region: 'green', x: 883, y: 700 },
],
connections: [
{ from: 'Seattle', to: 'Portland', cost: 3 },
{ from: 'Seattle', to: 'Boise', cost: 12 },
{ from: 'Seattle', to: 'Billings', cost: 9 },
{ from: 'Portland', to: 'Boise', cost: 13 },
{ from: 'Portland', to: 'San Francisco', cost: 24 },
{ from: 'Boise', to: 'Billings', cost: 12 },
{ from: 'Boise', to: 'Cheyenne', cost: 24 },
{ from: 'Boise', to: 'San Francisco', cost: 23 },
{ from: 'Boise', to: 'Saltlake City', cost: 8 },
{ from: 'Billings', to: 'Cheyenne', cost: 9 },
{ from: 'Billings', to: 'Fargo', cost: 17 },
{ from: 'Billings', to: 'Minneapolis', cost: 18 },
{ from: 'Cheyenne', to: 'Denver', cost: 0 },
{ from: 'Cheyenne', to: 'Omaha', cost: 14 },
{ from: 'Cheyenne', to: 'Minneapolis', cost: 18 },
{ from: 'Denver', to: 'Saltlake City', cost: 21 },
{ from: 'Denver', to: 'Santa Fe', cost: 13 },
{ from: 'Denver', to: 'Kansas City', cost: 16 },
{ from: 'Omaha', to: 'Kansas City', cost: 5 },
{ from: 'Omaha', to: 'Minneapolis', cost: 8 },
{ from: 'Omaha', to: 'Chicago', cost: 13 },
{ from: 'San Francisco', to: 'Los Angeles', cost: 9 },
{ from: 'San Francisco', to: 'Las Vegas', cost: 14 },
{ from: 'San Francisco', to: 'Saltlake City', cost: 27 },
{ from: 'Los Angeles', to: 'San Diego', cost: 3 },
{ from: 'Los Angeles', to: 'Las Vegas', cost: 9 },
{ from: 'San Diego', to: 'Las Vegas', cost: 9 },
{ from: 'San Diego', to: 'Phoenix', cost: 14 },
{ from: 'Las Vegas', to: 'Saltlake City', cost: 18 },
{ from: 'Las Vegas', to: 'Phoenix', cost: 15 },
{ from: 'Las Vegas', to: 'Santa Fe', cost: 27 },
{ from: 'Saltlake City', to: 'Santa Fe', cost: 28 },
{ from: 'Phoenix', to: 'Santa Fe', cost: 18 },
{ from: 'Santa Fe', to: 'Kansas City', cost: 16 },
{ from: 'Santa Fe', to: 'Oklahoma City', cost: 15 },
{ from: 'Santa Fe', to: 'Dallas', cost: 16 },
{ from: 'Santa Fe', to: 'Houston', cost: 21 },
{ from: 'Kansas City', to: 'Oklahoma City', cost: 8 },
{ from: 'Kansas City', to: 'Menphis', cost: 12 },
{ from: 'Kansas City', to: 'Chicago', cost: 8 },
{ from: 'Kansas City', to: 'St. Louis', cost: 6 },
{ from: 'Oklahoma City', to: 'Dallas', cost: 3 },
{ from: 'Oklahoma City', to: 'Menphis', cost: 14 },
{ from: 'Dallas', to: 'Houston', cost: 5 },
{ from: 'Dallas', to: 'Menphis', cost: 12 },
{ from: 'Dallas', to: 'New Orleans', cost: 12 },
{ from: 'Houston', to: 'New Orleans', cost: 8 },
{ from: 'Menphis', to: 'Birmingham', cost: 6 },
{ from: 'Menphis', to: 'New Orleans', cost: 7 },
{ from: 'Menphis', to: 'St. Louis', cost: 7 },
{ from: 'Birmingham', to: 'New Orleans', cost: 11 },
{ from: 'Birmingham', to: 'Atlanta', cost: 3 },
{ from: 'Birmingham', to: 'Jacksonvile', cost: 9 },
{ from: 'New Orleans', to: 'Jacksonvile', cost: 16 },
{ from: 'Fargo', to: 'Duluth', cost: 6 },
{ from: 'Fargo', to: 'Minneapolis', cost: 6 },
{ from: 'Duluth', to: 'Minneapolis', cost: 5 },
{ from: 'Duluth', to: 'Chicago', cost: 12 },
{ from: 'Duluth', to: 'Detroit', cost: 15 },
{ from: 'Minneapolis', to: 'Chicago', cost: 8 },
{ from: 'Chicago', to: 'St. Louis', cost: 10 },
{ from: 'Chicago', to: 'Cincinnati', cost: 7 },
{ from: 'Chicago', to: 'Detroit', cost: 7 },
{ from: 'St. Louis', to: 'Cincinnati', cost: 12 },
{ from: 'St. Louis', to: 'Atlanta', cost: 12 },
{ from: 'Cincinnati', to: 'Knoxvile', cost: 6 },
{ from: 'Cincinnati', to: 'Detroit', cost: 4 },
{ from: 'Cincinnati', to: 'Pittsburgh', cost: 7 },
{ from: 'Cincinnati', to: 'Raleigh', cost: 15 },
{ from: 'Knoxvile', to: 'Atlanta', cost: 5 },
{ from: 'Detroit', to: 'Buffalo', cost: 7 },
{ from: 'Detroit', to: 'Pittsburgh', cost: 6 },
{ from: 'Buffalo', to: 'Pittsburgh', cost: 7 },
{ from: 'Buffalo', to: 'New York', cost: 8 },
{ from: 'Pittsburgh', to: 'Washington', cost: 6 },
{ from: 'Pittsburgh', to: 'Raleigh', cost: 7 },
{ from: 'Boston', to: 'New York', cost: 3 },
{ from: 'New York', to: 'Philadelphia', cost: 0 },
{ from: 'Philadelphia', to: 'Washington', cost: 3 },
{ from: 'Washington', to: 'Horecin', cost: 5 },
{ from: 'Horecin', to: 'Raleigh', cost: 3 },
{ from: 'Raleigh', to: 'Atlanta', cost: 7 },
{ from: 'Raleigh', to: 'Savannah', cost: 7 },
{ from: 'Atlanta', to: 'Savannah', cost: 7 },
{ from: 'Savannah', to: 'Jacksonvile', cost: 0 },
{ from: 'Jacksonvile', to: 'Tampa', cost: 4 },
{ from: 'Tampa', to: 'Miami', cost: 4 },
],
};
export default map;

370
engine/src/maps.ts Normal file
View file

@ -0,0 +1,370 @@
import { Map } from './gamestate';
export enum Regions {
Purple = 'purple',
Green = 'green',
Red = 'red',
Yellow = 'yellow',
Cyan = 'cyan',
Brown = 'brown',
}
export enum Cities {
Seattle = 'Seattle',
Portland = 'Portland',
Boise = 'Boise',
Billings = 'Billings',
Cheyenne = 'Cheyenne',
Denver = 'Denver',
Omaha = 'Omaha',
SanFrancisco = 'San Francisco',
LosAngeles = 'Los Angeles',
SanDiego = 'San Diego',
LasVegas = 'Las Vegas',
SaltlakeCity = 'Saltlake City',
Phoenix = 'Phoenix',
SantaFe = 'Santa Fe',
KansasCity = 'Kansas City',
OklahomaCity = 'Oklahoma City',
Dallas = 'Dallas',
Houston = 'Houston',
Menphis = 'Menphis',
Birmingham = 'Birmingham',
NewOrleans = 'New Orleans',
Fargo = 'Fargo',
Duluth = 'Duluth',
Minneapolis = 'Minneapolis',
Chicago = 'Chicago',
StLouis = 'St. Louis',
Cincinnati = 'Cincinnati',
Knoxvile = 'Knoxvile',
Detroit = 'Detroit',
Buffalo = 'Buffalo',
Pittsburgh = 'Pittsburgh',
Boston = 'Boston',
NewYork = 'New York',
Philadelphia = 'Philadelphia',
Washington = 'Washington',
Horecin = 'Horecin',
Raleigh = 'Raleigh',
Atlanta = 'Atlanta',
Savannah = 'Savannah',
Jacksonvile = 'Jacksonvile',
Tampa = 'Tampa',
Miami = 'Miami',
Flensburg = 'Flensburg',
Kiel = 'Kiel',
Hamburg = 'Hamburg',
Hannover = 'Hannover',
Bremen = 'Bremen',
Wilhelmshaven = 'Wilhelmshaven',
Cuxhaven = 'Cuxhaven',
Lubeck = 'Lubeck',
Rostock = 'Rostock',
Schwerin = 'Schwerin',
Torgelow = 'Torgelow',
Magdeburg = 'Magdeburg',
Berlin = 'Berlin',
FrankfurtO = 'Frankfurt-O',
Halle = 'Halle',
Leipzig = 'Leipzig',
Dresden = 'Dresden',
Erfurt = 'Erfurt',
Fulda = 'Fulda',
Würzburg = 'Würzburg',
Nurnberg = 'Nurnberg',
Osnabrück = 'Osnabrück',
Münster = 'Münster',
Essen = 'Essen',
Duisburg = 'Duisburg',
Dortmund = 'Dortmund',
Dusseldorf = 'Dusseldorf',
Kassel = 'Kassel',
Aachen = 'Aachen',
Köln = 'Köln',
Trier = 'Trier',
Wiesbaden = 'Wiesbaden',
FrankfurtM = 'Frankfurt-M',
Saarbrücken = 'Saarbrücken',
Mannheim = 'Mannheim',
Freiburg = 'Freiburg',
Stuttgart = 'Stuttgart',
Konstanz = 'Konstanz',
Augsburg = 'Augsburg',
Regensburg = 'Regensburg',
München = 'München',
Passau = 'Passau',
}
const maps: Map[] = [
{
name: 'USA',
cities: [
{ name: Cities.Seattle, region: Regions.Purple, x: 74, y: 99 },
{ name: Cities.Portland, region: Regions.Purple, x: 45, y: 167 },
{ name: Cities.Boise, region: Regions.Purple, x: 180, y: 220 },
{ name: Cities.Billings, region: Regions.Purple, x: 345, y: 180 },
{ name: Cities.Cheyenne, region: Regions.Purple, x: 410, y: 280 },
{ name: Cities.Denver, region: Regions.Purple, x: 400, y: 333 },
{ name: Cities.Omaha, region: Regions.Purple, x: 566, y: 293 },
{ name: Cities.SanFrancisco, region: Regions.Cyan, x: 48, y: 371 },
{ name: Cities.LosAngeles, region: Regions.Cyan, x: 116, y: 460 },
{ name: Cities.SanDiego, region: Regions.Cyan, x: 157, y: 507 },
{ name: Cities.LasVegas, region: Regions.Cyan, x: 200, y: 410 },
{ name: Cities.SaltlakeCity, region: Regions.Cyan, x: 266, y: 311 },
{ name: Cities.Phoenix, region: Regions.Cyan, x: 260, y: 486 },
{ name: Cities.SantaFe, region: Regions.Cyan, x: 371, y: 435 },
{ name: Cities.KansasCity, region: Regions.Red, x: 587, y: 356 },
{ name: Cities.OklahomaCity, region: Regions.Red, x: 550, y: 437 },
{ name: Cities.Dallas, region: Regions.Red, x: 560, y: 504 },
{ name: Cities.Houston, region: Regions.Red, x: 569, y: 571 },
{ name: Cities.Menphis, region: Regions.Red, x: 678, y: 449 },
{ name: Cities.Birmingham, region: Regions.Red, x: 739, y: 486 },
{ name: Cities.NewOrleans, region: Regions.Red, x: 674, y: 570 },
{ name: Cities.Fargo, region: Regions.Yellow, x: 551, y: 152 },
{ name: Cities.Duluth, region: Regions.Yellow, x: 637, y: 133 },
{ name: Cities.Minneapolis, region: Regions.Yellow, x: 621, y: 190 },
{ name: Cities.Chicago, region: Regions.Yellow, x: 716, y: 281 },
{ name: Cities.StLouis, region: Regions.Yellow, x: 678, y: 362 },
{ name: Cities.Cincinnati, region: Regions.Yellow, x: 795, y: 348 },
{ name: Cities.Knoxvile, region: Regions.Yellow, x: 796, y: 422 },
{ name: Cities.Detroit, region: Regions.Brown, x: 803, y: 262 },
{ name: Cities.Buffalo, region: Regions.Brown, x: 913, y: 251 },
{ name: Cities.Pittsburgh, region: Regions.Brown, x: 884, y: 316 },
{ name: Cities.Boston, region: Regions.Brown, x: 1052, y: 252 },
{ name: Cities.NewYork, region: Regions.Brown, x: 1010, y: 290 },
{ name: Cities.Philadelphia, region: Regions.Brown, x: 985, y: 330 },
{ name: Cities.Washington, region: Regions.Brown, x: 934, y: 357 },
{ name: Cities.Horecin, region: Regions.Green, x: 969, y: 405 },
{ name: Cities.Raleigh, region: Regions.Green, x: 915, y: 437 },
{ name: Cities.Atlanta, region: Regions.Green, x: 801, y: 487 },
{ name: Cities.Savannah, region: Regions.Green, x: 867, y: 507 },
{ name: Cities.Jacksonvile, region: Regions.Green, x: 861, y: 559 },
{ name: Cities.Tampa, region: Regions.Green, x: 819, y: 621 },
{ name: Cities.Miami, region: Regions.Green, x: 883, y: 670 },
],
connections: [
{ nodes: [Cities.Seattle, Cities.Portland], cost: 3 },
{ nodes: [Cities.Seattle, Cities.Boise], cost: 12 },
{ nodes: [Cities.Seattle, Cities.Billings], cost: 9 },
{ nodes: [Cities.Portland, Cities.Boise], cost: 13 },
{ nodes: [Cities.Portland, Cities.SanFrancisco], cost: 24 },
{ nodes: [Cities.Boise, Cities.Billings], cost: 12 },
{ nodes: [Cities.Boise, Cities.Cheyenne], cost: 24 },
{ nodes: [Cities.Boise, Cities.SanFrancisco], cost: 23 },
{ nodes: [Cities.Boise, Cities.SaltlakeCity], cost: 8 },
{ nodes: [Cities.Billings, Cities.Cheyenne], cost: 9 },
{ nodes: [Cities.Billings, Cities.Fargo], cost: 17 },
{ nodes: [Cities.Billings, Cities.Minneapolis], cost: 18 },
{ nodes: [Cities.Cheyenne, Cities.Denver], cost: 0 },
{ nodes: [Cities.Cheyenne, Cities.Omaha], cost: 14 },
{ nodes: [Cities.Cheyenne, Cities.Minneapolis], cost: 18 },
{ nodes: [Cities.Denver, Cities.SaltlakeCity], cost: 21 },
{ nodes: [Cities.Denver, Cities.SantaFe], cost: 13 },
{ nodes: [Cities.Denver, Cities.KansasCity], cost: 16 },
{ nodes: [Cities.Omaha, Cities.KansasCity], cost: 5 },
{ nodes: [Cities.Omaha, Cities.Minneapolis], cost: 8 },
{ nodes: [Cities.Omaha, Cities.Chicago], cost: 13 },
{ nodes: [Cities.SanFrancisco, Cities.LosAngeles], cost: 9 },
{ nodes: [Cities.SanFrancisco, Cities.LasVegas], cost: 14 },
{ nodes: [Cities.SanFrancisco, Cities.SaltlakeCity], cost: 27 },
{ nodes: [Cities.LosAngeles, Cities.SanDiego], cost: 3 },
{ nodes: [Cities.LosAngeles, Cities.LasVegas], cost: 9 },
{ nodes: [Cities.SanDiego, Cities.LasVegas], cost: 9 },
{ nodes: [Cities.SanDiego, Cities.Phoenix], cost: 14 },
{ nodes: [Cities.LasVegas, Cities.SaltlakeCity], cost: 18 },
{ nodes: [Cities.LasVegas, Cities.Phoenix], cost: 15 },
{ nodes: [Cities.LasVegas, Cities.SantaFe], cost: 27 },
{ nodes: [Cities.SaltlakeCity, Cities.SantaFe], cost: 28 },
{ nodes: [Cities.Phoenix, Cities.SantaFe], cost: 18 },
{ nodes: [Cities.SantaFe, Cities.KansasCity], cost: 16 },
{ nodes: [Cities.SantaFe, Cities.OklahomaCity], cost: 15 },
{ nodes: [Cities.SantaFe, Cities.Dallas], cost: 16 },
{ nodes: [Cities.SantaFe, Cities.Houston], cost: 21 },
{ nodes: [Cities.KansasCity, Cities.OklahomaCity], cost: 8 },
{ nodes: [Cities.KansasCity, Cities.Menphis], cost: 12 },
{ nodes: [Cities.KansasCity, Cities.Chicago], cost: 8 },
{ nodes: [Cities.KansasCity, Cities.StLouis], cost: 6 },
{ nodes: [Cities.OklahomaCity, Cities.Dallas], cost: 3 },
{ nodes: [Cities.OklahomaCity, Cities.Menphis], cost: 14 },
{ nodes: [Cities.Dallas, Cities.Houston], cost: 5 },
{ nodes: [Cities.Dallas, Cities.Menphis], cost: 12 },
{ nodes: [Cities.Dallas, Cities.NewOrleans], cost: 12 },
{ nodes: [Cities.Houston, Cities.NewOrleans], cost: 8 },
{ nodes: [Cities.Menphis, Cities.Birmingham], cost: 6 },
{ nodes: [Cities.Menphis, Cities.NewOrleans], cost: 7 },
{ nodes: [Cities.Menphis, Cities.StLouis], cost: 7 },
{ nodes: [Cities.Birmingham, Cities.NewOrleans], cost: 11 },
{ nodes: [Cities.Birmingham, Cities.Atlanta], cost: 3 },
{ nodes: [Cities.Birmingham, Cities.Jacksonvile], cost: 9 },
{ nodes: [Cities.NewOrleans, Cities.Jacksonvile], cost: 16 },
{ nodes: [Cities.Fargo, Cities.Duluth], cost: 6 },
{ nodes: [Cities.Fargo, Cities.Minneapolis], cost: 6 },
{ nodes: [Cities.Duluth, Cities.Minneapolis], cost: 5 },
{ nodes: [Cities.Duluth, Cities.Chicago], cost: 12 },
{ nodes: [Cities.Duluth, Cities.Detroit], cost: 15 },
{ nodes: [Cities.Minneapolis, Cities.Chicago], cost: 8 },
{ nodes: [Cities.Chicago, Cities.StLouis], cost: 10 },
{ nodes: [Cities.Chicago, Cities.Cincinnati], cost: 7 },
{ nodes: [Cities.Chicago, Cities.Detroit], cost: 7 },
{ nodes: [Cities.StLouis, Cities.Cincinnati], cost: 12 },
{ nodes: [Cities.StLouis, Cities.Atlanta], cost: 12 },
{ nodes: [Cities.Cincinnati, Cities.Knoxvile], cost: 6 },
{ nodes: [Cities.Cincinnati, Cities.Detroit], cost: 4 },
{ nodes: [Cities.Cincinnati, Cities.Pittsburgh], cost: 7 },
{ nodes: [Cities.Cincinnati, Cities.Raleigh], cost: 15 },
{ nodes: [Cities.Knoxvile, Cities.Atlanta], cost: 5 },
{ nodes: [Cities.Detroit, Cities.Buffalo], cost: 7 },
{ nodes: [Cities.Detroit, Cities.Pittsburgh], cost: 6 },
{ nodes: [Cities.Buffalo, Cities.Pittsburgh], cost: 7 },
{ nodes: [Cities.Buffalo, Cities.NewYork], cost: 8 },
{ nodes: [Cities.Pittsburgh, Cities.Washington], cost: 6 },
{ nodes: [Cities.Pittsburgh, Cities.Raleigh], cost: 7 },
{ nodes: [Cities.Boston, Cities.NewYork], cost: 3 },
{ nodes: [Cities.NewYork, Cities.Philadelphia], cost: 0 },
{ nodes: [Cities.Philadelphia, Cities.Washington], cost: 3 },
{ nodes: [Cities.Washington, Cities.Horecin], cost: 5 },
{ nodes: [Cities.Horecin, Cities.Raleigh], cost: 3 },
{ nodes: [Cities.Raleigh, Cities.Atlanta], cost: 7 },
{ nodes: [Cities.Raleigh, Cities.Savannah], cost: 7 },
{ nodes: [Cities.Atlanta, Cities.Savannah], cost: 7 },
{ nodes: [Cities.Savannah, Cities.Jacksonvile], cost: 0 },
{ nodes: [Cities.Jacksonvile, Cities.Tampa], cost: 4 },
{ nodes: [Cities.Tampa, Cities.Miami], cost: 4 },
],
},
{
name: 'Germany',
cities: [
{ name: Cities.Flensburg, region: Regions.Green, x: 37, y: 427 },
{ name: Cities.Kiel, region: Regions.Green, x: 106, y: 392 },
{ name: Cities.Hamburg, region: Regions.Green, x: 212, y: 396 },
{ name: Cities.Hannover, region: Regions.Green, x: 378, y: 395 },
{ name: Cities.Bremen, region: Regions.Green, x: 276, y: 463 },
{ name: Cities.Wilhelmshaven, region: Regions.Green, x: 211, y: 521 },
{ name: Cities.Cuxhaven, region: Regions.Green, x: 168, y: 474 },
{ name: Cities.Lubeck, region: Regions.Brown, x: 153, y: 341 },
{ name: Cities.Rostock, region: Regions.Brown, x: 128, y: 256 },
{ name: Cities.Schwerin, region: Regions.Brown, x: 217, y: 297 },
{ name: Cities.Torgelow, region: Regions.Brown, x: 210, y: 126 },
{ name: Cities.Magdeburg, region: Regions.Brown, x: 389, y: 271 },
{ name: Cities.Berlin, region: Regions.Brown, x: 355, y: 170 },
{ name: Cities.FrankfurtO, region: Regions.Brown, x: 381, y: 99 },
{ name: Cities.Halle, region: Regions.Yellow, x: 493, y: 259 },
{ name: Cities.Leipzig, region: Regions.Yellow, x: 526, y: 222 },
{ name: Cities.Dresden, region: Regions.Yellow, x: 572, y: 126 },
{ name: Cities.Erfurt, region: Regions.Yellow, x: 567, y: 309 },
{ name: Cities.Fulda, region: Regions.Yellow, x: 628, y: 398 },
{ name: Cities.Würzburg, region: Regions.Yellow, x: 735, y: 386 },
{ name: Cities.Nurnberg, region: Regions.Yellow, x: 780, y: 309 },
{ name: Cities.Osnabrück, region: Regions.Red, x: 359, y: 516 },
{ name: Cities.Münster, region: Regions.Red, x: 427, y: 554 },
{ name: Cities.Essen, region: Regions.Red, x: 475, y: 603 },
{ name: Cities.Duisburg, region: Regions.Red, x: 456, y: 645 },
{ name: Cities.Dortmund, region: Regions.Red, x: 505, y: 543 },
{ name: Cities.Dusseldorf, region: Regions.Red, x: 537, y: 635 },
{ name: Cities.Kassel, region: Regions.Red, x: 524, y: 430 },
{ name: Cities.Aachen, region: Regions.Cyan, x: 614, y: 654 },
{ name: Cities.Köln, region: Regions.Cyan, x: 590, y: 589 },
{ name: Cities.Trier, region: Regions.Cyan, x: 739, y: 628 },
{ name: Cities.Wiesbaden, region: Regions.Cyan, x: 697, y: 514 },
{ name: Cities.FrankfurtM, region: Regions.Cyan, x: 672, y: 473 },
{ name: Cities.Saarbrücken, region: Regions.Cyan, x: 818, y: 568 },
{ name: Cities.Mannheim, region: Regions.Cyan, x: 796, y: 479 },
{ name: Cities.Freiburg, region: Regions.Purple, x: 966, y: 537 },
{ name: Cities.Stuttgart, region: Regions.Purple, x: 884, y: 458 },
{ name: Cities.Konstanz, region: Regions.Purple, x: 1011, y: 459 },
{ name: Cities.Augsburg, region: Regions.Purple, x: 911, y: 346 },
{ name: Cities.Regensburg, region: Regions.Purple, x: 846, y: 256 },
{ name: Cities.München, region: Regions.Purple, x: 967, y: 278 },
{ name: Cities.Passau, region: Regions.Purple, x: 904, y: 153 },
],
connections: [
{ nodes: [Cities.Flensburg, Cities.Kiel], cost: 4 },
{ nodes: [Cities.Kiel, Cities.Hamburg], cost: 8 },
{ nodes: [Cities.Kiel, Cities.Lubeck], cost: 4 },
{ nodes: [Cities.Hamburg, Cities.Hannover], cost: 17 },
{ nodes: [Cities.Hamburg, Cities.Bremen], cost: 11 },
{ nodes: [Cities.Hamburg, Cities.Cuxhaven], cost: 11 },
{ nodes: [Cities.Hamburg, Cities.Lubeck], cost: 6 },
{ nodes: [Cities.Hamburg, Cities.Schwerin], cost: 8 },
{ nodes: [Cities.Bremen, Cities.Wilhelmshaven], cost: 11 },
{ nodes: [Cities.Bremen, Cities.Hannover], cost: 10 },
{ nodes: [Cities.Bremen, Cities.Cuxhaven], cost: 8 },
{ nodes: [Cities.Bremen, Cities.Osnabrück], cost: 11 },
{ nodes: [Cities.Hannover, Cities.Schwerin], cost: 19 },
{ nodes: [Cities.Hannover, Cities.Magdeburg], cost: 15 },
{ nodes: [Cities.Hannover, Cities.Erfurt], cost: 19 },
{ nodes: [Cities.Hannover, Cities.Osnabrück], cost: 16 },
{ nodes: [Cities.Hannover, Cities.Kassel], cost: 15 },
{ nodes: [Cities.Wilhelmshaven, Cities.Osnabrück], cost: 14 },
{ nodes: [Cities.Lubeck, Cities.Schwerin], cost: 6 },
{ nodes: [Cities.Schwerin, Cities.Rostock], cost: 6 },
{ nodes: [Cities.Schwerin, Cities.Torgelow], cost: 19 },
{ nodes: [Cities.Schwerin, Cities.Berlin], cost: 18 },
{ nodes: [Cities.Schwerin, Cities.Magdeburg], cost: 16 },
{ nodes: [Cities.Torgelow, Cities.Rostock], cost: 19 },
{ nodes: [Cities.Torgelow, Cities.Berlin], cost: 15 },
{ nodes: [Cities.Berlin, Cities.Magdeburg], cost: 10 },
{ nodes: [Cities.Berlin, Cities.FrankfurtO], cost: 6 },
{ nodes: [Cities.Berlin, Cities.Halle], cost: 17 },
{ nodes: [Cities.Magdeburg, Cities.Halle], cost: 11 },
{ nodes: [Cities.FrankfurtO, Cities.Leipzig], cost: 21 },
{ nodes: [Cities.FrankfurtO, Cities.Dresden], cost: 16 },
{ nodes: [Cities.Halle, Cities.Leipzig], cost: 0 },
{ nodes: [Cities.Leipzig, Cities.Dresden], cost: 13 },
{ nodes: [Cities.Erfurt, Cities.Halle], cost: 6 },
{ nodes: [Cities.Erfurt, Cities.Dresden], cost: 19 },
{ nodes: [Cities.Erfurt, Cities.Nurnberg], cost: 21 },
{ nodes: [Cities.Erfurt, Cities.Fulda], cost: 13 },
{ nodes: [Cities.Erfurt, Cities.Kassel], cost: 15 },
{ nodes: [Cities.Fulda, Cities.Würzburg], cost: 11 },
{ nodes: [Cities.Fulda, Cities.Kassel], cost: 8 },
{ nodes: [Cities.Fulda, Cities.FrankfurtM], cost: 8 },
{ nodes: [Cities.Würzburg, Cities.Nurnberg], cost: 8 },
{ nodes: [Cities.Würzburg, Cities.FrankfurtM], cost: 13 },
{ nodes: [Cities.Würzburg, Cities.Mannheim], cost: 10 },
{ nodes: [Cities.Würzburg, Cities.Stuttgart], cost: 12 },
{ nodes: [Cities.Würzburg, Cities.Augsburg], cost: 19 },
{ nodes: [Cities.Nurnberg, Cities.Augsburg], cost: 18 },
{ nodes: [Cities.Nurnberg, Cities.Regensburg], cost: 12 },
{ nodes: [Cities.Osnabrück, Cities.Münster], cost: 7 },
{ nodes: [Cities.Osnabrück, Cities.Kassel], cost: 20 },
{ nodes: [Cities.Münster, Cities.Essen], cost: 6 },
{ nodes: [Cities.Münster, Cities.Dortmund], cost: 2 },
{ nodes: [Cities.Essen, Cities.Duisburg], cost: 0 },
{ nodes: [Cities.Essen, Cities.Dusseldorf], cost: 2 },
{ nodes: [Cities.Essen, Cities.Dortmund], cost: 4 },
{ nodes: [Cities.Dortmund, Cities.Kassel], cost: 18 },
{ nodes: [Cities.Dortmund, Cities.Köln], cost: 10 },
{ nodes: [Cities.Dortmund, Cities.FrankfurtM], cost: 20 },
{ nodes: [Cities.Kassel, Cities.FrankfurtM], cost: 13 },
{ nodes: [Cities.Dusseldorf, Cities.Aachen], cost: 9 },
{ nodes: [Cities.Dusseldorf, Cities.Köln], cost: 4 },
{ nodes: [Cities.Aachen, Cities.Köln], cost: 7 },
{ nodes: [Cities.Aachen, Cities.Trier], cost: 19 },
{ nodes: [Cities.Trier, Cities.Köln], cost: 20 },
{ nodes: [Cities.Trier, Cities.Wiesbaden], cost: 18 },
{ nodes: [Cities.Trier, Cities.Saarbrücken], cost: 11 },
{ nodes: [Cities.Wiesbaden, Cities.FrankfurtM], cost: 0 },
{ nodes: [Cities.Wiesbaden, Cities.Köln], cost: 21 },
{ nodes: [Cities.Wiesbaden, Cities.Saarbrücken], cost: 10 },
{ nodes: [Cities.Wiesbaden, Cities.Mannheim], cost: 11 },
{ nodes: [Cities.Mannheim, Cities.Saarbrücken], cost: 11 },
{ nodes: [Cities.Mannheim, Cities.Stuttgart], cost: 6 },
{ nodes: [Cities.Stuttgart, Cities.Saarbrücken], cost: 17 },
{ nodes: [Cities.Stuttgart, Cities.Freiburg], cost: 16 },
{ nodes: [Cities.Stuttgart, Cities.Konstanz], cost: 16 },
{ nodes: [Cities.Stuttgart, Cities.Augsburg], cost: 15 },
{ nodes: [Cities.Konstanz, Cities.Freiburg], cost: 14 },
{ nodes: [Cities.Konstanz, Cities.Augsburg], cost: 17 },
{ nodes: [Cities.Regensburg, Cities.Augsburg], cost: 13 },
{ nodes: [Cities.Regensburg, Cities.München], cost: 10 },
{ nodes: [Cities.Regensburg, Cities.Passau], cost: 12 },
{ nodes: [Cities.Augsburg, Cities.München], cost: 6 },
{ nodes: [Cities.Passau, Cities.München], cost: 14 },
],
},
];
export default maps;

View file

@ -10,7 +10,7 @@
<source src="../audio/notification.mp3" type="audio/mpeg" />
<source src="../audio/notification.ogg" type="audio/ogg" />
</audio>
<svg id="scene" viewBox="0 0 1500 800" height="700" style="width: 100%">
<svg v-if="G" id="scene" viewBox="0 0 1500 800" height="700" style="width: 100%">
<rect width="100%" height="100%" x="0" y="0" fill="yellowgreen" />
<rect width="185" height="40" x="10" y="10" rx="3" fill="goldenrod" />
@ -203,28 +203,22 @@
</text>
<text x="955" y="14" font-weight="600" fill="black">Actual Market:</text>
<text v-if="G && G.step < 3" x="955" y="80" font-weight="600" fill="black">Future Market:</text>
<text v-if="G.step < 3" x="955" y="80" font-weight="600" fill="black">Future Market:</text>
<template v-if="G">
<template v-if="gameEnded(G)">
<Button
:transform="`translate(140, 580)`"
:width="130"
:text="'Final Score'"
@click="endScoreVisible = true"
/>
</template>
<template v-else>
<text x="30" y="580" font-weight="600" fill="black" style="font-size: 32px">
Step: {{ G.step }}
</text>
<text x="30" y="620" font-weight="600" fill="black" style="font-size: 32px">
Phase: {{ G.phase }}
</text>
<text x="30" y="680" font-weight="600" fill="black" style="font-size: 24px">
Resource Resupply: {{ G.resourceResupply[G.step - 1] }}
</text>
</template>
<template v-if="gameEnded(G)">
<Button
:transform="`translate(140, 580)`"
:width="130"
:text="'Final Score'"
@click="endScoreVisible = true"
/>
</template>
<template v-else>
<text x="30" y="580" font-weight="600" fill="black" style="font-size: 32px">Step: {{ G.step }}</text>
<text x="30" y="620" font-weight="600" fill="black" style="font-size: 32px">Phase: {{ G.phase }}</text>
<text x="30" y="680" font-weight="600" fill="black" style="font-size: 24px">
Resource Resupply: {{ G.resourceResupply[G.step - 1] }}
</text>
</template>
<PassButton transform="translate(1355, 15)" :enabled="canPass()" @click="pass()" />
@ -234,122 +228,113 @@
<HelpButton transform="translate(1450, 54)" :isOn="!preferences.disableHelp" @click="toggleHelp()" />
<RulesButton transform="translate(1450, 95)" @click="rulesVisible = true" />
<template v-if="G">
<template v-if="G.phase == 'Auction' && G.chosenPowerPlant">
<text x="1220" y="14" font-weight="600" fill="black">Current Auction:</text>
<Calculator
v-if="canBid()"
transform="translate(1220, 80)"
:minValue="G.currentBid + 1 || G.chosenPowerPlant.number"
:maxValue="G.players[player].money"
@bid="bid($event)"
/>
</template>
<template v-if="G.phase == 'Auction' && G.chosenPowerPlant">
<text x="1220" y="14" font-weight="600" fill="black">Current Auction:</text>
<Calculator
v-if="canBid()"
transform="translate(1220, 80)"
:minValue="G.currentBid + 1 || G.chosenPowerPlant.number"
:maxValue="G.players[player].money"
@bid="bid($event)"
/>
</template>
<template v-for="city in G.map.cities">
<circle
:key="city.name + '_region'"
r="25"
:cx="city.x"
:cy="city.y - 30"
:fill="city.region"
stroke="black"
>
<title>{{ city.name }}</title>
</circle>
<circle
:key="city.name + '_circle'"
r="20"
:cx="city.x"
:cy="city.y - 30"
fill="gray"
stroke="black"
>
<title>{{ city.name }}</title>
</circle>
</template>
<template v-for="city in G.map.cities">
<circle
:key="city.name + '_region'"
r="25"
:cx="city.x"
:cy="city.y"
:fill="city.region"
stroke="black"
>
<title>{{ city.name }}</title>
</circle>
<circle :key="city.name + '_circle'" r="20" :cx="city.x" :cy="city.y" fill="gray" stroke="black">
<title>{{ city.name }}</title>
</circle>
</template>
<template v-for="connection in G.map.connections">
<line
:key="connection.from + '_' + connection.to + '_line1'"
:x1="getX1(connection)"
:y1="getY1(connection) - 30"
:x2="getX2(connection)"
:y2="getY2(connection) - 30"
stroke-width="10"
stroke="black"
/>
<line
:key="connection.from + '_' + connection.to + '_line2'"
:x1="getX1(connection)"
:y1="getY1(connection) - 30"
:x2="getX2(connection)"
:y2="getY2(connection) - 30"
stroke-width="9"
stroke="gray"
/>
</template>
<template v-for="connection in G.map.connections">
<line
:key="connection.nodes[0] + '_' + connection.nodes[1] + '_line1'"
:x1="getX1(connection)"
:y1="getY1(connection)"
:x2="getX2(connection)"
:y2="getY2(connection)"
stroke-width="10"
stroke="black"
/>
<line
:key="connection.nodes[0] + '_' + connection.nodes[1] + '_line2'"
:x1="getX1(connection)"
:y1="getY1(connection)"
:x2="getX2(connection)"
:y2="getY2(connection)"
stroke-width="9"
stroke="gray"
/>
</template>
<template v-for="city in G.map.cities">
<circle
:key="city.name + '_circle2'"
:class="[{ canClick: canBuild(city) }]"
r="20"
:cx="city.x"
:cy="city.y - 30"
fill="gray"
@click="canBuild(city) && build(city)"
>
<title>{{ city.name }}</title>
</circle>
</template>
<template v-for="city in G.map.cities">
<circle
:key="city.name + '_circle2'"
:class="[{ canClick: canBuild(city) }]"
r="20"
:cx="city.x"
:cy="city.y"
fill="gray"
@click="canBuild(city) && build(city)"
>
<title>{{ city.name }}</title>
</circle>
</template>
<template v-for="connection in G.map.connections">
<circle
v-if="connection.cost > 0"
:key="connection.from + '_' + connection.to + '_border'"
stroke="black"
:r="10 + (connection.cost * 10) / 28"
:cx="(getX1(connection) + getX2(connection)) / 2"
:cy="(getY1(connection) + getY2(connection) - 60) / 2"
:fill="connection.cost > 15 ? 'gold' : connection.cost > 10 ? 'lightgray' : 'tan'"
/>
<circle
v-if="connection.cost > 0"
:key="connection.from + '_' + connection.to + '_circle'"
:r="6 + (connection.cost * 10) / 28"
:cx="(getX1(connection) + getX2(connection)) / 2"
:cy="(getY1(connection) + getY2(connection) - 60) / 2"
fill="gray"
stroke="black"
/>
<text
v-if="connection.cost > 0"
:key="connection.from + '_' + connection.to + '_text'"
text-anchor="middle"
:style="`font-size: ${12 + (connection.cost * 6) / 28}px`"
fill="black"
:x="(getX1(connection) + getX2(connection)) / 2"
:y="(getY1(connection) + getY2(connection) - 60) / 2"
>
{{ connection.cost }}
</text>
</template>
<template v-for="connection in G.map.connections">
<circle
v-if="connection.cost > 0"
:key="connection.nodes[0] + '_' + connection.nodes[1] + '_border'"
stroke="black"
:r="10 + (connection.cost * 10) / 28"
:cx="(getX1(connection) + getX2(connection)) / 2"
:cy="(getY1(connection) + getY2(connection)) / 2"
:fill="connection.cost > 15 ? 'gold' : connection.cost > 10 ? 'lightgray' : 'tan'"
/>
<circle
v-if="connection.cost > 0"
:key="connection.nodes[0] + '_' + connection.nodes[1] + '_circle'"
:r="6 + (connection.cost * 10) / 28"
:cx="(getX1(connection) + getX2(connection)) / 2"
:cy="(getY1(connection) + getY2(connection)) / 2"
fill="gray"
stroke="black"
/>
<text
v-if="connection.cost > 0"
:key="connection.nodes[0] + '_' + connection.nodes[1] + '_text'"
text-anchor="middle"
:style="`font-size: ${12 + (connection.cost * 6) / 28}px`"
fill="black"
:x="(getX1(connection) + getX2(connection)) / 2"
:y="(getY1(connection) + getY2(connection)) / 2"
>
{{ connection.cost }}
</text>
</template>
<template v-for="(p, i) in G.players">
<PlayerBoard
:key="'B' + i"
:player="p"
:color="playerColors[i]"
:transform="`translate(1100, ${140 + 110 * i})`"
:owner="i"
:isCurrentPlayer="isCurrentPlayer(i)"
:ended="gameEnded(G)"
:isPlayer="player == i"
:ranking="sortedPlayers.findIndex((x) => x.id == p.id) + 1"
@powerPlantClick="powerPlantClick($event)"
/>
</template>
<template v-for="(p, i) in G.players">
<PlayerBoard
:key="'B' + i"
:player="p"
:color="playerColors[i]"
:transform="`translate(1100, ${140 + 110 * i})`"
:owner="i"
:isCurrentPlayer="isCurrentPlayer(i)"
:ended="gameEnded(G)"
:isPlayer="player == i"
:ranking="sortedPlayers.findIndex((x) => x.id == p.id) + 1"
@powerPlantClick="powerPlantClick($event)"
/>
</template>
<template v-for="house in houses">
@ -443,7 +428,7 @@
rx="2px"
/>
<g v-if="G && canChoose()">
<g v-if="canChoose()">
<rect
v-if="G.step < 3"
x="950"
@ -481,37 +466,35 @@
stroke-width="2px"
/>
<template v-if="G">
<template v-for="city in G.map.cities">
<circle
v-if="canBuild(city)"
:key="city.name + '_circleHelp'"
:class="[{ canClick: canBuild(city) }]"
r="18"
:cx="city.x"
:cy="city.y - 30"
<template v-for="city in G.map.cities">
<circle
v-if="canBuild(city)"
:key="city.name + '_circleHelp'"
:class="[{ canClick: canBuild(city) }]"
r="18"
:cx="city.x"
:cy="city.y"
fill="none"
stroke="blue"
stroke-width="4px"
/>
</template>
<template v-for="(player, pi) in G.players">
<template v-for="(powerPlant, ppi) in player.powerPlants">
<rect
v-if="canUsePowerPlant(powerPlant)"
:key="pi + '_' + ppi + '_helper'"
:x="player.powerPlants.length < 5 ? 1120 + 80 * ppi : 1105 + 70 * ppi"
:y="170 + 110 * pi"
width="60"
height="40"
fill="none"
stroke="blue"
stroke-width="4px"
rx="2px"
/>
</template>
<template v-for="(player, pi) in G.players">
<template v-for="(powerPlant, ppi) in player.powerPlants">
<rect
v-if="canUsePowerPlant(powerPlant)"
:key="pi + '_' + ppi + '_helper'"
:x="player.powerPlants.length < 5 ? 1120 + 80 * ppi : 1105 + 70 * ppi"
:y="170 + 110 * pi"
width="60"
height="40"
fill="none"
stroke="blue"
stroke-width="4px"
rx="2px"
/>
</template>
</template>
</template>
</template>
</svg>
@ -759,13 +742,13 @@ export default class Game extends Vue {
let offsetX, offsetY;
if (cityPiece.position == 0) {
offsetX = -6;
offsetY = -48;
offsetY = -18;
} else if (cityPiece.position == 1) {
offsetX = -15;
offsetY = -34;
offsetY = -4;
} else {
offsetX = 1;
offsetY = -34;
offsetY = -4;
}
this.houses.push({
@ -786,7 +769,7 @@ export default class Game extends Vue {
y:
15 +
(adjustCityCount[player.cities.length].indexOf(pi) * 30) /
adjustCityCount[player.cities.length].length,
adjustCityCount[player.cities.length].length,
color: this.playerColors[pi],
owner: pi,
});
@ -936,22 +919,22 @@ export default class Game extends Vue {
}
getX1(connection) {
const city = this.G!.map.cities.find((city) => city.name == connection.from)!;
const city = this.G!.map.cities.find((city) => city.name == connection.nodes[0])!;
return city.x;
}
getY1(connection) {
const city = this.G!.map.cities.find((city) => city.name == connection.from)!;
const city = this.G!.map.cities.find((city) => city.name == connection.nodes[0])!;
return city.y;
}
getX2(connection) {
const city = this.G!.map.cities.find((city) => city.name == connection.to)!;
const city = this.G!.map.cities.find((city) => city.name == connection.nodes[1])!;
return city.x;
}
getY2(connection) {
const city = this.G!.map.cities.find((city) => city.name == connection.to)!;
const city = this.G!.map.cities.find((city) => city.name == connection.nodes[1])!;
return city.y;
}

View file

@ -3,12 +3,14 @@ import { move as execMove, Move, setup, stripSecret } from 'powergrid-engine';
import { moveAI } from 'powergrid-engine/src/engine';
import launch from './launch';
const delayBase = 0;
function launchSelfContained(selector = '#app') {
const strip = false;
const emitter = launch(selector);
let gameState = setup(6, {});
let gameState = setup(6, { map: 'Germany' });
for (let i = 0; i < gameState.players.length; i++) {
gameState.players[i].name = `Player ${i + 1}`;
@ -27,7 +29,7 @@ function launchSelfContained(selector = '#app') {
emitter.emit('state', cloneDeep(strip ? stripSecret(gameState, playerIndex) : gameState));
let delay = 1000;
let delay = delayBase;
while (gameState.players.some((pl) => pl.isAI && pl.availableMoves)) {
gameState = moveAI(
gameState,
@ -36,7 +38,7 @@ function launchSelfContained(selector = '#app') {
let newState = cloneDeep(strip ? stripSecret(gameState, playerIndex) : gameState);
console.log('new game state', newState);
setTimeout(() => emitter.emit('state', newState), delay);
delay += 1000;
delay += delayBase;
}
console.log('available moves', gameState.players[playerIndex].availableMoves);
@ -49,7 +51,7 @@ function launchSelfContained(selector = '#app') {
emitter.emit('player', { index: playerIndex });
emitter.emit('state', cloneDeep(strip ? stripSecret(gameState, playerIndex) : gameState));
let delay = 1000;
let delay = delayBase;
while (gameState.players.some((pl) => pl.isAI && pl.availableMoves)) {
gameState = moveAI(
gameState,
@ -57,7 +59,7 @@ function launchSelfContained(selector = '#app') {
);
let newState = cloneDeep(strip ? stripSecret(gameState, playerIndex) : gameState);
setTimeout(() => emitter.emit('state', newState), delay);
delay += 1000;
delay += delayBase;
}
console.log('available moves', gameState.players[playerIndex].availableMoves);