Skip to content

Commit 676049a

Browse files
Merge branch 'master' into public-release
2 parents 6dcfdf5 + b7aaecf commit 676049a

File tree

14 files changed

+100
-28
lines changed

14 files changed

+100
-28
lines changed

client/src/components/controls-bar/controls-bar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const ControlsBar: React.FC = () => {
167167
icon={<ControlIcons.SkipForwardsIcon />}
168168
tooltip={'Increase Speed'}
169169
onClick={() => GameRunner.multiplyUpdatesPerSecond(2)}
170-
disabled={Math.abs(targetUPS) >= 64}
170+
disabled={Math.abs(targetUPS) >= 128}
171171
/>
172172
<ControlsBarButton
173173
icon={<ControlIcons.PlaybackStopIcon />}

client/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const CLIENT_VERSION = '1.2.0'
1+
export const CLIENT_VERSION = '1.3.0'
22
export const SPEC_VERSION = '1'
33
export const BATTLECODE_YEAR: number = 2025
44
export const MAP_SIZE_RANGE = {

client/src/playback/Bodies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export class Body {
275275
this.drawHealthBar(match, overlayCtx)
276276
}
277277
if (focused || config.showPaintBars) {
278-
this.drawPaintBar(match, overlayCtx, config.showHealthBars)
278+
this.drawPaintBar(match, overlayCtx, focused || config.showHealthBars)
279279
}
280280
}
281281
}

