master
potatoxel 7 months ago
parent 5f8bbd297b
commit 87aad30006
  1. 7
      scenes/game/country.gd
  2. 7
      scenes/game/game.gd
  3. 8
      scenes/game/game.tscn

@ -7,6 +7,7 @@ var color
var money = 8
var stock_price = 1
var total_stocks = 0
var player_stocks = [0,0,0]
var tile_positions
var armies = []
var boats = []
@ -33,3 +34,9 @@ func remove_boat(unit):
func compute_balance():
money += len(factory_positions) - len(armies) - len(boats)
func get_controller_id():
for i in len(player_stocks):
if player_stocks[i] >= 4:
return i
return -1

@ -116,6 +116,7 @@ func _refresh_stock_ui():
func _on_stock_buy_button_pressed(country):
if turn.object.money >= country.stock_price and country.total_stocks < 7:
country.total_stocks += 1
country.player_stocks[turn.object.id] += 1
turn.object.stocks[country.id] += 1
turn.object.money -= country.stock_price
country.money += country.stock_price
@ -124,6 +125,7 @@ func _on_stock_buy_button_pressed(country):
func _on_stock_sell_button_pressed(country):
if country.money >= country.stock_price and turn.object.stocks[country.id] > 0:
country.total_stocks -= 1
country.player_stocks[turn.object.id] -= 1
turn.object.stocks[country.id] -= 1
turn.object.money += country.stock_price
country.money -= country.stock_price
@ -137,7 +139,7 @@ func _process(delta):
$CanvasLayer/Control/VBoxContainer/BuyFactory.visible = turn.layer == "country"
$CanvasLayer/Control/VBoxContainer/BuyArmy.visible = turn.layer == "country"
$CanvasLayer/Control/VBoxContainer/BuyBoat.visible = turn.layer == "country"
$CanvasLayer/Control/VBoxContainer/Stocks.visible = turn.layer == "player"
@ -156,6 +158,9 @@ func _on_EndTurnButton_pressed():
if turn.layer == "player":
_refresh_stock_ui()
else:
$CanvasLayer/Control/ControllerLabel.text = "Controller: " + (players[turn.object.get_controller_id()].name if turn.object.get_controller_id() >= 0 else "none")
$CanvasLayer/Control/ControllerLabel.visible = turn.layer == "country"
$CanvasLayer/Control/VBoxContainer/TurnLabel.text = turn.object.name + "'s turn."

@ -110,6 +110,14 @@ margin_left = -79.0
margin_top = -40.0
text = "END TURN"
[node name="ControllerLabel" type="Label" parent="CanvasLayer/Control"]
anchor_left = 0.5
anchor_right = 0.5
margin_left = -42.0
margin_right = 42.0
margin_bottom = 14.0
text = "CONTROLLER"
[connection signal="tile_pressed" from="Grid" to="." method="_on_Grid_tile_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/BuyFactory" to="." method="_on_BuyFactory_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/BuyArmy" to="." method="_on_BuyArmy_pressed"]

Loading…
Cancel
Save