|
|
|
@ -41,7 +41,12 @@ func _setup_players(): |
|
|
|
|
player.id = player_id |
|
|
|
|
player.name = str(player_id) |
|
|
|
|
players.append(player) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player.connect("win", self, "_on_player_win", [player]) |
|
|
|
|
|
|
|
|
|
func _on_player_win(player): |
|
|
|
|
$CanvasLayer/Control/Winner.show() |
|
|
|
|
$CanvasLayer/Control/Winner.text = "Player " + player.name + " wins!!!" |
|
|
|
|
|
|
|
|
|
func _setup_countries(): |
|
|
|
|
var id = 0 |
|
|
|
@ -58,9 +63,6 @@ func _setup_countries(): |
|
|
|
|
|
|
|
|
|
$Grid.countries = countries |
|
|
|
|
$Grid.setup() |
|
|
|
|
|
|
|
|
|
countries[1].add_unit({}, Vector2(1,1)) |
|
|
|
|
countries[2].add_unit({}, Vector2(1,2)) |
|
|
|
|
|
|
|
|
|
func _setup_turns(): |
|
|
|
|
for player in players: |
|
|
|
@ -170,7 +172,7 @@ func _on_stock_sell_button_pressed(country): |
|
|
|
|
_refresh_stock_ui() |
|
|
|
|
|
|
|
|
|
func _on_PayDividends_pressed(): |
|
|
|
|
if turn.object.money > 7: |
|
|
|
|
if turn.object.money >= 7: |
|
|
|
|
turn.object.money -= 7 |
|
|
|
|
for i in len(turn.object.player_stocks): |
|
|
|
|
var stocks = turn.object.player_stocks[i] |
|
|
|
@ -250,11 +252,11 @@ func _on_Grid_tile_pressed(v): |
|
|
|
|
country.money -= 3 |
|
|
|
|
country.add_unit({}, v) |
|
|
|
|
"buy_boat": |
|
|
|
|
if country.money >= 3 and $Grid.has_adjacent_factory(v, country) and tile.needs_boat and len(tile.boats) == 0: |
|
|
|
|
if country.money >= 3 and $Grid.has_adjacent_factory(v, country) and tile.needs_boat and not $Grid.tile_have_boat_of_country(tile, country): |
|
|
|
|
country.money -= 3 |
|
|
|
|
country.add_boat({}, v) |
|
|
|
|
null: |
|
|
|
|
if $Grid.selected_thing is Boat and $Grid.selected_thing.get_tile_position() == v or len(tile.boats) == 0: |
|
|
|
|
if is_instance_valid($Grid.selected_thing) and $Grid.selected_thing is Boat and $Grid.selected_thing.get_tile_position() == v or len(tile.boats) == 0: |
|
|
|
|
for army in tile.units: |
|
|
|
|
if army.country == country: |
|
|
|
|
$Grid.selected_thing = army.entity |
|
|
|
|