cls = BaseLight.find_cls(light_config["type"])
return cls.BASE_COST + int(cls.find_cost(light_config) / 10) + num_colours
+def light_info(light_config):
+ """Generate info about a light to go in the tooltip. """
+ cls = BaseLight.find_cls(light_config["type"])
+ return cls.get_info(light_config)
+
class BaseLight(object):
""" Common light functionality. """
cost = 5 * config["intensity"]
return cost
+ @classmethod
+ def get_info(cls, config):
+ return ["intensity: %g" % config["intensity"]]
+
def add(self, space):
if self.body.space is not None:
space.remove(self.body, *self.body.shapes)
cost += 5 * (ir[1] - ir[0])
return cost
+ @classmethod
+ def get_info(cls, config):
+ pr = config.get("pulse_range", cls.DEFAULT_PULSE_RANGE)
+ pv = config.get("pulse_velocity", cls.DEFAULT_PULSE_VELOCITY)
+ ir = config.get("intensity_range", cls.DEFAULT_INTENSITY_RANGE)
+ iv = config.get("intensity_velocity", cls.DEFAULT_INTENSITY_VELOCITY)
+ return [
+ "intensity: %g - %g, velocity %g" % (ir[0], ir[1], iv),
+ "pulse: %d - %d, velocity %g" % (pr[0], pr[1], pv),
+ ]
+
class SpotLight(BaseLight):
def find_cost(cls, config):
cost = super(SpotLight, cls).find_cost(config)
cost += config.get("angular_velocity", 0)
+ cost += config["spread"] / 10
+ rl = config["radius_limits"]
+ cost += (rl[1] - rl[0]) / 10
return cost
+
+ @classmethod
+ def get_info(cls, config):
+ info = super(SpotLight, cls).get_info(config)
+ rl = config["radius_limits"]
+ info.extend([
+ "spread: %d" % config["spread"],
+ "length: %d" % (rl[1] - rl[0]),
+ "angular velocity: %g" % config.get("angular_velocity", 0),
+ ])
+ return info