Пример #1
0
    def townadded(self, team, town):
        debug('added town {}', town)

        if not team.controlled_by(self.local.player):
            debug('local player doesn\'t control this town')
            return

        resource = '/' + self.datasrc.getresource(town.race['resource_icon'])
        energy = '/' + self.datasrc.getresource(town.race['energy_icon'])

        self.resources[town.resources.rpid] = {
            'name': town.name,
            'resource_image': resource,
            'energy_image': energy,
            'resource_value': 0,
            'energy_value': 0,
            'position': (0, 0),
        }

        town.resources.onchange.add(self.update_resources)
        town.onentityadded.add(self.update_founder)

        # refresh the number right now
        self.update_resources(town.resources)
        self.update_founder(town, town.founder)
Пример #2
0
 def load_data(self):
     debug('camera load data')
     data = self.datasrc.getmisc('camera.initial.position')
     look = data[str(self.local.pid)]
     self.lookx = int(look['x'])
     self.looky = int(look['y'])
     self.sx = int(look['sx'])
     self.sy = int(look['sy'])
Пример #3
0
 def findlike(self, proto, pos):
     x, y = pos
     debug('looking for ', proto, x, y)
     R = 20
     for e in self.map.entities_in_rect(x - R, y - R, x + R, y + R):
         if e.proto.name == proto.name:
             debug('found', e, e.proto)
             return e
Пример #4
0
    def deduct(self, cost):
        self.resource -= cost.resource
        self.energy -= cost.energy

        debug('paid %d, %d, resources now %d, %d' %
              (cost.resource, cost.energy, self.resource, self.energy))

        self.onchange.emit(self)
Пример #5
0
    def addentity(self, ent):
        debug('adding entity {} to town {}', ent.eid, self)
        self.eids.add(ent.eid)
        self.towncomponents.add(ent.town)

        self.onentityadded.emit(self, ent)
Пример #6
0
 def founder(self):
     try:
         return self.em.get(self.founder_eid)
     except KeyError:
         debug('founder not loaded yet {} {}', self, self.founder_eid)
         return None
Пример #7
0
 def moveto(self, target, range=None):
     debug('moveto {0}@{1}', target, range)
     self.target = target
     self.range = range
     self.findpath()
Пример #8
0
 def deduct(self, amt):
     self.quantity -= amt
     debug(f'resource has {self.quantity} remaining')
     if self.quantity <= 0:
         if self.deplete:
             self.deplete(self.eid)
Пример #9
0
 def step(self):
     if not self.ready and self.locator.placed:
         debug('footprinting {}', self.ent)
         self.ready = self.map.footprint(self.locator)
Пример #10
0
 def emit(self, *args, **kwargs):
     for func in self.listeners:
         if self.debug:
             debug('emitting {0} to {1}(*{2}, **{3})', self.debug, func,
                   args, kwargs)
         func(*args, **kwargs)