@occultus/condition-api 0.22.0-alpha.6 → 0.22.0-beta.2
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/ExpCondition.ts +10 -7
- package/src/api/ItemConditions.ts +7 -10
- package/src/api/ItemTagConditions.ts +5 -5
- package/src/api/KillEntityConditions.ts +1 -1
- package/src/api/KillEntityFamilyCondition.ts +1 -1
- package/src/api/LevelConditions.ts +10 -7
- 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.2",
|
|
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.2",
|
|
32
|
+
"@occultus/text-api": "0.21.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typedoc": "^0.28.15"
|
package/src/api/ExpCondition.ts
CHANGED
|
@@ -10,7 +10,10 @@ export class ExpConditions extends Conditions {
|
|
|
10
10
|
* @param experience 满足条件所需的最低等级
|
|
11
11
|
* @param consumeAmount 倘若为`true`,则条件检查通过后会自动消耗对应等级
|
|
12
12
|
*/
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(
|
|
14
|
+
protected experience: number,
|
|
15
|
+
protected consumeAmount = false
|
|
16
|
+
) {
|
|
14
17
|
super();
|
|
15
18
|
}
|
|
16
19
|
check(player: Player, visual = false) {
|
|
@@ -28,9 +31,9 @@ export class ExpConditions extends Conditions {
|
|
|
28
31
|
// 达到 %s 级
|
|
29
32
|
{
|
|
30
33
|
translate: "task.condition.level",
|
|
31
|
-
with: { text: this.experience.toString() }
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
+
with: { text: this.experience.toString() }
|
|
35
|
+
}
|
|
36
|
+
]
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
getFailedReason(): RawMessage {
|
|
@@ -39,9 +42,9 @@ export class ExpConditions extends Conditions {
|
|
|
39
42
|
// 你需要达到 %s 级
|
|
40
43
|
{
|
|
41
44
|
translate: "task.condition.level.failed",
|
|
42
|
-
with: { text: this.experience.toString() }
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
+
with: { text: this.experience.toString() }
|
|
46
|
+
}
|
|
47
|
+
]
|
|
45
48
|
};
|
|
46
49
|
}
|
|
47
50
|
}
|
|
@@ -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
|
/**
|
|
@@ -39,11 +36,11 @@ export class ItemConditions extends Conditions {
|
|
|
39
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) {
|
|
44
41
|
if (visual) return true;
|
|
45
42
|
if (!this.consumeAmount) return true;
|
|
46
|
-
|
|
43
|
+
removeItemOfPlayer(player, this.itemType, this.amount);
|
|
47
44
|
return true;
|
|
48
45
|
}
|
|
49
46
|
return false;
|
|
@@ -57,8 +54,8 @@ export class ItemConditions extends Conditions {
|
|
|
57
54
|
rawtext: [
|
|
58
55
|
{ translate: this.getItem().localizationKey },
|
|
59
56
|
{ text: " × " },
|
|
60
|
-
{ text: this.getItem().amount.toString() }
|
|
61
|
-
]
|
|
57
|
+
{ text: this.getItem().amount.toString() }
|
|
58
|
+
]
|
|
62
59
|
};
|
|
63
60
|
}
|
|
64
61
|
/**
|
|
@@ -73,8 +70,8 @@ export class ItemConditions extends Conditions {
|
|
|
73
70
|
{ text: " " },
|
|
74
71
|
{ translate: this.getItem().localizationKey },
|
|
75
72
|
{ text: " × " },
|
|
76
|
-
{ text: this.getItem().amount.toString() }
|
|
77
|
-
]
|
|
73
|
+
{ text: this.getItem().amount.toString() }
|
|
74
|
+
]
|
|
78
75
|
};
|
|
79
76
|
}
|
|
80
77
|
}
|
|
@@ -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
|
|
|
@@ -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
|
}
|
|
@@ -14,7 +14,7 @@ export class KillEntityConditions extends Conditions {
|
|
|
14
14
|
constructor(public entityType: string) {
|
|
15
15
|
super();
|
|
16
16
|
}
|
|
17
|
-
check(
|
|
17
|
+
check(_player: Player, _visual = false) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
getTextProvider(): RawMessage {
|
|
@@ -9,7 +9,10 @@ export class LevelConditions extends Conditions {
|
|
|
9
9
|
* @param level 满足条件所需的最低等级
|
|
10
10
|
* @param consumeAmount 倘若为`true`,则条件检查通过后会自动消耗对应等级
|
|
11
11
|
*/
|
|
12
|
-
constructor(
|
|
12
|
+
constructor(
|
|
13
|
+
protected level: number,
|
|
14
|
+
protected consumeAmount = false
|
|
15
|
+
) {
|
|
13
16
|
super();
|
|
14
17
|
}
|
|
15
18
|
check(player: Player, visual = false) {
|
|
@@ -27,9 +30,9 @@ export class LevelConditions extends Conditions {
|
|
|
27
30
|
// 达到 %s 级
|
|
28
31
|
{
|
|
29
32
|
translate: "task.condition.level",
|
|
30
|
-
with: { text: this.level.toString() }
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
+
with: { text: this.level.toString() }
|
|
34
|
+
}
|
|
35
|
+
]
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
getFailedReason(): RawMessage {
|
|
@@ -38,9 +41,9 @@ export class LevelConditions extends Conditions {
|
|
|
38
41
|
// 你需要达到 %s 级
|
|
39
42
|
{
|
|
40
43
|
translate: "task.condition.level.failed",
|
|
41
|
-
with: { text: this.level.toString() }
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
+
with: { text: this.level.toString() }
|
|
45
|
+
}
|
|
46
|
+
]
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
49
|
}
|
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";
|