Skip to content

Commit 6d11f42

Browse files
committed
polish: fold final-review nits
- resolution.ts: thread leader substitution into pickLine for receiver-side, self-build, death, FR, PreRoundMood, and PostRoundReaction events; prevents literal '{leader}' leaking when bank categories are empty (Netanyahoo's propagandaReceive / buildFactory) - Setup: require non-empty name + country for every human before Start enables - SoftWarnPanel: remove unused 'orders' prop
1 parent 5425c79 commit 6d11f42

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/engine/resolution.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function resolveRound(state: GameState): ResolveResult {
3333
const bank = getBank(id);
3434
if (!bank) continue;
3535
const snapBack = s.lastColumnNamedLeader === id;
36-
const r = pickLine(bank, 'preRoundMood', s.rngState, { snapBack });
36+
const r = pickLine(bank, 'preRoundMood', s.rngState, { snapBack, substitutions: { leader: s.leaders[id].name } });
3737
s.rngState = r.rngState;
3838
events.push({ kind: 'PreRoundMood', leaderId: id, quote: r.quote, snapBack });
3939
}
@@ -178,7 +178,7 @@ export function resolveRound(state: GameState): ResolveResult {
178178
senderQuote = p.quote;
179179
}
180180
if (receiverBank) {
181-
const p = pickLine(receiverBank, 'propagandaReceive', s.rngState);
181+
const p = pickLine(receiverBank, 'propagandaReceive', s.rngState, { substitutions: { leader: s.leaders[e.to].name } });
182182
s.rngState = p.rngState;
183183
receiverQuote = p.quote;
184184
}
@@ -196,7 +196,7 @@ export function resolveRound(state: GameState): ResolveResult {
196196
senderQuote = p.quote;
197197
}
198198
if (receiverBank) {
199-
const p = pickLine(receiverBank, 'beingWooed', s.rngState);
199+
const p = pickLine(receiverBank, 'beingWooed', s.rngState, { substitutions: { leader: s.leaders[e.to].name } });
200200
s.rngState = p.rngState;
201201
receiverQuote = p.quote;
202202
}
@@ -206,31 +206,31 @@ export function resolveRound(state: GameState): ResolveResult {
206206
case 'FactoryBuilt': {
207207
const bank = isHuman(e.by) ? undefined : getBank(e.by);
208208
if (!bank) break;
209-
const p = pickLine(bank, 'buildFactory', s.rngState);
209+
const p = pickLine(bank, 'buildFactory', s.rngState, { substitutions: { leader: s.leaders[e.by].name } });
210210
s.rngState = p.rngState;
211211
events[i] = { ...e, quote: p.quote };
212212
break;
213213
}
214214
case 'DefenceBuilt': {
215215
const bank = isHuman(e.by) ? undefined : getBank(e.by);
216216
if (!bank) break;
217-
const p = pickLine(bank, 'buildDefence', s.rngState);
217+
const p = pickLine(bank, 'buildDefence', s.rngState, { substitutions: { leader: s.leaders[e.by].name } });
218218
s.rngState = p.rngState;
219219
events[i] = { ...e, quote: p.quote };
220220
break;
221221
}
222222
case 'LeaderEliminated': {
223223
const bank = isHuman(e.id) ? undefined : getBank(e.id);
224224
if (!bank) break;
225-
const p = pickLine(bank, 'death', s.rngState);
225+
const p = pickLine(bank, 'death', s.rngState, { substitutions: { leader: s.leaders[e.id].name } });
226226
s.rngState = p.rngState;
227227
events[i] = { ...e, quote: p.quote };
228228
break;
229229
}
230230
case 'FinalRetaliationTriggered': {
231231
const bank = isHuman(e.by) ? undefined : getBank(e.by);
232232
if (!bank) break;
233-
const p = pickLine(bank, 'finalRetaliation', s.rngState);
233+
const p = pickLine(bank, 'finalRetaliation', s.rngState, { substitutions: { leader: s.leaders[e.by].name } });
234234
s.rngState = p.rngState;
235235
events[i] = { ...e, quote: p.quote };
236236
break;
@@ -262,7 +262,7 @@ export function resolveRound(state: GameState): ResolveResult {
262262
if (!s.leaders[id].alive) continue;
263263
const bank = getBank(id);
264264
if (!bank) continue;
265-
const r = pickLine(bank, 'reaction', s.rngState);
265+
const r = pickLine(bank, 'reaction', s.rngState, { substitutions: { leader: s.leaders[id].name } });
266266
s.rngState = r.rngState;
267267
events.push({ kind: 'PostRoundReaction', leaderId: id, quote: r.quote });
268268
}

src/ui/components/SoftWarnPanel.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import type { GameState, Order, SoftWarning } from '../../engine/types';
1+
import type { GameState, SoftWarning } from '../../engine/types';
22
import styles from './SoftWarnPanel.module.css';
33

44
interface Props {
55
warnings: SoftWarning[];
6-
orders: Order[];
76
game: GameState;
87
}
98

10-
export default function SoftWarnPanel({ warnings, orders: _orders, game }: Props) {
9+
export default function SoftWarnPanel({ warnings, game }: Props) {
1110
if (warnings.length === 0) return null;
1211
return (
1312
<div className={styles.panel}>

src/ui/screens/Planning.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default function Planning({ state, dispatch }: ScreenProps) {
136136
<div className={`${styles.apSummary} ${overBudget ? styles.over : ''}`}>
137137
AP used: {apUsed} / {apTotal}
138138
</div>
139-
<SoftWarnPanel warnings={softWarnings} orders={orders} game={game} />
139+
<SoftWarnPanel warnings={softWarnings} game={game} />
140140
</section>
141141

142142
<OrderForm state={game} playerId={activeId} committedOrders={orders} onAdd={addOrder} />

src/ui/screens/Setup.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export default function Setup({ dispatch }: ScreenProps) {
2828
const [difficulty, setDifficulty] = useState<Difficulty>('normal');
2929
const [seedInput, setSeedInput] = useState('');
3030

31-
const canStart = selectedAi.length >= 2 && selectedAi.length <= 4;
31+
const allHumansComplete = humans.every((h) => h.name.trim() !== '' && h.country.trim() !== '');
32+
const canStart = selectedAi.length >= 2 && selectedAi.length <= 4 && allHumansComplete;
3233

3334
function addHuman() {
3435
if (humans.length >= 5) return;

0 commit comments

Comments
 (0)