Ejemplo n.º 1
0
    def __init__(self, parent, name,
                 thinker=None, items=[], statchanges={}, changes={}):
        copy_attrs(self, parent, 'stats', 'data', "base_actions")
        self.name = name

        if not thinker:
            thinker = parent.thinker
        self.thinker = thinker.instance(self)

        for stat, value in statchanges.items():
            self.stats[stat] += value
            #Local rules for stat modificiations

        for stat, value in parent.rules:
            self.stats[stat] = eval(value)
            #Personal rules for stat definition that default to global rules

        self.limbs = []
        self.limb_dict = {}
        self.buildbody(parent.body)

        self.equipped = []
        self.items = []
        self.item_dict = {}
        for item in parent.items + items:
            self.additem(item)
        #self.equipall()

        for name, value in changes.items():
            if type(value) in (str, int, dict, list):
                value = type(value)(value)
                #Makes a copy of the value, so we don't change the original
            else:
                value = value.instance(self)
            setattr(self, name, value)
Ejemplo n.º 2
0
    def __init__(self, parent, being, uplimb=None, prefix=""):
        copy_attrs(self, parent, 'data', 'stats', 'actions', 'equip', 'rules')
        self.prefix = prefix + " "
        self.name = prefix + parent.name
        self.being = being
        self.item = None
        self.status_list = []
        self.attached = []
        self.uplimb = uplimb
        if uplimb:
            uplimb.attached.append(self)

        self.applydatarules()
        self.applystats()
Ejemplo n.º 3
0
 def __init__(self, parent, actor, game=None):
     copy_attrs(
         self,
         parent,
         "name",
         "listeners",
         "data",
         "max_targets",
         "min_targets",
         "inverted_targets",
         "argsinfo"
     )
     self.parent = parent
     self.actor = actor
     if not game:
         import main
         game = main.game
     self.game = game
Ejemplo n.º 4
0
    def __init__(self, parent, targets=[], **args):
        copy_attrs(self, parent, "name", "data", "actor", "game")
        if type(targets) != list:
            targets = [targets]
        self.targets = targets
        self.args = args
        self.parent = parent
        self.listeners = defaultdict(lambda *a: lambda *a: None)
        for name, listener in parent.listeners.items():
            self.listeners[name] = MethodType(listener, self)

        if not (parent.min_targets <= len(targets) <= parent.max_targets):
            raise Exception("%s tried to %s an invalid amount of targets" % (
                                self.actor.name,
                                self.name
                            ))

        if parent.inverted_targets:
            newtargets = []
            for being in game.beings.values():
                if being not in targets:
                    newtargets.append(target)
            targets = newtargets
Ejemplo n.º 5
0
 def __init__(self, parent, name):
     copy_attrs(self, parent, 'equip', 'stats', 'actions', 'data')
     self.name = name
     self.owner = None
     self.limb = None