quake2ts 0.0.229 → 0.0.231

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1568,24 +1568,38 @@ function pickupArmor(inventory, item, time) {
1568
1568
  if (armorType) {
1569
1569
  const armorInfo = ARMOR_INFO[armorType];
1570
1570
  if (!inventory.armor || inventory.armor.armorType !== armorType) {
1571
- inventory.armor = { armorType, armorCount: item.amount };
1571
+ let take = true;
1572
+ if (inventory.armor) {
1573
+ const oldInfo = ARMOR_INFO[inventory.armor.armorType];
1574
+ if (oldInfo.normalProtection > armorInfo.normalProtection) {
1575
+ take = false;
1576
+ }
1577
+ }
1578
+ if (take) {
1579
+ inventory.armor = { armorType, armorCount: item.amount };
1580
+ setPickup(inventory, icon, time);
1581
+ return true;
1582
+ } else {
1583
+ return false;
1584
+ }
1572
1585
  } else {
1573
1586
  inventory.armor.armorCount += item.amount;
1574
1587
  if (inventory.armor.armorCount > armorInfo.maxCount) {
1575
1588
  inventory.armor.armorCount = armorInfo.maxCount;
1576
1589
  }
1590
+ setPickup(inventory, icon, time);
1591
+ return true;
1577
1592
  }
1578
- setPickup(inventory, icon, time);
1579
- return true;
1580
1593
  }
1581
1594
  if (item.id === "item_armor_shard") {
1582
1595
  if (!inventory.armor) {
1583
- return false;
1584
- }
1585
- inventory.armor.armorCount += item.amount;
1586
- const armorInfo = ARMOR_INFO[inventory.armor.armorType];
1587
- if (inventory.armor.armorCount > armorInfo.maxCount) {
1588
- inventory.armor.armorCount = armorInfo.maxCount;
1596
+ inventory.armor = { armorType: "jacket" /* JACKET */, armorCount: item.amount };
1597
+ } else {
1598
+ inventory.armor.armorCount += item.amount;
1599
+ const armorInfo = ARMOR_INFO[inventory.armor.armorType];
1600
+ if (inventory.armor.armorCount > armorInfo.maxCount) {
1601
+ inventory.armor.armorCount = armorInfo.maxCount;
1602
+ }
1589
1603
  }
1590
1604
  return true;
1591
1605
  }