File tree 6 files changed +24
-2
lines changed
6 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 32
32
"Minus" : false ,
33
33
"Modulus" : false ,
34
34
"Multiplication" : false ,
35
+ "NullSafeMethodCall" : false ,
35
36
"Plus" : false ,
36
37
"RoundingFamily" : false ,
37
38
"TrueValue" : false ,
Original file line number Diff line number Diff line change @@ -87,6 +87,11 @@ public function getEquipped(): Item
87
87
return $ this ->items [$ this ->equippedSlot ];
88
88
}
89
89
90
+ public function getItemSlot (InventorySlot $ slot ): ?Item
91
+ {
92
+ return ($ this ->items [$ slot ->value ] ?? null );
93
+ }
94
+
90
95
private function tryRemoveLastEquippedGrenade (Item $ item ): void
91
96
{
92
97
$ index = array_search ($ item ->getSlot ()->value , $ this ->lastEquippedGrenadeSlots , true );
Original file line number Diff line number Diff line change @@ -329,6 +329,10 @@ public function serialize(): array
329
329
$ ammoReserve = $ equippedItem ->getAmmoReserve ();
330
330
$ reloading = $ equippedItem ->isReloading ();
331
331
}
332
+ $ filledSlots = $ this ->inventory ->getFilledSlots ();
333
+ if (isset ($ filledSlots [InventorySlot::SLOT_GRENADE_FLASH ->value ])) {
334
+ $ filledSlots [InventorySlot::SLOT_GRENADE_FLASH ->value ]['pcs ' ] = $ this ->inventory ->getItemSlot (InventorySlot::SLOT_GRENADE_FLASH )?->getQuantity();
335
+ }
332
336
333
337
return [
334
338
'id ' => $ this ->id ,
@@ -338,7 +342,7 @@ public function serialize(): array
338
342
'canAttack ' => $ canAttack ,
339
343
'canBuy ' => $ this ->world ->canBuy ($ this ),
340
344
'canPlant ' => $ this ->world ->canPlant ($ this ),
341
- 'slots ' => $ this -> inventory -> getFilledSlots () ,
345
+ 'slots ' => $ filledSlots ,
342
346
'health ' => $ this ->health ,
343
347
'position ' => $ this ->position ->toArray (),
344
348
'look ' => $ this ->sight ->toArray (),
Original file line number Diff line number Diff line change @@ -588,15 +588,18 @@ public function testPlayerBuyTwoFlashes(): void
588
588
$ this ->assertSame ($ itemPrice , $ item ->getPrice ());
589
589
$ this ->assertFalse ($ game ->getPlayer (1 )->getInventory ()->canBuy ($ item ));
590
590
$ this ->assertSame (2 , $ item ->getQuantity ());
591
+ $ this ->assertSame (2 , $ game ->getPlayer (1 )->serialize ()['slots ' ][InventorySlot::SLOT_GRENADE_FLASH ->value ]['pcs ' ] ?? false ); // @phpstan-ignore-line
591
592
592
593
$ flashBang1 = $ game ->getPlayer (1 )->dropEquippedItem ();
594
+ $ this ->assertSame (1 , $ game ->getPlayer (1 )->serialize ()['slots ' ][InventorySlot::SLOT_GRENADE_FLASH ->value ]['pcs ' ] ?? false ); // @phpstan-ignore-line
593
595
$ this ->assertInstanceOf (Flashbang::class, $ flashBang1 );
594
596
$ flashBang2 = $ game ->getPlayer (1 )->dropEquippedItem ();
595
597
$ this ->assertInstanceOf (Flashbang::class, $ flashBang2 );
596
598
$ this ->assertFalse ($ flashBang1 === $ flashBang2 );
597
599
$ this ->assertTrue ($ item === $ flashBang2 );
598
600
$ this ->assertSame (1 , $ flashBang1 ->getQuantity ());
599
601
$ this ->assertSame (1 , $ flashBang2 ->getQuantity ());
602
+ $ this ->assertNull ($ game ->getPlayer (1 )->serialize ()['slots ' ][InventorySlot::SLOT_GRENADE_FLASH ->value ]['pcs ' ] ?? null ); // @phpstan-ignore-line
600
603
}
601
604
602
605
public function testPlayerBuyMaxFourGrenades (): void
Original file line number Diff line number Diff line change 496
496
padding : 8px ;
497
497
}
498
498
499
+ # hud .inventory .grenades span > span .count {
500
+ padding : 0 ;
501
+ font-size : 12px ;
502
+ color : # ffebc5 ;
503
+ position : relative;
504
+ left : -6px ;
505
+ }
506
+
499
507
# hud .inventory .highlight {
500
508
font-weight : bold;
501
509
color : # ffebc5 ;
Original file line number Diff line number Diff line change @@ -208,7 +208,8 @@ export class HUD {
208
208
return
209
209
}
210
210
211
- grenade += `<span${ slotId === slot ? ' class="highlight"' : '' } >${ Enum . ItemIdToIcon [ item . id ] } </span>`
211
+ let grenadeCount = ( item . pcs > 1 ) ? `<span class="count">x${ item . pcs } </span>` : ''
212
+ grenade += `<span${ slotId === slot ? ' class="highlight"' : '' } >${ Enum . ItemIdToIcon [ item . id ] } ${ grenadeCount } </span>`
212
213
} )
213
214
this . #elements. inventory . innerHTML = html + `<div class="grenades">${ grenade } </div>`
214
215
}
You can’t perform that action at this time.
0 commit comments