This commit is contained in:
Tandy 2026-09-26 15:09:14 -06:00
commit e764f0cfa4
30 changed files with 363 additions and 30 deletions

6
GameState.tscn Normal file
View file

@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://bohql2ihaumsa"]
[ext_resource type="Script" uid="uid://drcn0r0bw1qol" path="res://game_state.gd" id="1_xw8og"]
[node name="GameState" type="Node" unique_id=137706129]
script = ExtResource("1_xw8og")

1
cannot_consume.dtl Normal file
View file

@ -0,0 +1 @@
You only have {for_timeline_calls.economy_amount} {for_timeline_calls.requested_currency}. You require at least {for_timeline_calls.requested_amount} {for_timeline_calls.requested_currency} to accept this offer.

1
cannot_consume.dtl.uid Normal file
View file

@ -0,0 +1 @@
uid://28m3sy62npp5

View file

@ -0,0 +1,8 @@
- Accept Terms
set {COUNTEROFFER_REPONSE} = 0
- Reject Terms
set {COUNTEROFFER_REPONSE} = 1.0
- Execute Them
set {COUNTEROFFER_REPONSE} = 2.0
- Respond Later
set {COUNTEROFFER_REPONSE} = 3.0

View file

@ -0,0 +1 @@
uid://bqggbdwbd0eru

View file

@ -1,6 +1,7 @@
extends Node
signal productions_update(p: Array[Production])
@warning_ignore("unused_signal")
signal production_log(producer: Currency, p: Production)
@export var currencies: Array[Production]
@export var members: Array
@ -28,8 +29,14 @@ func sync_currency():
break
productions_update.emit(currencies)
func get_currency_amount(currency: Currency) -> int:
var c := get_currency(currency)
return c.amount
func produce(producer: Currency, production: Production):
func can_consume(production: Production) -> bool:
return get_currency_amount(production.currency) >= production.amount
func produce(production: Production):
sync_currency.call_deferred()
var c := get_currency(production.currency)
c.amount += production.amount
@ -41,9 +48,7 @@ func simulate():
var pp := Production.new()
pp.currency = p.currency
pp.amount = c.amount * p.amount
produce(c.currency, pp)
# TODO remove this
production_log.emit.call_deferred(c.currency, pp)
produce(pp)
func _ready() -> void:
simulate()

19
game_state.gd Normal file
View file

@ -0,0 +1,19 @@
extends Node
var letters: Array[Letter]
signal add_letter(l: Letter)
signal remove_letter(l: Letter)
func _ready() -> void:
add_letter.connect(on_add_letter)
remove_letter.connect(on_remove_letter)
func on_add_letter(l: Letter):
letters.append(l)
func on_remove_letter(l: Letter):
var i := letters.find(l)
if i == -1:
push_error("Removed Letter not found", l)
return
letters.remove_at(i)

1
game_state.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://drcn0r0bw1qol

View file

@ -0,0 +1,14 @@
extends Button
@export var letter: Letter
func _ready() -> void:
GameState.remove_letter.connect(on_remove_letter)
%Source.text = letter.source.name
%Subject.text = letter.subject_field
func on_remove_letter(_l: Letter):
queue_free()
func _on_pressed() -> void:
letter.start()

View file

@ -0,0 +1 @@
uid://nb536nqdwd8g

View file

@ -0,0 +1,32 @@
[gd_scene format=3 uid="uid://da2ldx7una0a2"]
[ext_resource type="Script" uid="uid://nb536nqdwd8g" path="res://gui/inbox_message_subject.gd" id="1_npjct"]
[node name="InboxMessageSubject" type="Button" unique_id=1590519653]
custom_minimum_size = Vector2(0, 40)
script = ExtResource("1_npjct")
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=1923870606]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 30
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 30
theme_override_constants/margin_bottom = 20
[node name="Source" type="Label" parent="MarginContainer" unique_id=1252337854]
unique_name_in_owner = true
layout_mode = 2
text = "<Source>"
[node name="Subject" type="Label" parent="MarginContainer" unique_id=707399847]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
text = "<Subject>"
[connection signal="pressed" from="." to="." method="_on_pressed"]

18
gui/inbox_panel.gd Normal file
View file

@ -0,0 +1,18 @@
extends Control
func _ready() -> void:
UserContext.open_inbox.connect(open)
GameState.add_letter.connect(add_letter)
visible = false
func add_letter(l: Letter):
var ldis := preload("res://gui/inbox_message_subject.tscn").instantiate()
ldis.letter = l
%Letters.add_child(ldis)
func open():
visible = true
func _on_close_button_pressed() -> void:
visible = false

