isaacscript-common 10.0.0 → 10.1.0

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.
Files changed (88) hide show
  1. package/dist/index.d.ts +78 -22
  2. package/dist/isaacscript-common.lua +203 -102
  3. package/dist/package.lua +2 -2
  4. package/dist/src/features/deployJSONRoom.d.ts +16 -6
  5. package/dist/src/features/deployJSONRoom.d.ts.map +1 -1
  6. package/dist/src/features/deployJSONRoom.lua +16 -6
  7. package/dist/src/features/saveDataManager/load.d.ts.map +1 -1
  8. package/dist/src/features/saveDataManager/merge.d.ts.map +1 -1
  9. package/dist/src/features/saveDataManager/saveDataManagerConstants.d.ts +1 -1
  10. package/dist/src/features/saveDataManager/saveDataManagerConstants.d.ts.map +1 -1
  11. package/dist/src/functions/bitSet128.d.ts +2 -1
  12. package/dist/src/functions/bitSet128.d.ts.map +1 -1
  13. package/dist/src/functions/bitSet128.lua +2 -2
  14. package/dist/src/functions/color.d.ts +2 -3
  15. package/dist/src/functions/color.d.ts.map +1 -1
  16. package/dist/src/functions/color.lua +2 -2
  17. package/dist/src/functions/curses.d.ts +1 -1
  18. package/dist/src/functions/curses.lua +1 -1
  19. package/dist/src/functions/deepCopy.d.ts +2 -1
  20. package/dist/src/functions/deepCopy.d.ts.map +1 -1
  21. package/dist/src/functions/deepCopy.lua +19 -25
  22. package/dist/src/functions/deepCopyTests.lua +13 -26
  23. package/dist/src/functions/doors.d.ts +9 -1
  24. package/dist/src/functions/doors.d.ts.map +1 -1
  25. package/dist/src/functions/doors.lua +8 -1
  26. package/dist/src/functions/kColor.d.ts +2 -3
  27. package/dist/src/functions/kColor.d.ts.map +1 -1
  28. package/dist/src/functions/kColor.lua +2 -2
  29. package/dist/src/functions/rng.d.ts +2 -2
  30. package/dist/src/functions/rng.d.ts.map +1 -1
  31. package/dist/src/functions/serialization.d.ts +11 -4
  32. package/dist/src/functions/serialization.d.ts.map +1 -1
  33. package/dist/src/functions/serialization.lua +15 -0
  34. package/dist/src/functions/table.d.ts +2 -2
  35. package/dist/src/functions/table.d.ts.map +1 -1
  36. package/dist/src/functions/table.lua +6 -5
  37. package/dist/src/functions/vector.d.ts +2 -1
  38. package/dist/src/functions/vector.d.ts.map +1 -1
  39. package/dist/src/functions/vector.lua +2 -2
  40. package/dist/src/functions/weighted.d.ts +6 -0
  41. package/dist/src/functions/weighted.d.ts.map +1 -0
  42. package/dist/src/functions/weighted.lua +35 -0
  43. package/dist/src/index.d.ts +2 -1
  44. package/dist/src/index.d.ts.map +1 -1
  45. package/dist/src/index.lua +8 -0
  46. package/dist/src/interfaces/SaveData.d.ts +3 -8
  47. package/dist/src/interfaces/SaveData.d.ts.map +1 -1
  48. package/dist/src/objects/isaacAPIClassTypeToBrand.d.ts +1 -1
  49. package/dist/src/objects/isaacAPIClassTypeToBrand.d.ts.map +1 -1
  50. package/dist/src/objects/isaacAPIClassTypeToBrand.lua +2 -2
  51. package/dist/src/objects/isaacAPIClassTypeToFunctions.d.ts +36 -8
  52. package/dist/src/objects/isaacAPIClassTypeToFunctions.d.ts.map +1 -1
  53. package/dist/src/objects/isaacAPIClassTypeToFunctions.lua +42 -7
  54. package/dist/src/types/WeightedArray.d.ts +4 -0
  55. package/dist/src/types/WeightedArray.d.ts.map +1 -0
  56. package/dist/src/types/{SerializedIsaacAPIClass.lua → WeightedArray.lua} +0 -0
  57. package/package.json +2 -2
  58. package/src/callbacks/customRevive.ts +1 -2
  59. package/src/features/deployJSONRoom.ts +16 -6
  60. package/src/features/saveDataManager/exports.ts +1 -1
  61. package/src/features/saveDataManager/load.ts +0 -2
  62. package/src/features/saveDataManager/merge.ts +0 -3
  63. package/src/features/saveDataManager/saveDataManagerConstants.ts +1 -1
  64. package/src/functions/bitSet128.ts +8 -2
  65. package/src/functions/color.ts +8 -2
  66. package/src/functions/curses.ts +1 -1
  67. package/src/functions/deepCopy.ts +25 -23
  68. package/src/functions/deepCopyTests.ts +19 -41
  69. package/src/functions/doors.ts +13 -1
  70. package/src/functions/initArray.ts +1 -1
  71. package/src/functions/kColor.ts +8 -2
  72. package/src/functions/rng.ts +2 -0
  73. package/src/functions/serialization.ts +72 -18
  74. package/src/functions/table.ts +8 -5
  75. package/src/functions/vector.ts +11 -3
  76. package/src/functions/weighted.ts +36 -0
  77. package/src/index.ts +2 -1
  78. package/src/interfaces/SaveData.ts +4 -3
  79. package/src/objects/isaacAPIClassTypeToBrand.ts +1 -1
  80. package/src/objects/isaacAPIClassTypeToFunctions.ts +58 -9
  81. package/src/types/WeightedArray.ts +2 -0
  82. package/dist/src/enums/private/CopyableIsaacAPIClassType.d.ts +0 -12
  83. package/dist/src/enums/private/CopyableIsaacAPIClassType.d.ts.map +0 -1
  84. package/dist/src/enums/private/CopyableIsaacAPIClassType.lua +0 -10
  85. package/dist/src/types/SerializedIsaacAPIClass.d.ts +0 -11
  86. package/dist/src/types/SerializedIsaacAPIClass.d.ts.map +0 -1
  87. package/src/enums/private/CopyableIsaacAPIClassType.ts +0 -11
  88. package/src/types/SerializedIsaacAPIClass.ts +0 -9
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 10.0.0
3
+ isaacscript-common 10.1.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -4268,6 +4268,14 @@ do
4268
4268
  end
