예제 #1
0
 def update(self):
     self.has_run = False
     self.attributes = {}
     self.effects = {}
     self.restricted = set()
     attrs = Attribute.all().ancestor(self.player).fetch(1000)
     for attr in attrs:
         self.attributes[attr.name] = attr
         if attr not in self.attribute_types:
             self.attribute_types[attr.name] = cached_get_by_key_name(AttributeType, attr.name)
     # if you're missing default attributes, create them
     for name in ["health", "energy"]:
         if name not in self.attributes:
             self.attributes[name] = Attribute.get_or_prepare(self.player, name)
             if name not in self.attribute_types:
                 self.attribute_types[name] = cached_get_by_key_name(AttributeType, name)
예제 #2
0
 def add_effect(self, attr_name, amount):
     try:
         self.effects[attr_name] += amount
     except KeyError:
         self.effects[attr_name] = amount
         self.attribute_types[attr_name] = cached_get_by_key_name(AttributeType, attr_name)