Author: elias
Date: Fri Oct 3 17:00:16 2008
New Revision: 29827
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29827&view=rev
Log:
fix for bug #12384
Modified:
trunk/data/tools/wmlunits
Modified: trunk/data/tools/wmlunits
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmlunits?rev=29827&r1=29826&r2=29827&view=diff
==============================================================================
--- trunk/data/tools/wmlunits (original)
+++ trunk/data/tools/wmlunits Fri Oct 3 17:00:16 2008
@@ -331,6 +331,36 @@
if not name: name = ability.name
anames.append(name)
return anames
+
+ def get_recursive_attacks(self, this_unit):
+
+ def copy_attributes(copy_from, copy_to):
+ for c in copy_from.children():
+ if isinstance(c, wmldata.DataText):
+ copy_to.set_text_val(c.name, c.data)
+
+ # Use attacks of base_units as base, if we have one.
+ base_unit = self.wesnoth.get_base_unit(this_unit)
+ attacks = []
+ if base_unit:
+ attacks = self.get_recursive_attacks(base_unit)
+
+ base_attacks = attacks[:]
+ for i, attack in enumerate(this_unit.get_all("attack")):
+ aid = attack.get_text_val("name")
+ if aid:
+ # The attack does have a name - either merge with the base
+ # which has the same name, or else append it as new attack.
+ for already in base_attacks:
+ if already.get_text_val("name") == aid:
+ copy_attributes(attack, already)
+ break
+ else:
+ attacks.append(attack)
+ else:
+ # The attack has no name, so merge based on order.
+ copy_attributes(attack, attacks[i])
+ return attacks
def write_units(self):
def write(x): self.output.write(x)
@@ -433,8 +463,8 @@
# Write info about attacks.
write("\n<div style=\"clear:both\">")
- for attack in u.get_all("attack"):
-
+ attacks = self.get_recursive_attacks(u)
+ for attack in attacks:
n = attack.get_text_val("number")
x = attack.get_text_val("damage")
@@ -592,37 +622,8 @@
# Write info about attacks.
write("<table class=\"unitinfo\">\n")
-
- def copy_attributes(copy_from, copy_to):
- for c in copy_from.children():
- if isinstance(c, wmldata.DataText):
- copy_to.set_text_val(c.name, c.data)
-
- def get_recursive_attacks(this_unit):
- # Use attacks of base_units as base, if we have one.
- base_unit = self.wesnoth.get_base_unit(this_unit)
- attacks = []
- if base_unit:
- attacks = get_recursive_attacks(base_unit)
-
- base_attacks = attacks[:]
- for i, attack in enumerate(this_unit.get_all("attack")):
- aid = attack.get_text_val("name")
- if aid:
- # The attack does have a name - either merge with the base
- # which has the same name, or else append it as new attack.
- for already in base_attacks:
- if already.get_text_val("name") == aid:
- copy_attributes(attack, already)
- break
- else:
- attacks.append(attack)
- else:
- # The attack has no name, so merge based on order.
- copy_attributes(attack, attacks[i])
- return attacks
-
- attacks = get_recursive_attacks(unit)
+
+ attacks = self.get_recursive_attacks(unit)
for attack in attacks:
write("<tr>")
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits