mirror of
https://github.com/motajs/template.git
synced 2026-11-10 21:14:33 +08:00
feat: 新增道具迭代方法
This commit is contained in:
1 parent
ea7a404cc6
commit
afc484465e
2 files changed
+9
No files matched your search
@@ -43,6 +43,10 @@ export class HeroItems<THero> implements IHeroItems<THero> {
|
||||
return this.internalGetItemState(item);
|
||||
}
|
||||
|
||||
iterateItems(): Iterable<[num: number, item: IHeroItemState<THero>]> {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
itemCount(item: number | string): number {
|
||||
return this.getItemState(item)?.count ?? 0;
|
||||
}
|
||||
|
||||
@@ -626,6 +626,11 @@ export interface IHeroItems<THero>
|
||||
*/
|
||||
getItemState(item: number | string): Readonly<IHeroItemState<THero>> | null;
|
||||
|
||||
/**
|
||||
* 迭代勇士所拥有的所有道具,键表示道具的图块数字,值表示道具状态
|
||||
*/
|
||||
iterateItems(): Iterable<[num: number, item: IHeroItemState<THero>]>;
|
||||
|
||||
/**
|
||||
* 使用道具,仅对 Constant 与 Consumable 类型生效。Consumable 类型使用后数量减一。
|
||||
* @param item 道具图块数字或字符串 id
|
||||
|
||||
Reference in new issue
Block a user