@@ -103,7 +103,6 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
103103 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
104104 // chomping animation
105105 const src = match . currentRound . bodies . getById ( this . robotId ) // cat
106- if ( ! src ) return
107106 // const target = match.currentRound.bodies.getById(this.actionData.id()) // rat being eaten
108107 const coords = renderUtils . getRenderCoords ( src . pos . x , src . pos . y , match . map . dimension , true )
109108 const random1 = ( ( src . pos . x * 491 + src . pos . y * 603 + match . currentRound . roundNumber * 343 ) / 100 ) % 1 // https://xkcd.com/221/
@@ -193,8 +192,6 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
193192 const src = round . bodies . getById ( this . robotId )
194193 const target = round . bodies . getById ( this . actionData . id ( ) ) // rat getting napped
195194
196- if ( ! target ) return
197-
198195 if ( target . beingCarried ) {
199196 // drop the target
200197 const carrier = round . bodies . getById ( target . carrierRobot ! )
@@ -216,10 +213,7 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
216213 }
217214 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
218215 //target rat moves onto src rat, circle around carried group thing
219- const src = match . currentRound . bodies . getById ( this . robotId )
220-
221- if ( ! src ) return
222-
216+ const src = match . currentRound . bodies . getById ( this . robotId )
223217 const srcCoords = renderUtils . getRenderCoords ( src . pos . x , src . pos . y , match . map . dimension , true )
224218 const t = match . getInterpolationFactor ( )
225219 const bump = Math . sin ( t * Math . PI * 8 ) * 0.03
@@ -316,7 +310,6 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
316310 apply ( round : Round ) : void {
317311 // remove cheese from map and increment body cheese count
318312 const body = round . bodies . getById ( this . robotId )
319- if ( ! body ) return
320313 const amt = round . map . cheeseData [ this . actionData . loc ( ) ]
321314 round . map . cheeseData [ this . actionData . loc ( ) ] = 0
322315 body . cheese += amt
@@ -325,7 +318,6 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
325318 // cheese pickup animation
326319 const map = match . currentRound . map
327320 const body = match . currentRound . bodies . getById ( this . robotId )
328- if ( ! body ) return
329321 const coords = renderUtils . getRenderCoords ( body . pos . x , body . pos . y , map . dimension , false )
330322 const factor = match . getInterpolationFactor ( )
331323 const isEndpoint = factor == 0 || factor == 1
@@ -438,15 +430,13 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
438430 apply ( round : Round ) : void {
439431 // maybe move cat to target loc
440432 const body = round . bodies . getById ( this . robotId )
441- if ( ! body ) return
442433 const startPos = round . map . indexToLocation ( this . actionData . startLoc ( ) )
443434 const endPos = round . map . indexToLocation ( this . actionData . endLoc ( ) )
444435 console . log ( 'pounce from' , startPos , 'to' , endPos )
445436 }
446437 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
447438 // cat pouncing animation
448439 const body = match . currentRound . bodies . getById ( this . robotId )
449- if ( ! body ) return
450440 const startPos = match . map . indexToLocation ( this . actionData . startLoc ( ) )
451441 const endPos = match . map . indexToLocation ( this . actionData . endLoc ( ) )
452442 const startCoords = renderUtils . getRenderCoords ( startPos . x , startPos . y , match . map . dimension , true )
@@ -477,7 +467,6 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
477467 }
478468 finish ( round : Round ) : void {
479469 const body = round . bodies . getById ( this . robotId )
480- if ( ! body ) return
481470 body . textureOverride = false
482471 }
483472 } ,
@@ -532,7 +521,6 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
532521 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
533522 // trap triggering animation
534523 const body = match . currentRound . bodies . getById ( this . robotId )
535- if ( ! body ) return
536524 // const pos = match.map.indexToLocation(this.actionData.loc())
537525 const pos = body . getInterpolatedCoords ( match )
538526 const coords = renderUtils . getRenderCoords ( pos . x , pos . y , match . map . dimension , true )
@@ -579,7 +567,6 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
579567 apply ( round : Round ) : void {
580568 // maybe move rat to target loc
581569 const body = round . bodies . getById ( this . robotId )
582- if ( ! body ) return
583570 const endLoc = round . map . indexToLocation ( this . actionData . loc ( ) )
584571 if ( body . carriedRobot !== undefined ) {
585572 const carrier = round . bodies . getById ( body . carriedRobot )
@@ -588,18 +575,17 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
588575 body . carrierRobot = undefined
589576 body . beingCarried = false
590577 body . size = 1
591- body . pos = { ...endLoc }
578+ // body.pos = { ...endLoc }
592579 }
593580 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
594581 const body = match . currentRound . bodies . getById ( this . robotId )
595- if ( ! body ) return
596582 const pos = body . getInterpolatedCoords ( match )
597583 const coords = renderUtils . getRenderCoords ( pos . x , pos . y , match . map . dimension , true )
598584 const interp = match . getInterpolationFactor ( )
599585
600586 const from = pos
601587 const to = match . currentRound . map . indexToLocation ( this . actionData . loc ( ) )
602- console . log ( 'throw from' , from , 'to' , to )
588+
603589 const dx = to . x - from . x
604590 const dy = to . y - from . y
605591 const mag = Math . hypot ( dx , dy )
@@ -646,12 +632,10 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
646632 apply ( round : Round ) : void {
647633 // promote body in-place to RatKing while preserving ID/state
648634 const body = round . bodies . getById ( this . robotId )
649- if ( ! body ) return
650635 body . promoteTo ( schema . RobotType . RAT_KING )
651636 }
652637 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
653638 const body = match . currentRound . bodies . getById ( this . robotId )
654- if ( ! body ) return
655639 const pos = body . getInterpolatedCoords ( match )
656640 const coords = renderUtils . getRenderCoords ( pos . x , pos . y , match . map . dimension , true )
657641
@@ -700,7 +684,6 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
700684
701685 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
702686 const body = match . currentRound . bodies . getById ( this . robotId )
703- if ( ! body ) return
704687 const renderCoords = renderUtils . getRenderCoords (
705688 body . pos . x ,
706689 body . pos . y ,
0 commit comments