Author: sveinung
Date: Sun Apr 26 05:41:42 2015
New Revision: 28879

URL: http://svn.gna.org/viewcvs/freeciv?rev=28879&view=rev
Log:
Unhardcode the reduction of the Enter Marketplace bonus.

Introduce the new effect Trade_Revenue_Pct. Use it to move the reduction of
the bonus received when entering a market place to the ruleset.

See patch #6035

Modified:
    trunk/ai/default/advdomestic.c
    trunk/ai/default/daieffects.c
    trunk/common/effects.h
    trunk/common/traderoutes.c
    trunk/data/alien/effects.ruleset
    trunk/data/civ1/effects.ruleset
    trunk/data/civ2/effects.ruleset
    trunk/data/civ2civ3/effects.ruleset
    trunk/data/classic/effects.ruleset
    trunk/data/experimental/effects.ruleset
    trunk/doc/README.effects
    trunk/fc_version
    trunk/server/rscompat.c

Modified: trunk/ai/default/advdomestic.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advdomestic.c?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/ai/default/advdomestic.c      (original)
+++ trunk/ai/default/advdomestic.c      Sun Apr 26 05:41:42 2015
@@ -187,6 +187,7 @@
   int pct = 0;
   int trader_trait;
   bool need_boat = FALSE;
+  bool trade_action;
 
   if (city_list_size(pplayer->cities) < 5) {
     /* Consider trade routes only if enough destination cities.
@@ -325,10 +326,19 @@
   bonus = get_city_bonus(pcity, EFT_TRADE_REVENUE_BONUS);
   income = (float)income * pow(2.0, (double)bonus / 1000.0);
 
-  if (!utype_can_do_action(unit_type, ACTION_TRADE_ROUTE)) {
-    /* Enter Marketplace has less initial income. */
-    income = (income + 2) / 3;
-  }
+  /* A ruleset may use the Trade_Revenue_Pct effect to reduce the one time
+   * bonus if no trade route is established. Make sure it gets the correct
+   * action. */
+  trade_action = utype_can_do_action(unit_type, ACTION_TRADE_ROUTE) ?
+        ACTION_TRADE_ROUTE : ACTION_MARKETPLACE;
+  income += get_target_bonus_effects(NULL,
+                                     pplayer, NULL,
+                                     pcity, NULL,
+                                     city_tile(pcity),
+                                     NULL, NULL,
+                                     NULL, NULL,
+                                     action_by_number(trade_action),
+                                     EFT_TRADE_REVENUE_PCT) * income / 100;
 
   if (dest_city_nat_same_cont) {
     pct = trade_route_type_trade_pct(TRT_NATIONAL);

Modified: trunk/ai/default/daieffects.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/daieffects.c?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/ai/default/daieffects.c       (original)
+++ trunk/ai/default/daieffects.c       Sun Apr 26 05:41:42 2015
@@ -547,6 +547,10 @@
       v += amount; /* AI wants migration into its cities! */
     } iterate_outward_end;
     break;
+  case EFT_TRADE_REVENUE_PCT:
+    trait = ai_trait_get_value(TRAIT_TRADER, pplayer);
+    v += trait * amount * c / (20 * TRAIT_DEFAULT_VALUE);
+    break;
   case EFT_MAX_TRADE_ROUTES:
     trait = ai_trait_get_value(TRAIT_TRADER, pplayer);
     v += amount

Modified: trunk/common/effects.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/effects.h?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/common/effects.h      (original)
+++ trunk/common/effects.h      Sun Apr 26 05:41:42 2015
@@ -275,6 +275,8 @@
 #define SPECENUM_VALUE106NAME "Illegal_Action_Move_Cost"
 #define SPECENUM_VALUE107 EFT_HAVE_CONTACTS
 #define SPECENUM_VALUE107NAME "Have_Contacts"
+#define SPECENUM_VALUE108 EFT_TRADE_REVENUE_PCT
+#define SPECENUM_VALUE108NAME "Trade_Revenue_Pct"
 /* keep this last */
 #define SPECENUM_COUNT EFT_COUNT
 #include "specenum_gen.h"

Modified: trunk/common/traderoutes.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/traderoutes.c?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/common/traderoutes.c  (original)
+++ trunk/common/traderoutes.c  Sun Apr 26 05:41:42 2015
@@ -390,12 +390,24 @@
   
   tb = (float)tb * pow(2.0, (double)bonus / 1000.0);
 
-  if (!establish_trade) {
-    /* There will only be a full bonus if a new trade route is
-     * established. The one time bonus from Enter Marketplace is about one
-     * third of the one time bonus from Establish Trade Route. */
-    tb = (tb + 2) / 3;
-  }
+  /* Trade_Revenue_Pct allows the ruleset to modify the final bonus.
+   * Example: reduce the one time bonus when no trade route is
+   * established. */
+  tb += get_target_bonus_effects(NULL,
+                                 city_owner(pc1),
+                                 city_owner(pc2),
+                                 pc1,
+                                 NULL,
+                                 city_tile(pc1),
+                                 /* TODO: Should unit requirements be
+                                  * allowed so stuff like moves left and
+                                  * unit type can modify the bonus? */
+                                 NULL, NULL,
+                                 NULL, NULL,
+                                 action_by_number(establish_trade ?
+                                   ACTION_TRADE_ROUTE :
+                                   ACTION_MARKETPLACE),
+                                 EFT_TRADE_REVENUE_PCT) * tb / 100;
 
   return tb;
 }

