Skip to content

Commit f1b4652

Browse files
Merge remote-tracking branch 'origin/schema'
2 parents 50bf1e3 + cfad42c commit f1b4652

File tree

7 files changed

+36
-12
lines changed

7 files changed

+36
-12
lines changed

client/src/playback/Actions.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,11 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
393393
// add a trap to map
394394
const body = round.bodies.getById(this.robotId)
395395

396-
round.map.trapData[this.actionData.loc()] = 1 + body.team.id // 1 for team 0, 2 for team 1
396+
if (this.actionData.isRatTrapType()) {
397+
round.map.ratTrapData[this.actionData.loc()] = 1 + body.team.id // 1 for team 0, 2 for team 1
398+
} else {
399+
round.map.catTrapData[this.actionData.loc()] = 1 + body.team.id // 1 for team 0, 2 for team 1
400+
}
397401
}
398402
draw(match: Match, ctx: CanvasRenderingContext2D): void {
399403
// place trap animation
@@ -403,11 +407,17 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
403407
const isEndpoint = factor == 0 || factor == 1
404408
const size = isEndpoint ? 1 : Math.max(factor * 1.5, 0.3)
405409
const alpha = isEndpoint ? 1 : (factor < 0.5 ? factor : 1 - factor) * 2
410+
let imgPath: string
411+
if (this.actionData.isRatTrapType()) {
412+
imgPath = 'icons/rat_trap.png'
413+
} else {
414+
imgPath = 'icons/cat_trap.png'
415+
}
406416

407417
ctx.globalAlpha = alpha
408418
ctx.shadowBlur = 4
409419
ctx.shadowColor = 'black'
410-
renderUtils.renderCenteredImageOrLoadingIndicator(ctx, getImageIfLoaded('icons/trap.png'), coords, size)
420+
renderUtils.renderCenteredImageOrLoadingIndicator(ctx, getImageIfLoaded(imgPath), coords, size)
411421
ctx.shadowBlur = 0
412422
ctx.shadowColor = ''
413423
ctx.globalAlpha = 1
@@ -416,13 +426,15 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
416426
[schema.Action.RemoveTrap]: class RemoveTrapAction extends Action<schema.RemoveTrap> {
417427
apply(round: Round): void {
418428
// remove a trap from map
419-
round.map.trapData[this.actionData.loc()] = 0
429+
round.map.ratTrapData[this.actionData.loc()] = 0
430+
round.map.catTrapData[this.actionData.loc()] = 0
420431
}
421432
},
422433
[schema.Action.TriggerTrap]: class TriggerTrapAction extends Action<schema.TriggerTrap> {
423434
apply(round: Round): void {
424435
// remove trap from map
425-
round.map.trapData[this.actionData.loc()] = 0 // remove trap
436+
round.map.ratTrapData[this.actionData.loc()] = 0 // remove trap
437+
round.map.catTrapData[this.actionData.loc()] = 0 // remove trap
426438
}
427439
draw(match: Match, ctx: CanvasRenderingContext2D): void {
428440
// trap triggering animation

client/src/playback/Bodies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ export class Body {
660660
`${this.robotType === schema.RobotType.RAT ? 'Cheese: ' + this.cheese : ''}`,
661661
`Move Cooldown: ${this.moveCooldown}`,
662662
`Action Cooldown: ${this.actionCooldown}`,
663-
`Turning Cooldown: ${this.turningCooldown}`,
663+
`${this.robotType !== schema.RobotType.CAT ? 'Turning Cooldown: ' + this.turningCooldown : ''}`,
664664
`Bytecodes Used: ${this.bytecodesUsed}${
665665
this.bytecodesUsed >= this.metadata.bytecodeLimit() ? ' <EXCEEDED!>' : ''
666666
}`

client/src/playback/Brushes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const makeEditorActionData = (
131131
case schema.Action.DieAction:
132132
return { id: () => targetId, dieType: () => 0 }
133133
case schema.Action.PlaceTrap:
134-
return { loc: () => loc, team: () => 0 }
134+
return { isRatTrapType: () => true, loc: () => loc, team: () => 0 }
135135
case schema.Action.PlaceDirt:
136136
return { loc: () => loc }
137137
case schema.Action.RatAttack:

client/src/playback/Map.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export class CurrentMap {
3939
public readonly staticMap: StaticMap
4040
public readonly dirt: Int8Array
4141
public readonly markers: [Int8Array, Int8Array] // Each team has markers
42-
public readonly trapData: Int8Array
42+
public readonly ratTrapData: Int8Array
43+
public readonly catTrapData: Int8Array
4344
public readonly cheeseData: Int8Array
4445
public readonly resourcePatterns: ResourcePatternData[]
4546

@@ -62,7 +63,8 @@ export class CurrentMap {
6263
this.cheeseData = new Int8Array(from.cheese)
6364
this.markers = [new Int8Array(this.width * this.height), new Int8Array(this.width * this.height)]
6465
this.resourcePatterns = []
65-
this.trapData = new Int8Array(this.width * this.height)
66+
this.ratTrapData = new Int8Array(this.width * this.height)
67+
this.catTrapData = new Int8Array(this.width * this.height)
6668
} else {
6769
// Create current map from current map (copy)
6870

@@ -73,7 +75,8 @@ export class CurrentMap {
7375

7476
// Assumes ResourcePatternData is immutable
7577
this.resourcePatterns = [...from.resourcePatterns]
76-
this.trapData = new Int8Array(from.trapData)
78+
this.ratTrapData = new Int8Array(from.ratTrapData)
79+
this.catTrapData = new Int8Array(from.catTrapData)
7780
}
7881
}
7982

@@ -173,11 +176,20 @@ export class CurrentMap {
173176
)
174177
}
175178

176-
const trap = this.trapData[schemaIdx]
177-
if (trap) {
179+
const ratTrap = this.ratTrapData[schemaIdx]
180+
if (ratTrap) {
178181
renderUtils.renderCenteredImageOrLoadingIndicator(
179182
ctx,
180-
getImageIfLoaded('icons/trap.png'),
183+
getImageIfLoaded('icons/rat_trap.png'),
184+
coords,
185+
1.0
186+
)
187+
}
188+
const catTrap = this.catTrapData[schemaIdx]
189+
if (catTrap) {
190+
renderUtils.renderCenteredImageOrLoadingIndicator(
191+
ctx,
192+
getImageIfLoaded('icons/cat_trap.png'),
181193
coords,
182194
1.0
183195
)
79.4 KB
Loading
17.8 KB
Loading

0 commit comments

Comments
 (0)