diff --git a/.import/Blue_Square.png-ae535163e31b183d7b98f1e9b7ee13d3.md5 b/.import/Blue_Square.png-ae535163e31b183d7b98f1e9b7ee13d3.md5 index bb1696d..63f83bc 100644 --- a/.import/Blue_Square.png-ae535163e31b183d7b98f1e9b7ee13d3.md5 +++ b/.import/Blue_Square.png-ae535163e31b183d7b98f1e9b7ee13d3.md5 @@ -1,3 +1,3 @@ -source_md5="201c8d64f549e4cd5bfafead420971c8" -dest_md5="2f77245de30b1cc29db0463f8328eb31" +source_md5="17a6d967f3b7416282a1320659ff3bde" +dest_md5="f99cd8dd7825f1ee2d3e36f96720f05d" diff --git a/.import/Blue_Square.png-ae535163e31b183d7b98f1e9b7ee13d3.stex b/.import/Blue_Square.png-ae535163e31b183d7b98f1e9b7ee13d3.stex index 9cbd12e..370a967 100644 Binary files a/.import/Blue_Square.png-ae535163e31b183d7b98f1e9b7ee13d3.stex and b/.import/Blue_Square.png-ae535163e31b183d7b98f1e9b7ee13d3.stex differ diff --git a/.import/Blue_Square.png-d16f1d6378ac4470e5e4c5fdfb3d6335.md5 b/.import/Blue_Square.png-d16f1d6378ac4470e5e4c5fdfb3d6335.md5 new file mode 100644 index 0000000..bb1696d --- /dev/null +++ b/.import/Blue_Square.png-d16f1d6378ac4470e5e4c5fdfb3d6335.md5 @@ -0,0 +1,3 @@ +source_md5="201c8d64f549e4cd5bfafead420971c8" +dest_md5="2f77245de30b1cc29db0463f8328eb31" + diff --git a/.import/Blue_Square.png-d16f1d6378ac4470e5e4c5fdfb3d6335.stex b/.import/Blue_Square.png-d16f1d6378ac4470e5e4c5fdfb3d6335.stex new file mode 100644 index 0000000..9cbd12e Binary files /dev/null and b/.import/Blue_Square.png-d16f1d6378ac4470e5e4c5fdfb3d6335.stex differ diff --git a/.import/Red_Square.png-770b8c2c1fe78febcf1c5cf3528e08fe.md5 b/.import/Red_Square.png-770b8c2c1fe78febcf1c5cf3528e08fe.md5 index b02d317..28dd319 100644 --- a/.import/Red_Square.png-770b8c2c1fe78febcf1c5cf3528e08fe.md5 +++ b/.import/Red_Square.png-770b8c2c1fe78febcf1c5cf3528e08fe.md5 @@ -1,3 +1,3 @@ -source_md5="470b78ce180a1fbae0f8601102da7565" -dest_md5="dcc2b8ffafffaa18192b0b38fdf856cb" +source_md5="e657dc9897d2f1b7a2d36ede40c50389" +dest_md5="53f1af83a9f8127f8ca5f335762ed1d6" diff --git a/.import/Red_Square.png-770b8c2c1fe78febcf1c5cf3528e08fe.stex b/.import/Red_Square.png-770b8c2c1fe78febcf1c5cf3528e08fe.stex index 8716894..ff606b4 100644 Binary files a/.import/Red_Square.png-770b8c2c1fe78febcf1c5cf3528e08fe.stex and b/.import/Red_Square.png-770b8c2c1fe78febcf1c5cf3528e08fe.stex differ diff --git a/.import/Red_Square.png-a8d761d5e77c7435746f77940263fa78.md5 b/.import/Red_Square.png-a8d761d5e77c7435746f77940263fa78.md5 new file mode 100644 index 0000000..b02d317 --- /dev/null +++ b/.import/Red_Square.png-a8d761d5e77c7435746f77940263fa78.md5 @@ -0,0 +1,3 @@ +source_md5="470b78ce180a1fbae0f8601102da7565" +dest_md5="dcc2b8ffafffaa18192b0b38fdf856cb" + diff --git a/.import/Red_Square.png-a8d761d5e77c7435746f77940263fa78.stex b/.import/Red_Square.png-a8d761d5e77c7435746f77940263fa78.stex new file mode 100644 index 0000000..8716894 Binary files /dev/null and b/.import/Red_Square.png-a8d761d5e77c7435746f77940263fa78.stex differ diff --git a/.import/favicon.png-801e823cfc153ed89bbb828ce5cff222.md5 b/.import/favicon.png-801e823cfc153ed89bbb828ce5cff222.md5 new file mode 100644 index 0000000..7b61c3e --- /dev/null +++ b/.import/favicon.png-801e823cfc153ed89bbb828ce5cff222.md5 @@ -0,0 +1,3 @@ +source_md5="47313fa4c47a9963fddd764e1ec6e4a8" +dest_md5="2ded9e7f9060e2b530aab678b135fc5b" + diff --git a/.import/favicon.png-801e823cfc153ed89bbb828ce5cff222.stex b/.import/favicon.png-801e823cfc153ed89bbb828ce5cff222.stex new file mode 100644 index 0000000..3ca6461 Binary files /dev/null and b/.import/favicon.png-801e823cfc153ed89bbb828ce5cff222.stex differ diff --git a/Assets/Blue_Square.png b/Assets/Blue_Square.png index 2910c1e..ca77a3b 100644 Binary files a/Assets/Blue_Square.png and b/Assets/Blue_Square.png differ diff --git a/Assets/Red_Square.png b/Assets/Red_Square.png index a059716..931381d 100644 Binary files a/Assets/Red_Square.png and b/Assets/Red_Square.png differ diff --git a/Scenes/Levels/Level Components/Country.tscn b/Scenes/Levels/Level Components/Country.tscn index 9ce8065..60615e7 100644 --- a/Scenes/Levels/Level Components/Country.tscn +++ b/Scenes/Levels/Level Components/Country.tscn @@ -14,13 +14,18 @@ script = ExtResource( 1 ) script = ExtResource( 3 ) [node name="Label" type="Label" parent="."] -margin_left = -16.0 -margin_top = -4.0 -margin_right = 16.0 +margin_left = -10.0 +margin_top = -10.0 +margin_right = 10.0 margin_bottom = 10.0 +align = 1 +valign = 3 +autowrap = true __meta__ = { "_edit_use_anchors_": false } [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) + +[node name="Tween" type="Tween" parent="."] diff --git a/Scripts/Levels/Level Components/Country.gd b/Scripts/Levels/Level Components/Country.gd index d510535..3194f2e 100644 --- a/Scripts/Levels/Level Components/Country.gd +++ b/Scripts/Levels/Level Components/Country.gd @@ -11,13 +11,12 @@ var num_reinforcements: int = 0 var flashing = false var time_since_last_flash = 0 -var flashing_period = 0.5 +const flashing_period = 0.5 var flash_mask_sprite = null # List of locations to move to to complete the attack animation. -const movement_speed = 0.2 -const distance_to_stop_moving_at = 16 -var locations_to_move_to = [] +const destination_movement_duration = 0.2 +const origin_movement_duration = 0.4 func save(): var save_dict = {} @@ -43,7 +42,7 @@ func change_ownership_to(player): func update_labels(): var label_text = str(num_troops) if num_reinforcements > 0: - label_text += " + " + str(num_reinforcements) + label_text += " +" + str(num_reinforcements) get_node("Label").text = label_text belongs_to.update_labels() @@ -62,17 +61,22 @@ func draw_line_to_country(selected_country): new_line.add_point(Vector2(0,0)) new_line.add_point(selected_country.position - position) -func can_attack(): +func get_attackable_countries(): + var attackable_countries = [] for country in connected_countries: if country.num_troops < num_troops and country.belongs_to != belongs_to: - return true - return false + attackable_countries.append(country) + return attackable_countries func _input_event(viewport, event, shape_idx): if get_tree().get_current_scene().get_name() == "Level Creator": if event.is_action_just_released(): self.on_click(event) +func move_to(duration, destination): + get_node("Tween").interpolate_property(self, "position", position, destination, duration) + get_node("Tween").start() + func on_click(event): # Level Creator Behaviour if get_tree().get_current_scene().get_name() == "Level Creator": @@ -141,8 +145,8 @@ func on_click(event): var attacker = Game_Manager.selected_country if (attacker in connected_countries) and (attacker.num_troops > num_troops): # Movement animation - attacker.locations_to_move_to.append(position) - attacker.locations_to_move_to.append(attacker.position) + attacker.move_to(destination_movement_duration, position) + attacker.get_node("Tween").interpolate_callback(attacker, destination_movement_duration, "move_to", origin_movement_duration, attacker.position) # Attack logic that changes troops and updates labels num_troops = attacker.num_troops - num_troops @@ -179,6 +183,7 @@ func on_click(event): if event.button_index == BUTTON_RIGHT: # Check that a reinforcement has been previously added to this country if num_reinforcements > 0: + Game_Manager.curr_player.num_reinforcements += 1 num_reinforcements -= 1 update_labels() @@ -281,8 +286,8 @@ func _process(delta): time_since_last_flash = 0 # Moving to a spot if the locations_to_move_to list is non empty - if locations_to_move_to: - position = position.linear_interpolate(locations_to_move_to[0], movement_speed) - # Checking if the destination has been reached - if position.distance_to(locations_to_move_to[0]) < distance_to_stop_moving_at: - position = locations_to_move_to.pop_front() +# if locations_to_move_to: +# position = position.linear_interpolate(locations_to_move_to[0], movement_speed) +# # Checking if the destination has been reached +# if position.distance_to(locations_to_move_to[0]) < distance_to_stop_moving_at: +# position = locations_to_move_to.pop_front() diff --git a/Scripts/Levels/Level Main.gd b/Scripts/Levels/Level Main.gd index b4bbfbf..0be7bda 100644 --- a/Scripts/Levels/Level Main.gd +++ b/Scripts/Levels/Level Main.gd @@ -135,6 +135,34 @@ remote func end_reinforcement_disable(hide_boolean): get_node("CanvasLayer/End Reinforcement").show() ####### +# AI +####### +# We duplicate the existing countries so that modifications here do not propogate outside +func clone_country(country): + var new_country = Country.init(country.x, country.y, country.country_name, country.player) + new_country.num_troops = country.num_troops + return new_country + +func extract_game_state(): + var game_state = {} + for player in players.values(): + game_state[player.color] = {} + for country in player.owner_countries: + game_state[player.color][country.country_name] = clone_country(country) + return game_state + +func get_child_states(game_state, curr_player_color): + for country in game_state[curr_player_color]: + for attackable_country in country.get_attackable_countries(): + pass + +# The depth parameter is not how deep the function is currently, +# but how much deeper it should go +# minimax(extract_game_state(), 3, -INF, INF, true) +func minimax(game_state, depth, alpha, beta, maximizing_player): + pass +###### + # Clear the player dictionary, rerandomise troop allocation and redo player turn order and country allocation func reroll_spawn(): for player in players.values(): @@ -202,7 +230,7 @@ func add_random_countries(player, num_countries): func is_attack_over(): for country in curr_player.owned_countries: - if country.can_attack(): + if country.get_attackable_countries(): return false return true diff --git a/project.godot b/project.godot index b9d7fe0..c541fbb 100644 --- a/project.godot +++ b/project.godot @@ -40,6 +40,7 @@ config/icon="res://icon.png" window/size/width=1920 window/size/height=1080 +window/size/fullscreen=true window/stretch/mode="viewport" window/stretch/aspect="keep"