4269
4269
  end
4270
4270
  end
4271
+ do
4272
+ local ____export = require("lua_modules.isaac-typescript-definitions.dist.src.enums.CopyableIsaacAPIClassType")
4273
+ for ____exportKey, ____exportValue in pairs(____export) do
4274
+ if ____exportKey ~= "default" then
4275
+ ____exports[____exportKey] = ____exportValue
4276
+ end
4277
+ end
4278
+ end
4271
4279
  do
4272
4280
  local ____export = require("lua_modules.isaac-typescript-definitions.dist.src.enums.CurseID")
4273
4281
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -4853,7 +4861,7 @@ return ____exports
4853
4861
  ["lua_modules.isaac-typescript-definitions.dist.package"] = function(...)
4854
4862
  return {
4855
4863
  name = "isaac-typescript-definitions",
4856
- version = "7.0.0",
4864
+ version = "7.2.1",
4857
4865
  description = "TypeScript definitions for The Binding of Isaac: Repentance.",
4858
4866
  keywords = {"isaac", "rebirth", "afterbirth", "repentance"},
4859
4867
  homepage = "https://isaacscript.github.io/",
@@ -10007,7 +10015,7 @@ ____exports.SwingerVariant.SWINGER = 0
10007
10015
  ____exports.SwingerVariant[____exports.SwingerVariant.SWINGER] = "SWINGER"
10008
10016
  ____exports.SwingerVariant.SWINGER_HEAD = 1
10009
10017
  ____exports.SwingerVariant[____exports.SwingerVariant.SWINGER_HEAD] = "SWINGER_HEAD"
10010
- ____exports.SwingerVariant.SWINGER_NECK = 2
10018
+ ____exports.SwingerVariant.SWINGER_NECK = 10
10011
10019
  ____exports.SwingerVariant[____exports.SwingerVariant.SWINGER_NECK] = "SWINGER_NECK"
10012
10020
  --- For `EntityType.DIP` (217).
10013
10021
  ____exports.DipVariant = {}
@@ -11012,6 +11020,17 @@ ____exports.ControllerIndex.CONTROLLER_2 = 2
11012
11020
  ____exports.ControllerIndex[____exports.ControllerIndex.CONTROLLER_2] = "CONTROLLER_2"
11013
11021
  ____exports.ControllerIndex.CONTROLLER_3 = 3
11014
11022
  ____exports.ControllerIndex[____exports.ControllerIndex.CONTROLLER_3] = "CONTROLLER_3"
11023
+ return ____exports
11024
+ end,
11025
+ ["lua_modules.isaac-typescript-definitions.dist.src.enums.CopyableIsaacAPIClassType"] = function(...)
11026
+ local ____exports = {}
11027
+ --- An enum containing the Isaac API classes that can be safely copied / serialized.
11028
+ ____exports.CopyableIsaacAPIClassType = {}
11029
+ ____exports.CopyableIsaacAPIClassType.BIT_SET_128 = "BitSet128"
11030
+ ____exports.CopyableIsaacAPIClassType.COLOR = "Color"
11031
+ ____exports.CopyableIsaacAPIClassType.K_COLOR = "KColor"
11032
+ ____exports.CopyableIsaacAPIClassType.RNG = "RNG"
11033
+ ____exports.CopyableIsaacAPIClassType.VECTOR = "Vector"
11015
11034
  return ____exports
11016
11035
  end,
11017
11036
  ["lua_modules.isaac-typescript-definitions.dist.src.enums.CurseID"] = function(...)
@@ -18407,7 +18426,7 @@ local ____types = require("src.functions.types")
18407
18426
  local isBoolean = ____types.isBoolean
18408
18427
  local isNumber = ____types.isNumber
18409
18428
  local isString = ____types.isString
18410
- local isTable = ____types.isTable
18429
+ local isUserdata = ____types.isUserdata
18411
18430
  --- In a `Map`, you can use the `clear` method to delete every element. However, in a `LuaMap`, the
18412
18431
  -- `clear` method does not exist. Use this helper function as a drop-in replacement for this.
18413
18432
  function ____exports.clearTable(self, luaMap)
@@ -18415,13 +18434,14 @@ function ____exports.clearTable(self, luaMap)
18415
18434
  luaMap[key] = nil
18416
18435
  end
18417
18436
  end
18418
- --- Helper function to copy specific values from a object to a table.
18419
- function ____exports.copyValuesToTable(self, object, keys, luaMap)
18420
- if not isTable(nil, object) then
18437
+ --- Helper function to copy specific values from a userdata object (e.g. `Vector`) to a table.
18438
+ function ____exports.copyUserdataValuesToTable(self, object, keys, luaMap)
18439
+ if not isUserdata(nil, object) then
18421
18440
  error("Failed to copy an object values to a table, since the object was of type: " .. type(object))
18422
18441
  end
18442
+ local userdata = object
18423
18443
  for ____, key in ipairs(keys) do
18424
- local value = object[key]
18444
+ local value = userdata[key]
18425
18445
  luaMap[key] = value
18426
18446
  end
18427
18447
  end
@@ -20201,7 +20221,7 @@ local getRandomSeed = ____rng.getRandomSeed
20201
20221
  local isRNG = ____rng.isRNG
20202
20222
  local newRNG = ____rng.newRNG
20203
20223
  local ____table = require("src.functions.table")
20204
- local copyValuesToTable = ____table.copyValuesToTable
20224
+ local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
20205
20225
  local getNumbersFromTable = ____table.getNumbersFromTable
20206
20226
  local tableHasKeys = ____table.tableHasKeys
20207
20227
  local ____types = require("src.functions.types")
@@ -20275,7 +20295,7 @@ function ____exports.serializeVector(self, vector)
20275
20295
  error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
20276
20296
  end
20277
20297
  local vectorTable = {}
20278
- copyValuesToTable(nil, vector, KEYS, vectorTable)
20298
+ copyUserdataValuesToTable(nil, vector, KEYS, vectorTable)
20279
20299
  vectorTable[SerializationBrand.VECTOR] = ""
20280
20300
  return vectorTable
20281
20301
  end
@@ -22548,7 +22568,8 @@ function ____exports.getRoomShapeDoorSlotCoordinates(self, roomShape, doorSlot)
22548
22568
  local coordinatesMap = ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES[roomShape]
22549
22569
  return coordinatesMap:get(doorSlot)
22550
22570
  end
22551
- --- Helper function to find unused door slots in the room that can be used to make custom doors.
22571
+ --- Helper function to find unused door slots in the current room that can be used to make custom
22572
+ -- doors.
22552
22573
  function ____exports.getUnusedDoorSlots(self)
22553
22574
  local room = game:GetRoom()
22554
22575
  local doorSlots = getEnumValues(nil, DoorSlot)
@@ -22557,6 +22578,12 @@ function ____exports.getUnusedDoorSlots(self)
22557
22578
  function(____, doorSlot) return room:IsDoorSlotAllowed(doorSlot) and room:GetDoor(doorSlot) == nil end
22558
22579
  )
