summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDipesh Amin <yaypunkrock@gmail.com>2011-08-23 22:42:42 +0100
committerDipesh Amin <yaypunkrock@gmail.com>2011-08-23 22:42:42 +0100
commit2cd71629569e8501667f3243cad50b8aa3a2efd6 (patch)
treed13cfa5641e652b9edc4d045057f3eb044a57137
parenteac0a33f4862ebdff5ac8e00fb819dbe34422597 (diff)
downloadmanamarket-2cd71629569e8501667f3243cad50b8aa3a2efd6.tar.gz
manamarket-2cd71629569e8501667f3243cad50b8aa3a2efd6.tar.bz2
manamarket-2cd71629569e8501667f3243cad50b8aa3a2efd6.tar.xz
manamarket-2cd71629569e8501667f3243cad50b8aa3a2efd6.zip
Add some code to prevent problems with the !add command.
Prevents the case where a person tries to add more than one piece of equiptment per slot. I also added some code to stop people adding items for free.
-rwxr-xr-xmain.py7
-rw-r--r--utils.py2
2 files changed, 9 insertions, 0 deletions
diff --git a/main.py b/main.py
index 9307031..d275ffa 100755
--- a/main.py
+++ b/main.py
@@ -358,6 +358,13 @@ def process_whisper(nick, msg, mapserv):
mapserv.sendall(whisper(nick, "Item not found, check spelling."))
return
+ if amount > 1 and 'equip' in ItemDB.getItem(ItemDB.findId(item_name)).type:
+ mapserv.sendall(whisper(nick, "You can only add one piece of equiptment per slot."))
+ return
+ elif price == 0:
+ mapserv.sendall(whisper(nick, "Nothing in life is free."))
+ return
+
item = Item()
item.player = nick
item.get = 1 # 1 = get, 0 = give
diff --git a/utils.py b/utils.py
index 2e1d0e8..007bbcc 100644
--- a/utils.py
+++ b/utils.py
@@ -58,6 +58,8 @@ class ItemDB:
item_struct.name = item.get('name')
if item.get('weight'):
item_struct.weight = item.get('weight')
+ if item.get('type'):
+ item_struct.type = item.get('type')
item_struct.description = item.get('description')
self.item_names[int(item.get('id'))] = item_struct