@occultus/condition-api 0.22.0-alpha.5 → 0.22.0-beta.1
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.
- package/README.md +1 -1
- package/package.json +3 -3
- package/src/api/Conditions.ts +2 -1
- package/src/api/ExpCondition.ts +2 -1
- package/src/api/ItemConditions.ts +5 -7
- package/src/api/ItemTagConditions.ts +7 -7
- package/src/api/KillEntityConditions.ts +1 -1
- package/src/api/KillEntityFamilyCondition.ts +1 -1
- package/src/api/LevelConditions.ts +2 -1
- package/src/index.ts +10 -10
package/README.md
CHANGED
|
@@ -27,4 +27,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
27
27
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
28
28
|
|
|
29
29
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
30
|
-
```
|
|
30
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@occultus/condition-api",
|
|
3
|
-
"version": "0.22.0-
|
|
3
|
+
"version": "0.22.0-beta.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://codeberg.org/TeamOccultus/StarTenonAPI"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@occultus/format-api": "0.21.0",
|
|
31
|
-
"@occultus/
|
|
32
|
-
"@occultus/
|
|
31
|
+
"@occultus/toolkit": "0.22.1",
|
|
32
|
+
"@occultus/text-api": "0.21.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typedoc": "^0.28.15"
|
package/src/api/Conditions.ts
CHANGED
|
@@ -12,9 +12,10 @@ export abstract class Conditions {
|
|
|
12
12
|
* 检查玩家是否满足条件
|
|
13
13
|
*
|
|
14
14
|
* @param player 要检查的玩家对象
|
|
15
|
+
* @param visual 将这次检查设置为虚拟检查,不会消耗条件对应游戏元素的数量
|
|
15
16
|
* @return 如果玩家满足条件返回`true`,否则返回`false`
|
|
16
17
|
*/
|
|
17
|
-
abstract check(player: Player): boolean;
|
|
18
|
+
abstract check(player: Player, visual?: boolean): boolean;
|
|
18
19
|
/**
|
|
19
20
|
* 获取条件的文本,该文本将会在任务面板中显示
|
|
20
21
|
*
|
package/src/api/ExpCondition.ts
CHANGED
|
@@ -16,8 +16,9 @@ export class ExpConditions extends Conditions {
|
|
|
16
16
|
) {
|
|
17
17
|
super();
|
|
18
18
|
}
|
|
19
|
-
check(player: Player) {
|
|
19
|
+
check(player: Player, visual = false) {
|
|
20
20
|
if (getAllExp(player) >= this.experience) {
|
|
21
|
+
if (visual) return true;
|
|
21
22
|
if (!this.consumeAmount) return true;
|
|
22
23
|
player.addExperience(-this.experience);
|
|
23
24
|
return true;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { ItemStack, Player, RawMessage } from "@minecraft/server";
|
|
2
2
|
import { Conditions } from "./Conditions";
|
|
3
|
-
import {
|
|
4
|
-
getItemAmountInContainer,
|
|
5
|
-
removeItemInContainer
|
|
6
|
-
} from "@occultus/toolkit";
|
|
3
|
+
import { getItemAmountOfPlayer, removeItemOfPlayer } from "@occultus/toolkit";
|
|
7
4
|
import { TextProvider } from "@occultus/text-api";
|
|
8
5
|
|
|
9
6
|
/**
|
|
@@ -36,13 +33,14 @@ export class ItemConditions extends Conditions {
|
|
|
36
33
|
* @param player
|
|
37
34
|
* @return
|
|
38
35
|
*/
|
|
39
|
-
check(player: Player) {
|
|
36
|
+
check(player: Player, visual = false) {
|
|
40
37
|
const container = player.getComponent("minecraft:inventory")?.container;
|
|
41
38
|
if (!container) return false;
|
|
42
|
-
const amount =
|
|
39
|
+
const amount = getItemAmountOfPlayer(player, this.getItem().typeId);
|
|
43
40
|
if (amount >= this.getItem().amount) {
|
|
41
|
+
if (visual) return true;
|
|
44
42
|
if (!this.consumeAmount) return true;
|
|
45
|
-
|
|
43
|
+
removeItemOfPlayer(player, this.itemType, this.amount);
|
|
46
44
|
return true;
|
|
47
45
|
}
|
|
48
46
|
return false;
|
|
@@ -2,7 +2,7 @@ import { Player, RawMessage } from "@minecraft/server";
|
|
|
2
2
|
import { Conditions } from "./Conditions";
|
|
3
3
|
import {
|
|
4
4
|
getTagItemAmountInContainer,
|
|
5
|
-
removeTagItemInContainer
|
|
5
|
+
removeTagItemInContainer
|
|
6
6
|
} from "@occultus/toolkit";
|
|
7
7
|
import { TextProvider } from "@occultus/text-api";
|
|
8
8
|
|
|
@@ -31,12 +31,12 @@ export class ItemTagConditions extends Conditions {
|
|
|
31
31
|
* @param player
|
|
32
32
|
* @return
|
|
33
33
|
*/
|
|
34
|
-
check(player: Player) {
|
|
34
|
+
check(player: Player, visual = false) {
|
|
35
35
|
const container = player.getComponent("minecraft:inventory")?.container;
|
|
36
36
|
if (!container) return false;
|
|
37
37
|
const amount = getTagItemAmountInContainer(container, this.tag);
|
|
38
|
-
|
|
39
38
|
if (amount >= this.amount) {
|
|
39
|
+
if (visual) return true;
|
|
40
40
|
if (!this.consumeAmount) return true;
|
|
41
41
|
removeTagItemInContainer(container, this.tag, this.amount);
|
|
42
42
|
return true;
|
|
@@ -52,8 +52,8 @@ export class ItemTagConditions extends Conditions {
|
|
|
52
52
|
rawtext: [
|
|
53
53
|
{ translate: "task.condition.itemTag" },
|
|
54
54
|
{ text: " × " },
|
|
55
|
-
{ text: this.translateKey }
|
|
56
|
-
]
|
|
55
|
+
{ text: this.translateKey }
|
|
56
|
+
]
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
@@ -68,8 +68,8 @@ export class ItemTagConditions extends Conditions {
|
|
|
68
68
|
{ text: " " },
|
|
69
69
|
{ translate: this.translateKey },
|
|
70
70
|
{ text: " × " },
|
|
71
|
-
{ text: this.amount.toString() }
|
|
72
|
-
]
|
|
71
|
+
{ text: this.amount.toString() }
|
|
72
|
+
]
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -15,8 +15,9 @@ export class LevelConditions extends Conditions {
|
|
|
15
15
|
) {
|
|
16
16
|
super();
|
|
17
17
|
}
|
|
18
|
-
check(player: Player) {
|
|
18
|
+
check(player: Player, visual = false) {
|
|
19
19
|
if (player.level >= this.level) {
|
|
20
|
+
if (visual) return true;
|
|
20
21
|
if (!this.consumeAmount) return true;
|
|
21
22
|
player.addLevels(-this.level);
|
|
22
23
|
return true;
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @occultus/condition-api
|
|
3
|
-
*/
|
|
4
|
-
export * from "./api/ItemConditions";
|
|
5
|
-
export * from "./api/KillEntityConditions";
|
|
6
|
-
export * from "./api/KillEntityFamilyCondition";
|
|
7
|
-
export * from "./api/LevelConditions";
|
|
8
|
-
export * from "./api/ExpCondition";
|
|
9
|
-
export * from "./api/ItemTagConditions"
|
|
10
|
-
export * from "./api/Conditions";
|
|
1
|
+
/**
|
|
2
|
+
* @module @occultus/condition-api
|
|
3
|
+
*/
|
|
4
|
+
export * from "./api/ItemConditions";
|
|
5
|
+
export * from "./api/KillEntityConditions";
|
|
6
|
+
export * from "./api/KillEntityFamilyCondition";
|
|
7
|
+
export * from "./api/LevelConditions";
|
|
8
|
+
export * from "./api/ExpCondition";
|
|
9
|
+
export * from "./api/ItemTagConditions";
|
|
10
|
+
export * from "./api/Conditions";
|