@@ -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
0 commit comments