Author: dragonking
Date: Thu Jul 31 00:42:13 2008
New Revision: 28277

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28277&view=rev
Log:
New formula function: debug_print

Modified:
    trunk/data/recruitment.fai
    trunk/src/formula_function.cpp

Modified: trunk/data/recruitment.fai
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/recruitment.fai?rev=28277&r1=28276&r2=28277&view=diff
==============================================================================
--- trunk/data/recruitment.fai (original)
+++ trunk/data/recruitment.fai Thu Jul 31 00:42:13 2008
@@ -210,7 +210,12 @@
                                        [
                                                
max_possible_damage_with_retaliation( unit, enemy_unit )
                                        ],
-                                       self[0] - self[1]
+                                       max(
+                                               [
+                                                       self[0] - self[2],
+                                                       self[1] - self[3]
+                                               ]
+                                       )
                                ) 
                        )
                )
@@ -225,7 +230,12 @@
                                        [
                                                
max_possible_damage_with_retaliation( enemy_unit, unit )
                                        ],
-                                       self[1] - self[0]
+                                       max(
+                                               [
+                                                       self[2] - self[0],
+                                                       self[3] - self[1]
+                                               ]
+                                       )
                                )
                        )
                )
@@ -467,9 +477,9 @@
 
 if(my_leader.loc = loc(11,23),
        if( teams[my_side].gold>20,
-               
recruit(unit_chooser(self,recruitment_list_builder(eval(self),apply_abilities_weights(apply_weapon_specials_weights(evaluate_attackers(self))),apply_abilities_weights(apply_weapon_specials_weights(evaluate_defenders(self)))))),
-               fallback('') ), 
+               
recruit(unit_chooser(self,recruitment_list_builder(eval(self),apply_abilities_weights(apply_weapon_specials_weights(debug_print(evaluate_attackers(self)))),apply_abilities_weights(apply_weapon_specials_weights(evaluate_defenders(self)))))),
+               fallback('human') ), 
        if(vars.check = turn, 
-               [set_var('check', 0), fallback('')], 
+               [set_var('check', 0), fallback('human')], 
                [set_var('check', turn), move(my_leader.loc, 
nearest_keep(my_leader.loc))])
 )

Modified: trunk/src/formula_function.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/formula_function.cpp?rev=28277&r1=28276&r2=28277&view=diff
==============================================================================
--- trunk/src/formula_function.cpp (original)
+++ trunk/src/formula_function.cpp Thu Jul 31 00:42:13 2008
@@ -260,6 +260,25 @@
                }
 
                return variant(res);
+       }
+};
+
+class debug_print_function : public function_expression {
+public:
+       explicit debug_print_function(const args_list& args)
+            : function_expression("debug_print", args, 1, 1)
+       {}
+
+private:
+       variant execute(const formula_callable& variables) const {
+               const variant var = args()[0]->evaluate(variables);
+
+               std::string str;
+
+               var.serialize_to_string(str);
+               std::cerr<< str << std::endl;
+
+               return var;
        }
 };
 
@@ -845,6 +864,7 @@
                FUNCTION(min);
                FUNCTION(max);
                FUNCTION(choose);
+               FUNCTION(debug_print);
                FUNCTION(wave);
                FUNCTION(sort);
                FUNCTION(contains_string);


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

Reply via email to