1
gui/inbox_panel.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://bjroelscgyvam

55
gui/inbox_panel.tscn Normal file
View file

@ -0,0 +1,55 @@
[gd_scene format=3 uid="uid://vanflt5jr7tx"]
[ext_resource type="Script" uid="uid://bjroelscgyvam" path="res://gui/inbox_panel.gd" id="1_nt1oc"]
[node name="InboxPanel" type="Control" unique_id=534578339]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_nt1oc")
[node name="Panel" type="Panel" parent="." unique_id=192689149]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Panel" unique_id=1054918739]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -20.0
offset_right = 20.0
offset_bottom = 40.0
grow_horizontal = 2
[node name="Title" type="Label" parent="Panel/VBoxContainer" unique_id=870802361]
layout_mode = 2
theme_override_font_sizes/font_size = 45
text = "Royal Messages"
[node name="Letters" type="VBoxContainer" parent="Panel/VBoxContainer" unique_id=508578167]
unique_name_in_owner = true
layout_mode = 2
[node name="CloseButton" type="Button" parent="Panel" unique_id=1499327494]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -25.0
offset_top = -31.0
offset_right = 25.0
grow_horizontal = 2
grow_vertical = 0
text = "Close"
[connection signal="pressed" from="Panel/CloseButton" to="." method="_on_close_button_pressed"]

View file

@ -8,3 +8,4 @@ func append(producer: Currency, production: Production):
display.producer = producer
display.production = production
add_child(display)
move_child(display, 0)

View file

@ -0,0 +1,7 @@
extends ScrollContainer
func _ready() -> void:
Economy.production_log.connect(production_log)
func production_log(_a, _b):
scroll_vertical = 0

View file

@ -0,0 +1 @@
uid://xk1grxwmi0cj

View file

@ -0,0 +1,15 @@
[gd_scene format=3 uid="uid://dx3y20p75chkj"]
[ext_resource type="PackedScene" uid="uid://cxv743rjsolk5" path="res://gui/production_ledger.tscn" id="1_ef7ko"]
[ext_resource type="Script" uid="uid://xk1grxwmi0cj" path="res://gui/production_ledger_scroll.gd" id="1_q4hel"]
[node name="ScrollContainer" type="ScrollContainer" unique_id=587807919]
custom_minimum_size = Vector2(600, 100)
offset_left = 153.0
offset_top = 346.0
offset_right = 161.0
offset_bottom = 346.0
script = ExtResource("1_q4hel")
[node name="ProductionChart2" parent="." unique_id=1301678172 instance=ExtResource("1_ef7ko")]
layout_mode = 2

View file

@ -1,14 +1,25 @@
extends Control
@export var producer: Currency
@export var producer: Currency = null
@export var production: Production
func _ready() -> void:
%producer.text = producer.name
if producer != null:
%producer.text = producer.name
%Production.visible = true
%Production2.visible = false
else:
%Production.visible = false
%Production2.visible = true
%amount.text = str(abs(production.amount))
%amount2.text = str(abs(production.amount))
if production.amount > 0:
%type.text = "produced"
%producer2.text = "You gained"
else:
%type.text = "consumed"
%producer2.text = "You lost"
%production.text = production.currency.name
%production2.text = production.currency.name

View file

@ -5,32 +5,59 @@
[node name="ProductionLog" type="MarginContainer" unique_id=253822540]
script = ExtResource("1_ei3g1")
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=1073672077]
[node name="Production" type="HBoxContainer" parent="." unique_id=1073672077]
unique_name_in_owner = true
layout_mode = 2
[node name="producer" type="Label" parent="HBoxContainer" unique_id=1739229616]
[node name="producer" type="Label" parent="Production" unique_id=1739229616]
unique_name_in_owner = true
layout_mode = 2
text = "<Currency Name>"
[node name="type" type="Label" parent="HBoxContainer" unique_id=660284845]
[node name="type" type="Label" parent="Production" unique_id=660284845]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
text = "produced"
[node name="amount" type="Label" parent="HBoxContainer" unique_id=146404186]
[node name="amount" type="Label" parent="Production" unique_id=146404186]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
text = "0"
[node name="text_produced2" type="Label" parent="HBoxContainer" unique_id=1784666448]
[node name="text_produced2" type="Label" parent="Production" unique_id=1784666448]
layout_mode = 2
size_flags_horizontal = 8
text = "of"
[node name="production" type="Label" parent="HBoxContainer" unique_id=1547964707]
[node name="production" type="Label" parent="Production" unique_id=1547964707]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
text = "<currency name>"
[node name="Production2" type="HBoxContainer" parent="." unique_id=471354461]
unique_name_in_owner = true
layout_mode = 2
[node name="producer2" type="Label" parent="Production2" unique_id=1688839821]
unique_name_in_owner = true
layout_mode = 2
text = "You lost"
[node name="amount2" type="Label" parent="Production2" unique_id=1453456742]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8
text = "0"
[node name="text_produced2" type="Label" parent="Production2" unique_id=776506345]
layout_mode = 2
size_flags_horizontal = 8
text = "of"
[node name="production2" type="Label" parent="Production2" unique_id=593187984]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 8

