Merge branch 'master' of ctpug.org.za:koperkapel
[koperkapel.git] / koperkapel / vehicles / base.py
index 9aff447f1fdbb0134635059671773734a9a6bd9a..31f7eeaaa4f9ced6ac2285ab336038afd7975841 100644 (file)
@@ -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,16 @@ 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
+
     _vehicle_types = {}
 
     @classmethod