Permalink
Browse files

Implement Attr()

  • Loading branch information...
jleclanche committed Jul 18, 2015
1 parent 886cfc2 commit 4e70b3e046ae81512ade7c908c2c6381df2a554f
Showing with 14 additions and 0 deletions.
  1. +14 −0 fireplace/actions.py
@@ -42,6 +42,20 @@ def evaluate(self, source, game):
return len(self.selector.eval(game, source))
class Attr(LazyNum):
"""
Lazily evaluate the sum of all tags in a selector
"""
def __init__(self, selector, tag):
super().__init__()
self.selector = selector
self.tag = tag
def evaluate(self, source, game):
entities = self.selector.eval(game, source)
return sum(e.tags[self.tag] for e in entities)
class Evaluator:
"""
Lazily evaluate a condition at runtime.

0 comments on commit 4e70b3e

Please sign in to comment.