Skip to content

Commit

Permalink
Beta 2 (#17)
Browse files Browse the repository at this point in the history
* update tags inferface

* beta2

release candidate

fixes #16
fixes #11

todo:
- equipment recipe
- thorough testing of tags features
  • Loading branch information
ChapelR authored Feb 19, 2024
1 parent 4c578f9 commit e74a5b6
Show file tree
Hide file tree
Showing 17 changed files with 1,969 additions and 1,928 deletions.
2 changes: 1 addition & 1 deletion dist/simple-inventory.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/simple-inventory.js

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions docs/InventoryAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ Cannot be set by users.

Returns the number of unique items in the inventory. Each type of item is only counted once, regardless of the quantity.

### `inventory#tags`

##### ( array )

Cannot be set by users.

Returns the array of tags.

## `Inventory` Instance Methods

### `inventory#count()`
Expand Down Expand Up @@ -392,6 +400,54 @@ Can be chained.

Can be chained.

### `inventory#hasTag()`

##### Syntax

```
<inventory>.hasTag(tag)
```

##### Arguments

- `tag` (string) a tag to check for

Returns whether the inventory has the indicated tag.

##### Returns ( boolean )

### `inventory#hasAllTags()`

##### Syntax

```
<inventory>.hasAllTags(tagList)
```

##### Arguments

- `tagList` (string | string array) a list of tags to check for; can be strings passed as individual arguments, an array of strings, or any combination thereof

Returns whether the inventory has **all of** the indicated tag(s).

##### Returns ( boolean )

### `inventory#hasAnyTags()`

##### Syntax

```
<inventory>.hasAnyTags(tagList)
```

##### Arguments

- `tagList` (string | string array) a list of tags to check for; can be strings passed as individual arguments, an array of strings, or any combination thereof

Returns whether the inventory has **any of** the indicated tag(s).

##### Returns ( boolean )

### `inventory#clone()`

##### Syntax
Expand Down
58 changes: 57 additions & 1 deletion docs/ItemAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ Replaces the item's ID in the user-interfaces.

Can be set to any string value.

### `item#tags`

##### ( array )

Cannot be set by users.

Returns the array of tags.

## `Item` Instance Methods

### `item#use()`
Expand Down Expand Up @@ -136,4 +144,52 @@ Creates a dialog box and renders the item's description into it.

##### Returns ( `this` )

Can be chained.
Can be chained.

### `item#hasTag()`

##### Syntax

```
<item>.hasTag(tag)
```

##### Arguments

- `tag` (string) a tag to check for

Returns whether the item has the indicated tag.

##### Returns ( boolean )

### `item#hasAllTags()`

##### Syntax

```
<item>.hasAllTags(tagList)
```

##### Arguments

- `tagList` (string | string array) a list of tags to check for; can be strings passed as individual arguments, an array of strings, or any combination thereof

Returns whether the item has **all of** the indicated tag(s).

##### Returns ( boolean )

### `item#hasAnyTags()`

##### Syntax

```
<item>.hasAnyTags(tagList)
```

##### Arguments

- `tagList` (string | string array) a list of tags to check for; can be strings passed as individual arguments, an array of strings, or any combination thereof

Returns whether the item has **any of** the indicated tag(s).

##### Returns ( boolean )
6 changes: 3 additions & 3 deletions docs/demo.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/recipes/collectibles.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/recipes/crafting.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/recipes/keys.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/recipes/potions.html

Large diffs are not rendered by default.

52 changes: 24 additions & 28 deletions docs/recipes/shop.html

Large diffs are not rendered by default.

46 changes: 21 additions & 25 deletions docs/recipes/shop/index.twee
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Config.ui.stowBarInitially = false;
["pretty stone", 3]
])>>

<<pickup $shop "coal" 10 "gold nugget" 2, "iron ingot" 5>>
<<pickup $shop "coal" 10 "gold nugget" 2 "iron ingot" 5>>
<<pickup $storage "iron ingot" 1 "glass shard" 20>>
<<pickup $player "glass shard" 10 "pretty stone" 20, "gemstone" 5>>

Expand All @@ -54,20 +54,22 @@ Gold: @@#gold;<<= $gold>>@@
<span>_item</span>
<span class="count">_amount</span>
<span class="buy-link">
<<link "Buy">>
<<if $gold < _price>>
<<run UI.alert("You don't have enough gold!")>>
<<else>>
<<gold `-1 * _price`>>
<<transfer $shop $player _item 1>>
<<set _amount -->>
<<if _amount > 0>>
<<replace `"p.buy-listing[data-item=\"" + _item + "\"] > .count"`>>_amount<</replace>>
<<capture _item, _amount, _price>>
<<link "Buy">>
<<if $gold < _price>>
<<run UI.alert("You don't have enough gold!")>>
<<else>>
<<remove `"p.buy-listing[data-item=\"" + _item + "\"]"`>>
<<gold `-1 * _price`>>
<<transfer $shop $player _item 1>>
<<set _amount -->>
<<if _amount > 0>>
<<replace `"p.buy-listing[data-item=\"" + _item + "\"] > .count"`>>_amount<</replace>>
<<else>>
<<remove `"p.buy-listing[data-item=\"" + _item + "\"]"`>>
<</if>>
<</if>>
<</if>>
<</link>>
<</link>>
<</capture>>
</span>
</p>
<</widget>>
Expand All @@ -80,10 +82,8 @@ Gold: @@#gold;<<= $gold>>@@
<span>_item</span>
<span class="count">_amount</span>
<span class="sell-link">
<<link "Sell">>
<<if $gold < _price>>
<<run UI.alert("You don't have enough gold!")>>
<<else>>
<<capture _item, _amount, _price>>
<<link "Sell">>
<<gold _price>>
<<transfer $player $shop _item 1>>
<<set _amount -->>
Expand All @@ -92,8 +92,8 @@ Gold: @@#gold;<<= $gold>>@@
<<else>>
<<remove `"p.sell-listing[data-item=\"" + _item + "\"]"`>>
<</if>>
<</if>>
<</link>>
<</link>>
<</capture>>
</span>
</p>
<</widget>>
Expand Down Expand Up @@ -133,9 +133,7 @@ You arrive at the market!
<h2>Items for sale:</h2>
<div class="shopping-interface">
<<for _item, _amount range $shop.table>>
<<capture _item _amount>>
<<buylink _item _amount>>
<</capture>>
<<buylink _item _amount>>
<</for>>
</div>
<br><br>
Expand All @@ -145,9 +143,7 @@ You arrive at the market!
<h2>Items on hand:</h2>
<div class="shopping-interface">
<<for _item, _amount range $player.table>>
<<capture _item _amount>>
<<selllink _item _amount>>
<</capture>>
<<selllink _item _amount>>
<</for>>
</div>
<br><br>
Expand Down
Loading

0 comments on commit e74a5b6

Please sign in to comment.