Skip to content

Commit

Permalink
Code clean and improve error prints
Browse files Browse the repository at this point in the history
  • Loading branch information
davcri committed Jan 3, 2019
1 parent bccc590 commit 088de6a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
6 changes: 4 additions & 2 deletions GameObjects/Card/Scripts/Card.gd
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ func capture():

func _load_cards_data_from_json():
var file = File.new()
file.open(CARDS_DATA_PATH, file.READ)
var exit_code = file.open(CARDS_DATA_PATH, file.READ)
if exit_code != 0:
print("Error", exit_code, "while opening", CARDS_DATA_PATH)
var file_data = file.get_as_text()
var error_str = validate_json(file_data)
if not error_str:
# JSON is valid
return parse_json(file_data)
else:
prints("Invalide JSON\n", error_str)
prints("Invalid JSON\n", error_str)

func set_covered(is_covered):
covered = is_covered
Expand Down
13 changes: 9 additions & 4 deletions GameScenes/Battle/Battle.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ _sections_unfolded = [ "Margin", "Transform" ]

[node name="Field" type="GridContainer" parent="." index="1"]

editor/display_folded = true
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
Expand Down Expand Up @@ -629,6 +630,8 @@ _sections_unfolded = [ "Material", "Rect", "Textures", "Visibility" ]

[node name="State" type="Node" parent="GameLogic/SelectionPointer" index="0"]

editor/display_folded = true

[node name="SelectingCard" type="Node" parent="GameLogic/SelectionPointer/State" index="0"]

script = ExtResource( 11 )
Expand All @@ -650,6 +653,8 @@ script = ExtResource( 13 )

[node name="Audio" type="Node" parent="GameLogic/SelectionPointer" index="1"]

editor/display_folded = true

[node name="CursorMove" type="AudioStreamPlayer" parent="GameLogic/SelectionPointer/Audio" index="0"]

stream = ExtResource( 14 )
Expand Down Expand Up @@ -768,10 +773,10 @@ expand = true
stretch_mode = 0
script = ExtResource( 20 )

[connection signal="turn_finished" from="Player2Cards" to="GameLogic/SelectionPointer" method="_on_Player2Cards_turn_finished"]

[connection signal="turn_finished" from="Player2Cards" to="GameLogic" method="_on_Player2Cards_turn_finished"]

[connection signal="turn_finished" from="Player2Cards" to="GameLogic/SelectionPointer" method="_on_Player2Cards_turn_finished"]

[connection signal="player_captured_a_card" from="GameLogic" to="Scores" method="_on_GameLogic_player_captured_a_card"]

[connection signal="card_selected" from="GameLogic/SelectionPointer/State/SelectingCard" to="GameLogic/SelectionPointer" method="_on_SelectingCard_card_selected"]
Expand All @@ -780,10 +785,10 @@ script = ExtResource( 20 )

[connection signal="change_to_idle_state" from="GameLogic/SelectionPointer/State/CardSelected" to="GameLogic/SelectionPointer" method="_on_CardSelected_change_to_idle_state"]

[connection signal="place_card" from="GameLogic/SelectionPointer/State/CardSelected" to="GameLogic" method="_on_CardSelected_place_card"]

[connection signal="place_card" from="GameLogic/SelectionPointer/State/CardSelected" to="Player1Cards" method="_on_CardSelected_place_card"]

[connection signal="place_card" from="GameLogic/SelectionPointer/State/CardSelected" to="GameLogic" method="_on_CardSelected_place_card"]

[connection signal="place_card" from="GameLogic/SelectionPointer/State/CardSelected" to="Player2Cards" method="_on_CardSelected_place_card"]

[connection signal="return_to_card_selection" from="GameLogic/SelectionPointer/State/CardSelected" to="GameLogic/SelectionPointer" method="_on_CardSelected_return_to_card_selection"]
Expand Down
3 changes: 0 additions & 3 deletions GameScenes/Battle/Scripts/Scores.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ extends Control
func _ready():
pass



func _on_GameLogic_player_captured_a_card(player_id):
print(player_id)
if player_id == 1:
$Player1Score.increase()
$Player2Score.decrease()
Expand Down
2 changes: 1 addition & 1 deletion GameScenes/Game/Game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use_filter = true
font_data = ExtResource( 5 )
_sections_unfolded = [ "Settings" ]

[node name="TripleTriad" type="Control"]
[node name="TripleTriad" type="Control" index="0"]

anchor_left = 0.0
anchor_top = 0.0
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Or you can:

## TODO

- Randomize starting cards
- Add ending screen
- Show battle result message (Draw, You Win, You Lose)
- Restarte the battle
Expand Down
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ config_version=3
config/name="TripleTriad"
run/main_scene="res://GameScenes/Game/Game.tscn"
config/icon="res://icon.png"
run/name="TripleTriad"

[display]

window/size/width=1536
window/size/height=896
window/size/fullscreen=true
window/size/test_width=800
window/size/test_height=600
window/stretch/mode="2d"
Expand Down

0 comments on commit 088de6a

Please sign in to comment.