client/src/playback/GameRenderer.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class GameRendererClass {
155155

156156
private canvasMouseMove(e: MouseEvent) {
157157
const newTile = eventToPoint(e)
158+
if (!newTile) return
158159
if (newTile.x !== this.mouseTile?.x || newTile.y !== this.mouseTile?.y) {
159160
this.mouseTile = newTile
160161
this.render()
@@ -176,7 +177,9 @@ class GameRendererClass {
176177
}
177178

178179
private canvasMouseEnter(e: MouseEvent) {
179-
this.mouseTile = eventToPoint(e)
180+
const point = eventToPoint(e)
181+
if (!point) return
182+
this.mouseTile = point
180183
this.mouseDown = e.buttons > 0
181184
if (e.buttons === 2) this.mouseDownRight = true
182185
this._trigger(this._canvasHoverListeners)
@@ -192,6 +195,9 @@ class GameRendererClass {
192195
return
193196

194197
this.selectedTile = eventToPoint(e)
198+
199+
if (!this.selectedTile) return
200+
195201
const newSelectedBody = GameRunner.match?.currentRound.bodies.getBodyAtLocation(
196202
this.selectedTile.x,
197203
this.selectedTile.y
@@ -244,15 +250,16 @@ class GameRendererClass {
244250
}
245251
}
246252

247-
const eventToPoint = (e: MouseEvent) => {
253+
const eventToPoint = (e: MouseEvent): Vector | undefined => {
248254
const canvas = e.target as HTMLCanvasElement
249255
const rect = canvas.getBoundingClientRect()
250-
const map = GameRunner.match?.map ?? assert.fail('map is null in onclick')
256+
const map = GameRunner.match?.map
257+
if (!map) return undefined
251258
let x = Math.floor(((e.clientX - rect.left) / rect.width) * map.width)
252259
let y = Math.floor((1 - (e.clientY - rect.top) / rect.height) * map.height)
253260
x = Math.max(0, Math.min(x, map.width - 1))
254261
y = Math.max(0, Math.min(y, map.height - 1))
255-
return { x: x, y: y }
262+
return { x, y }
256263
}
257264

258265
export const GameRenderer = new GameRendererClass()

client/src/playback/GameRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class GameRunnerClass {
123123
multiplyUpdatesPerSecond(multiplier: number) {
124124
if (!this.match) return
125125
const scaled = this.targetUPS * multiplier
126-
const newMag = Math.max(1 / 4, Math.min(64, Math.abs(scaled)))
126+
const newMag = Math.max(1 / 4, Math.min(128, Math.abs(scaled)))
127127
this.targetUPS = Math.sign(scaled) * newMag
128128
this._trigger(this._controlListeners)
129129
}

client/src/playback/Map.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ export class CurrentMap {
7373
return this.staticMap.locationToIndex(x, y)
7474
}
7575

76+
locationToIndexUnchecked(x: number, y: number): number {
77+
return this.staticMap.locationToIndexUnchecked(x, y)
78+
}
79+
7680
applySymmetry(point: Vector): Vector {
7781
return this.staticMap.applySymmetry(point)
7882
}
@@ -96,7 +100,7 @@ export class CurrentMap {
96100
const dimension = this.dimension
97101
for (let i = 0; i < dimension.width; i++) {
98102
for (let j = 0; j < dimension.height; j++) {
99-
const schemaIdx = this.locationToIndex(i, j)
103+
const schemaIdx = this.locationToIndexUnchecked(i, j)
100104
const coords = renderUtils.getRenderCoords(i, j, dimension)
101105

102106
// Render rounded (clipped) paint
@@ -321,6 +325,10 @@ export class StaticMap {
321325
return Math.floor(y) * this.width + Math.floor(x)
322326
}
323327

328+
locationToIndexUnchecked(x: number, y: number): number {
329+
return y * this.width + x
330+
}
331+
324332
/**
325333
* Returns a point representing the reflection of the given point following the map's symmetry.
326334
*/
@@ -360,7 +368,7 @@ export class StaticMap {
360368

361369
for (let i = 0; i < this.dimension.width; i++) {
362370
for (let j = 0; j < this.dimension.height; j++) {
363-
const schemaIdx = this.locationToIndex(i, j)
371+
const schemaIdx = this.locationToIndexUnchecked(i, j)
364372
const coords = renderUtils.getRenderCoords(i, j, this.dimension)
365373

366374
// Render rounded (clipped) wall

client/src/playback/Match.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,15 @@ export default class Match {
181181
const currentTurnNumber = this.currentRound.turnNumber
182182

183183
this._currentSimulationStep += deltaTime * MAX_SIMULATION_STEPS
184+
184185
if (this.playbackPerTurn) {
186+
// This works because of the way floor works
187+
const deltaTurns = Math.floor(this._currentSimulationStep / MAX_SIMULATION_STEPS)
185188
if (this._currentSimulationStep >= MAX_SIMULATION_STEPS) {
186-
this._stepTurn(1)
189+
this._stepTurn(deltaTurns)
187190
this._currentSimulationStep = 0
188191
} else if (this._currentSimulationStep < 0) {
189-
this._stepTurn(-1)
192+
this._stepTurn(deltaTurns)
190193
this._currentSimulationStep = MAX_SIMULATION_STEPS - 1
191194
}
192195
} else {
@@ -230,6 +233,8 @@ export default class Match {
230233
}
231234

232235
private _updateSimulationRoundsByTime(deltaTime: number): void {
236+
// This works because of the way floor works
237+
const deltaRounds = Math.floor(this._currentSimulationStep / MAX_SIMULATION_STEPS)
233238
if (this.currentRound.roundNumber == this.maxRound && deltaTime > 0) {
234239
// If we are at the end, round the simulation to the max value
235240
this._currentSimulationStep = Math.min(this._currentSimulationStep, MAX_SIMULATION_STEPS)
@@ -239,12 +244,12 @@ export default class Match {
239244
} else if (this._currentSimulationStep < 0) {
240245
// If we are going in reverse, step the rounds back by one. Also,
241246
// apply all turns for that round so that the transition is smooth
242-
this._stepRound(-1)
247+
this._stepRound(deltaRounds)
243248
this.currentRound.jumpToTurn(this.currentRound.turnsLength)
244249
this._currentSimulationStep = MAX_SIMULATION_STEPS - 1
245250
} else if (this._currentSimulationStep >= MAX_SIMULATION_STEPS) {
246251
// If we are going forward, simply step the turn
247-
this._stepRound(1)
252+
this._stepRound(deltaRounds)
248253
}
249254
}
250255

engine/src/main/battlecode/common/GameConstants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ public class GameConstants {
120120
public static final int EXTRA_RESOURCES_FROM_PATTERN = 3;
121121

122122
/** The extra damage all ally towers get for each level 1 defense tower */
123-
public static final int EXTRA_DAMAGE_FROM_DEFENSE_TOWER = 10;
123+
public static final int EXTRA_DAMAGE_FROM_DEFENSE_TOWER = 5;
124124

125125
/** The increase in extra damage for ally towers for upgrading a defense tower */
126-
public static final int EXTRA_TOWER_DAMAGE_LEVEL_INCREASE = 5;
126+
public static final int EXTRA_TOWER_DAMAGE_LEVEL_INCREASE = 2;
127127

128128
/** The percent of the defense tower damage buff that is applied to AoE attacks */
129-
public static final int DEFENSE_ATTACK_BUFF_AOE_EFFECTIVENESS = 50;
129+
public static final int DEFENSE_ATTACK_BUFF_AOE_EFFECTIVENESS = 0;
130130

131131
/** Maximum amount of turns a robot can go at 0 paint without dying */
132132
public static final int MAX_TURNS_WITHOUT_PAINT = 10;

engine/src/main/battlecode/common/PaintType.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ public boolean isAlly() {
1111
return this == ALLY_PRIMARY || this == ALLY_SECONDARY;
1212
}
1313

14+
public boolean isEnemy(){
15+
return this == ENEMY_PRIMARY || this == ENEMY_SECONDARY;
16+
}
17+
1418
public boolean isSecondary() {
1519
return this == ALLY_SECONDARY || this == ENEMY_SECONDARY;
1620
}

engine/src/main/battlecode/common/RobotController.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,16 @@ public interface RobotController {
685685
// ***** ATTACK / HEAL ********
686686
// ****************************
687687

688+
/**
689+
* Tests whether this robot can paint the given location.
690+
*
691+
* @param loc target location to paint
692+
* @return true if rc.attack(loc) will paint the given location
693+
*
694+
* @battlecode.doc.costlymethod
695+
*/
696+
boolean canPaint(MapLocation loc);
697+
688698
/**
689699
* Tests whether this robot can attack the given location. Types of
690700
* attacks for specific units determine whether or not towers, other
@@ -866,6 +876,7 @@ public interface RobotController {
866876
* @param red the red component of the dot's color
867877
* @param green the green component of the dot's color
868878
* @param blue the blue component of the dot's color
879+
* @throws GameActionException if the location is off the map
869880
*
870881
* @battlecode.doc.costlymethod
871882
*/
@@ -879,6 +890,7 @@ public interface RobotController {
879890
* @param red the red component of the line's color
880891
* @param green the green component of the line's color
881892
* @param blue the blue component of the line's color
893+
* @throws GameActionException if any location is off the map
882894
*
883895
* @battlecode.doc.costlymethod
884896
*/

0 commit comments

Comments
 (0)