From 19c2f95f74c4818f494c6a7a654e8aa5c6e4e08c Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sat, 5 Mar 2016 13:38:22 +0200 Subject: [PATCH] Implement 5s rule for seating. --- koperkapel/vehicles/base.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/koperkapel/vehicles/base.py b/koperkapel/vehicles/base.py index 1b2f3ed..f4506d6 100644 --- a/koperkapel/vehicles/base.py +++ b/koperkapel/vehicles/base.py @@ -18,18 +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 + def seating(self, world): + roach_seating = world.vehicles[self.vehicle_type].seating + roach_seating_numbers = enumerate(zip(roach_seating, self.seats)) + return { + roach: seat_pos + for seat_pos, (roach, _) in roach_seating_numbers if roach + } _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 + return cls.by_type(world.vehicles.current) @classmethod def by_type(cls, vehicle_type): -- 2.34.1