File: item.py

package info (click to toggle)
crossfire-maps 1.75.0%2Bdfsg1-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 275,656 kB
  • sloc: python: 7,711; sql: 92; sh: 73; makefile: 7
file content (38 lines) | stat: -rw-r--r-- 1,074 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
#item.py
# This is one of the files that can be called by an npc_dialog,
# The following code runs when a dialog has a pre rule of 'item'
# The syntax is ["item", "itemname", "numberrequired"]
# numberrequired is optional, if it is missing then 1 is assumed.
# To deliver a True verdict, the player must have at least numberrequired
# copies of an item with name 'itemname'
# if the itemname is 'money' then as a special case, the check
# is against the total value of coin held, in silver. In this
# case the value of the coin must exceed numberrequired silver,
# in any denominations
#
## DIALOGCHECK
## MINARGS 1
## MAXARGS 2
## .*
## \d+
## ENDDIALOGCHECK

itemname = args[0]
if len(args) == 2:
    quantity = args[1]
else:
    quantity = 1
if itemname == "money":
    if character.Money < int(quantity):
        verdict = False
else:
    inv = character.CheckInventory(itemname)
    if inv:
        q = inv.Quantity
        if q == 0:
            q = 1
        if q < int(quantity):
            verdict = False
    else:
        verdict = False