@@ -26,6 +26,7 @@ export class Game {
2626 #dropItems = { } ;
2727 #throwables = { } ;
2828 #roundIntervalIds = [ ] ;
29+ #roundDamage = { did : { } , got : { } }
2930 #playerSlotsVisibleModels = [
3031 InventorySlot . SLOT_KNIFE , InventorySlot . SLOT_PRIMARY , InventorySlot . SLOT_SECONDARY ,
3132 InventorySlot . SLOT_BOMB , InventorySlot . SLOT_GRENADE_DECOY , InventorySlot . SLOT_GRENADE_MOLOTOV ,
@@ -93,6 +94,8 @@ export class Game {
9394 unpause ( ) {
9495 this . #paused = false
9596 this . #hud. clearTopMessage ( )
97+ this . #hud. updateRoundDamage ( null )
98+ this . #roundDamage = { did : { } , got : { } }
9699 console . log ( "Game unpause" )
97100 }
98101
@@ -119,6 +122,7 @@ export class Game {
119122 this . #round = newRoundNumber
120123 this . #hud. displayTopMessage ( winner + ' wins' )
121124 this . #hud. requestFullScoreBoardUpdate ( this . score )
125+ this . #hud. updateRoundDamage ( this . #roundDamage, this . getEnemyPlayers ( ) )
122126 }
123127
124128 halfTime ( ) {
@@ -130,7 +134,8 @@ export class Game {
130134 }
131135
132136 playerHit ( data , wasHeadshot ) {
133- if ( data . player === this . playerSpectate . getId ( ) ) {
137+ const playerHitId = data . player
138+ if ( playerHitId === this . playerSpectate . getId ( ) ) {
134139 const anglePlayer = Math . round ( this . getPlayerSpectateRotation ( ) [ 0 ] )
135140 const camera = this . #world. getCamera ( )
136141
@@ -155,6 +160,21 @@ export class Game {
155160 } else {
156161 this . #world. bulletPlayerHit ( data . position , wasHeadshot )
157162 }
163+
164+ const damage = data . extra . damage
165+ const myId = this . playerMe . getId ( )
166+ const attackerId = data . extra . shooter
167+ if ( playerHitId === myId ) {
168+ if ( ! this . #roundDamage. got [ attackerId ] ) {
169+ this . #roundDamage. got [ attackerId ] = [ ]
170+ }
171+ this . #roundDamage. got [ attackerId ] . push ( damage )
172+ } else if ( attackerId === myId ) {
173+ if ( ! this . #roundDamage. did [ playerHitId ] ) {
174+ this . #roundDamage. did [ playerHitId ] = [ ]
175+ }
176+ this . #roundDamage. did [ playerHitId ] . push ( damage )
177+ }
158178 }
159179
160180 processSound ( data ) {
@@ -573,6 +593,11 @@ export class Game {
573593 return this . players . filter ( ( player ) => player . isAttacker ( ) === meIsAttacker )
574594 }
575595
596+ getEnemyPlayers ( ) {
597+ let meIsAttacker = this . playerMe . isAttacker ( )
598+ return this . players . filter ( ( player ) => player . isAttacker ( ) !== meIsAttacker )
599+ }
600+
576601 meIsAlive ( ) {
577602 return this . playerMe . isAlive ( )
578603 }
0 commit comments