| 1 |
# -*- coding: utf-8 -*- |
| 2 |
#item.py |
| 3 |
# This is one of the files that can be called by an npc_dialog, |
| 4 |
# The following code runs when a dialog has a pre rule of 'item' |
| 5 |
# The syntax is ["item", "itemname", "numberrequired"] |
| 6 |
# numberrequired is optional, if it is missing then 1 is assumed. |
| 7 |
# To deliver a True verdict, the player must have at least numberrequired |
| 8 |
# copies of an item with name 'itemname' |
| 9 |
# if the itemname is 'money' then as a special case, the check |
| 10 |
# is against the total value of coin held, in silver. In this |
| 11 |
# case the value of the coin must exceed numberrequired silver, |
| 12 |
# in any denominations |
| 13 |
# |
| 14 |
## DIALOGCHECK |
| 15 |
## MINARGS 1 |
| 16 |
## MAXARGS 2 |
| 17 |
## .* |
| 18 |
## \d+ |
| 19 |
## ENDDIALOGCHECK |
| 20 |
|
| 21 |
itemname = args[0] |
| 22 |
if len(args) == 2: |
| 23 |
quantity = args[1] |
| 24 |
else: |
| 25 |
quantity = 1 |
| 26 |
if itemname == "money": |
| 27 |
if character.Money < int(quantity): |
| 28 |
verdict = False |
| 29 |
else: |
| 30 |
inv = character.CheckInventory(itemname) |
| 31 |
if inv: |
| 32 |
q = inv.Quantity |
| 33 |
if q == 0: |
| 34 |
q = 1 |
| 35 |
if q < int(quantity): |
| 36 |
verdict = False |
| 37 |
else: |
| 38 |
verdict = False |