From 9e587bd4e33718271a311d87c4ae86be2fefd03c Mon Sep 17 00:00:00 2001 From: Greg Taylor Date: Mon, 23 Apr 2007 15:22:40 +0000 Subject: [PATCH] Important update: Fixed two crash bugs in attribute getting/setting. Less importantly, the money value shown in 'inventory' now pluralizes properly. --- apps/objects/models.py | 8 ++++---- commands_general.py | 10 +++++----- commands_privileged.py | 2 +- evennia.sql | Bin 65536 -> 65536 bytes 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/objects/models.py b/apps/objects/models.py index 573df86539..4ddb6a9d93 100755 --- a/apps/objects/models.py +++ b/apps/objects/models.py @@ -324,7 +324,7 @@ class Object(models.Model): """ if self.has_attribute(attribute): # Attribute already exists, update it. - attrib_obj = Attribute.objects.filter(object=self).filter(name=attribute) + attrib_obj = Attribute.objects.filter(object=self).filter(name=attribute)[0] attrib_obj.value = new_value attrib_obj.save() else: @@ -445,14 +445,14 @@ class Object(models.Model): def get_attribute_value(self, attrib, default=False): """ - Returns the value of an attribute on an object. + Returns the value of an attribute on an object. You may need to + type cast the returned value from this function! attrib: (str) The attribute's name. """ if self.has_attribute(attrib): attrib = Attribute.objects.filter(object=self).filter(name=attrib) - attrib_value = attrib[0].value - return attrib_value.value + return attrib[0].value else: if default: return default diff --git a/commands_general.py b/commands_general.py index 238dbcffdc..43a529239b 100644 --- a/commands_general.py +++ b/commands_general.py @@ -29,12 +29,12 @@ def cmd_inventory(cdat): for item in pobject.get_contents(): session.msg(" %s" % (item.get_ansiname(),)) - money = pobject.get_attribute_value("MONEY", default=0) - if money > 0: - money_name = functions_db.get_server_config("MONEY_NAME_PLURAL") - else: + money = int(pobject.get_attribute_value("MONEY", default=0)) + if money == 1: money_name = functions_db.get_server_config("MONEY_NAME_SINGULAR") - + else: + money_name = functions_db.get_server_config("MONEY_NAME_PLURAL") + session.msg("You have %d %s." % (money,money_name)) def cmd_look(cdat): diff --git a/commands_privileged.py b/commands_privileged.py index 27d3cd19c8..3a9338aa60 100644 --- a/commands_privileged.py +++ b/commands_privileged.py @@ -557,7 +557,7 @@ def cmd_set(cdat): attrib_value = eq_args[1][splicenum:] # In global_defines.py, see NOSET_ATTRIBS for protected attribute names. - if not functions_db.is_modifiable_attrib(attrib_name): + if not functions_db.is_modifiable_attrib(attrib_name) and not pobject.is_superuser(): session.msg("You can't modify that attribute.") return diff --git a/evennia.sql b/evennia.sql index 996055e5b49db3e4ff8487290ce61a4b0a6a8231..600480cbbf18934bf8e895c0b40a34df61199847 100755 GIT binary patch delta 169 zcmV;a09OBifCPYm1dtm6!m%9aX9@!Y(EtPT1L6bGvk?%(0}&4c1^^cm2mwt`PDNQU zH829R;%g!#3IhY~00a61^aJj*5fI=51_c8F0RjWF^pl<)1_BWPG#Lo9n6YXCDB%DR z0R{jARRLH5ssgzJlmc!7M*<)L`2&an(E~66hXV-#F98Mv&yj(Gv#hiw0h7hH!;{gq XO_O%ECjkJHp0+2G9=2Gsh_`r1QL!~L delta 141 zcmV;80CN9;fCPYm1dtm6s<9mCX9xlV;s68k1LCt05Y_{;;%g!#2m%B200a61^s^BV z=mWF#lb#(0GA%L!5dgE8v1$S+b^s9p1^@y>0ayX50rmmW17ZU^0~7-71Be2}0v-W} v0-gac0R{ullMw`hv#hiw0h5%rO_MOUSd-zlCjo7f3AZPc(Y3>~h_`r1`T8*|