X-Git-Url: https://git.yukkurigames.com/?p=python-bulletml.git;a=blobdiff_plain;f=bulletml%2Fexpr.py;h=33f7d44bf1af0ba57be9955ec30b461a8c6064c3;hp=80224760f2039f66397fa0a62d2eb53ac34bf606;hb=9b5018cadee8ae1f5599b20095f47e4fa8b0bcc0;hpb=2e1e64f1f8076dd21a5ea1e7f8af6dbb74946d57 diff --git a/bulletml/expr.py b/bulletml/expr.py index 8022476..33f7d44 100644 --- a/bulletml/expr.py +++ b/bulletml/expr.py @@ -57,8 +57,13 @@ class NumberDef(object): if self.__value is not None: return self.__value rand = random.random() - variables = dict(rand=rand, rank=rank, params=params) + variables = { 'rand': rand, 'rank': rank, 'params': params } return eval(self.__expr, variables) def __repr__(self): return "%s(%r)" % (type(self).__name__, self.__original) + +class INumberDef(NumberDef): + """A NumberDef, but returns rounded integer results.""" + def __call__(self, params, rank): + return int(round(super(INumberDef, self).__call__(params, rank)))