Slightly more advanced roach seating.
authorSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 11:07:36 +0000 (13:07 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 11:07:36 +0000 (13:07 +0200)
koperkapel/vehicles/base.py

index fb4640dd73be2a47e217bd0c1f66ac27565188ec..1b2f3ed279ff471ff9d151d9c5a4ca93e7e3ba24 100644 (file)
@@ -18,8 +18,19 @@ class Vehicle:
     def init_seats(self):
         raise NotImplementedError("Vehicles should specify a list of seats")
 
+    def assign_seats(self, seating):
+        for roach_name, seat in zip(seating, self.seats):
+            seat.roach = roach_name
+
     _vehicle_types = {}
 
+    @classmethod
+    def current(cls, world):
+        vehicle = cls.by_type(world.vehicles.current)
+        vehicle.assign_seats(
+            world.vehicles[vehicle.vehicle_type].seating)
+        return vehicle
+
     @classmethod
     def by_type(cls, vehicle_type):
         return cls._vehicle_types.get(vehicle_type)()