Skip to content

Commit 0a86406

Browse files
Merge branch 'master' into public-release
2 parents 6d00399 + 43bd7c7 commit 0a86406

File tree

9 files changed

+37
-18
lines changed

9 files changed

+37
-18
lines changed

client/src/client-config.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const DEFAULT_CONFIG = {
3636
focusRobotTurn: true,
3737
enableFancyPaint: true,
3838
streamRunnerGames: true,
39+
populateRunnerGames: true,
3940
profileGames: false,
4041
validateMaps: false,
4142
resolutionScale: 100,
@@ -68,6 +69,7 @@ const configDescription: Record<keyof ClientConfig, string> = {
6869
focusRobotTurn: 'Focus the robot when performing their turn during turn-stepping mode',
6970
enableFancyPaint: 'Enable fancy paint rendering',
7071
streamRunnerGames: 'Stream each round from the runner live as the game is being played',
72+
populateRunnerGames: 'Display the finished game immediately when the runner is finished running',
7173
profileGames: 'Enable saving profiling data when running games',
7274
validateMaps: 'Validate maps before running a game',
7375
resolutionScale: 'Resolution scale for the game area. Decrease to help performance.',

client/src/components/button.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { MouseEvent, PropsWithChildren } from 'react'
22

33
type Props = {
44
className?: string
5+
style?: React.CSSProperties
56
onClick: (event: MouseEvent<HTMLButtonElement>) => void
67
disabled?: boolean
78
}
@@ -15,6 +16,7 @@ export const Button = (props: PropsWithChildren<Props>) => {
1516
(props.disabled ? ' opacity-50 cursor-not-allowed' : '')
1617
}
1718
onClick={props.onClick}
19+
style={props.style}
1820
>
1921
{props.children}
2022
</button>
@@ -28,6 +30,7 @@ export const SmallButton = (props: PropsWithChildren<Props>) => (
2830
(props.className ?? '')
2931
}
3032
onClick={props.onClick}
33+
style={props.style}
3134
>
3235
{props.children}
3336
</button>
@@ -40,6 +43,7 @@ export const BrightButton = (props: PropsWithChildren<Props>) => (
4043
(props.className ?? '')
4144
}
4245
onClick={props.onClick}
46+
style={props.style}
4347
>
4448
{props.children}
4549
</button>

client/src/components/sidebar/runner/runner.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { nativeAPI } from './native-api-wrapper'
55
import { Select } from '../../forms'
66
import { InputDialog } from '../../input-dialog'
77
import Tooltip from '../../tooltip'
8-
import { SectionHeader } from '../../section-header'
98
import { FixedSizeList, ListOnScrollProps } from 'react-window'
10-
import { OpenExternal } from '../../../icons/open-external'
119
import { BasicDialog } from '../../basic-dialog'
1210
import { RingBuffer } from '../../../util/ring-buffer'
1311
import { ProfilerDialog } from './profiler'
@@ -141,11 +139,11 @@ export const RunnerPage: React.FC<RunnerPageProps> = ({ open, scaffold }) => {
141139
<MapSelector
142140
maps={maps}
143141
availableMaps={availableMaps}
144-
onSelect={(m) => setMaps(new Set([...maps, m]))}
145-
onDeselect={(m) => setMaps(new Set([...maps].filter((x) => x !== m)))}
142+
onSelect={(m) => setMaps(new Set([...maps, ...m]))}
143+
onDeselect={(m) => setMaps(new Set([...maps].filter((x) => !m.includes(x))))}
146144
/>
147145
<SmallButton
148-
className="mt-2"
146+
className="mt-3"
149147
onClick={() => {
150148
resetSettings()
151149
reloadData()
@@ -330,8 +328,8 @@ const TeamSelector: React.FC<TeamSelectorProps> = ({ teamA, teamB, options, onCh
330328
interface MapSelectorProps {
331329
maps: Set<string>
332330
availableMaps: Set<string>
333-
onSelect: (map: string) => void
334-
onDeselect: (map: string) => void
331+
onSelect: (map: string[]) => void
332+
onDeselect: (map: string[]) => void
335333
}
336334

337335
const MapSelector: React.FC<MapSelectorProps> = ({ maps, availableMaps, onSelect, onDeselect }) => {
@@ -354,7 +352,7 @@ const MapSelector: React.FC<MapSelectorProps> = ({ maps, availableMaps, onSelect
354352
<div
355353
key={m}
356354
className={'cursor-pointer hover:bg-lightHighlight flex items-center justify-between'}
357-
onClick={() => (maps.has(m) ? onDeselect(m) : onSelect(m))}
355+
onClick={() => (maps.has(m) ? onDeselect([m]) : onSelect([m]))}
358356
>
359357
{m}
360358
<input
@@ -368,6 +366,14 @@ const MapSelector: React.FC<MapSelectorProps> = ({ maps, availableMaps, onSelect
368366
})}
369367
</div>
370368
</Resizable>
369+
<div className="flex gap-2 items-center mt-1 justify-center">
370+
<SmallButton style={{ margin: 0 }} onClick={() => onSelect([...availableMaps])}>
371+
Select All
372+
</SmallButton>
373+
<SmallButton style={{ margin: 0 }} onClick={() => onDeselect([...availableMaps])}>
374+
Deselect All
375+
</SmallButton>
376+
</div>
371377
</div>
372378
)
373379
}

client/src/components/sidebar/runner/scaffold.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,16 @@ export const useScaffold = (): Scaffold => {
202202
}
203203

204204
const onGameComplete = (game: Game) => {
205-
appContext.setState((prevState) => ({
206-
...prevState,
207-
queue: prevState.queue.find((g) => g == game) ? prevState.queue : prevState.queue.concat([game])
208-
}))
209-
if (game.matches.length > 0) GameRunner.setMatch(game.matches[0])
205+
appContext.setState((prevState) => {
206+
if (prevState.config.populateRunnerGames && game.matches.length > 0) {
207+
GameRunner.setMatch(game.matches[0])
208+
}
209+
210+
return {
211+
...prevState,
212+
queue: prevState.queue.find((g) => g == game) ? prevState.queue : prevState.queue.concat([game])
213+
}
214+
})
210215
}
211216

212217
setWebSocketListener(

client/src/components/sidebar/runner/websocket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class WebSocketListener {
6262
// Auto progress the round if the user hasn't done it themselves
6363
// We only want to do this if the currently selected match is the one being updated
6464
if (this.activeMatch && this.activeMatch === GameRunner.match) {
65-
const newRound = this.activeMatch.maxRound - 1
65+
const newRound = Math.max(this.activeMatch.maxRound - 2, 1)
6666
if (this.lastSetRound == this.activeMatch.currentRound.roundNumber) {
6767
GameRunner.jumpToRound(newRound)
6868
this.lastSetRound = newRound

client/src/playback/Map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class CurrentMap {
191191

192192
if (config.showSRPOutlines || config.showSRPText) {
193193
ctx.globalAlpha = 1
194-
ctx.lineWidth = 0.03
194+
ctx.lineWidth = 0.05
195195
this.resourcePatterns.forEach((srp) => {
196196
const topLeftCoords = renderUtils.getRenderCoords(srp.center.x - 2, srp.center.y + 2, this.dimension)
197197
const roundsRemaining = Math.max(srp.createRound + 50 - match.currentRound.roundNumber, -1)

client/src/playback/Match.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export default class Match {
313313
// Determine the maximum round we are allowed to jump to. If the game is
314314
// incomplete (still being updated with rounds), prevent jumping to the last
315315
// round to prevent issues (TODO: investigate why, but this seems to fix it)
316-
const maxRound = this.maxRound - (this.game.complete ? 0 : 1)
316+
const maxRound = this.maxRound - (this.game.complete ? 0 : 2)
317317

318318
roundNumber = Math.max(1, Math.min(roundNumber, maxRound))
319319
if (roundNumber == this.currentRound.roundNumber) return

engine/src/main/battlecode/world/InternalRobot.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,6 @@ public void processEndOfTurn() {
601601
if (!indicatorString.equals("")) {
602602
this.gameWorld.getMatchMaker().addIndicatorString(this.ID, this.indicatorString);
603603
}
604-
this.gameWorld.getMatchMaker().endTurn(this.ID, this.health, this.paintAmount, this.movementCooldownTurns, this.actionCooldownTurns, this.bytecodesUsed, this.location);
605-
this.roundsAlive++;
606604

607605
if (this.getType().isRobotType()){
608606
Team owningTeam = this.gameWorld.teamFromPaint(this.gameWorld.getPaint(this.location));
@@ -627,6 +625,9 @@ public void processEndOfTurn() {
627625
if (this.paintAmount == 0 && type.isRobotType()){
628626
this.addHealth(-GameConstants.NO_PAINT_DAMAGE);
629627
}
628+
629+
this.gameWorld.getMatchMaker().endTurn(this.ID, this.health, this.paintAmount, this.movementCooldownTurns, this.actionCooldownTurns, this.bytecodesUsed, this.location);
630+
this.roundsAlive++;
630631
}
631632

632633
// *********************************

engine/src/main/battlecode/world/RobotControllerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ public boolean canMopSwing(Direction dir) {
970970

971971
@Override
972972
public void mopSwing(Direction dir) throws GameActionException {
973+
assertCanMopSwing(dir);
973974
this.robot.addActionCooldownTurns(GameConstants.ATTACK_MOPPER_SWING_COOLDOWN);
974975
this.robot.mopSwing(dir);
975976
}

0 commit comments

Comments
 (0)