57
letters/counteroffer.gd Normal file
View file

@ -0,0 +1,57 @@
extends Letter
@export var request: Production
func start():
Dialogic.VAR.for_timeline_calls.requested_currency = request.currency.name
Dialogic.VAR.for_timeline_calls.requested_amount = request.amount
Dialogic.VAR.for_timeline_calls.requestee_class = source.name
Dialogic.VAR.for_timeline_calls.requestee_name = "a " + source.name
Dialogic.start(timeline)
await Dialogic.timeline_ended
var response: int
while true:
Dialogic.start(preload("res://counteroffer_response.dtl"))
await Dialogic.timeline_ended
response = int(Dialogic.VAR.get_variable("COUNTEROFFER_REPONSE"))
if response == 0:
# Accept
if not Economy.can_consume(request):
var supply := Economy.get_currency_amount(request.currency)
Dialogic.VAR.for_timeline_calls.economy_amount = supply
Dialogic.start(preload("res://cannot_consume.dtl"))
await Dialogic.timeline_ended
continue
var request_neg = request.duplicate()
request_neg.amount = -request_neg.amount
Economy.produce(request_neg)
Economy.production_log.emit(null, request_neg)
break
#elif response == 1:
## Reject
#pass
elif response == 1 or response == 2:
# Execute
var execution := Production.new()
execution.currency = source
execution.amount = -1
Economy.produce(execution)
Economy.production_log.emit(null, execution)
break
elif response == 3:
# Cancel
break
else:
push_error("Got unknown response: ", response)
return
if response == 2:
var corpse := Production.new()
corpse.currency = preload("res://currency/inanimate/corpse.tres")
corpse.amount = 1
Economy.produce(corpse)
Economy.production_log.emit(null, corpse)
if response != 3:
GameState.remove_letter.emit(self)

View file

@ -0,0 +1 @@
uid://c47ee6kd2x6oi

View file

@ -0,0 +1,9 @@
[gd_resource type="Resource" format=3 uid="uid://dvmpw3ctoqdxh"]
[ext_resource type="Script" uid="uid://c47ee6kd2x6oi" path="res://letters/counteroffer.gd" id="1_85ymh"]
[ext_resource type="Resource" uid="uid://dkh7gj7jgul27" path="res://test/counteroffer request.dtl" id="2_85ymh"]
[resource]
script = ExtResource("1_85ymh")
timeline = ExtResource("2_85ymh")
metadata/_custom_type_script = "uid://cadv11m8ohoxe"

9
letters/letter.gd Normal file
View file

@ -0,0 +1,9 @@
extends Resource
class_name Letter
@export var source: Currency
@export var timeline: DialogicTimeline
@export var subject_field: String = "No Subject"
func start():
Dialogic.start(timeline)

1
letters/letter.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://cadv11m8ohoxe

View file

