Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/games/blockilization/client/more.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function unitExtras(u: UnitWire, act: (label: string, o: Parameters<typeo
act('Build Academy', { t: 'greatPerson', unit: u.id, action: 'improvement' }, '+3 science on this tile, for good.');
break;
case 'great_engineer':
act('Hurry production', { t: 'greatPerson', unit: u.id, action: 'hurry' }, 'In one of your cities: a great deal of production toward what it builds (wonders too).');
act('Hurry production', { t: 'greatPerson', unit: u.id, action: 'hurry' }, 'In one of your cities: a great deal of production toward what it builds now (wonders too), as much as it needs and no more.');
act('Build Manufactory', { t: 'greatPerson', unit: u.id, action: 'improvement' }, '+3 production on this tile, for good.');
break;
case 'great_merchant':
Expand Down
8 changes: 7 additions & 1 deletion src/games/blockilization/rules/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2365,7 +2365,13 @@ function greatAction(game: Game, p: Player, u: Unit, action: Extract<Order, { t:
if (!abilities.includes('hurry')) return fail('Only a Great Engineer');
const city = cityAt(game, u.tile);
if (!city || city.owner !== p.index) return fail('Stand it in one of your cities');
city.prod += 300 + 30 * city.pop;
// Toward what's being built now and no more than it still needs (Civ V's): none of it is left
// over to finish what comes after it in a turn each.
const item = city.queue[0];
if (!item) return fail(`${city.name} isn't building anything`);
const left = itemCost(game, item) - city.prod;
if (left <= 0) return fail(`${city.name} has already finished what it's building`);
city.prod += Math.min(left, 300 + 30 * city.pop);
return used(`Your Great Engineer has hurried the work in ${city.name}.`);
}
case 'trade': {
Expand Down
26 changes: 25 additions & 1 deletion src/games/blockilization/tests/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CIV_SYMBOL, glyphPaths } from '../client/icons';
import { atWar, canStand, cityAt, createGame, maxMoves, seesUnit, techCost, unitSight, updateAllVisibility } from '../rules/core';
import { assignCitizens, cityEffects, cityYields, workedYields, connected, dissent, foodKept, freshWater, goldUpkeep, growthThreshold, greatCost, greatPeopleBonus, happiness, policyCost, purchaseCost, strategic, tileCultureCost, tileYields, UNHAPPINESS_PER_CITY, weighing, workable } from '../rules/economy';
import { faithCost, faithTurn, faithUnit, foundReligion, maxReligions, prophetCost, religionsLeft, spreadsOf } from '../rules/faith';
import { ANARCHY_TURNS, apply, applyOnce, blockers, canBuild, workTurns, constructible, canChooseIdeology, ideologySwitch, SWITCH_DISSENT, canDig, canFound, checkVictory, endTurn, faithPurchases, healing, learn, plunder, productionToward, score, shareResearch, trainable, trainOptions, upgradeCost, upgradeTo, wellFormed, type Order } from '../rules/game';
import { ANARCHY_TURNS, apply, applyOnce, blockers, canBuild, workTurns, constructible, canChooseIdeology, ideologySwitch, SWITCH_DISSENT, canDig, canFound, checkVictory, endTurn, faithPurchases, healing, itemCost, learn, plunder, productionToward, score, shareResearch, trainable, trainOptions, upgradeCost, upgradeTo, wellFormed, type Order } from '../rules/game';
import { colOf, distance, line, neighbour, neighbours, rowOf, tileAt, within } from '../rules/hex';
import { generate, Rng, START_ISLAND } from '../rules/mapgen';
import { NATURAL_WONDERS } from '../rules/nature';
Expand Down Expand Up @@ -1817,6 +1817,30 @@ test('great people used: the Mausoleum’s gold, Reliquary’s faith, Rationalis
eq(game.tiles[at(6, 5)].improvement, 'landmark', 'a landmark');
});

test('a Great Engineer hurries what’s being built now and no more: nothing left over for what comes after', () => {
const { game, at } = blank();
const c = city(game, 0, at(10, 8), { pop: 10 });
const monument = { kind: 'building', id: 'monument' } as const;
c.queue = [monument, { kind: 'unit', id: 'warrior' }, { kind: 'unit', id: 'warrior' }, { kind: 'unit', id: 'warrior' }];
const g = unit(game, 'great_engineer', 0, c.tile);
ok(apply(game, 0, { t: 'greatPerson', unit: g.id, action: 'hurry' }).ok, 'hurried');
eq(c.prod, itemCost(game, monument), 'as much as the monument needs');
endTurn(game);
ok(c.buildings.includes('monument'), 'the monument built');
ok(c.prod < itemCost(game, { kind: 'unit', id: 'warrior' }), `only a turn's production carried to the warrior (${c.prod})`);
endTurn(game);
eq(game.units.filter((u) => u.type === 'warrior' && u.owner === 0).length, 0, 'which takes more than a turn');
// Nothing to hurry: the engineer kept.
c.queue = [];
c.prod = 0;
const g2 = unit(game, 'great_engineer', 0, c.tile);
ok(!apply(game, 0, { t: 'greatPerson', unit: g2.id, action: 'hurry' }).ok && game.units.includes(g2), 'not with nothing being built');
// A wonder far from done gets the whole of it.
c.queue = [{ kind: 'building', id: 'cn_tower' }];
ok(apply(game, 0, { t: 'greatPerson', unit: g2.id, action: 'hurry' }).ok, 'a wonder hurried');
eq(c.prod, 300 + 30 * c.pop, 'with all 300 and 30 a citizen');
});

// -------------------------------------------------------------------------------------------------
// City-states, trade, spies, research agreements
// -------------------------------------------------------------------------------------------------
Expand Down
Loading