X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=koperkapel%2Fvehicles%2Fbase.py;h=c2a24f64ecbfb6cb5d9f27cc03ae11da0a3cf141;hb=55c4bcf03552816d8da08974179aac95b40996af;hp=9aff447f1fdbb0134635059671773734a9a6bd9a;hpb=ac587543218e5179289e18a147e7118f10348dfe;p=koperkapel.git diff --git a/koperkapel/vehicles/base.py b/koperkapel/vehicles/base.py index 9aff447..c2a24f6 100644 --- a/koperkapel/vehicles/base.py +++ b/koperkapel/vehicles/base.py @@ -1,5 +1,6 @@ """ Base class for vehicles. """ +from itertools import chain, islice, repeat from pygame.constants import BLEND_RGBA_MULT from pgzero.actor import Actor from pgzero.loaders import images @@ -30,6 +31,22 @@ class Vehicle: for seat_pos, (roach, _) in roach_seating_numbers if roach } + def seat_roach(self, world, roach, seat_pos): + vehicle = world.vehicles[self.vehicle_type] + seats = len(self.seats) + seating = list(vehicle.seating) + seating = list(islice( + chain(seating, repeat(None, seats)), 0, seats)) + seating[seat_pos] = roach + # line below records new seating on the world proxy + vehicle.seating = seating + + def roach_at(self, world, seat_pos): + roach_seating = world.vehicles[self.vehicle_type].seating + if seat_pos >= len(roach_seating): + return None + return roach_seating[seat_pos] + _vehicle_types = {} @classmethod