@ -19,13 +19,16 @@ Dialogic="*uid://ds2q0uclmolvu"
Economy="*uid://dnpioqaes87yb"
Random="*uid://cu3n7igqstbxi"
UserContext="*uid://0a08ucta58lp"
GameState="*uid://bohql2ihaumsa"
[dialogic]
directories/dch_directory={}
directories/dtl_directory={
"asking for currency solo": "res://test/asking for currency solo.dtl",
"cannot_consume": "res://cannot_consume.dtl",
"counteroffer request": "res://test/counteroffer request.dtl",
"counteroffer_response": "res://counteroffer_response.dtl",
"new intel": "res://test/new intel.dtl",
"outro": "res://test/outro.dtl",
"outro but you win actually": "res://test/outro but you win actually.dtl",
@ -37,13 +40,15 @@ directories/dtl_directory={
}
layout/style_directory={}
variables={
"RNG": 0,
"RNG_1_4": 0,
"COUNTEROFFER_REPONSE": 0,
"RNG": "",
"RNG_1_4": "",
"for_timeline_calls": {
"requested_amount": 69,
"requested_currency": "dollareedoos",
"requestee_class": "people",
"requestee_name": "john nameman"
"economy_amount": "",
"requested_amount": "",
"requested_currency": "",
"requestee_class": "",
"requestee_name": ""
},
"kingdom_name": "coolland",
"player_goal": "killing",

View file

@ -4,7 +4,7 @@ do Random.dialogic_random(1, 4)
You've received a letter from {for_timeline_calls.requestee_name} the {for_timeline_calls.requestee_class}.
if {RNG_1_4} == 1.0:
"Greetings your majesty. {for_timeline_calls.requestee_name} the {for_timeline_calls.requestee_class} here."
"I've recently recived an offer from Sir Archie Nemisye for my services.. and I'm afraid it is [i]much[/i] higher than what I'm currently reciving."
"I've recently recived an offer from Sir Archie Nemisye for my services.. and I'm afraid it is [i]much[/i] higher than what I'm currently receiving."
"I'm nothing if not a (mostly) loyal subject however, so if you should see fit to match that ammount ({for_timeline_calls.requested_amount} {for_timeline_calls.requested_currency} to be exact), I will gladly stay in your service."
elif {RNG_1_4} == 2.0:

View file

@ -9,3 +9,14 @@ func _on_get_cow_pressed() -> void:
func _on_run_simulate_pressed() -> void:
Economy.simulate()
func _on_open_inbox_pressed() -> void:
UserContext.open_inbox.emit()
var letter := preload("res://letters/counteroffer.tres").duplicate()
letter.request = Production.new()
letter.request.currency = preload("res://currency/inanimate/beer.tres")
letter.request.amount = 10
letter.source = preload("res://currency/sentient/drunk.tres")
GameState.add_letter.emit(letter)

View file

@ -2,8 +2,9 @@
[ext_resource type="Script" uid="uid://6438cbkn3fhm" path="res://test/test_economy.gd" id="1_s48qe"]
[ext_resource type="PackedScene" uid="uid://desvyn6e28oar" path="res://gui/production_chart.tscn" id="2_jd86c"]
[ext_resource type="PackedScene" uid="uid://cxv743rjsolk5" path="res://gui/production_ledger.tscn" id="3_jd7cj"]
[ext_resource type="PackedScene" uid="uid://dx3y20p75chkj" path="res://gui/production_ledger_scroll.tscn" id="3_n4oyp"]
[ext_resource type="PackedScene" uid="uid://75htlmk51oo" path="res://gui/currency_inspector_panel.tscn" id="4_7ya5o"]
[ext_resource type="PackedScene" uid="uid://vanflt5jr7tx" path="res://gui/inbox_panel.tscn" id="5_n4oyp"]
[node name="TestEconomy" type="Control" unique_id=629898212]
layout_mode = 3
@ -17,16 +18,19 @@ script = ExtResource("1_s48qe")
[node name="ProductionChart" parent="." unique_id=1301678172 instance=ExtResource("2_jd86c")]
layout_mode = 0
[node name="ScrollContainer" type="ScrollContainer" parent="." unique_id=1023925432]
custom_minimum_size = Vector2(600, 100)
layout_mode = 0
offset_left = 153.0
offset_top = 346.0
offset_right = 161.0
offset_bottom = 346.0
[node name="ProductionChart2" parent="ScrollContainer" unique_id=1698529519 instance=ExtResource("3_jd7cj")]
layout_mode = 2
[node name="ScrollContainer" parent="." unique_id=587807919 instance=ExtResource("3_n4oyp")]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -300.0
offset_top = -100.0
offset_right = 300.0
offset_bottom = 0.0
grow_horizontal = 2
grow_vertical = 0
[node name="Control" type="Control" parent="." unique_id=641955392]
layout_mode = 1
@ -55,8 +59,16 @@ text = "Get cow"
layout_mode = 2
text = "Run simulate"
[node name="OpenInbox" type="Button" parent="Control/VBoxContainer" unique_id=1148713984]
layout_mode = 2
text = "OpenInbox"
[node name="CurrencyInspectorPanel" parent="." unique_id=169191981 instance=ExtResource("4_7ya5o")]
layout_mode = 1
[node name="InboxPanel" parent="." unique_id=534578339 instance=ExtResource("5_n4oyp")]
layout_mode = 1
[connection signal="pressed" from="Control/VBoxContainer/GetCow" to="." method="_on_get_cow_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/RunSimulate" to="." method="_on_run_simulate_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/OpenInbox" to="." method="_on_open_inbox_pressed"]

View file

@ -2,3 +2,6 @@ extends Node
@warning_ignore("unused_signal")
signal currency_inspect(c: Currency)
@warning_ignore("unused_signal")
signal open_inbox