generated from krampus/template-godot4
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 15c9fd812e | |||
| 688ffcbf47 | |||
| 6921a1ff63 | |||
| bb36f42635 | |||
| 627c2b38e6 |
BIN
assets/fonts/NotoColorEmoji.ttf
Normal file
BIN
assets/fonts/NotoColorEmoji.ttf
Normal file
Binary file not shown.
36
assets/fonts/NotoColorEmoji.ttf.import
Normal file
36
assets/fonts/NotoColorEmoji.ttf.import
Normal file
@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://cv63xhs0xcoc1"
|
||||
path="res://.godot/imported/NotoColorEmoji.ttf-5bcefd16ba84146614613f6de606de52.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/fonts/NotoColorEmoji.ttf"
|
||||
dest_files=["res://.godot/imported/NotoColorEmoji.ttf-5bcefd16ba84146614613f6de606de52.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
disable_embedded_bitmaps=true
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
modulate_color_glyphs=false
|
||||
hinting=1
|
||||
subpixel_positioning=4
|
||||
keep_rounding_remainders=true
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
BIN
assets/package/boxes_SpriteSheet.png
(Stored with Git LFS)
Normal file
BIN
assets/package/boxes_SpriteSheet.png
(Stored with Git LFS)
Normal file
Binary file not shown.
40
assets/package/boxes_SpriteSheet.png.import
Normal file
40
assets/package/boxes_SpriteSheet.png.import
Normal file
@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://s1kqdqdvvrxf"
|
||||
path="res://.godot/imported/boxes_SpriteSheet.png-971c2ed38a50dc5fe065e5b69e2ea946.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/package/boxes_SpriteSheet.png"
|
||||
dest_files=["res://.godot/imported/boxes_SpriteSheet.png-971c2ed38a50dc5fe065e5b69e2ea946.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@ -15,9 +15,11 @@ var tiles: Dictionary[Vector2i, Tile] = {}
|
||||
var buildings: Dictionary[Vector2i, Building] = {}
|
||||
var active_building: Building
|
||||
var active_tile: Tile
|
||||
var is_destroying_building: bool = false
|
||||
var current_map_coord: Vector2i
|
||||
var prev_map_coord: Vector2i
|
||||
var is_controlling_camera: bool = false
|
||||
var is_placing_post_office: bool = false
|
||||
|
||||
@onready var tile_map: TileMapLayer = %Tiles
|
||||
@onready var board_state: Node2D = %BoardState
|
||||
@ -39,12 +41,19 @@ func _input(event: InputEvent) -> void:
|
||||
active_tile.position = tile_map.map_to_local(current_map_coord)
|
||||
if active_building != null:
|
||||
active_building.position = tile_map.map_to_local(current_map_coord)
|
||||
if is_destroying_building:
|
||||
if buildings.has(current_map_coord):
|
||||
buildings[current_map_coord].show_bomb()
|
||||
if prev_map_coord != current_map_coord and buildings.has(prev_map_coord):
|
||||
buildings[prev_map_coord].hide_bomb()
|
||||
prev_map_coord = current_map_coord
|
||||
if event.is_action_pressed("select"):
|
||||
if active_tile != null:
|
||||
place_active_tile()
|
||||
elif active_building != null:
|
||||
place_active_building()
|
||||
if is_destroying_building:
|
||||
destroy_current_building()
|
||||
_handle_building_rotation(event)
|
||||
_handle_spawn_rotation(event)
|
||||
|
||||
@ -63,6 +72,9 @@ func set_active_building(building: Building) -> void:
|
||||
active_building.player = Globals.board_game.current_board_state.current_player
|
||||
active_building.modulate = Color(1, 1, 1, 0.5)
|
||||
active_building.is_placing = true
|
||||
if active_building is PostOffice:
|
||||
is_placing_post_office = !is_placing_post_office
|
||||
active_building.place()
|
||||
|
||||
|
||||
func place_active_tile() -> void:
|
||||
@ -114,9 +126,6 @@ func place_active_building() -> void:
|
||||
for surr_coord in tile_map.get_surrounding_cells(coord):
|
||||
if buildings.has(surr_coord):
|
||||
return
|
||||
Globals.board_game.current_board_state.players[0].money -= active_building.cost
|
||||
if Globals.board_game.current_board_state.state != BoardState.State.INITIAL_SETUP:
|
||||
Globals.board_game.current_board_state.players[0].build_actions_taken += 1
|
||||
active_building.modulate = Color(1, 1, 1, 1)
|
||||
for coord in active_building.get_tile_coords():
|
||||
buildings[coord] = active_building
|
||||
@ -124,32 +133,47 @@ func place_active_building() -> void:
|
||||
tiles.erase(coord)
|
||||
if active_building is Spawn:
|
||||
Globals.board_game.current_board_state.spawn_placements -= 1
|
||||
if active_building is PostOffice and is_placing_post_office:
|
||||
set_active_building(Building.deserialize(active_building.serialize()))
|
||||
return
|
||||
Globals.board_game.current_board_state.players[0].money -= active_building.cost
|
||||
if Globals.board_game.current_board_state.state != BoardState.State.INITIAL_SETUP:
|
||||
Globals.board_game.current_board_state.players[0].build_actions_taken += 1
|
||||
board_state_changed.emit()
|
||||
active_building = null
|
||||
|
||||
|
||||
func destroy_current_building() -> void:
|
||||
if buildings.has(current_map_coord):
|
||||
var building = buildings[current_map_coord]
|
||||
if building is not Home and building is not HQ:
|
||||
remove_building(building)
|
||||
Globals.board_game.current_board_state.buildings_to_destroy -= 1
|
||||
|
||||
|
||||
func remove_home(player: Player) -> void:
|
||||
for coord in buildings.keys():
|
||||
var building = buildings[coord]
|
||||
if building is Home and building.player.id == player.id:
|
||||
remove_building(coord, building)
|
||||
remove_building(building)
|
||||
|
||||
|
||||
func remove_hq(player: Player) -> void:
|
||||
for coord in buildings.keys():
|
||||
var building = buildings[coord]
|
||||
if building is HQ and building.player.id == player.id:
|
||||
remove_building(coord, building)
|
||||
remove_building(building)
|
||||
|
||||
|
||||
func remove_building(coord: Vector2i, building: Building) -> void:
|
||||
func remove_building(building: Building) -> void:
|
||||
for coord in building.get_tile_coords():
|
||||
buildings.erase(coord)
|
||||
building.free()
|
||||
var ground: Ground = GROUND.instantiate()
|
||||
board_state.add_child(ground)
|
||||
ground.position = tile_map.map_to_local(coord)
|
||||
ground.coords = coord
|
||||
tiles[coord] = ground
|
||||
building.free()
|
||||
|
||||
|
||||
func _handle_building_rotation(event: InputEvent) -> void:
|
||||
@ -212,6 +236,8 @@ func set_board_state(bs: BoardState) -> void:
|
||||
buildings[coord] = building
|
||||
building.position = tile_map.map_to_local(building.starting_coord)
|
||||
building.rotation_degrees += 90 * building.get_rotation_count()
|
||||
if building is PostOffice:
|
||||
building.place()
|
||||
|
||||
|
||||
func initialize() -> void:
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
class_name Citizen extends CharacterBody2D
|
||||
|
||||
enum Status { NONE, DRUNK, ARMED, CAFFEINATED }
|
||||
enum Status { NONE, DRUNK, ARMED, CAFFEINATED, PACKAGED }
|
||||
|
||||
const DRUNK_ICON = preload("uid://28x2e52skdt1")
|
||||
const COFFEE_ICON = preload("uid://0644a3psplk8")
|
||||
const ARMED_ICON = preload("uid://cn8biugbtcns5")
|
||||
const PACKAGE_ICON = preload("uid://drhv16h2tgoju")
|
||||
|
||||
var direction: Board.Direction:
|
||||
set(new_direction):
|
||||
@ -29,6 +30,7 @@ var money: int = 0
|
||||
var money_label_tween: Tween
|
||||
var tiles_visited: Dictionary[Tile, int] = {}
|
||||
var buildings_visited: Dictionary[Building, int] = {}
|
||||
var package_distance: int = 0
|
||||
|
||||
var _statuses: Array[Status] = []
|
||||
|
||||
@ -61,6 +63,8 @@ func add_status(status: Status) -> void:
|
||||
status_container.add_child(COFFEE_ICON.instantiate())
|
||||
Status.ARMED:
|
||||
status_container.add_child(ARMED_ICON.instantiate())
|
||||
Status.PACKAGED:
|
||||
status_container.add_child(PACKAGE_ICON.instantiate())
|
||||
|
||||
|
||||
func remove_status(status: Status) -> void:
|
||||
@ -186,6 +190,8 @@ func handle_tile_area_exited(_area: Area2D):
|
||||
if direction != Board.Direction.NONE:
|
||||
direction = Board.Direction.NONE
|
||||
return
|
||||
if get_status_count(Citizen.Status.PACKAGED) > 0:
|
||||
package_distance += 1
|
||||
if !direction_queue.is_empty():
|
||||
direction = direction_queue.pop_front()
|
||||
elif Globals.board_game.board.buildings.has(current_tile_coords):
|
||||
|
||||
@ -18,6 +18,21 @@ var tile_rotation: Board.Direction = Board.Direction.UP
|
||||
@onready var bomb_sprite: Sprite2D = %BombSprite
|
||||
|
||||
|
||||
func can_citizen_enter(_coord: Vector2i, _direction: Board.Direction) -> bool:
|
||||
print("The extending class has to implement this!")
|
||||
return false
|
||||
|
||||
|
||||
func get_tile_coords() -> Array[Vector2i]:
|
||||
print("The extending class has to implement this!")
|
||||
return []
|
||||
|
||||
|
||||
func get_direction_queue(_citizen: Citizen) -> Array[Board.Direction]:
|
||||
print("The extending class has to implement this!")
|
||||
return []
|
||||
|
||||
|
||||
func building_entered(body: Node2D) -> void:
|
||||
if body is Citizen:
|
||||
print("Activate building effect!")
|
||||
|
||||
@ -22,7 +22,7 @@ region = Rect2(16, 16, 16, 16)
|
||||
atlas = ExtResource("2_gnrqc")
|
||||
region = Rect2(0, 16, 16, 16)
|
||||
|
||||
[node name="Demolitions" type="Node2D" unique_id=746270571]
|
||||
[node name="Demolitions" type="Node2D" unique_id=746270571 groups=["PostTurnActions"]]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_veblj")
|
||||
|
||||
|
||||
31
prefabs/tiles/buildings/post_office.gd
Normal file
31
prefabs/tiles/buildings/post_office.gd
Normal file
@ -0,0 +1,31 @@
|
||||
class_name PostOffice extends Building
|
||||
|
||||
@onready var preview_node: Node2D = %Preview
|
||||
@onready var board_node: Node2D = %Board
|
||||
|
||||
|
||||
func place() -> void:
|
||||
preview_node.hide()
|
||||
board_node.show()
|
||||
|
||||
|
||||
func can_citizen_enter(_coord: Vector2i, _direction: Board.Direction) -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func get_tile_coords() -> Array[Vector2i]:
|
||||
return [starting_coord]
|
||||
|
||||
|
||||
func get_direction_queue(_citizen: Citizen) -> Array[Board.Direction]:
|
||||
return []
|
||||
|
||||
|
||||
func activate(citizen: Citizen) -> void:
|
||||
if citizen.get_status_count(Citizen.Status.PACKAGED) > 0:
|
||||
citizen.remove_all_statuses(Citizen.Status.PACKAGED)
|
||||
citizen.money += ceili(citizen.package_distance / 2.0)
|
||||
citizen.play_money_animation()
|
||||
citizen.package_distance = 0
|
||||
else:
|
||||
citizen.add_status(Citizen.Status.PACKAGED)
|
||||
1
prefabs/tiles/buildings/post_office.gd.uid
Normal file
1
prefabs/tiles/buildings/post_office.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bgde73oxvye5t
|
||||
119
prefabs/tiles/buildings/post_office.tscn
Normal file
119
prefabs/tiles/buildings/post_office.tscn
Normal file
@ -0,0 +1,119 @@
|
||||
[gd_scene format=3 uid="uid://bpi8owv5lxyjy"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bgde73oxvye5t" path="res://prefabs/tiles/buildings/post_office.gd" id="1_0ascf"]
|
||||
[ext_resource type="Texture2D" uid="uid://dijho2wx1l4sm" path="res://assets/bomb/bomb.png" id="3_vwkts"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_vwg8v"]
|
||||
outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vwg8v"]
|
||||
size = Vector2(109, 109)
|
||||
|
||||
[node name="PostOffice" type="Node2D" unique_id=746270571]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_0ascf")
|
||||
|
||||
[node name="Preview" type="Node2D" parent="." unique_id=515630033]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="Outline" type="ColorRect" parent="Preview" unique_id=889061850]
|
||||
custom_minimum_size = Vector2(110, 110)
|
||||
offset_left = -82.5
|
||||
offset_top = -28.0
|
||||
offset_right = 27.5
|
||||
offset_bottom = 82.0
|
||||
mouse_filter = 2
|
||||
color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="Preview/Outline" unique_id=803405966]
|
||||
custom_minimum_size = Vector2(108, 108)
|
||||
layout_mode = 0
|
||||
offset_left = 1.0
|
||||
offset_top = 1.0
|
||||
offset_right = 109.0
|
||||
offset_bottom = 109.0
|
||||
mouse_filter = 2
|
||||
color = Color(0, 0.71932274, 0.79595864, 1)
|
||||
|
||||
[node name="Outline2" type="ColorRect" parent="Preview" unique_id=1396499698]
|
||||
custom_minimum_size = Vector2(110, 110)
|
||||
offset_left = -28.0
|
||||
offset_top = -82.0
|
||||
offset_right = 82.0
|
||||
offset_bottom = 28.0
|
||||
mouse_filter = 2
|
||||
color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="Preview/Outline2" unique_id=167610173]
|
||||
custom_minimum_size = Vector2(108, 108)
|
||||
layout_mode = 0
|
||||
offset_left = 1.0
|
||||
offset_top = 1.0
|
||||
offset_right = 109.0
|
||||
offset_bottom = 109.0
|
||||
mouse_filter = 2
|
||||
color = Color(0, 0.71932274, 0.79595864, 1)
|
||||
|
||||
[node name="Size" type="Control" parent="Preview" unique_id=1036213581]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_left = -82.5
|
||||
offset_top = -82.5
|
||||
offset_right = 82.5
|
||||
offset_bottom = 82.5
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Preview" unique_id=29286194]
|
||||
custom_minimum_size = Vector2(165, 165)
|
||||
offset_left = -82.5
|
||||
offset_top = -82.5
|
||||
offset_right = 82.5
|
||||
offset_bottom = 82.5
|
||||
text = "POST
|
||||
OFFICE"
|
||||
label_settings = SubResource("LabelSettings_vwg8v")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Board" type="Node2D" parent="." unique_id=1675613235]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
[node name="Outline" type="ColorRect" parent="Board" unique_id=1599746913]
|
||||
custom_minimum_size = Vector2(110, 110)
|
||||
offset_left = -55.0
|
||||
offset_top = -55.0
|
||||
offset_right = 55.0
|
||||
offset_bottom = 55.0
|
||||
mouse_filter = 2
|
||||
color = Color(0, 0.7176471, 0.79607844, 1)
|
||||
|
||||
[node name="Label2" type="Label" parent="Board" unique_id=1535058806]
|
||||
custom_minimum_size = Vector2(110, 110)
|
||||
offset_left = -55.0
|
||||
offset_top = -55.0
|
||||
offset_right = 55.0
|
||||
offset_bottom = 55.0
|
||||
text = "POST
|
||||
OFFICE"
|
||||
label_settings = SubResource("LabelSettings_vwg8v")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Square1" type="Area2D" parent="Board" unique_id=333775731]
|
||||
process_mode = 3
|
||||
monitoring = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Board/Square1" unique_id=1122204523]
|
||||
process_mode = 3
|
||||
shape = SubResource("RectangleShape2D_vwg8v")
|
||||
|
||||
[node name="BombSprite" type="Sprite2D" parent="Board" unique_id=2024150262]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
scale = Vector2(0.415, 0.415)
|
||||
texture = ExtResource("3_vwkts")
|
||||
|
||||
[connection signal="area_entered" from="Board/Square1" to="." method="_on_building_area_entered"]
|
||||
@ -20,7 +20,7 @@ func set_player(player: Player) -> void:
|
||||
|
||||
func _update_player_info(player: Player) -> void:
|
||||
money_label.text = "$%d" % player.money
|
||||
votes_label.text = "%d 🗳️" % player.votes
|
||||
votes_label.text = "%d" % player.votes
|
||||
for child in permits_container.get_children():
|
||||
child.queue_free()
|
||||
for i in range(player.building_permits):
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
[gd_scene format=3 uid="uid://8sd8fkx3hua0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ccx3jyc31veok" path="res://prefabs/ui/player_info.gd" id="1_tautg"]
|
||||
[ext_resource type="FontFile" uid="uid://cv63xhs0xcoc1" path="res://assets/fonts/NotoColorEmoji.ttf" id="2_lpiko"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_lpiko"]
|
||||
resource_local_to_scene = true
|
||||
@ -20,6 +21,10 @@ font_color = Color(0, 0, 1, 1)
|
||||
outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_foovh"]
|
||||
font = ExtResource("2_lpiko")
|
||||
font_size = 24
|
||||
|
||||
[node name="PlayerInfo" type="HBoxContainer" unique_id=1335388560]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
@ -42,8 +47,16 @@ layout_mode = 2
|
||||
text = "$0"
|
||||
label_settings = SubResource("LabelSettings_tautg")
|
||||
|
||||
[node name="Votes" type="Label" parent="." unique_id=1929524068]
|
||||
[node name="Votes" type="HBoxContainer" parent="." unique_id=902142402]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Votes" type="Label" parent="Votes" unique_id=1929524068]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "0"
|
||||
label_settings = SubResource("LabelSettings_0g7uu")
|
||||
|
||||
[node name="Icon" type="Label" parent="Votes" unique_id=1102179585]
|
||||
layout_mode = 2
|
||||
text = "🗳️"
|
||||
label_settings = SubResource("LabelSettings_foovh")
|
||||
|
||||
13
prefabs/ui/status_icons/package_icon.tscn
Normal file
13
prefabs/ui/status_icons/package_icon.tscn
Normal file
@ -0,0 +1,13 @@
|
||||
[gd_scene format=3 uid="uid://drhv16h2tgoju"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://s1kqdqdvvrxf" path="res://assets/package/boxes_SpriteSheet.png" id="1_a86ef"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_af8ve"]
|
||||
atlas = ExtResource("1_a86ef")
|
||||
region = Rect2(1, 0, 16, 18)
|
||||
|
||||
[node name="PackageIcon" type="TextureRect" unique_id=585475146]
|
||||
texture_filter = 1
|
||||
custom_minimum_size = Vector2(10, 10)
|
||||
texture = SubResource("AtlasTexture_af8ve")
|
||||
expand_mode = 3
|
||||
@ -12,7 +12,7 @@ var buildings: Array[Building] = []
|
||||
var players_passed: int = 0
|
||||
var real_estate_market: Array[Building] = []
|
||||
var spawn_placements: int = 0
|
||||
var buildings_destroyed: int = 0
|
||||
var buildings_to_destroy: int = 0
|
||||
var citizens_starting_money: int = 0
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ func serialize() -> Dictionary:
|
||||
result["state"] = state
|
||||
result["players_passed"] = players_passed
|
||||
result["spawn_placements"] = spawn_placements
|
||||
result["buildings_destroyed"] = buildings_destroyed
|
||||
result["buildings_to_destroy"] = buildings_to_destroy
|
||||
result["citizens_starting_money"] = citizens_starting_money
|
||||
result["current_player"] = current_player.serialize()
|
||||
result["players"] = []
|
||||
@ -61,7 +61,7 @@ static func deserialize(data: Dictionary) -> BoardState:
|
||||
result.state = data["state"]
|
||||
result.players_passed = data["players_passed"]
|
||||
result.spawn_placements = data["spawn_placements"]
|
||||
result.buildings_destroyed = data["buildings_destroyed"]
|
||||
result.buildings_to_destroy = data["buildings_to_destroy"]
|
||||
result.citizens_starting_money = data["citizens_starting_money"]
|
||||
result.current_player = Player.deserialize(data["current_player"])
|
||||
for p in data["players"]:
|
||||
|
||||
@ -17,6 +17,7 @@ const SHOP_SCENE = preload("uid://dbn63mv0peqf")
|
||||
const CHURCH_SCENE = preload("uid://brn0nbkela0m4")
|
||||
const CITY_HALL_SCENE = preload("uid://dtnejoimqiu0o")
|
||||
const DEMOLITIONS_SCENE = preload("uid://dvmglvbersupv")
|
||||
const POST_OFFICE_SCENE = preload("uid://bpi8owv5lxyjy")
|
||||
|
||||
const BASE_DECK = [
|
||||
BANK_SCENE,
|
||||
@ -28,9 +29,13 @@ const BASE_DECK = [
|
||||
OFFICE_SCENE,
|
||||
SHOP_SCENE,
|
||||
CHURCH_SCENE,
|
||||
CITY_HALL_SCENE
|
||||
CITY_HALL_SCENE,
|
||||
DEMOLITIONS_SCENE,
|
||||
POST_OFFICE_SCENE
|
||||
]
|
||||
|
||||
const WINNING_MONEY_AMOUNT: int = 200
|
||||
|
||||
var citizen_count: int = 0:
|
||||
set(value):
|
||||
#print(value)
|
||||
@ -164,22 +169,12 @@ func cancel_placement() -> void:
|
||||
|
||||
|
||||
func start_day() -> void:
|
||||
if (
|
||||
current_board_state.day > 0
|
||||
and current_board_state.state != BoardState.State.PLACING_SPAWNS
|
||||
and current_board_state.state != BoardState.State.DESTROYING_BUILDINGS
|
||||
):
|
||||
current_board_state.players.sort_custom(
|
||||
func(p1: Player, p2: Player) -> bool: return p1.money > p2.money
|
||||
)
|
||||
current_board_state.current_player = current_board_state.players[0]
|
||||
|
||||
await all_players_ready_for_day_start
|
||||
|
||||
if current_board_state.state == BoardState.State.DESTROYING_BUILDINGS:
|
||||
if current_board_state.buildings_destroyed > 0:
|
||||
if current_board_state.buildings_to_destroy > 0:
|
||||
if current_board_state.current_player.id == Globals.game.this_player.id:
|
||||
print("here")
|
||||
board.is_destroying_building = true
|
||||
return
|
||||
current_board_state.state = BoardState.State.DRAFT
|
||||
|
||||
if current_board_state.state == BoardState.State.PLACING_SPAWNS:
|
||||
if current_board_state.spawn_placements > 0:
|
||||
@ -189,6 +184,15 @@ func start_day() -> void:
|
||||
)
|
||||
return
|
||||
current_board_state.state = BoardState.State.DRAFT
|
||||
|
||||
if current_board_state.day > 0:
|
||||
current_board_state.players.sort_custom(
|
||||
func(p1: Player, p2: Player) -> bool: return p1.money < p2.money
|
||||
)
|
||||
current_board_state.current_player = current_board_state.players[0]
|
||||
|
||||
await all_players_ready_for_day_start
|
||||
|
||||
current_board_state.day += 1
|
||||
current_board_state.turn = 1
|
||||
current_board_state.state = BoardState.State.DRAFT
|
||||
@ -199,7 +203,7 @@ func start_day() -> void:
|
||||
|
||||
seed(Globals.game.sum_player_ids())
|
||||
deck.shuffle()
|
||||
# deck.push_front(DEMOLITIONS_SCENE.instantiate())
|
||||
#deck.push_front(POST_OFFICE_SCENE.instantiate())
|
||||
var turn_index := current_board_state.get_this_player_index()
|
||||
controls.give_hand(deck.slice(0 + (3 * turn_index), 3 + (3 * turn_index)))
|
||||
controls.set_info()
|
||||
@ -231,7 +235,7 @@ func handle_board_state_changed() -> void:
|
||||
pending_board_state = BoardState.new()
|
||||
pending_board_state.day = current_board_state.day
|
||||
pending_board_state.spawn_placements = current_board_state.spawn_placements
|
||||
pending_board_state.buildings_destroyed = current_board_state.buildings_destroyed
|
||||
pending_board_state.buildings_to_destroy = current_board_state.buildings_to_destroy
|
||||
if (
|
||||
current_board_state.state != BoardState.State.DRAFT
|
||||
and current_board_state.state != BoardState.State.PLACING_SPAWNS
|
||||
@ -270,19 +274,14 @@ func handle_pass() -> void:
|
||||
advance_board_state.rpc(current_board_state.serialize())
|
||||
|
||||
|
||||
func _reset_turn() -> void:
|
||||
pending_board_state = null
|
||||
update_board_state.rpc(original_board_state.serialize())
|
||||
|
||||
|
||||
func handle_citizens_finished() -> void:
|
||||
for child in board.board_state.get_children():
|
||||
if child.get_groups().has("PostTurnActions"):
|
||||
child.handle_post_turn_actions()
|
||||
is_playing_day = false
|
||||
controls._reset_turn()
|
||||
controls.reset_turn()
|
||||
var winning_player_idx = current_board_state.players.find_custom(
|
||||
func(p: Player) -> bool: return p.money >= 100
|
||||
func(p: Player) -> bool: return p.money >= WINNING_MONEY_AMOUNT
|
||||
)
|
||||
if winning_player_idx != -1:
|
||||
game_over.set_winning_player(current_board_state.players[winning_player_idx])
|
||||
@ -309,9 +308,9 @@ func queue_spawn_placement(num_placements: int) -> void:
|
||||
current_board_state.state = BoardState.State.PLACING_SPAWNS
|
||||
|
||||
|
||||
func queue_building_destruction(num_placements: int) -> void:
|
||||
current_board_state.spawn_placements += num_placements * current_board_state.players.size()
|
||||
current_board_state.state = BoardState.State.PLACING_SPAWNS
|
||||
func queue_building_destruction(num: int) -> void:
|
||||
current_board_state.buildings_to_destroy += num * current_board_state.players.size()
|
||||
current_board_state.state = BoardState.State.DESTROYING_BUILDINGS
|
||||
|
||||
|
||||
func sell_building_permit() -> void:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user