Follow-up Comment #2, patch #1808 (project wesnoth):

The coding style is not an issue. Note that you don't have to write
wml_actions["store_unit"], you can simply write wml_actions.store_unit. There
is also a place where performance can be improved: when there are more than
two objects to concatenate and none of them is translatable, use
string.format. That way, the intermediate strings do not have to be created.

As for the feature itself, I'm a bit dissatisfied. You handle only one
subtag: [status]. It's too restrictive in my opinion. You could improve
[modify_unit] so that it handles arbitrary subtags: [variables], [defense],
[movement_costs], and so on. Moreover, if there are two [attacks] subtags in
the modifications, then the first one should apply to the first attack, and
the second one to the second one. To summarize, all the subtags that are not
called [filter] should be handled in a uniform and recursive way.

For instance, modifications should be handled in two steps. First, using
pairs like you do, but discarding all the values that are tables. Second,
using ipairs to get all the subtags, and then handling them recursively. You
will also need an auxiliary table to remember how many subtags with a given
name you have already encountered, so as to modify the corresponding one in
the unit.

    _______________________________________________________

Reply to this item at:

  <http://gna.org/patch/?1808>

_______________________________________________
  Message posté via/par Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to