Skip to content

Commit

Permalink
Remove points from score and show failure text when not selecting 2 p…
Browse files Browse the repository at this point in the history
…rofile cards in 10 secs
  • Loading branch information
binaryDiv committed Oct 3, 2022
1 parent 5db4a7f commit 77da514
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
26 changes: 20 additions & 6 deletions src/screens/main_game/MainGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ const LocationCardPoolScene := preload("res://objects/cards/date_cards/location_
const ActivityCardPoolScene := preload("res://objects/cards/date_cards/activity_cards/ActivityCardPool.tscn")
const PlayerScene := preload("res://actors/player/Player.tscn")

# Remove profiles from the pool if the date score is above this value or below the negative value
const PROFILE_REMOVAL_THRESHOLD := 60

# Node references
onready var hud := $HUD as HUD
onready var countdown_bar := hud.countdown_bar as CountdownBar
onready var fail_text_label := $HUD/FailTextLabel as RichTextLabel

# Current phase
var current_phase := 0
Expand Down Expand Up @@ -155,9 +159,13 @@ func finish_phase1() -> void:
# Check if cards were chosen
var pairing_screen := current_phase_scene as PairingScreen
if not pairing_screen.all_card_slots_filled():
print_debug("Player hasn't finished! :(")
# TODO: remove one life and restart phase
# TODO: disable movement while paused
print_debug("Player hasn't selected two profiles! :(")

# Remove 100 points and show failure text, then restart round
total_score -= 100
display_fail_text("Too slow!\n[color=#ff0000]-100 points[/color]\n(Please select two profile cards.)")

# Dramatic pause!
yield(get_tree().create_timer(1), "timeout")
finish_round()
return
Expand All @@ -173,6 +181,13 @@ func finish_phase1() -> void:
# Start next phase
start_phase2()

func display_fail_text(_text: String) -> void:
fail_text_label.bbcode_text = "[center]%s[/center]" % _text

# Remove text after 3 seconds
yield(get_tree().create_timer(3), "timeout")
fail_text_label.bbcode_text = ""

# Phase 2: Date planning
func start_phase2() -> void:
print_debug("Starting phase 2...")
Expand All @@ -199,8 +214,7 @@ func start_phase2() -> void:
countdown_bar.init_timer(10)

# Start countdown (after a second delay)
# TODO: don't allow interactions in this delay
yield(get_tree().create_timer(1), "timeout")
yield(get_tree().create_timer(0.5), "timeout")
countdown_bar.start_timer()

func finish_phase2() -> void:
Expand Down Expand Up @@ -255,7 +269,7 @@ func finish_phase3() -> void:
total_score += _round_score

# Remove cards from pool if the date was especially nice - or terrible.
if _round_score <= -100 or _round_score >= 100:
if _round_score <= -PROFILE_REMOVAL_THRESHOLD or _round_score >= PROFILE_REMOVAL_THRESHOLD:
print_debug("Removing profiles %s and %s from pool." % [pairing_profile_card1.name, pairing_profile_card2.name])
profile_card_pool.remove_from_pool(pairing_profile_card1.name)
profile_card_pool.remove_from_pool(pairing_profile_card2.name)
Expand Down
1 change: 0 additions & 1 deletion src/screens/main_game/phase1/PairingScreen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func all_card_slots_filled() -> bool:
func find_card_touched_by_player() -> ProfileCard:
for _card in profile_cards:
var card := _card as ProfileCard
# TODO: Handle cases where multiple cards are touched at the same time
if card and card.overlaps_body(player) and card.selectable:
return card
return null
Expand Down
1 change: 0 additions & 1 deletion src/screens/main_game/phase2/PlanningScreen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func all_card_slots_filled() -> bool:
func find_card_touched_by_player() -> BaseDateCard:
for _card in date_cards:
var card := _card as BaseDateCard
# TODO: Handle cases where multiple cards are touched at the same time
if card and card.overlaps_body(player) and card.selectable:
return card
return null
Expand Down
4 changes: 2 additions & 2 deletions src/screens/main_game/phase3/DatingScreen.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ script = ExtResource( 1 )
[node name="DateOMeter" parent="." index="0" instance=ExtResource( 3 )]
position = Vector2( 640, 80 )

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="." index="1"]

[node name="StatusTextLabel" type="RichTextLabel" parent="." index="1"]
anchor_right = 1.0
anchor_bottom = 1.0
Expand All @@ -25,3 +23,5 @@ bbcode_text = "[center]Checking romantic compatibility...
text = "Checking romantic compatibility...
No points"
fit_content_height = true

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="." index="2"]
10 changes: 10 additions & 0 deletions src/ui/hud/HUD.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,13 @@ anchor_bottom = 1.0
margin_left = 1080.0
margin_top = 680.0
text = "Score: 1000"

[node name="FailTextLabel" type="RichTextLabel" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 320.0
margin_top = 616.0
margin_right = -320.0
margin_bottom = -8.0
bbcode_enabled = true
fit_content_height = true

0 comments on commit 77da514

Please sign in to comment.