X-Git-Url: https://git.yukkurigames.com/?p=python-bulletml.git;a=blobdiff_plain;f=bulletml%2Fparser.py;h=187fa86e7df4dc5f866abd741c4939f9b62c7579;hp=10459ccb5f326a04f1bb1482d6a246c54d26df62;hb=181030a9517b3742250dadbf6df7ed633b50831e;hpb=8b5f536fd3c64a9cfd21f82f3460b64f02bff73b diff --git a/bulletml/parser.py b/bulletml/parser.py index 10459cc..187fa86 100644 --- a/bulletml/parser.py +++ b/bulletml/parser.py @@ -52,7 +52,7 @@ class Direction(object): self.value = NumberDef(element.text) def __call__(self, params, rank): - return self.value(params, rank) + return (self.value(params, rank), self.type) def __repr__(self): return "%s(%r, type=%r)" % ( @@ -88,11 +88,10 @@ class Speed(object): self.value = NumberDef(element.text) def __call__(self, params, rank): - return self.value(params, rank) + return (self.value(params, rank), self.type) def __repr__(self): - return "%s(%r, type=%r)" % ( - type(self).__name__, self.value, self.type) + return "%s(%r, type=%r)" % (type(self).__name__, self.value, self.type) class ChangeSpeed(object): """Speed change over time.""" @@ -206,20 +205,18 @@ class BulletDef(object): elif tag == "speed": self.speed = Speed(doc, subelem) elif tag == "action": - self.actions.append(ActionDef(doc, element)) + self.actions.append(ActionDef(doc, subelem)) elif tag == "actionRef": - self.actions.append(ActionRef(doc, element)) + self.actions.append(ActionRef(doc, subelem)) def __call__(self, params, rank): actions = [] for action in self.actions: - try: - actions.append((action.params(params), action.action)) - except AttributeError: - actions.append((params, action)) - return (self.direction and self.direction(params, rank), - self.speed and self.speed(params, rank), - actions) + actions.append(action(params, rank)) + return ( + self.direction and self.direction(params, rank), + self.speed and self.speed(params, rank), + actions) def __repr__(self): return "%s(direction=%r, speed=%r, actions=%r)" % ( @@ -297,7 +294,7 @@ class FireDef(object): for subelem in element.getchildren(): tag = realtag(subelem) if tag == "direction": - self.direction = Direction(doc, subelem) + self.direction = Direction(doc, subelem, "aim") elif tag == "speed": self.speed = Speed(doc, subelem) elif tag == "bullet":