def update(self, shift=0.0): if self.speed > 0: self.speed -= 0.1 else: self.speed = 0 if -90 < self.angle <= 90: self.angle -= 0.5 else: self.angle += 0.5 Weapon.update(self, shift=shift) self.health -= 1 self.rect.center = self.x, self.y self.pxarray = pygame.PixelArray(self.bitmap) pxa_len_x = len(self.pxarray) pxa_len_y = len(self.pxarray[0]) for x in range(pxa_len_x): for y in range(pxa_len_y): G = self.bitmap.unmap_rgb(self.pxarray[x][y])[1] + 5 if G > 255: G = 0 self.pxarray[x][y] = (255, G, 0, self.bitmap.unmap_rgb(self.pxarray[x][y])[3]) del self.pxarray
def make_piece(name: str, leader: bool, heavy: bool) -> Model: """Template function to create a model piece""" leadership = 8 if leader: leadership += 1 weapons = [ Weapon('laspistol', 18, 'pistol 1', 4, 0, '1', None), Weapon('grenade', 8, 'grenade 6', 8, -1, '1', 'blast'), Weapon('chainsword', 'melee', 'melee 2', 5, -1, '1', None) ] elif heavy: weapons = [ Weapon('rocket', 36, 'heavy 1', 8, -2, '1', None), Weapon('grenade', 8, 'grenade D6', 8, -1, '1', 'blast'), Weapon('knife', 'melee', 'melee 1', 4, 0, '1', None) ] else: weapons = [ Weapon('lasgun', 36, 'assault 2', 5, 0, '1', None), Weapon('grenade', 8, 'grenade D6', 8, -1, '1', 'blast'), Weapon('knife', 'melee', 'melee 1', 4, 0, '1', None) ] # change to user strength, attacks] return Model( ModelStats(name, 6, 4, 4, 4, 4, 1, 1, leadership, 5), [], [], [], # not sure how this is gonna look like callbacks? weapons )
def __init__(self, parameters, x_pos, y_pos, factor, speed=1.0, angle=0.0, member='missle'): Weapon.__init__(self, parameters, x_pos, y_pos, factor, speed=speed, angle=angle, member=member) self.assel = self.param['assel'] self.fuel = self.live self.wfire_bitmap = pygame.image.load(self.param['bitmap_path_wf'] ).convert_alpha() self.wfire_bitmap = pygame.transform.scale(self.wfire_bitmap, list((int(i * factor) for i in self.wfire_bitmap.get_size()))) self.radius = self.param['detected_radius'] * self.factor self.smoke = self.param['effect2']
def make_tank(name: str, pos: int, off_board: bool) -> Unit: """Example tank to check heavy guns, blast and damage tables""" return Unit(name, 'Tank', pos, Strategy.HOLD, [ Model( ModelStats("Tank", 12, "-", 3, 8, 8, 10, "-", 10, 3), [ DamageTable(6, 10, {"ballistic_skill": 3, "movement": 12}), DamageTable(3, 5, {"ballistic_skill": 4, "movement": 8}), DamageTable(0, 2, {"ballistic_skill": 5, "movement": 6}) ], [], [], [ Weapon('Main Cannon', 72, 'heavy 1', 8, 0, 'D6', 'blast'), Weapon('Lascannon', 48, 'heavy 2', 8, -2, 'D3', None), Weapon('Heavy Bolter', 23, 'heavy 3', 7, 0, '1', None), ] ) ], {'vehicle'}, False)
def update(self, shift=0.0): if self.fuel > 0: self.speed += self.assel self.fuel -= 1 elif self.fuel == 0: self.fuel -= 1 self.org_bitmap = self.wfire_bitmap self.bitmap = self.wfire_bitmap self.bitmap = pygame.transform.rotate(self.org_bitmap, self.angle) self.rect = self.bitmap.get_rect() self.rect.center = self.x, self.y self.mask = pygame.mask.from_surface(self.bitmap) else: self.g_force += 0.05 self.speed -= self.assel / 10 Weapon.update(self, shift=shift) if self.speed <= 0: self.remove_flag = 1
def resolve_weapons(selection: Dict, sub_selections): """Converts the dictionary into a list of weapons""" weapons = [] # import pdb # pdb.set_trace() for s in selection['selection_entries'].values(): weapons.extend(resolve_weapons(s, sub_selections)) for s in selection['selection_entry_groups'].values(): weapons.extend(resolve_weapons(s, sub_selections)) for p in selection['profiles']: if p['profile_type'] == 'Weapon' and selection['id'] in sub_selections[1]: name = selection['name'] or p['name'] weapons.append( Weapon(name, p['Range'].replace('"', ''), p['Type'], p['S'], p['AP'], p['D'], p['Abilities']) ) return weapons
def __init__(self, parameters, x_pos, y_pos, factor, speed=0.0, angle=0.0, member='snag'): Weapon.__init__(self, parameters, x_pos, y_pos, factor, speed=speed, angle=angle, member=member) self.health = self.live self.step = 0
def update(self, shift=0.0): Weapon.update(self, shift=shift) self.live -= 1 if self.live == 0: self.remove_flag = 1
def __init__(self, parameters, x_pos, y_pos, factor, speed=0.0, angle=0.0, member='cannon'): Weapon.__init__(self, parameters, x_pos, y_pos, factor, speed=speed, angle=angle, member=member)