Skip to content

Commit 9996d65

Browse files
Merge branch 'schema'
2 parents 04f7814 + 255afb5 commit 9996d65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+824
-815
lines changed

.github/workflows/release-client.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ jobs:
108108
# the same result
109109
- name: Upload dist files artifact
110110
if: matrix.upload-dist
111-
uses: actions/upload-artifact@v3
111+
uses: actions/upload-artifact@v4
112112
with:
113113
name: client-dist
114114
path: ./client/dist
115115

116116
- name: Upload client artifact
117-
uses: actions/upload-artifact@v3
117+
uses: actions/upload-artifact@v4
118118
with:
119119
name: client-${{ matrix.build-name }}
120120
path: |
@@ -157,14 +157,14 @@ jobs:
157157
distribution: adopt
158158

159159
- name: Download all client artifacts
160-
uses: actions/download-artifact@v3
160+
uses: actions/download-artifact@v4
161161
with:
162162
path: ./client/artifacts
163163

164164
# Always cleanup even if other commands failed so we don't unnecessarily store
165165
# the artifacts in the cloud
166166
- name: Cleanup client artifacts
167-
uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af
167+
uses: geekyeggo/delete-artifact@v5
168168
if: always()
169169
with:
170170
name: client-*

client/src/colors.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ export const Sections = {
7676
export const Colors = {
7777
GAMEAREA_BACKGROUND: new Color(
7878
'GAMEAREA_BACKGROUND',
79-
'#2e2323',
79+
'#4f345a',
8080
'--color-gamearea-background',
8181
'Background',
8282
Sections.INTERFACE
8383
),
8484
SIDEBAR_BACKGROUND: new Color(
8585
'SIDEBAR_BACKGROUND',
86-
'#3f3131',
86+
'#40284b',
8787
'--color-sidebar-background',
8888
'Sidebar',
8989
Sections.INTERFACE
@@ -116,9 +116,9 @@ export const Colors = {
116116
),
117117
LIGHT_CARD: new Color('LIGHT_CARD', '#f7f7f722', '--color-light-card', 'Light Card', Sections.INTERFACE),
118118

119-
WALLS_COLOR: new Color('WALLS_COLOR', '#547f31', '--color-walls', 'Walls', Sections.GENERAL),
120-
DIRT_COLOR: new Color('DIRT_COLOR', '#991111', '--color-dirt', 'Dirt', Sections.GENERAL),
121-
TILES_COLOR: new Color('TILES_COLOR', '#4c301e', '--color-tile', 'Tiles', Sections.GENERAL),
119+
WALLS_COLOR: new Color('WALLS_COLOR', '#52485a', '--color-walls', 'Walls', Sections.GENERAL),
120+
DIRT_COLOR: new Color('DIRT_COLOR', '#3b2931', '--color-dirt', 'Dirt', Sections.GENERAL),
121+
TILES_COLOR: new Color('TILES_COLOR', '#221725', '--color-tile', 'Tiles', Sections.GENERAL),
122122

123123
TEAM_ONE: new Color('TEAM_ONE', '#fcc00d', '--color-team0', 'Text', Sections.CHEDDAR),
124124

@@ -131,8 +131,8 @@ export const Presets: ColorPreset[] = [
131131
data: {
132132
version: 0,
133133
colors: {
134-
GAMEAREA_BACKGROUND: '#2e2323',
135-
SIDEBAR_BACKGROUND: '#3f3131',
134+
GAMEAREA_BACKGROUND: '#4f345a',
135+
SIDEBAR_BACKGROUND: '#40284b',
136136
RED: '#ff9194',
137137
PINK: '#ffb4c1',
138138
GREEN: '#00a28e',
@@ -148,8 +148,8 @@ export const Presets: ColorPreset[] = [
148148
LIGHT: '#aaaaaa22',
149149
LIGHT_HIGHLIGHT: '#ffffff33',
150150
LIGHT_CARD: '#f7f7f722',
151-
WALLS_COLOR: '#547f31',
152-
TILES_COLOR: '#4c301e',
151+
WALLS_COLOR: '#52485A',
152+
TILES_COLOR: '#221725',
153153
TEAM_ONE: '#fcc00d',
154154
TEAM_TWO: '#c91c7e'
155155
}

client/src/constants.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ export const DIRECTIONS: Record<number, Array<number>> = {
2323

2424
export const ENGINE_BUILTIN_MAP_NAMES: string[] = [
2525
// Default
26-
//'DefaultSmall',
27-
//'DefaultMedium',
28-
//'DefaultLarge',
29-
//'DefaultHuge',
26+
'DefaultSmall',
27+
'DefaultMedium',
28+
'DefaultLarge'
3029
// Sprint 1
3130
// Sprint 2
3231
// HS

client/src/playback/Actions.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
118118
const fontY =
119119
coords.y - (2 + 4 * random2) * interpolationFactor + 8 * interpolationFactor * interpolationFactor - 0.5
120120
ctx.fillText('nom', fontX, fontY)
121-
src.imgPath = 'robots/cat/cat_feed.png' // is reset in `finish`.
121+
src.imgPath = `robots/cat/cat_feed_${src.direction}.png`// is reset in `finish`.
122122
ctx.restore()
123123
}
124124

@@ -344,6 +344,12 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
344344
}
345345
ctx.stroke()
346346
ctx.globalAlpha = 1
347+
body.imgPath = `robots/cat/cat_scratch_${body.direction}.png`
348+
}
349+
350+
finish(round: Round): void {
351+
const body = round.bodies.getById(this.robotId)
352+
body.imgPath = 'robots/cat/cat.png'
347353
}
348354
},
349355
[schema.Action.CatPounce]: class CatPounceAction extends Action<schema.CatPounce> {

client/src/playback/Brushes.ts

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,15 @@ export class WallsBrush extends SymmetricMapEditorBrush<StaticMap> {
317317
const cheeseMine = this.map.cheeseMines.findIndex((l) => squareIntersects(l, pos, 2))
318318
const dirt = this.map.initialDirt[idx]
319319

320+
for (const waypoints of this.map.catWaypoints.values()) {
321+
for (const waypoint of waypoints) {
322+
if (waypoint.x === pos.x && waypoint.y === pos.y) return true
323+
for (let nei of this.map.getNeighbors(waypoint.x, waypoint.y)) {
324+
if (nei.x === pos.x && nei.y === pos.y) return true
325+
}
326+
}
327+
}
328+
320329
if (cheeseMine !== -1 || dirt) return true
321330

322331
this.map.walls[idx] = 1
@@ -476,11 +485,13 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
476485
public symmetricApply(x: number, y: number, fields: Record<string, MapEditorBrushField>, robotOne: boolean) {
477486
const isCat: boolean = fields.isCat.value
478487
const selectedBodyID = GameRenderer.getSelectedRobot()
488+
let lastSelectedCatLoc: Vector | null = null
479489

480490
if (selectedBodyID !== null && selectedBodyID !== undefined) {
481491
const body = this.bodies.bodies.get(selectedBodyID)
482492
if (body && body.robotType === schema.RobotType.CAT) {
483493
this.lastSelectedCat = selectedBodyID
494+
lastSelectedCatLoc = this.bodies.getById(this.lastSelectedCat)?.pos
484495
}
485496
}
486497

@@ -491,6 +502,7 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
491502
if (!robotOne) {
492503
const symmetricPoint = this.map.applySymmetryCat(this.bodies.getById(this.lastSelectedCat)!.pos)
493504
currentCat = this.bodies.getBodyAtLocation(symmetricPoint.x, symmetricPoint.y)!.id
505+
lastSelectedCatLoc = this.map.applySymmetry(lastSelectedCatLoc!)
494506
}
495507

496508
// if undoing a waypoint addition
@@ -518,6 +530,9 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
518530
return null
519531
}
520532

533+
if (!this.map.catWaypoints.has(currentCat)) {
534+
this.map.catWaypoints.set(currentCat, [lastSelectedCatLoc!])
535+
}
521536
this.map.catWaypoints.get(currentCat)?.push({ x, y })
522537

523538
return () => {
@@ -535,7 +550,6 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
535550

536551
const id = this.bodies.getNextID()
537552
this.bodies.spawnBodyFromValues(id, schema.RobotType.CAT, team, pos, 0, robotOne ? 0 : 1)
538-
this.map.catWaypoints.set(id, [{ x: x, y: y }]) // add initial waypoint at spawn location
539553

540554
return id
541555
}
@@ -546,23 +560,27 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
546560
if (!body) return null
547561

548562
const team = body.team
563+
const pos = body.pos
549564
this.bodies.removeBody(body.id)
550565
const waypoints = this.map.catWaypoints.get(body.id)
551566
this.map.catWaypoints.delete(body.id)
552567

553-
return { team, waypoints }
568+
return { team, waypoints, pos }
554569
}
555-
556570
if (isCat) {
557571
// shouldnt matter which team we add to since cats are neutral
558572
const id = add(x, y, this.bodies.game.teams[0])
559573
if (id) return () => this.bodies.removeBody(id)
560574
return null
561575
} else {
562-
const { team, waypoints } = remove(x, y)!
576+
const removed = remove(x, y)
577+
if (!removed) return null
578+
579+
const { team, waypoints, pos } = removed
563580
if (!team) return null
581+
564582
return () => {
565-
add(x, y, team)
583+
add(pos.x, pos.y, team)
566584
if (waypoints) {
567585
this.map.catWaypoints.set(this.bodies.getBodyAtLocation(x, y)!.id, waypoints)
568586
}
@@ -573,14 +591,23 @@ export class CatBrush extends SymmetricMapEditorBrush<StaticMap> {
573591
// Override default symmetric apply behavior because cats occupy a 2x2 footprint
574592
public apply(x: number, y: number, fields: Record<string, MapEditorBrushField>, robotOne: boolean): UndoFunction {
575593
const undoFunctions: UndoFunction[] = []
594+
595+
const body = this.bodies.getBodyAtLocation(x, y)
596+
const anchor = body?.pos
597+
576598
const undo0 = this.symmetricApply(x, y, fields, robotOne)
577599

578600
// Return early if brush could not be applied
579601
if (!undo0) return () => {}
580602

581603
undoFunctions.push(undo0)
582604

583-
const symmetryPoint = this.map.applySymmetryCat({ x: x, y: y })
605+
let symmetryPoint: { x: number; y: number }
606+
if (fields.catOrWaypointMode.value === 1) {
607+
symmetryPoint = this.map.applySymmetry({ x: x, y: y })
608+
} else {
609+
symmetryPoint = !anchor ? this.map.applySymmetryCat({ x: x, y: y }) : this.map.applySymmetryCat(anchor)
610+
}
584611
if (symmetryPoint.x != x || symmetryPoint.y != y) {
585612
const undo1 = this.symmetricApply(symmetryPoint.x, symmetryPoint.y, fields, !robotOne)
586613

client/src/playback/Map.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ export class CurrentMap {
261261
ctx.fill()
262262
})
263263
waypoints?.forEach((waypoint, idx) => {
264-
let prevWaypoint = bodies.getById(selectedBodyID).pos
265-
if (idx > 0) {
264+
let prevWaypoint = waypoints[0]
265+
if (idx > 1) {
266266
prevWaypoint = waypoints[idx - 1]
267267
}
268268
const startCoords = renderUtils.getRenderCoords(prevWaypoint.x, prevWaypoint.y, this.dimension)
@@ -562,17 +562,6 @@ export class StaticMap {
562562
this.dimension.height
563563
)
564564

565-
const dirtImg = getImageIfLoaded('dirty.png')
566-
if (dirtImg) {
567-
ctx.drawImage(
568-
dirtImg,
569-
this.dimension.minCorner.x,
570-
this.dimension.minCorner.y,
571-
this.dimension.width,
572-
this.dimension.height
573-
)
574-
}
575-
576565
for (let i = 0; i < this.dimension.width; i++) {
577566
for (let j = 0; j < this.dimension.height; j++) {
578567
const schemaIdx = this.locationToIndexUnchecked(i, j)

client/src/playback/RoundStat.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default class RoundStat {
7676
let totalCatDamage = 0
7777
let totalRatKings = 0
7878
for (let i = 0; i < delta.teamIdsLength(); i++) {
79-
totalCheese += delta.teamCheeseAmounts(i)!
79+
totalCheese += delta.teamCheeseTransferred(i)!
8080
totalCatDamage += delta.teamCatDamage(i)!
8181
totalRatKings += delta.teamAliveRatKings(i)!
8282
}
@@ -86,12 +86,12 @@ export default class RoundStat {
8686
assert(team != undefined, `team ${i} not found in game.teams in round`)
8787
const teamStat = this.teams.get(team) ?? assert.fail(`team ${i} not found in team stats in round`)
8888

89-
teamStat.cheeseAmount = delta.teamCollectedCheeseAmounts(i) ?? assert.fail('missing cheese amount')
89+
teamStat.cheeseAmount = delta.teamCheeseTransferred(i) ?? assert.fail('missing cheese amount')
9090
teamStat.cheesePercent = teamStat.cheeseAmount / totalCheese
9191
teamStat.catDamageAmount = delta.teamCatDamage(i) ?? assert.fail('missing cat damage amount')
92-
teamStat.catDamagePercent = teamStat.catDamageAmount / totalCatDamage
92+
teamStat.catDamagePercent = totalCatDamage ? teamStat.catDamageAmount / totalCatDamage : 0
9393
teamStat.ratKingCount = delta.teamAliveRatKings(i) ?? assert.fail('missing rat king count')
94-
teamStat.ratKingPercent = teamStat.ratKingCount / totalRatKings
94+
teamStat.ratKingPercent = totalRatKings ? teamStat.ratKingCount / totalRatKings : 0
9595
teamStat.dirtAmount = delta.teamDirtAmounts(i) ?? assert.fail('missing dirt amount')
9696
teamStat.ratTrapAmount = delta.teamRatTrapCount(i) ?? assert.fail('missing rat trap amount')
9797
teamStat.catTrapAmount = delta.teamCatTrapCount(i) ?? assert.fail('missing cat trap amount')
350 KB
Loading
-283 KB
Loading
660 KB
Loading

0 commit comments

Comments
 (0)