22559
22580
  end
22581
+ --- Helper function to check if the current room has one or more open door slots that can be used to
22582
+ -- make custom doors.
22583
+ function ____exports.hasUnusedDoorSlot(self)
22584
+ local unusedDoorSlots = ____exports.getUnusedDoorSlots(nil)
22585
+ return #unusedDoorSlots > 0
22586
+ end
22560
22587
  function ____exports.isAngelRoomDoor(self, door)
22561
22588
  return door.TargetRoomType == RoomType.ANGEL
22562
22589
  end
@@ -24919,7 +24946,7 @@ local getRandomSeed = ____rng.getRandomSeed
24919
24946
  local isRNG = ____rng.isRNG
24920
24947
  local newRNG = ____rng.newRNG
24921
24948
  local ____table = require("src.functions.table")
24922
- local copyValuesToTable = ____table.copyValuesToTable
24949
+ local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
24923
24950
  local getNumbersFromTable = ____table.getNumbersFromTable
24924
24951
  local tableHasKeys = ____table.tableHasKeys
24925
24952
  local ____types = require("src.functions.types")
@@ -25003,7 +25030,7 @@ function ____exports.serializeKColor(self, kColor)
25003
25030
  error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
25004
25031
  end
25005
25032
  local kColorTable = {}
25006
- copyValuesToTable(nil, kColor, KEYS, kColorTable)
25033
+ copyUserdataValuesToTable(nil, kColor, KEYS, kColorTable)
25007
25034
  kColorTable[SerializationBrand.K_COLOR] = ""
25008
25035
  return kColorTable
25009
25036
  end
@@ -26887,18 +26914,6 @@ ____exports.SerializationType.SERIALIZE = 1
26887
26914
  ____exports.SerializationType[____exports.SerializationType.SERIALIZE] = "SERIALIZE"
26888
26915
  ____exports.SerializationType.DESERIALIZE = 2
26889
26916
  ____exports.SerializationType[____exports.SerializationType.DESERIALIZE] = "DESERIALIZE"
26890
- return ____exports
26891
- end,
26892
- ["src.enums.private.CopyableIsaacAPIClassType"] = function(...)
26893
- local ____exports = {}
26894
- --- - This must match the JSDoc comments for `deepCopy` and `merge`.
26895
- -- - This must match the `SerializableIsaacAPIClass` type union.
26896
- ____exports.CopyableIsaacAPIClassType = {}
26897
- ____exports.CopyableIsaacAPIClassType.BIT_SET_128 = "BitSet128"
26898
- ____exports.CopyableIsaacAPIClassType.COLOR = "Color"
26899
- ____exports.CopyableIsaacAPIClassType.K_COLOR = "KColor"
26900
- ____exports.CopyableIsaacAPIClassType.RNG = "RNG"
26901
- ____exports.CopyableIsaacAPIClassType.VECTOR = "Vector"
26902
26917
  return ____exports
26903
26918
  end,
26904
26919
  ["src.features.saveDataManager.saveDataManagerConstants"] = function(...)
@@ -29618,8 +29633,8 @@ return ____exports
29618
29633
  end,
29619
29634
  ["src.objects.isaacAPIClassTypeToBrand"] = function(...)
29620
29635
  local ____exports = {}
29621
- local ____CopyableIsaacAPIClassType = require("src.enums.private.CopyableIsaacAPIClassType")
29622
- local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
29636
+ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
29637
+ local CopyableIsaacAPIClassType = ____isaac_2Dtypescript_2Ddefinitions.CopyableIsaacAPIClassType
29623
29638
  local ____SerializationBrand = require("src.enums.private.SerializationBrand")
29624
29639
  local SerializationBrand = ____SerializationBrand.SerializationBrand
