@@ -183,15 +183,40 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
183183 }
184184 } ,
185185 [ schema . Action . RatNap ] : class RatNapAction extends Action < schema . RatNap > {
186+ private static readonly OFFSET = { x : - 0.35 , y : 0 }
186187 apply ( round : Round ) : void {
187188 // move the target onto the source adjust target's size using scale factor
188189 const src = round . bodies . getById ( this . robotId )
189190 const target = round . bodies . getById ( this . actionData . id ( ) ) // rat getting napped
191+
192+ target . lastPos = { ...target . pos }
193+ target . pos = { x : src . pos . x + RatNapAction . OFFSET . x , y : src . pos . y + RatNapAction . OFFSET . y }
194+ target . size = 0.6
190195 }
191196 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
192197 //target rat moves onto src rat, circle around carried group thing
193- const src = match . currentRound . bodies . getById ( this . robotId )
194- const target = match . currentRound . bodies . getById ( this . actionData . id ( ) ) // rat getting napped
198+ const src = match . currentRound . bodies . getById ( this . robotId )
199+ const srcCoords = renderUtils . getRenderCoords ( src . pos . x , src . pos . y , match . map . dimension , true )
200+ const t = match . getInterpolationFactor ( )
201+ const bump = Math . sin ( t * Math . PI * 8 ) * 0.03
202+ const half = 0.5 + bump
203+ const radius = 0.08 // corner radius
204+
205+ ctx . save ( )
206+ ctx . shadowBlur = 12
207+ ctx . shadowColor = src . team . color
208+ ctx . strokeStyle = src . team . color
209+ ctx . globalAlpha = 0.7
210+ ctx . lineWidth = 0.04
211+ ctx . beginPath ( )
212+ ctx . moveTo ( srcCoords . x - half + radius , srcCoords . y - half )
213+ ctx . arcTo ( srcCoords . x + half , srcCoords . y - half , srcCoords . x + half , srcCoords . y + half , radius )
214+ ctx . arcTo ( srcCoords . x + half , srcCoords . y + half , srcCoords . x - half , srcCoords . y + half , radius )
215+ ctx . arcTo ( srcCoords . x - half , srcCoords . y + half , srcCoords . x - half , srcCoords . y - half , radius )
216+ ctx . arcTo ( srcCoords . x - half , srcCoords . y - half , srcCoords . x + half , srcCoords . y - half , radius )
217+ ctx . stroke ( )
218+ ctx . restore ( )
219+ ctx . restore ( )
195220 }
196221 } ,
197222 [ schema . Action . RatCollision ] : class RatCollisionAction extends Action < schema . RatCollision > {
@@ -200,6 +225,33 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
200225 const src = match . currentRound . bodies . getById ( this . robotId )
201226 const pos = match . map . indexToLocation ( this . actionData . loc ( ) )
202227 const coords = renderUtils . getRenderCoords ( pos . x , pos . y , match . map . dimension , true )
228+ const t = match . getInterpolationFactor ( )
229+
230+ ctx . save ( )
231+ // dusty base color that fills the cell and fades out
232+ const baseAlpha = 0.4 * ( 1 - t )
233+ ctx . fillStyle = `rgba(150,130,110,${ baseAlpha } )`
234+ ctx . fillRect ( coords . x - 0.5 , coords . y - 0.5 , 1 , 1 )
235+
236+ // these are the random rocks that fill the cell
237+ const rockCount = 10
238+ for ( let i = 0 ; i < rockCount ; i ++ ) {
239+ const rx = coords . x - 0.5 + Math . random ( ) * 1
240+ const ry = coords . y - 0.5 + Math . random ( ) * 1
241+ const size = 0.08 + Math . random ( ) * 0.15
242+ const shade = 90 + Math . floor ( Math . random ( ) * 50 )
243+ const alpha = 0.7 * ( 1 - t )
244+ ctx . fillStyle = `rgba(${ shade } ,${ shade - 10 } ,${ shade - 20 } ,${ alpha } )`
245+ ctx . fillRect ( rx , ry , size , size )
246+ }
247+
248+ // ring outside the cell (also fades out)
249+ ctx . strokeStyle = src . team . color
250+ ctx . globalAlpha = 0.35 * ( 1 - t )
251+ ctx . lineWidth = 0.04
252+ ctx . strokeRect ( coords . x - 0.5 , coords . y - 0.5 , 1 , 1 )
253+ ctx . restore ( )
254+
203255 }
204256 } ,
205257 [ schema . Action . PlaceDirt ] : class PlaceDirtAction extends Action < schema . PlaceDirt > {
@@ -284,8 +336,8 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
284336 const target = round . bodies . getById ( this . actionData . id ( ) )
285337 const amount = this . actionData . amount ( )
286338
287- body . cheese -= amount
288- target . cheese += amount
339+ body . cheese -= Math . min ( body . cheese , amount )
340+ target . cheese += Math . min ( body . cheese , amount )
289341 }
290342 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
291343 const srcBody = match . currentRound . bodies . getById ( this . robotId )
0 commit comments