quake2ts 0.0.230 → 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.
@@ -1401,24 +1401,38 @@ function pickupArmor(inventory, item, time) {
1401
1401
  if (armorType) {
1402
1402
  const armorInfo = ARMOR_INFO[armorType];
1403
1403
  if (!inventory.armor || inventory.armor.armorType !== armorType) {
1404
- inventory.armor = { armorType, armorCount: item.amount };
1404
+ let take = true;
1405
+ if (inventory.armor) {
1406
+ const oldInfo = ARMOR_INFO[inventory.armor.armorType];
1407
+ if (oldInfo.normalProtection > armorInfo.normalProtection) {
1408
+ take = false;
1409
+ }
1410
+ }
1411
+ if (take) {
1412
+ inventory.armor = { armorType, armorCount: item.amount };
1413
+ setPickup(inventory, icon, time);
1414
+ return true;
1415
+ } else {
1416
+ return false;
1417
+ }
1405
1418
  } else {
1406
1419
  inventory.armor.armorCount += item.amount;
1407
1420
  if (inventory.armor.armorCount > armorInfo.maxCount) {
1408
1421
  inventory.armor.armorCount = armorInfo.maxCount;
1409
1422
  }
1423
+ setPickup(inventory, icon, time);
1424
+ return true;
1410
1425
  }
1411
- setPickup(inventory, icon, time);
1412
- return true;
1413
1426
  }
1414
1427
  if (item.id === "item_armor_shard") {
1415
1428
  if (!inventory.armor) {
1416
- return false;
1417
- }
1418
- inventory.armor.armorCount += item.amount;
1419
- const armorInfo = ARMOR_INFO[inventory.armor.armorType];
1420
- if (inventory.armor.armorCount > armorInfo.maxCount) {
1421
- inventory.armor.armorCount = armorInfo.maxCount;
1429
+ inventory.armor = { armorType: "jacket" /* JACKET */, armorCount: item.amount };
1430
+ } else {
1431
+ inventory.armor.armorCount += item.amount;
1432
+ const armorInfo = ARMOR_INFO[inventory.armor.armorType];
1433
+ if (inventory.armor.armorCount > armorInfo.maxCount) {
1434
+ inventory.armor.armorCount = armorInfo.maxCount;
1435
+ }
1422
1436
  }
1423
1437
  return true;
1424
1438
  }