Permalink
Browse files

Allow town upgrades.

  • Loading branch information...
1 parent e6e12e2 commit a0ef2f212eac5af94a63f632f9b21324c2a13f55 @jsnell committed Sep 26, 2011
Showing with 36 additions and 4 deletions.
  1. +3 −4 src/build.cc
  2. +33 −0 testdata/build22.pb
View
7 src/build.cc
@@ -102,6 +102,9 @@ class BuildHandler : public Handler {
return 2;
}
+ if (track_in_a_pointing_to_b(&game, build_loc, source))
+ return 0;
+
const Track* track = track_in_a_pointing_to_b(&game, source, build_loc);
if (track) {
@@ -374,10 +377,6 @@ class BuildHandler : public Handler {
if (current.has_city_index())
continue;
- // FIXME: need to handle complex upgrades
- if (current.track_size())
- continue;
-
int cost = game.terrain(current.terrain_index()).build_cost();
// TODO: terrain cost not always relevant (e.g. complex upgrades)
View
33 testdata/build22.pb
@@ -0,0 +1,33 @@
+game {
+ player {
+ cash: 10
+ state {
+ }
+ }
+ order: 0
+ current_order_index: 0
+ phase: PHASE_BUILD
+ map {
+ row {
+ hex { city_index: 0 }
+ hex { track { owner_index: 0 from { row: 0 col: 0 } to { row: 0 col: 2 } } }
+ hex {
+ has_town: true
+ track { from { row: 0 col: 2 } to { row: 0 col: 3 } }
+ }
+ hex { }
+ hex { }
+ }
+ }
+ city {
+ }
+ terrain {
+ build_cost: 2
+ }
+}
+expected_options {
+ action {
+ build_in { location { row: 0 col: 2 } }
+ }
+ action { build_finish: true }
+}

0 comments on commit a0ef2f2

Please sign in to comment.