29625
29640
  ____exports.ISAAC_API_CLASS_TYPE_TO_BRAND = {
@@ -29639,7 +29654,7 @@ local SerializationBrand = ____SerializationBrand.SerializationBrand
29639
29654
  local ____isaacAPIClass = require("src.functions.isaacAPIClass")
29640
29655
  local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
29641
29656
  local ____table = require("src.functions.table")
29642
- local copyValuesToTable = ____table.copyValuesToTable
29657
+ local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
29643
29658
  local getNumbersFromTable = ____table.getNumbersFromTable
29644
29659
  local tableHasKeys = ____table.tableHasKeys
29645
29660
  local ____types = require("src.functions.types")
@@ -29698,7 +29713,7 @@ function ____exports.serializeBitSet128(self, bitSet128)
29698
29713
  error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
29699
29714
  end
29700
29715
  local bitSet128Table = {}
29701
- copyValuesToTable(nil, bitSet128, KEYS, bitSet128Table)
29716
+ copyUserdataValuesToTable(nil, bitSet128, KEYS, bitSet128Table)
29702
29717
  bitSet128Table[SerializationBrand.BIT_SET_128] = ""
29703
29718
  return bitSet128Table
29704
29719
  end
@@ -29719,7 +29734,7 @@ local getRandomSeed = ____rng.getRandomSeed
29719
29734
  local isRNG = ____rng.isRNG
29720
29735
  local newRNG = ____rng.newRNG
29721
29736
  local ____table = require("src.functions.table")
29722
- local copyValuesToTable = ____table.copyValuesToTable
29737
+ local copyUserdataValuesToTable = ____table.copyUserdataValuesToTable
29723
29738
  local getNumbersFromTable = ____table.getNumbersFromTable
29724
29739
  local tableHasKeys = ____table.tableHasKeys
29725
29740
  local ____types = require("src.functions.types")
@@ -29824,7 +29839,7 @@ function ____exports.serializeColor(self, color)
29824
29839
  error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
29825
29840
  end
29826
29841
  local colorTable = {}
29827
- copyValuesToTable(nil, color, KEYS, colorTable)
29842
+ copyUserdataValuesToTable(nil, color, KEYS, colorTable)
29828
29843
  colorTable[SerializationBrand.COLOR] = ""
29829
29844
  return colorTable
29830
29845
  end
@@ -29832,44 +29847,75 @@ return ____exports
29832
29847
  end,
29833
29848
  ["src.objects.isaacAPIClassTypeToFunctions"] = function(...)
29834
29849
  local ____exports = {}
29835
- local ____CopyableIsaacAPIClassType = require("src.enums.private.CopyableIsaacAPIClassType")
29836
- local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
29850
+ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
29851
+ local CopyableIsaacAPIClassType = ____isaac_2Dtypescript_2Ddefinitions.CopyableIsaacAPIClassType
29837
29852
  local ____bitSet128 = require("src.functions.bitSet128")
29838
29853
  local copyBitSet128 = ____bitSet128.copyBitSet128
29839
29854
  local deserializeBitSet128 = ____bitSet128.deserializeBitSet128
29855
+ local isBitSet128 = ____bitSet128.isBitSet128
29840
29856
  local isSerializedBitSet128 = ____bitSet128.isSerializedBitSet128
29841
29857
  local serializeBitSet128 = ____bitSet128.serializeBitSet128
29842
29858
  local ____color = require("src.functions.color")
29843
29859
  local copyColor = ____color.copyColor
29844
29860
  local deserializeColor = ____color.deserializeColor
29861
+ local isColor = ____color.isColor
29845
29862
  local isSerializedColor = ____color.isSerializedColor
29846
29863
  local serializeColor = ____color.serializeColor
29847
29864
  local ____kColor = require("src.functions.kColor")
29848
29865
  local copyKColor = ____kColor.copyKColor
29849
29866
  local deserializeKColor = ____kColor.deserializeKColor
29867
+ local isKColor = ____kColor.isKColor
29850
29868
  local isSerializedKColor = ____kColor.isSerializedKColor
29851
29869
  local serializeKColor = ____kColor.serializeKColor
29852
29870
  local ____rng = require("src.functions.rng")
29853
29871
  local copyRNG = ____rng.copyRNG
29854
29872
  local deserializeRNG = ____rng.deserializeRNG
29873
+ local isRNG = ____rng.isRNG
29855
29874
  local isSerializedRNG = ____rng.isSerializedRNG
29856
29875
  local serializeRNG = ____rng.serializeRNG
29857
29876
  local ____vector = require("src.functions.vector")
29858
29877
  local copyVector = ____vector.copyVector
29859
29878
  local deserializeVector = ____vector.deserializeVector
29860
29879
  local isSerializedVector = ____vector.isSerializedVector
29880
+ local isVector = ____vector.isVector
29861
29881
  local serializeVector = ____vector.serializeVector
29862
29882
  ____exports.ISAAC_API_CLASS_TYPE_TO_FUNCTIONS = {
29863
- [CopyableIsaacAPIClassType.BIT_SET_128] = {isSerialized = isSerializedBitSet128, copy = copyBitSet128, serialize = serializeBitSet128, deserialize = deserializeBitSet128},
29864
- [CopyableIsaacAPIClassType.COLOR] = {isSerialized = isSerializedColor, copy = copyColor, serialize = serializeColor, deserialize = deserializeColor},
29865
- [CopyableIsaacAPIClassType.K_COLOR] = {isSerialized = isSerializedKColor, copy = copyKColor, serialize = serializeKColor, deserialize = deserializeKColor},
29866
- [CopyableIsaacAPIClassType.RNG] = {isSerialized = isSerializedRNG, copy = copyRNG, serialize = serializeRNG, deserialize = deserializeRNG},
29867
- [CopyableIsaacAPIClassType.VECTOR] = {isSerialized = isSerializedVector, copy = copyVector, serialize = serializeVector, deserialize = deserializeVector}
29883
+ [CopyableIsaacAPIClassType.BIT_SET_128] = {
29884
+ is = isBitSet128,
29885
+ isSerialized = isSerializedBitSet128,
29886
+ copy = copyBitSet128,
29887
+ serialize = serializeBitSet128,
29888
+ deserialize = deserializeBitSet128
29889
+ },
29890
+ [CopyableIsaacAPIClassType.COLOR] = {
29891
+ is = isColor,
29892
+ isSerialized = isSerializedColor,
29893
+ copy = copyColor,
29894
+ serialize = serializeColor,
29895
+ deserialize = deserializeColor
29896
+ },
29897
+ [CopyableIsaacAPIClassType.K_COLOR] = {
29898
+ is = isKColor,
29899
+ isSerialized = isSerializedKColor,
29900
+ copy = copyKColor,
29901
+ serialize = serializeKColor,
29902
+ deserialize = deserializeKColor
29903
+ },
29904
+ [CopyableIsaacAPIClassType.RNG] = {
29905
+ is = isRNG,
29906
+ isSerialized = isSerializedRNG,
29907
+ copy = copyRNG,
29908
+ serialize = serializeRNG,
29909
+ deserialize = deserializeRNG
29910
+ },
29911
+ [CopyableIsaacAPIClassType.VECTOR] = {
29912
+ is = isVector,
29913
+ isSerialized = isSerializedVector,
29914
+ copy = copyVector,
29915
+ serialize = serializeVector,
29916
+ deserialize = deserializeVector
29917
+ }
29868
29918
  }
29869
- return ____exports
29870
- end,
29871
- ["src.types.SerializedIsaacAPIClass"] = function(...)
29872
- local ____exports = {}
29873
29919
  return ____exports
29874
29920
  end,
29875
29921
  ["src.functions.serialization"] = function(...)
@@ -29938,6 +29984,21 @@ function ____exports.deserializeIsaacAPIClass(self, serializedIsaacAPIClass)
29938
29984
  end
29939
29985
  return functions:deserialize(serializedIsaacAPIClass)
29940
29986
  end
29987
+ --- Helper function to generically check if a given object is a copyable Isaac API class. (This is
29988
+ -- used by the save data manager when determining what is safe to copy.)
29989
+ --
29990
+ -- For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
29991
+ function ____exports.isCopyableIsaacAPIClass(self, object)
29992
+ local allFunctions = __TS__ObjectValues(ISAAC_API_CLASS_TYPE_TO_FUNCTIONS)
29993
+ local isFunctions = __TS__ArrayMap(
29994
+ allFunctions,
29995
+ function(____, functions) return functions.is end
29996
+ )
29997
+ return __TS__ArraySome(
29998
+ isFunctions,
29999
+ function(____, identityFunction) return identityFunction(nil, object) end
30000
+ )
30001
+ end
29941
30002
  --- Helper function to generically check if a given Lua table is a serialized Isaac API class. (This
29942
30003
  -- is used by the save data manager when reading data from the "save#.dat" file.)
29943
30004
  --
@@ -29976,18 +30037,16 @@ return ____exports
29976
30037
  end,
29977
30038
  ["src.functions.deepCopy"] = function(...)
29978
30039
  local ____lualib = require("lualib_bundle")
29979
- local Set = ____lualib.Set
29980
30040
  local __TS__New = ____lualib.__TS__New
29981
30041
  local Map = ____lualib.Map
30042
+ local Set = ____lualib.Set
29982
30043
  local __TS__Iterator = ____lualib.__TS__Iterator
29983
30044
  local __TS__ArraySort = ____lualib.__TS__ArraySort
29984
30045
  local __TS__ArraySome = ____lualib.__TS__ArraySome
29985
30046
  local ____exports = {}
29986
- local deepCopyTable, deepCopyDefaultMap, getNewDefaultMap, deepCopyMap, deepCopySet, deepCopyTSTLClass, deepCopyArray, deepCopyNormalLuaTable, getCopiedEntries, checkMetatable, deepCopyUserdata, COPYABLE_ISAAC_API_CLASS_TYPES_SET
30047
+ local deepCopyTable, deepCopyDefaultMap, getNewDefaultMap, deepCopyMap, deepCopySet, deepCopyTSTLClass, deepCopyArray, deepCopyNormalLuaTable, getCopiedEntries, checkMetatable, deepCopyUserdata
29987
30048
  local ____DefaultMap = require("src.classes.DefaultMap")
29988
30049
  local DefaultMap = ____DefaultMap.DefaultMap
29989
- local ____CopyableIsaacAPIClassType = require("src.enums.private.CopyableIsaacAPIClassType")
29990
- local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
29991
30050
  local ____SerializationBrand = require("src.enums.private.SerializationBrand")
29992
30051
  local SerializationBrand = ____SerializationBrand.SerializationBrand
29993
30052
  local ____SerializationType = require("src.enums.SerializationType")
@@ -29998,8 +30057,6 @@ local ____serializationBrands = require("src.features.saveDataManager.serializat
29998
30057
  local isSerializationBrand = ____serializationBrands.isSerializationBrand
29999
30058
  local ____array = require("src.functions.array")
30000
30059
  local isArray = ____array.isArray
30001
- local ____enums = require("src.functions.enums")
30002
- local getEnumValues = ____enums.getEnumValues
30003
30060
  local ____isaacAPIClass = require("src.functions.isaacAPIClass")
30004
30061
  local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
30005
30062
  local ____log = require("src.functions.log")
@@ -30007,6 +30064,7 @@ local log = ____log.log
30007
30064
  local ____serialization = require("src.functions.serialization")
30008
30065
  local copyIsaacAPIClass = ____serialization.copyIsaacAPIClass
30009
30066
  local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
30067
+ local isCopyableIsaacAPIClass = ____serialization.isCopyableIsaacAPIClass
30010
30068
  local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
30011
30069
  local serializeIsaacAPIClass = ____serialization.serializeIsaacAPIClass
30012
30070
  local ____tstlClass = require("src.functions.tstlClass")
@@ -30090,6 +30148,9 @@ function ____exports.deepCopy(self, value, serializationType, traversalDescripti
30090
30148
  if serializationType == SerializationType.SERIALIZE then
30091
30149
  error((("The deep copy function does not support serialization of \"" .. traversalDescription) .. "\", since it is type: ") .. valueType)
30092
30150
  end
30151
+ if serializationType == SerializationType.DESERIALIZE then
30152
+ error((("The deep copy function does not support deserialization of \"" .. traversalDescription) .. "\", since it is type: ") .. valueType)
30153
+ end
30093
30154
  return value
30094
30155
  end
30095
30156
  end
@@ -30241,15 +30302,15 @@ function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescri
30241
30302
  end
30242
30303
  function getNewDefaultMap(self, defaultMap, serializationType, traversalDescription, constructorArg)
30243
30304
  repeat
30244
- local ____switch34 = serializationType
30245
- local ____cond34 = ____switch34 == SerializationType.NONE
30246
- if ____cond34 then
30305
+ local ____switch35 = serializationType
30306
+ local ____cond35 = ____switch35 == SerializationType.NONE
30307
+ if ____cond35 then
30247
30308
  do
30248
30309
  return __TS__New(DefaultMap, constructorArg)
30249
30310
  end
30250
30311
  end
30251
- ____cond34 = ____cond34 or ____switch34 == SerializationType.SERIALIZE
30252
- if ____cond34 then
30312
+ ____cond35 = ____cond35 or ____switch35 == SerializationType.SERIALIZE
30313
+ if ____cond35 then
30253
30314
  do
30254
30315
  local newDefaultMap = {}
30255
30316
  newDefaultMap[SerializationBrand.DEFAULT_MAP] = ""
@@ -30257,8 +30318,8 @@ function getNewDefaultMap(self, defaultMap, serializationType, traversalDescript
30257
30318
  return newDefaultMap
30258
30319
  end
30259
30320
  end
30260
- ____cond34 = ____cond34 or ____switch34 == SerializationType.DESERIALIZE
30261
- if ____cond34 then
30321
+ ____cond35 = ____cond35 or ____switch35 == SerializationType.DESERIALIZE
30322
+ if ____cond35 then
30262
30323
  do
30263
30324
  if isDefaultMap(nil, defaultMap) then
30264
30325
  error(("The deep copy function failed to deserialize a default map of \"" .. traversalDescription) .. "\", since it was not a Lua table.")
@@ -30458,7 +30519,7 @@ function getCopiedEntries(self, object, serializationType, traversalDescription,
30458
30519
  local value = ____value[2]
30459
30520
  do
30460
30521
  if isSerializationBrand(nil, key) then
30461
- goto __continue87
30522
+ goto __continue88
30462
30523
  end
30463
30524
  traversalDescription = getTraversalDescription(nil, key, traversalDescription)
30464
30525
  local newValue = ____exports.deepCopy(
@@ -30480,7 +30541,7 @@ function getCopiedEntries(self, object, serializationType, traversalDescription,
30480
30541
  end
30481
30542
  copiedEntries[#copiedEntries + 1] = {keyToUse, newValue}
30482
30543
  end
30483
- ::__continue87::
30544
+ ::__continue88::
30484
30545
  end
30485
30546
  return {entries = copiedEntries, convertedNumberKeysToStrings = convertNumberKeysToStrings}
30486
30547
  end
@@ -30493,15 +30554,12 @@ function checkMetatable(self, luaMap, traversalDescription)
30493
30554
  error(("The deepCopy function detected that " .. tableDescription) .. " has a metatable. Copying tables with metatables is not supported, unless they are explicitly handled by the save data manager. (e.g. TypeScriptToLua Maps, TypeScriptToLua Sets, etc.)")
30494
30555
  end
30495
30556
  function deepCopyUserdata(self, value, serializationType, traversalDescription)
30496
- if SAVE_DATA_MANAGER_DEBUG then
30497
- log(nil, "deepCopy is copying userdata.")
30498
- end
30499
30557
  local classType = getIsaacAPIClassName(nil, value)
30500
30558
  if classType == nil then
30501
30559
  error("The deep copy function was not able to derive the Isaac API class type for: " .. traversalDescription)
30502
30560
  end
30503
- if not COPYABLE_ISAAC_API_CLASS_TYPES_SET:has(classType) then
30504
- error((("The deep copy function does not support copying \"" .. traversalDescription) .. "\", since it is an Isaac API class of type: ") .. classType)
30561
+ if not isCopyableIsaacAPIClass(nil, value) then
30562
+ error((("The deep copy function does not support serializing \"" .. traversalDescription) .. "\", since it is an Isaac API class of type: ") .. classType)
30505
30563
  end
30506
30564
  repeat
30507
30565
  local ____switch99 = serializationType
@@ -30520,15 +30578,12 @@ function deepCopyUserdata(self, value, serializationType, traversalDescription)
30520
30578
  ____cond99 = ____cond99 or ____switch99 == SerializationType.DESERIALIZE
30521
30579
  if ____cond99 then
30522
30580
  do
30523
- return deserializeIsaacAPIClass(nil, value)
30581
+ error(("The deep copy function can not deserialize \"" .. traversalDescription) .. "\", since it is userdata.")
30524
30582
  end
30583
+ break
30525
30584
  end
30526
30585
  until true
30527
30586
  end
30528
- COPYABLE_ISAAC_API_CLASS_TYPES_SET = __TS__New(
30529
- Set,
30530
- getEnumValues(nil, CopyableIsaacAPIClassType)
30531
- )
30532
30587
  return ____exports
30533
30588
  end,
30534
30589
  ["src.interfaces.SaveData"] = function(...)
@@ -31936,7 +31991,7 @@ local ____flag = require("src.functions.flag")
31936
31991
  local hasFlag = ____flag.hasFlag
31937
31992
  --- Helper function to get the actual bit flag for modded curses.
31938
31993
  --
31939
- -- Will throw a runtime error if the provided curse does not exist.
31994
+ -- Will throw a run-time error if the provided curse does not exist.
31940
31995
  --
31941
31996
  -- Use this over the `Isaac.GetCurseIdByName` method because that will return an integer instead of
31942
31997
  -- a bit flag.
@@ -45570,16 +45625,21 @@ end
45570
45625
  -- Specifically, this will clear the current room of all entities and grid entities, and then spawn
45571
45626
  -- all of the entries and grid entities in the provided JSON room.
45572
45627
  --
45628
+ -- You can create JSON rooms by using the `convert-xml-to-json` tool (e.g. `npx convert-xml-to-json
45629
+ -- my-rooms.xml`).
45630
+ --
45573
45631
  -- This function is meant to be used in the `POST_NEW_ROOM` callback.
45574
45632
  --
45575
45633
  -- For example:
45576
45634
  --
45577
45635
  -- ```ts
45578
45636
  --
45579
- -- import customRooms from "./customRooms";
45637
+ -- import customRooms from "./customRooms.json";
45580
45638
  --
45581
- -- const firstJSONRoom = customRooms.rooms.room[0];
45582
- -- deployJSONRoom(firstJSONRoom);
45639
+ -- export function postNewRoom(): void {
45640
+ -- const firstJSONRoom = customRooms.rooms.room[0];
45641
+ -- deployJSONRoom(firstJSONRoom);
45642
+ -- }
45583
45643
  -- ```
45584
45644
  --
45585
45645
  -- @param jsonRoom The JSON room to deploy. *
@@ -45617,6 +45677,9 @@ end
45617
45677
  -- Specifically, this will clear the current room of all entities and grid entities, and then spawn
45618
45678
  -- all of the entries and grid entities in one of the provided JSON rooms.
45619
45679
  --
45680
+ -- You can create JSON rooms by using the `convert-xml-to-json` tool (e.g. `npx convert-xml-to-json
45681
+ -- my-rooms.xml`).
45682
+ --
45620
45683
  -- This function is meant to be used in the `POST_NEW_ROOM` callback.
45621
45684
  --
45622
45685
  -- Note that this function does not simply choose a random element in the provided array; it will
@@ -45626,10 +45689,12 @@ end
45626
45689
  -- For example:
45627
45690
  --
45628
45691
  -- ```ts
45629
- -- import customRooms from "./customRooms";
45692
+ -- import customRooms from "./customRooms.json";
45630
45693
  --
45631
- -- const jsonRooms = customRooms.rooms.room;
45632
- -- deployRandomJSONRoom(jsonRooms);
45694
+ -- export function postNewRoom(): void {
45695
+ -- const jsonRooms = customRooms.rooms.room;
45696
+ -- deployRandomJSONRoom(jsonRooms);
45697
+ -- }
45633
45698
  -- ```
45634
45699
  --
45635
45700
  -- @param jsonRooms An array of JSON rooms to randomly select from. In practice, this will be
@@ -46845,7 +46910,7 @@ return ____exports
46845
46910
  ["package"] = function(...)
46846
46911
  return {
46847
46912
  name = "isaacscript-common",
46848
- version = "10.0.0",
46913
+ version = "10.1.0",
46849
46914
  description = "Helper functions and features for IsaacScript mods.",
46850
46915
  keywords = {"isaac", "rebirth", "afterbirth", "repentance"},
46851
46916
  homepage = "https://isaacscript.github.io/",
@@ -46856,7 +46921,7 @@ return {
46856
46921
  type = "commonjs",
46857
46922
  main = "dist/src/index",
46858
46923
  types = "dist/src/index.d.ts",
46859
- dependencies = {["isaac-typescript-definitions"] = "^7.0.0"}
46924
+ dependencies = {["isaac-typescript-definitions"] = "^7.2.1"}
46860
46925
  }
46861
46926
  end,
46862
46927
  ["src.functions.map"] = function(...)
@@ -48333,8 +48398,7 @@ function copiedObjectHasKeyAndValueString(self)
48333
48398
  local keyToLookFor = "abc"
48334
48399
  local valueToLookFor = "def"
48335
48400
  local oldObject = {abc = valueToLookFor}
48336
- local newTable = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasKeyAndValueString")
48337
- local newObject = newTable
48401
+ local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasKeyAndValueString")
48338
48402
  local value = newObject[keyToLookFor]
48339
48403
  if value == nil then
48340
48404
  error("The copied object did not have a key of: " .. keyToLookFor)
@@ -48351,8 +48415,7 @@ function copiedTableHasKeyAndValueNumber(self)
48351
48415
  local valueToLookFor = 456
48352
48416
  local oldTable = {}
48353
48417
  oldTable[keyToLookFor] = valueToLookFor
48354
- local newObject = deepCopy(nil, oldTable, SerializationType.NONE, "copiedTableHasKeyAndValueNumber")
48355
- local newTable = newObject
48418
+ local newTable = deepCopy(nil, oldTable, SerializationType.NONE, "copiedTableHasKeyAndValueNumber")
48356
48419
  local value = newTable[keyToLookFor]
48357
48420
  if value == nil then
48358
48421
  error("The copied object did not have a key of: " .. tostring(keyToLookFor))
@@ -48369,8 +48432,7 @@ function copiedTableDoesNotCoerceTypes(self)
48369
48432
  local valueToLookFor = 456
48370
48433
  local oldTable = {}
48371
48434
  oldTable[keyToLookFor] = valueToLookFor
48372
- local newObject = deepCopy(nil, oldTable, SerializationType.NONE, "copiedTableDoesNotCoerceTypes")
48373
- local newTable = newObject
48435
+ local newTable = deepCopy(nil, oldTable, SerializationType.NONE, "copiedTableDoesNotCoerceTypes")
48374
48436
  local keyString = tostring(keyToLookFor)
48375
48437
  local valueString = tostring(valueToLookFor)
48376
48438
  local valueFromString = newTable[keyString]
@@ -48386,8 +48448,7 @@ function copiedObjectHasNoReferencesForPrimitivesForward(self)
48386
48448
  local originalStringValue = "abcdef"
48387
48449
  local originalNumberValue = 123
48388
48450
  local oldObject = {abc = originalStringValue, def = originalNumberValue}
48389
- local newTable = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForPrimitivesForward")
48390
- local newObject = newTable
48451
+ local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForPrimitivesForward")
48391
48452
  oldObject.abc = "newValue"
48392
48453
  if oldObject.abc == newObject.abc then
48393
48454
  error("The copied object has a string reference going forward.")
@@ -48401,8 +48462,7 @@ function copiedObjectHasNoReferencesForPrimitivesBackward(self)
48401
48462
  local originalStringValue = "abcdef"
48402
48463
  local originalNumberValue = 123
48403
48464
  local oldObject = {abc = originalStringValue, def = originalNumberValue}
48404
- local newTable = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForPrimitivesBackward")
48405
- local newObject = newTable
48465
+ local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForPrimitivesBackward")
48406
48466
  newObject.abc = "newValue"
48407
48467
  if newObject.abc == oldObject.abc then
48408
48468
  error("The copied object has a string reference going backward.")
@@ -48414,8 +48474,7 @@ function copiedObjectHasNoReferencesForPrimitivesBackward(self)
48414
48474
  end
48415
48475
  function copiedObjectHasNoReferencesForArray(self)
48416
48476
  local oldObject = {abc = {1, 2, 3}}
48417
- local newTable = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForArray")
48418
- local newObject = newTable
48477
+ local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForArray")
48419
48478
  if oldObject.abc == newObject.abc then
48420
48479
  error("The copied object has the same point to the child array.")
48421
48480
  end
@@ -48442,8 +48501,7 @@ function copiedObjectHasChildObject(self)
48442
48501
  local keyToLookFor = "def"
48443
48502
  local valueToLookFor = "ghi"
48444
48503
  local oldObject = {abc = {def = valueToLookFor}}
48445
- local newTable = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasChildObject")
48446
- local newObject = newTable
48504
+ local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasChildObject")
48447
48505
  local childObject = newObject[childObjectIndex]
48448
48506
  if childObject == nil then
48449
48507
  error("Failed to find the child object at index: " .. childObjectIndex)
@@ -48467,8 +48525,7 @@ function copiedMapIsMap(self)
48467
48525
  local valueToLookFor = "def"
48468
48526
  local oldMap = __TS__New(Map)
48469
48527
  oldMap:set(keyToLookFor, valueToLookFor)
48470
- local newObject = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapIsMap")
48471
- local newMap = newObject
48528
+ local newMap = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapIsMap")
48472
48529
  if not isTSTLMap(nil, newMap) then
48473
48530
  error("The copied Map was not a Map and has a type of: " .. __TS__TypeOf(newMap))
48474
48531
  end
@@ -48478,8 +48535,7 @@ function copiedMapHasValue(self)
48478
48535
  local valueToLookFor = "def"
48479
48536
  local oldMap = __TS__New(Map)
48480
48537
  oldMap:set(keyToLookFor, valueToLookFor)
48481
- local newTable = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapHasValue")
48482
- local newMap = newTable
48538
+ local newMap = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapHasValue")
48483
48539
  if not isTSTLMap(nil, newMap) then
48484
48540
  error("The copied Map was not a Map and has a type of: " .. __TS__TypeOf(newMap))
48485
48541
  end
@@ -48495,8 +48551,7 @@ function copiedSetIsSet(self)
48495
48551
  local valueToLookFor = "abc"
48496
48552
  local oldSet = __TS__New(Set)
48497
48553
  oldSet:add(valueToLookFor)
48498
- local newTable = deepCopy(nil, oldSet, SerializationType.NONE, "copiedSetIsSet")
48499
- local newSet = newTable
48554
+ local newSet = deepCopy(nil, oldSet, SerializationType.NONE, "copiedSetIsSet")
48500
48555
  if not isTSTLSet(nil, newSet) then
48501
48556
  error("The copied Set was not a Set and has a type of: " .. __TS__TypeOf(newSet))
48502
48557
  end
@@ -48505,8 +48560,7 @@ function copiedSetHasValue(self)
48505
48560
  local valueToLookFor = "abc"
48506
48561
  local oldSet = __TS__New(Set)
48507
48562
  oldSet:add(valueToLookFor)
48508
- local newTable = deepCopy(nil, oldSet, SerializationType.NONE, "copiedSetHasValue")
48509
- local newSet = newTable
48563
+ local newSet = deepCopy(nil, oldSet, SerializationType.NONE, "copiedSetHasValue")
48510
48564
  if not isTSTLSet(nil, newSet) then
48511
48565
  error("The copied Set was not a Set and has a type of: " .. __TS__TypeOf(newSet))
48512
48566
  end
@@ -48523,8 +48577,7 @@ function copiedMapHasChildMap(self)
48523
48577
  local keyToLookFor = "childMap"
48524
48578
  local oldMap = __TS__New(Map)
48525
48579
  oldMap:set(keyToLookFor, oldChildMap)
48526
- local newTable = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapHasChildMap")
48527
- local newMap = newTable
48580
+ local newMap = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapHasChildMap")
48528
48581
  if not isTSTLMap(nil, newMap) then
48529
48582
  error("The copied Map was not a Map and had a type of: " .. __TS__TypeOf(newMap))
48530
48583
  end
@@ -48556,8 +48609,7 @@ function copiedDefaultMapHasChildDefaultMap(self)
48556
48609
  local oldChildMap = oldParentMap:getAndSetDefault(parentMapKey)
48557
48610
  oldChildMap:getAndSetDefault(childMapKey1)
48558
48611
  oldChildMap:set(childMapKey2, childMapCustomValue)
48559
- local newTable = deepCopy(nil, oldParentMap, SerializationType.NONE, "copiedDefaultMapHasChildDefaultMap")
48560
- local newParentMap = newTable
48612
+ local newParentMap = deepCopy(nil, oldParentMap, SerializationType.NONE, "copiedDefaultMapHasChildDefaultMap")
48561
48613
  if not isDefaultMap(nil, newParentMap) then
48562
48614
  error("The copied parent DefaultMap was not a DefaultMap and had a type of: " .. __TS__TypeOf(newParentMap))
48563
48615
  end
@@ -54832,6 +54884,47 @@ function ____exports.getVanillaTrinketSet(self)
54832
54884
  lazyInitVanillaTrinketTypes(nil)
54833
54885
  return VANILLA_TRINKET_TYPES_SET
54834
54886
  end
54887
+ return ____exports
54888
+ end,
54889
+ ["src.types.WeightedArray"] = function(...)
54890
+ local ____exports = {}
54891
+ return ____exports
54892
+ end,
54893
+ ["src.functions.weighted"] = function(...)
54894
+ local ____lualib = require("lualib_bundle")
54895
+ local __TS__ArrayMap = ____lualib.__TS__ArrayMap
54896
+ local ____exports = {}
54897
+ local ____array = require("src.functions.array")
54898
+ local arrayToString = ____array.arrayToString
54899
+ local sumArray = ____array.sumArray
54900
+ local ____random = require("src.functions.random")
54901
+ local getRandomFloat = ____random.getRandomFloat
54902
+ local ____rng = require("src.functions.rng")
54903
+ local getRandomSeed = ____rng.getRandomSeed
54904
+ --- Get a random value from a `WeightedArray`. (The second element in the array is the weight.)
54905
+ function ____exports.getRandomFromWeightedArray(self, weightedArray, seedOrRNG)
54906
+ if seedOrRNG == nil then
54907
+ seedOrRNG = getRandomSeed(nil)
54908
+ end
54909
+ if #weightedArray == 0 then
54910
+ error("Failed to get a random element from a weighted array since the provided array was empty.")
54911
+ end
54912
+ local weights = __TS__ArrayMap(
54913
+ weightedArray,
54914
+ function(____, tuple) return tuple[2] end
54915
+ )
54916
+ local totalWeight = sumArray(nil, weights)
54917
+ local randomWeight = getRandomFloat(nil, 0, totalWeight, seedOrRNG)
54918
+ local weightAccumulator = 0
54919
+ for ____, tuple in ipairs(weightedArray) do
54920
+ local element, weight = table.unpack(tuple)
54921
+ weightAccumulator = weightAccumulator + weight
54922
+ if weightAccumulator >= randomWeight then
54923
+ return element
54924
+ end
54925
+ end
54926
+ error("Failed to get a random element from a weighted array: " .. arrayToString(nil, weightedArray))
54927
+ end
54835
54928
  return ____exports
54836
54929
  end,
54837
54930
  ["src.objects.colors"] = function(...)
@@ -56095,6 +56188,14 @@ do
56095
56188
  end
56096
56189
  end
56097
56190
  end
56191
+ do
56192
+ local ____export = require("src.functions.weighted")
56193
+ for ____exportKey, ____exportValue in pairs(____export) do
56194
+ if ____exportKey ~= "default" then
56195
+ ____exports[____exportKey] = ____exportValue
56196
+ end
56197
+ end
56198
+ end
56098
56199
  do
56099
56200
  local ____export = require("src.maps.cardNameToTypeMap")
56100
56201
  for ____exportKey, ____exportValue in pairs(____export) do