Modified: trunk/data/alien/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/effects.ruleset?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/data/alien/effects.ruleset    (original)
+++ trunk/data/alien/effects.ruleset    Sun Apr 26 05:41:42 2015
@@ -1013,3 +1013,11 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_enter_marketplace_bonus_reduction]
+type   = "Trade_Revenue_Pct"
+value  = -67
+reqs   =
+    { "type", "name", "range"
+      "Action", "Enter Marketplace", "Local"
+    }

Modified: trunk/data/civ1/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/effects.ruleset?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/data/civ1/effects.ruleset     (original)
+++ trunk/data/civ1/effects.ruleset     Sun Apr 26 05:41:42 2015
@@ -1435,3 +1435,11 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_enter_marketplace_bonus_reduction]
+type   = "Trade_Revenue_Pct"
+value  = -67
+reqs   =
+    { "type", "name", "range"
+      "Action", "Enter Marketplace", "Local"
+    }

Modified: trunk/data/civ2/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/effects.ruleset?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/data/civ2/effects.ruleset     (original)
+++ trunk/data/civ2/effects.ruleset     Sun Apr 26 05:41:42 2015
@@ -2289,3 +2289,11 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_enter_marketplace_bonus_reduction]
+type   = "Trade_Revenue_Pct"
+value  = -67
+reqs   =
+    { "type", "name", "range"
+      "Action", "Enter Marketplace", "Local"
+    }

Modified: trunk/data/civ2civ3/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/effects.ruleset?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/data/civ2civ3/effects.ruleset (original)
+++ trunk/data/civ2civ3/effects.ruleset Sun Apr 26 05:41:42 2015
@@ -3738,3 +3738,11 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_enter_marketplace_bonus_reduction]
+type   = "Trade_Revenue_Pct"
+value  = -67
+reqs   =
+    { "type", "name", "range"
+      "Action", "Enter Marketplace", "Local"
+    }

Modified: trunk/data/classic/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/effects.ruleset?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/data/classic/effects.ruleset  (original)
+++ trunk/data/classic/effects.ruleset  Sun Apr 26 05:41:42 2015
@@ -2381,3 +2381,11 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_enter_marketplace_bonus_reduction]
+type   = "Trade_Revenue_Pct"
+value  = -67
+reqs   =
+    { "type", "name", "range"
+      "Action", "Enter Marketplace", "Local"
+    }

Modified: trunk/data/experimental/effects.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/effects.ruleset?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/data/experimental/effects.ruleset     (original)
+++ trunk/data/experimental/effects.ruleset     Sun Apr 26 05:41:42 2015
@@ -2703,3 +2703,11 @@
       "Action", "Found City", "Local", FALSE
       "Action", "Join City", "Local", FALSE
     }
+
+[effect_enter_marketplace_bonus_reduction]
+type   = "Trade_Revenue_Pct"
+value  = -67
+reqs   =
+    { "type", "name", "range"
+      "Action", "Enter Marketplace", "Local"
+    }

Modified: trunk/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.effects?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/doc/README.effects    (original)
+++ trunk/doc/README.effects    Sun Apr 26 05:41:42 2015
@@ -388,6 +388,11 @@
     One time trade revenue bonus is multiplied by pow(2, amount/1000).
     The amount value is taken from the caravan's home city.
 
+Trade_Revenue_Pct
+    Percentage bonus for the one time trade revenue. Supports action
+    requirements. The point of view is the caravan's home city.
+    Doesn't support unit related requirements.
+
 Traderoute_Pct
     Percentage bonus for trade from traderoutes. This bonus applies after
     the value of the traderoute is already calculated. It affects one end

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Sun Apr 26 05:41:42 2015
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Apr.23"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Apr.26"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/rscompat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/rscompat.c?rev=28879&r1=28878&r2=28879&view=diff
==============================================================================
--- trunk/server/rscompat.c     (original)
+++ trunk/server/rscompat.c     Sun Apr 26 05:41:42 2015
@@ -269,6 +269,16 @@
     action_enabler_add(enabler);
   }
 
+  if (info->ver_effects < 10) {
+    /* The reduced one time trade bonus of Enter Marketplace (compared to
+     * Establish Trade Route) has moved to the ruleset. */
+    struct effect *peffect = effect_new(EFT_TRADE_REVENUE_PCT, -67);
+
+    /* The reduction only applies to Enter Marketplace. */
+    effect_req_append(peffect, req_from_str("Action", "Local", FALSE, TRUE,
+                                            "Enter Marketplace"));
+  }
+
   iterate_effect_cache(effect_list_compat_cb, NULL);
 }
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to