Skip to content

Commit

Permalink
Merge pull request #58 from tjohnson314/master
Browse files Browse the repository at this point in the history
Enable Central Europe map
  • Loading branch information
coyotte508 committed Jul 11, 2023
2 parents d9583c1 + 48739d2 commit 8b87e72
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 6 deletions.
23 changes: 22 additions & 1 deletion engine/src/available-moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ export function availableMoves(G: GameState, player: Player): AvailableMoves {
}
}

// Nuclear plants for Central Europe are only allowed for players with cities in:
// Czechia (green), Slovakia (brown), Hungary (purple)
if (G.map.name == 'Central Europe') {
const validCities = player.cities
.map((c) => G.map.cities.find((c_) => c_.name == c.name)!)
.filter((c) => c.region == 'green' || c.region == 'brown' || c.region == 'purple');

if (validCities.length == 0) {
canBid = canBid.filter((p) => p.type != PowerPlantType.Uranium);
}
}

if (canBid.length > 0) {
moves[MoveName.ChoosePowerPlant] = canBid.map((p) => p.number);
}
Expand Down Expand Up @@ -184,7 +196,16 @@ export function availableMoves(G: GameState, player: Player): AvailableMoves {

if (G.garbageMarket > 0) {
const garbagePrices = G.garbagePrices ?? prices[ResourceType.Garbage];
const price = garbagePrices[garbagePrices.length - G.garbageMarket];
let price = garbagePrices[garbagePrices.length - G.garbageMarket];

// $1 cheaper for players in Wien in Central Europe
if (G.map.name == 'Central Europe') {
const wienCity = player.cities.filter((c) => c.name == 'Wien');
if (wienCity?.length > 0) {
price--;
}
}

if (
player.money >= price &&
player.garbageCapacity > player.garbageLeft &&
Expand Down
18 changes: 18 additions & 0 deletions engine/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,15 @@ export function move(G: GameState, move: Move, playerNumber: number, isUndo = fa
case ResourceType.Garbage: {
const garbagePrices = G.garbagePrices ?? prices[ResourceType.Garbage];
price = garbagePrices[garbagePrices.length - G.garbageMarket];

// $1 cheaper for players in Wien in Central Europe
if (G.map.name == 'Central Europe') {
const wienCity = player.cities.filter((c) => c.name == 'Wien');
if (wienCity?.length > 0) {
price--;
}
}

player.garbageLeft++;
G.garbageMarket--;
break;
Expand Down Expand Up @@ -1314,6 +1323,15 @@ export function move(G: GameState, move: Move, playerNumber: number, isUndo = fa
G.garbageMarket++;
const garbagePrices = G.garbagePrices ?? prices[ResourceType.Garbage];
price = garbagePrices[garbagePrices.length - G.garbageMarket];

// $1 cheaper for players in Wien in Central Europe
if (G.map.name == 'Central Europe') {
const wienCity = player.cities.filter((c) => c.name == 'Wien');
if (wienCity?.length > 0) {
price--;
}
}

break;
}

Expand Down
4 changes: 2 additions & 2 deletions engine/src/gamestate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export type MapName =
| 'India'
| 'China'
| 'Benelux'
| 'Russia';
| 'Russia'
| 'Central Europe';
// | 'Australia'
// | 'Baden-Württemberg'
// | 'Central Europe'
// | 'Japan'
// | 'Korea'
// | 'Northern Europe'
Expand Down
6 changes: 3 additions & 3 deletions engine/src/maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PowerPlant } from './gamestate';
import { map as america, mapRecharged as americaRecharged } from './maps/america';
import { map as benelux } from './maps/benelux';
import { map as brazil } from './maps/brazil';
import { map as centraleurope } from './maps/centraleurope';
import { map as china } from './maps/china';
import { map as france } from './maps/france';
import { map as germany, mapRecharged as germanyRecharged } from './maps/germany';
Expand All @@ -14,7 +15,6 @@ import { map as russia } from './maps/russia';
import { map as spainportugal } from './maps/spainportugal';
// import { map as australia } from './maps/australia';
// import { map as badenwurttemberg } from './maps/badenwurttemberg';
// import { map as centraleurope } from './maps/centraleurope';
// import { map as japan } from './maps/japan';
// import { map as korea } from './maps/korea';
// import { map as northerneurope } from './maps/northerneurope';
Expand Down Expand Up @@ -88,9 +88,9 @@ export const maps: GameMap[] = [
china,
benelux,
russia,
centraleurope,
// australia,
// badenwurttemberg,
// centraleurope,
// japan,
// korea,
// northerneurope,
Expand All @@ -111,9 +111,9 @@ export const mapsRecharged: GameMap[] = [
china,
benelux,
russia,
centraleurope,
// australia,
// badenwurttemberg,
// centraleurope,
// china,
// japan,
// korea,
Expand Down
30 changes: 30 additions & 0 deletions engine/src/maps/centraleurope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,34 @@ export const map: GameMap = {
layout: 'Portrait',
mapPosition: [70, -60],
adjustRatio: [1.15, 1.15],
resupply: [
[
[4, 5, 3],
[5, 6, 3],
[6, 7, 5],
[7, 8, 5],
[8, 10, 6],
],
[
[1, 2, 3],
[2, 2, 3],
[2, 3, 4],
[3, 4, 5],
[4, 5, 6],
],
[
[1, 3, 3],
[1, 3, 3],
[2, 4, 4],
[3, 4, 5],
[3, 6, 6],
],
[
[1, 1, 1],
[1, 1, 1],
[1, 2, 1],
[2, 2, 2],
[2, 3, 2],
],
],
};

0 comments on commit 8b87e72

Please sign in to comment.