Implement core bidding loop (minus loss state and destroy painting)
This commit is contained in:
parent
ed2516a478
commit
a96ec6cc92
8 changed files with 136 additions and 48 deletions
|
|
@ -14,14 +14,15 @@ signal ask_accepted
|
||||||
#meant to make the audience more inclined to bid as day progresses
|
#meant to make the audience more inclined to bid as day progresses
|
||||||
@export var audience_time_pressure := 1.4
|
@export var audience_time_pressure := 1.4
|
||||||
|
|
||||||
|
@export var min_audience_think_time := 0.5
|
||||||
|
@export var max_audience_think_time := 2.0
|
||||||
|
|
||||||
@export var bid_threshold := 3.0
|
@export var bid_threshold := 3.0
|
||||||
@export var think_chance := 0.5
|
@export var think_chance := 0.5
|
||||||
@export var think_min_time := 1.0
|
@export var think_min_time := 1.0
|
||||||
@export var think_max_time := 5.0
|
@export var think_max_time := 5.0
|
||||||
|
|
||||||
# Whether or not the audience has submitted a bid, and the next call
|
var current_ask: int
|
||||||
# needs to be higher than the last
|
|
||||||
var bid_pending = false
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
desk.numpad.ask_proposed.connect(_handle_ask_proposed)
|
desk.numpad.ask_proposed.connect(_handle_ask_proposed)
|
||||||
|
|
@ -29,22 +30,23 @@ func _ready() -> void:
|
||||||
|
|
||||||
func raise_paddle():
|
func raise_paddle():
|
||||||
#need to add in logic to animate paddle being raised
|
#need to add in logic to animate paddle being raised
|
||||||
bid_pending = true
|
game_manager.state = game_manager.bidding_state.BID
|
||||||
pass
|
print("Audience accepts the bid at $" + str(current_ask))
|
||||||
|
game_manager.current_bid = desk.numpad.proposed_ask
|
||||||
|
ask_accepted.emit()
|
||||||
|
|
||||||
|
|
||||||
func _handle_bid_delay_timeout():
|
func _handle_bid_delay_timeout():
|
||||||
if randf_range(1.2, 5.3) >= bid_threshold:
|
if randf_range(1.2, 5.3) >= bid_threshold:
|
||||||
raise_paddle()
|
raise_paddle()
|
||||||
game_manager.current_bid = desk.numpad.proposed_ask
|
|
||||||
ask_accepted.emit()
|
|
||||||
timer.stop()
|
timer.stop()
|
||||||
|
|
||||||
func _handle_ask_proposed():
|
func _handle_ask_proposed(amount):
|
||||||
if bid_pending:
|
current_ask = amount
|
||||||
bid_pending = false
|
|
||||||
|
|
||||||
if randf() <= think_chance:
|
if randf() <= think_chance:
|
||||||
timer.stop()
|
timer.stop()
|
||||||
var ask_duration: float = randf_range(1.0, 5.0)
|
var ask_duration: float = randf_range(min_audience_think_time, max_audience_think_time)
|
||||||
timer.wait_time = ask_duration
|
timer.wait_time = ask_duration
|
||||||
timer.start()
|
timer.start()
|
||||||
|
|
|
||||||
1
desk.gd
1
desk.gd
|
|
@ -4,6 +4,7 @@ class_name Desk extends Control
|
||||||
@export var game_manager: GameManager
|
@export var game_manager: GameManager
|
||||||
@export var turn_manager: TurnManager
|
@export var turn_manager: TurnManager
|
||||||
@export var audience_manager: AudienceManager
|
@export var audience_manager: AudienceManager
|
||||||
|
@export var gavel: Gavel
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
numpad.turn_manager = turn_manager
|
numpad.turn_manager = turn_manager
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,14 @@
|
||||||
[ext_resource type="AudioStream" uid="uid://bvto7ghmy8j0o" path="res://assets/gavel/audio/invalid-bet.wav" id="31_v5y5a"]
|
[ext_resource type="AudioStream" uid="uid://bvto7ghmy8j0o" path="res://assets/gavel/audio/invalid-bet.wav" id="31_v5y5a"]
|
||||||
[ext_resource type="AudioStream" uid="uid://b7qyt2h17kjea" path="res://assets/gavel/audio/ask-bet.wav" id="32_dnpqj"]
|
[ext_resource type="AudioStream" uid="uid://b7qyt2h17kjea" path="res://assets/gavel/audio/ask-bet.wav" id="32_dnpqj"]
|
||||||
|
|
||||||
[node name="Desk" type="Control" node_paths=PackedStringArray("numpad")]
|
[node name="Desk" type="Control" node_paths=PackedStringArray("numpad", "gavel")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 0
|
anchors_preset = 0
|
||||||
offset_right = 1280.0
|
offset_right = 1280.0
|
||||||
offset_bottom = 720.0
|
offset_bottom = 720.0
|
||||||
script = ExtResource("1_yugeg")
|
script = ExtResource("1_yugeg")
|
||||||
numpad = NodePath("Numpad")
|
numpad = NodePath("Numpad")
|
||||||
|
gavel = NodePath("Gavel")
|
||||||
|
|
||||||
[node name="Gavel" type="Node2D" parent="." node_paths=PackedStringArray("audio_player")]
|
[node name="Gavel" type="Node2D" parent="." node_paths=PackedStringArray("audio_player")]
|
||||||
position = Vector2(971, 563)
|
position = Vector2(971, 563)
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,54 @@
|
||||||
class_name GameManager extends Node2D
|
class_name GameManager extends Node2D
|
||||||
|
|
||||||
|
@export var audience_manager: AudienceManager
|
||||||
|
@export var desk: Desk
|
||||||
|
|
||||||
var paintings_sold = 0
|
var paintings_sold = 0
|
||||||
var paintings_total = 0
|
@export var paintings_total = 7
|
||||||
|
|
||||||
var paintings: Array = Array()
|
var paintings: Array = Array()
|
||||||
|
var current_painting = 0
|
||||||
|
|
||||||
# tracker variables for bid markers, proposing bids happens between numpad and audience
|
# tracker variables for bid markers, proposing bids happens between numpad and audience
|
||||||
var current_bid = 0
|
var current_bid = 0
|
||||||
|
var starting_price = 0
|
||||||
var final_bid = 0
|
var final_bid = 0
|
||||||
|
@export var current_bid_display: RichTextLabel
|
||||||
|
|
||||||
var target_sales: int = 0
|
var target_sales: int = 0
|
||||||
var total_sales: int = 0
|
var total_sales: int = 0
|
||||||
|
@export var sales_magnitude = 100000
|
||||||
|
@export var single_painting_magnitude = 1000
|
||||||
|
@export var initial_value_reduction: float = 0.6
|
||||||
|
|
||||||
# state tracker for a given painting's auction
|
# state tracker for a given painting's auction
|
||||||
var bidding_open: bool = false
|
var bidding_open: bool = false
|
||||||
signal bidding_start
|
enum bidding_state {CLOSED, READY, ASKING, BID}
|
||||||
|
var state: int = bidding_state.CLOSED
|
||||||
|
signal new_painting_displayed
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
paintings_total = randi_range(7,10)
|
audience_manager.ask_accepted.connect(_handle_ask_accepted)
|
||||||
target_sales = (paintings_total * 100000)/randf_range(1.25,2) # need to workshop the target sales generation process for more interesting numbers
|
desk.gavel.gavel_hit.connect(_handle_gavel_hit)
|
||||||
|
|
||||||
#var e = 0
|
#paintings_total = randi_range(7,10)
|
||||||
#for painting in paintings:
|
target_sales = randi_range(2,5) * sales_magnitude
|
||||||
#if e <= paintings_total:
|
|
||||||
#paintings.append()
|
|
||||||
|
|
||||||
|
var new_painting = 0
|
||||||
|
var new_painting_value: int
|
||||||
|
|
||||||
|
while new_painting < paintings_total:
|
||||||
|
new_painting_value = (target_sales/randf_range(paintings_total - 2, paintings_total + 2))
|
||||||
|
new_painting_value = snappedi(new_painting_value, single_painting_magnitude)
|
||||||
|
print(str(new_painting_value))
|
||||||
|
paintings.append(new_painting_value)
|
||||||
|
new_painting += 1
|
||||||
|
|
||||||
|
print(paintings)
|
||||||
|
print("You have " + str(paintings_total) + " paintings. Sell them for at least $" + str(target_sales) + " or face the consequences!")
|
||||||
|
print("Hit the gavel and input a starting bid to begin!")
|
||||||
|
|
||||||
|
next_painting(0)
|
||||||
#build out the initialization process, which should:
|
#build out the initialization process, which should:
|
||||||
# -- generate paintings and assign values
|
# -- generate paintings and assign values
|
||||||
# -- start the turn timer/auction timer
|
# -- start the turn timer/auction timer
|
||||||
|
|
@ -32,25 +56,39 @@ func _ready() -> void:
|
||||||
# -- have tts announcement of starting bid and start of auction
|
# -- have tts announcement of starting bid and start of auction
|
||||||
|
|
||||||
|
|
||||||
print("You have " + str(paintings_total) + " paintings. Sell them for at least $" + str(target_sales) + " or face the consequences!")
|
|
||||||
pass
|
|
||||||
|
|
||||||
func _on_gavel_gavel_hit():
|
|
||||||
bidding_open = not bidding_open
|
func _handle_gavel_hit():
|
||||||
if bidding_open == true:
|
if state == bidding_state.CLOSED:
|
||||||
current_bid = target_sales/(paintings_total + 2)
|
state = bidding_state.READY
|
||||||
print("The new painting will start selling at $" + str(current_bid))
|
print(str(state))
|
||||||
|
elif state == bidding_state.ASKING:
|
||||||
|
if current_bid != 0:
|
||||||
|
state = bidding_state.CLOSED
|
||||||
|
sell_painting()
|
||||||
|
print("Congrats on selling your painting for $" + str(current_bid) + "! You have made $" + str(total_sales) + " so far.")
|
||||||
|
current_painting += 1
|
||||||
|
next_painting((current_painting))
|
||||||
|
print("The next painting is valued at $" + str(starting_price) + " (should be $" + str(paintings[current_painting]) + ")")
|
||||||
|
(print(str(state)))
|
||||||
else:
|
else:
|
||||||
total_sales = total_sales + current_bid
|
pass
|
||||||
paintings_sold += 1
|
|
||||||
print("Congrats on selling your painting for $" + str(current_bid) + "! You have made $" + str(total_sales) + " so far.")
|
|
||||||
|
|
||||||
func destroy_painting():
|
func destroy_painting():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func next_painting():
|
func sell_painting():
|
||||||
pass
|
total_sales = total_sales + current_bid
|
||||||
|
|
||||||
|
func next_painting(a: int):
|
||||||
|
starting_price = paintings[a]
|
||||||
|
current_bid = 0
|
||||||
|
|
||||||
|
# will need to add animation/image swap
|
||||||
|
new_painting_displayed.emit()
|
||||||
|
|
||||||
|
func _handle_ask_accepted():
|
||||||
|
current_bid_display.text = str(current_bid)
|
||||||
# OTHER THINGS TO ADD:
|
# OTHER THINGS TO ADD:
|
||||||
# UI elements for score
|
# UI elements for score
|
||||||
# Bark manager
|
# Bark manager
|
||||||
|
|
|
||||||
2
gavel.gd
2
gavel.gd
|
|
@ -1,4 +1,4 @@
|
||||||
extends Node2D
|
class_name Gavel extends Node2D
|
||||||
|
|
||||||
signal gavel_hit
|
signal gavel_hit
|
||||||
|
|
||||||
|
|
|
||||||
28
main.tscn
28
main.tscn
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=8 format=3 uid="uid://dt4nq0nkmjiit"]
|
[gd_scene load_steps=9 format=3 uid="uid://dt4nq0nkmjiit"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b5tcsve1oo5ht" path="res://game_manager.gd" id="1_ig7tw"]
|
[ext_resource type="Script" uid="uid://b5tcsve1oo5ht" path="res://game_manager.gd" id="1_ig7tw"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cvqsf1nlfqwpr" path="res://assets/background/background.png" id="1_lquwl"]
|
[ext_resource type="Texture2D" uid="uid://cvqsf1nlfqwpr" path="res://assets/background/background.png" id="1_lquwl"]
|
||||||
|
|
@ -8,12 +8,30 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://c1acpop6amvcl" path="res://audience_manager.tscn" id="6_272bh"]
|
[ext_resource type="PackedScene" uid="uid://c1acpop6amvcl" path="res://audience_manager.tscn" id="6_272bh"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b8key4hjaldui" path="res://turn_manager.tscn" id="7_272bh"]
|
[ext_resource type="PackedScene" uid="uid://b8key4hjaldui" path="res://turn_manager.tscn" id="7_272bh"]
|
||||||
|
|
||||||
|
[sub_resource type="Theme" id="Theme_272bh"]
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D"]
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
[node name="Background" type="Sprite2D" parent="."]
|
[node name="Background" type="Sprite2D" parent="."]
|
||||||
position = Vector2(640, 360)
|
position = Vector2(640, 360)
|
||||||
texture = ExtResource("1_lquwl")
|
texture = ExtResource("1_lquwl")
|
||||||
|
|
||||||
|
[node name="UI" type="Control" parent="."]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 0
|
||||||
|
offset_right = 1280.0
|
||||||
|
offset_bottom = 720.0
|
||||||
|
|
||||||
|
[node name="RichTextLabel" type="RichTextLabel" parent="UI"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 480.0
|
||||||
|
offset_top = 434.0
|
||||||
|
offset_right = 796.0
|
||||||
|
offset_bottom = 457.0
|
||||||
|
theme = SubResource("Theme_272bh")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="Chairs" type="Node2D" parent="."]
|
[node name="Chairs" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="ChairsBack" type="Sprite2D" parent="Chairs"]
|
[node name="ChairsBack" type="Sprite2D" parent="Chairs"]
|
||||||
|
|
@ -24,8 +42,14 @@ texture = ExtResource("2_7mycd")
|
||||||
position = Vector2(640, 360)
|
position = Vector2(640, 360)
|
||||||
texture = ExtResource("3_272bh")
|
texture = ExtResource("3_272bh")
|
||||||
|
|
||||||
[node name="GameManager" type="Node2D" parent="."]
|
[node name="GameManager" type="Node2D" parent="." node_paths=PackedStringArray("audience_manager", "desk", "current_bid_display")]
|
||||||
script = ExtResource("1_ig7tw")
|
script = ExtResource("1_ig7tw")
|
||||||
|
audience_manager = NodePath("../AudienceManager")
|
||||||
|
desk = NodePath("../Desk")
|
||||||
|
current_bid_display = NodePath("../UI/RichTextLabel")
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="GameManager"]
|
||||||
|
wait_time = 300.0
|
||||||
|
|
||||||
[node name="Desk" parent="." node_paths=PackedStringArray("game_manager", "turn_manager", "audience_manager") instance=ExtResource("2_0xm2m")]
|
[node name="Desk" parent="." node_paths=PackedStringArray("game_manager", "turn_manager", "audience_manager") instance=ExtResource("2_0xm2m")]
|
||||||
game_manager = NodePath("../GameManager")
|
game_manager = NodePath("../GameManager")
|
||||||
|
|
|
||||||
36
numpad.gd
36
numpad.gd
|
|
@ -2,7 +2,7 @@ class_name Numpad extends Node2D
|
||||||
|
|
||||||
var numpad_buffer = Array()
|
var numpad_buffer = Array()
|
||||||
var proposed_ask: int
|
var proposed_ask: int
|
||||||
signal ask_proposed
|
signal ask_proposed(amount)
|
||||||
|
|
||||||
#var turn_manager: TurnManager
|
#var turn_manager: TurnManager
|
||||||
var audience_manager: AudienceManager
|
var audience_manager: AudienceManager
|
||||||
|
|
@ -25,17 +25,39 @@ func keypad_entry(entry: int):
|
||||||
numpad_buffer.append(str(entry))
|
numpad_buffer.append(str(entry))
|
||||||
|
|
||||||
func keypad_backspace():
|
func keypad_backspace():
|
||||||
numpad_buffer.remove_at(-1)
|
if numpad_buffer.size() > 0:
|
||||||
|
numpad_buffer.remove_at(-1)
|
||||||
|
|
||||||
func keypad_submit():
|
func keypad_submit():
|
||||||
var keypad_output: String = "".join(numpad_buffer)
|
var keypad_output: String = "".join(numpad_buffer)
|
||||||
proposed_ask = int(keypad_output) * 1000
|
proposed_ask = int(keypad_output) * 1000
|
||||||
|
|
||||||
if proposed_ask > game_manager.current_bid and audience_manager.bid_pending or proposed_ask == game_manager.current_bid:
|
match game_manager.state:
|
||||||
success_audio_player.play()
|
game_manager.bidding_state.READY:
|
||||||
ask_proposed.emit()
|
if proposed_ask == game_manager.starting_price:
|
||||||
else:
|
game_manager.state = game_manager.bidding_state.ASKING
|
||||||
error_audio_player.play()
|
success_audio_player.play()
|
||||||
|
ask_proposed.emit(proposed_ask)
|
||||||
|
print("asking for $" + str(proposed_ask))
|
||||||
|
else:
|
||||||
|
error_audio_player.play()
|
||||||
|
game_manager.bidding_state.ASKING:
|
||||||
|
if proposed_ask == game_manager.starting_price or proposed_ask == game_manager.current_bid or proposed_ask == audience_manager.current_ask and proposed_ask != 0:
|
||||||
|
success_audio_player.play()
|
||||||
|
ask_proposed.emit(proposed_ask)
|
||||||
|
print("starting the bidding at $" + str(proposed_ask))
|
||||||
|
else:
|
||||||
|
error_audio_player.play()
|
||||||
|
game_manager.bidding_state.BID:
|
||||||
|
if proposed_ask > game_manager.current_bid:
|
||||||
|
game_manager.state = game_manager.bidding_state.ASKING
|
||||||
|
success_audio_player.play()
|
||||||
|
ask_proposed.emit(proposed_ask)
|
||||||
|
print("asking for $" + str(proposed_ask))
|
||||||
|
else:
|
||||||
|
error_audio_player.play()
|
||||||
|
_:
|
||||||
|
error_audio_player.play()
|
||||||
|
|
||||||
reminder_timer.start(-1)
|
reminder_timer.start(-1)
|
||||||
numpad_buffer.clear()
|
numpad_buffer.clear()
|
||||||
|
|
|
||||||
|
|
@ -23,16 +23,16 @@ func _ready() -> void:
|
||||||
func turn_timer_animation():
|
func turn_timer_animation():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _speak_ask_proposed():
|
func _speak_ask_proposed(amount):
|
||||||
var speech_variance = randf()
|
var speech_variance = randf()
|
||||||
if speech_variance < 0.45:
|
if speech_variance < 0.45:
|
||||||
DisplayServer.tts_speak(str(desk.numpad.proposed_ask), voice_id, tts_volume, tts_pitch, tts_number_speed)
|
DisplayServer.tts_speak(str(amount), voice_id, tts_volume, tts_pitch, tts_number_speed)
|
||||||
elif speech_variance > 0.45 and speech_variance < 0.65:
|
elif speech_variance > 0.45 and speech_variance < 0.65:
|
||||||
DisplayServer.tts_speak("Do I hear" + str(desk.numpad.proposed_ask), voice_id, tts_volume, tts_pitch, tts_sentence_speed)
|
DisplayServer.tts_speak("Do I hear" + str(amount), voice_id, tts_volume, tts_pitch, tts_sentence_speed)
|
||||||
elif speech_variance > 0.65 and speech_variance < 0.8:
|
elif speech_variance > 0.65 and speech_variance < 0.8:
|
||||||
DisplayServer.tts_speak(str(desk.numpad.proposed_ask) + ", anybody?", voice_id, tts_volume, tts_pitch, tts_sentence_speed)
|
DisplayServer.tts_speak(str(amount) + ", anybody?", voice_id, tts_volume, tts_pitch, tts_sentence_speed)
|
||||||
else:
|
else:
|
||||||
DisplayServer.tts_speak("Can I get a" + str(desk.numpad.proposed_ask), voice_id, tts_volume, tts_pitch, tts_sentence_speed)
|
DisplayServer.tts_speak("Can I get a" + str(amount), voice_id, tts_volume, tts_pitch, tts_sentence_speed)
|
||||||
|
|
||||||
func _handle_ask_accepted():
|
func _handle_ask_accepted():
|
||||||
timer.start()
|
timer.start()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue