isaacscript-common 1.2.15 → 1.2.16
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.
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
import { PillEffectClass } from "../types/PillEffectClass";
|
|
3
|
+
import { PillEffectType } from "../types/PillEffectType";
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to get a pill effect class from a PillEffect enum value. In this context, the
|
|
6
|
+
* class is equal to the numerical prefix in the "class" tag in the "pocketitems.xml" file. Use the
|
|
7
|
+
* `getPillEffectType` helper function to determine whether or not the pill effect is positive,
|
|
8
|
+
* negative, or neutral.
|
|
9
|
+
*
|
|
10
|
+
* Due to limitations in the API, this function will not work properly for modded pill effects, and
|
|
11
|
+
* will always return `DEFAULT_PILL_EFFECT_CLASS` in those cases.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getPillEffectClass(pillEffect: PillEffect | int): PillEffectClass;
|
|
2
14
|
/**
|
|
3
15
|
* Helper function to get a pill effect name from a PillEffect enum value.
|
|
4
16
|
*
|
|
@@ -9,3 +21,13 @@
|
|
|
9
21
|
* ```
|
|
10
22
|
*/
|
|
11
23
|
export declare function getPillEffectName(pillEffect: PillEffect | int): string;
|
|
24
|
+
/**
|
|
25
|
+
* Helper function to get a pill effect type from a PillEffect enum value. In this context, the
|
|
26
|
+
* type is equal to positive, negative, or neutral. This is derived from the suffix of the the
|
|
27
|
+
* "class" tag in the "pocketitems.xml" file. Use the `getPillEffectClass` helper function to
|
|
28
|
+
* determine the "power" of the pill.
|
|
29
|
+
*
|
|
30
|
+
* Due to limitations in the API, this function will not work properly for modded pill effects, and
|
|
31
|
+
* will always return `DEFAULT_PILL_EFFECT_TYPE` in those cases.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getPillEffectType(pillEffect: PillEffect | int): PillEffectType;
|
package/dist/functions/pills.lua
CHANGED
|
@@ -2,8 +2,20 @@
|
|
|
2
2
|
local ____lualib = require("lualib_bundle")
|
|
3
3
|
local Map = ____lualib.Map
|
|
4
4
|
local ____exports = {}
|
|
5
|
+
local ____pillEffectClassMap = require("maps.pillEffectClassMap")
|
|
6
|
+
local PILL_EFFECT_CLASS_MAP = ____pillEffectClassMap.PILL_EFFECT_CLASS_MAP
|
|
5
7
|
local ____pillEffectNameMap = require("maps.pillEffectNameMap")
|
|
6
8
|
local PILL_EFFECT_NAME_MAP = ____pillEffectNameMap.PILL_EFFECT_NAME_MAP
|
|
9
|
+
local ____pillEffectTypeMap = require("maps.pillEffectTypeMap")
|
|
10
|
+
local PILL_EFFECT_TYPE_MAP = ____pillEffectTypeMap.PILL_EFFECT_TYPE_MAP
|
|
11
|
+
local ____PillEffectClass = require("types.PillEffectClass")
|
|
12
|
+
local DEFAULT_PILL_EFFECT_CLASS = ____PillEffectClass.DEFAULT_PILL_EFFECT_CLASS
|
|
13
|
+
local ____PillEffectType = require("types.PillEffectType")
|
|
14
|
+
local DEFAULT_PILL_EFFECT_TYPE = ____PillEffectType.DEFAULT_PILL_EFFECT_TYPE
|
|
15
|
+
function ____exports.getPillEffectClass(self, pillEffect)
|
|
16
|
+
local pillEffectClass = PILL_EFFECT_CLASS_MAP:get(pillEffect)
|
|
17
|
+
return pillEffectClass == nil and DEFAULT_PILL_EFFECT_CLASS or pillEffectClass
|
|
18
|
+
end
|
|
7
19
|
function ____exports.getPillEffectName(self, pillEffect)
|
|
8
20
|
local itemConfig = Isaac.GetItemConfig()
|
|
9
21
|
local defaultName = "Unknown"
|
|
@@ -20,4 +32,8 @@ function ____exports.getPillEffectName(self, pillEffect)
|
|
|
20
32
|
end
|
|
21
33
|
return itemConfigPillEffect.Name
|
|
22
34
|
end
|
|
35
|
+
function ____exports.getPillEffectType(self, pillEffect)
|
|
36
|
+
local pillEffectClass = PILL_EFFECT_TYPE_MAP:get(pillEffect)
|
|
37
|
+
return pillEffectClass == nil and DEFAULT_PILL_EFFECT_TYPE or pillEffectClass
|
|
38
|
+
end
|
|
23
39
|
return ____exports
|
|
@@ -9,4 +9,5 @@ ____exports.PillEffectClass.MEDIUM = 2
|
|
|
9
9
|
____exports.PillEffectClass[____exports.PillEffectClass.MEDIUM] = "MEDIUM"
|
|
10
10
|
____exports.PillEffectClass.MAJOR = 3
|
|
11
11
|
____exports.PillEffectClass[____exports.PillEffectClass.MAJOR] = "MAJOR"
|
|
12
|
+
____exports.DEFAULT_PILL_EFFECT_CLASS = ____exports.PillEffectClass.MEDIUM
|
|
12
13
|
return ____exports
|
|
@@ -7,4 +7,5 @@ ____exports.PillEffectType.NEGATIVE = 1
|
|
|
7
7
|
____exports.PillEffectType[____exports.PillEffectType.NEGATIVE] = "NEGATIVE"
|
|
8
8
|
____exports.PillEffectType.NEUTRAL = 2
|
|
9
9
|
____exports.PillEffectType[____exports.PillEffectType.NEUTRAL] = "NEUTRAL"
|
|
10
|
+
____exports.DEFAULT_PILL_EFFECT_TYPE = ____exports.PillEffectType.NEUTRAL
|
|
10
11
|
return ____exports
|