Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2003:
[Freeciv-Dev] (PR#2911) [PATCH] chance to win in civclient
Home

[Freeciv-Dev] (PR#2911) [PATCH] chance to win in civclient

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: vasc@xxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#2911) [PATCH] chance to win in civclient
From: "Vasco Alexandre da Silva Costa via RT" <rt@xxxxxxxxxxxxxx>
Date: Sun, 26 Jan 2003 10:27:45 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[vasc@xxxxxxxxxxxxxx - Sun Jan 26 18:21:15 2003]: 
 
> ---------- Forwarded message ---------- 
> Date: Sun, 26 Jan 2003 11:39:31 +0100 
> From: Andreas Røsdal <andrearo@xxxxxxxxxxxx> 
> To: freeciv-dev@xxxxxxxxxxx 
> Subject: [Freeciv-Dev] [PATCH]  chance to win in civclient 
>  
> Hello, 
>  
> I've made a patch that makes the planning of attacks quicker 
> and makes defending units from enemies easier. I think that 
> calculating your chance to win against an enemy unit takes 
> too much time to do manually. Therefore this patch calculates 
> the probability to win if your active unit attacks the selected 
> enemy unit, and the probability to win if your active unit 
> is defending against the selected enemy unit. 
 
I've made some changes. Here is the patch. This shall be commited 
ASAP. 
 
diff -u -r1.14 mapctrl.c
--- client/gui-gtk-2.0/mapctrl.c        9 Jan 2003 19:21:17 -0000       1.14
+++ client/gui-gtk-2.0/mapctrl.c        26 Jan 2003 18:25:13 -0000
@@ -19,6 +19,7 @@
 #include <gtk/gtk.h>
 
 #include "fcintl.h"
+#include "combat.h"
 #include "game.h"
 #include "map.h"
 #include "player.h"
@@ -171,6 +172,23 @@
          cross_head++;
         }
       } else {
+        struct unit *apunit;
+        
+        /* calculate chance to win */
+        if ((apunit = get_unit_in_focus())) {
+          /* chance to win when active unit is attacking the selected unit */
+          int att_chance = unit_win_chance(apunit, punit) * 100;
+
+          /* chance to win when selected unit is attacking the active unit */
+          int def_chance = (1.0 - unit_win_chance(punit, apunit)) * 100;
+
+          my_snprintf(s, sizeof(s), _("Chance to win: A:%d%% D:%d%%"),
+               att_chance, def_chance);
+          gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::parent", b,
+                                         "GtkLabel::label", s, NULL);
+          count++;
+        }
+
         my_snprintf(s, sizeof(s), _("A:%d D:%d FP:%d HP:%d0%%"),
                    ptype->attack_strength, 
                    ptype->defense_strength, ptype->firepower, 

[Prev in Thread] Current Thread [Next in Thread]