Merge branch 'master' of ssh://git.sjkillen.ca:2222/sjkillen/everything_has_a_price_jam

This commit is contained in:
Jacob 2026-09-26 22:32:12 -06:00
commit 961f93a4f4
16 changed files with 211 additions and 22 deletions

View file

@ -8,7 +8,7 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void: func _process(_delta: float) -> void:
var mouse: = get_viewport().get_mouse_position() var mouse: = get_viewport().get_mouse_position()
var size: = get_viewport().get_visible_rect().size var size: = get_viewport().get_visible_rect().size
if (mouse.x < (0.10*size.x)): if (mouse.x < (0.10*size.x)):
@ -24,13 +24,17 @@ func _process(delta: float) -> void:
func _input(event): func _input(event):
if event is InputEventMouseButton: if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed: if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed:
zoom.x +=1 zoom.x +=1
zoom.y +=1 zoom.y +=1
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed: elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed:
if zoom.x - 1 < 1:
zoom.x = 1
else:
zoom.x -= 1 zoom.x -= 1
if zoom.y - 1 < 1:
zoom.y = 1
else:
zoom.y -= 1 zoom.y -= 1

View file

@ -6,6 +6,19 @@ signal production_log(producer: Currency, p: Production)
@export var currencies: Array[Production] @export var currencies: Array[Production]
@export var members: Array @export var members: Array
@onready var events: Array[Event] = load_events()
func load_events() -> Array[Event]:
var dir := "res://random events"
var es: Array[Event] = []
for event_name in ResourceLoader.list_directory(dir):
var event: Event = load(dir + "/" + event_name)
es.push_back(event)
return es
func get_currency(c: Currency) -> Production: func get_currency(c: Currency) -> Production:
sync_currency.call_deferred() sync_currency.call_deferred()
for p in currencies: for p in currencies:
@ -18,6 +31,8 @@ func get_currency(c: Currency) -> Production:
return p return p
func do_bribing(p: Production) -> bool: func do_bribing(p: Production) -> bool:
if get_currency_amount(p.currency) < p.amount:
return false
produce(negate_production(p)) produce(negate_production(p))
return true return true
@ -50,7 +65,7 @@ func produce(production: Production):
var c := get_currency(production.currency) var c := get_currency(production.currency)
c.amount += production.amount c.amount += production.amount
func simulate(): func update_currencies():
productions_update.emit.call_deferred(currencies) productions_update.emit.call_deferred(currencies)
for c in currencies: for c in currencies:
for p in c.currency.production: for p in c.currency.production:
@ -59,6 +74,17 @@ func simulate():
pp.amount = c.amount * p.amount pp.amount = c.amount * p.amount
produce(pp) produce(pp)
func simulate():
update_currencies()
for e in events:
if e.requirements_satisfied() and e.will_happen():
var outcome := e.outcome()
for o in outcome:
produce(o)
production_log.emit(null, o)
if e.timeline != null:
Dialogic.start(e.timeline)
func get_all_currencies_in(dir: StringName): func get_all_currencies_in(dir: StringName):
var reses := ResourceLoader.list_directory(dir) var reses := ResourceLoader.list_directory(dir)
@ -75,4 +101,11 @@ func get_all_inanimate_currencies() -> Array:
return get_all_currencies_in("res://currency/inanimate") return get_all_currencies_in("res://currency/inanimate")
func _ready() -> void: func _ready() -> void:
%SimulateTickTimer.start()
update_currencies()
func _on_timer_timeout() -> void:
if Dialogic.current_timeline != null:
%SimulateTickTimer.start()
return
simulate() simulate()

View file

@ -62,3 +62,8 @@ metadata/_custom_type_script = "uid://dddyxbkq0ienn"
[node name="Economy" type="Node" unique_id=1950923383] [node name="Economy" type="Node" unique_id=1950923383]
script = ExtResource("1_csm0v") script = ExtResource("1_csm0v")
currencies = Array[ExtResource("2_tljx8")]([SubResource("Resource_g3220"), SubResource("Resource_bb1uu"), SubResource("Resource_vw3jp"), SubResource("Resource_xg8li"), SubResource("Resource_f6kxb"), SubResource("Resource_6u4g3"), SubResource("Resource_aqv3t"), SubResource("Resource_g2km3")]) currencies = Array[ExtResource("2_tljx8")]([SubResource("Resource_g3220"), SubResource("Resource_bb1uu"), SubResource("Resource_vw3jp"), SubResource("Resource_xg8li"), SubResource("Resource_f6kxb"), SubResource("Resource_6u4g3"), SubResource("Resource_aqv3t"), SubResource("Resource_g2km3")])
[node name="SimulateTickTimer" type="Timer" parent="." unique_id=1726107261]
unique_name_in_owner = true
[connection signal="timeout" from="SimulateTickTimer" to="." method="_on_timer_timeout"]

View file

@ -1,5 +1,30 @@
extends Resource extends Resource
class_name Event class_name Event
@export var modified_resource: Production @export var modified_resource: Production
@export var extra_mods: Array[Production]
@export var timeline: DialogicTimeline @export var timeline: DialogicTimeline
@export var requirements: Array[Production] @export var requirements: Array[Production]
enum EventNature {
Random,
Certain,
}
@export var probability: float = 0.005
@export var nature: EventNature = EventNature.Random
func requirements_satisfied() -> bool:
for requirement in requirements:
if Economy.get_currency_amount(requirement.currency) < requirement.amount:
return false
return true
func will_happen() -> bool:
if nature == EventNature.Certain:
return true
return randf() <= probability
func outcome() -> Array[Production]:
var stuff: Array[Production] = [modified_resource]
stuff.append_array(extra_mods)
return stuff

12
game.tscn Normal file
View file

@ -0,0 +1,12 @@
[gd_scene format=3 uid="uid://dkui3dlb4vu1c"]
[ext_resource type="PackedScene" uid="uid://bdk1r2u8clllr" path="res://map.tscn" id="1_e2o6t"]
[ext_resource type="PackedScene" uid="uid://d06w1wtct0mfs" path="res://test/test_economy.tscn" id="2_feb5d"]
[node name="Game" type="Node2D" unique_id=1791439508]
[node name="map" parent="." unique_id=575553336 instance=ExtResource("1_e2o6t")]
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1213874033]
[node name="TestEconomy" parent="CanvasLayer" unique_id=629898212 instance=ExtResource("2_feb5d")]

View file

@ -3,15 +3,12 @@
[ext_resource type="Script" uid="uid://bkptc7j6c1r7p" path="res://gui/currency_inspector_panel.gd" id="1_tj5vo"] [ext_resource type="Script" uid="uid://bkptc7j6c1r7p" path="res://gui/currency_inspector_panel.gd" id="1_tj5vo"]
[ext_resource type="Texture2D" uid="uid://bplvus0ytk2f8" path="res://thumbnails/beer.png" id="2_p4bd1"] [ext_resource type="Texture2D" uid="uid://bplvus0ytk2f8" path="res://thumbnails/beer.png" id="2_p4bd1"]
[node name="CurrencyInspectorPanel" type="Control" unique_id=169191981] [node name="CurrencyInspectorPanel" type="Panel" unique_id=1489159816]
custom_minimum_size = Vector2(0, 100) custom_minimum_size = Vector2(500, 100)
layout_mode = 3
anchors_preset = 11 anchors_preset = 11
anchor_left = 1.0 anchor_left = 1.0
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = -188.0
offset_right = -188.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_tj5vo") script = ExtResource("1_tj5vo")
@ -19,14 +16,10 @@ script = ExtResource("1_tj5vo")
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=362599487] [node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=362599487]
custom_minimum_size = Vector2(400, 0) custom_minimum_size = Vector2(400, 0)
custom_maximum_size = Vector2(400, -1) custom_maximum_size = Vector2(400, -1)
layout_mode = 1 layout_mode = 0
anchors_preset = 5 offset_left = 50.0
anchor_left = 0.5 offset_right = 450.0
anchor_right = 0.5 offset_bottom = 503.0
offset_left = -253.0
offset_right = 47.0
offset_bottom = 149.0
grow_horizontal = 2
[node name="InspectedCurrency" type="Label" parent="VBoxContainer" unique_id=1206438498] [node name="InspectedCurrency" type="Label" parent="VBoxContainer" unique_id=1206438498]
unique_name_in_owner = true unique_name_in_owner = true

View file

@ -10,7 +10,7 @@ config_version=5
[application] [application]
run/main_scene="uid://d06w1wtct0mfs" run/main_scene="uid://dkui3dlb4vu1c"
config/features=PackedStringArray("4.7") config/features=PackedStringArray("4.7")
[autoload] [autoload]
@ -26,6 +26,7 @@ LetterGeneration="*uid://d156m2y8b38qs"
directories/dch_directory={} directories/dch_directory={}
directories/dtl_directory={ directories/dtl_directory={
"a_pig_flew": "res://test/a_pig_flew.dtl",
"asking for currency solo": "res://test/asking for currency solo.dtl", "asking for currency solo": "res://test/asking for currency solo.dtl",
"bar_crawl": "res://test/bar_crawl.dtl", "bar_crawl": "res://test/bar_crawl.dtl",
"blood_rain": "res://test/blood_rain.dtl", "blood_rain": "res://test/blood_rain.dtl",
@ -33,8 +34,10 @@ directories/dtl_directory={
"counteroffer request": "res://test/counteroffer request.dtl", "counteroffer request": "res://test/counteroffer request.dtl",
"counteroffer_response": "res://counteroffer_response.dtl", "counteroffer_response": "res://counteroffer_response.dtl",
"dino": "res://test/dino.dtl", "dino": "res://test/dino.dtl",
"dino ending": "res://test/dino ending.dtl",
"double_agent": "res://test/double_agent.dtl", "double_agent": "res://test/double_agent.dtl",
"drought": "res://test/drought.dtl", "drought": "res://test/drought.dtl",
"from_farmer_to_table": "res://test/from_farmer_to_table.dtl",
"goldrush": "res://test/goldrush.dtl", "goldrush": "res://test/goldrush.dtl",
"new intel": "res://test/new intel.dtl", "new intel": "res://test/new intel.dtl",
"outbreak": "res://test/outbreak.dtl", "outbreak": "res://test/outbreak.dtl",
@ -133,5 +136,6 @@ dialogic_default_action={
[rendering] [rendering]
textures/canvas_textures/default_texture_filter=0
rendering_device/driver.windows="d3d12" rendering_device/driver.windows="d3d12"
renderer/rendering_method="gl_compatibility" renderer/rendering_method="gl_compatibility"

View file

@ -0,0 +1,33 @@
[gd_resource type="Resource" script_class="Event" format=3 uid="uid://ddjairvlvswck"]
[ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_puqnt"]
[ext_resource type="Resource" uid="uid://b5qok0rcalr" path="res://currency/sentient/cow.tres" id="2_tqpw4"]
[ext_resource type="Resource" uid="uid://dsohovjbf3s2p" path="res://currency/sentient/chicken.tres" id="3_unbcn"]
[ext_resource type="Resource" uid="uid://rdrcyvuvrp2m" path="res://currency/sentient/pig.tres" id="4_k6ytv"]
[ext_resource type="Script" uid="uid://diwdxofo6exg3" path="res://event.gd" id="5_ks6hr"]
[ext_resource type="Resource" uid="uid://dnfywi4qk5tj" path="res://test/a_pig_flew.dtl" id="6_tqpw4"]
[sub_resource type="Resource" id="Resource_stddx"]
script = ExtResource("1_puqnt")
currency = ExtResource("2_tqpw4")
amount = 15
metadata/_custom_type_script = "uid://dddyxbkq0ienn"
[sub_resource type="Resource" id="Resource_3520l"]
script = ExtResource("1_puqnt")
currency = ExtResource("3_unbcn")
amount = 15
metadata/_custom_type_script = "uid://dddyxbkq0ienn"
[sub_resource type="Resource" id="Resource_wblg4"]
script = ExtResource("1_puqnt")
currency = ExtResource("4_k6ytv")
amount = 15
metadata/_custom_type_script = "uid://dddyxbkq0ienn"
[resource]
script = ExtResource("5_ks6hr")
modified_resource = SubResource("Resource_wblg4")
extra_mods = Array[ExtResource("1_puqnt")]([SubResource("Resource_stddx"), SubResource("Resource_3520l")])
timeline = ExtResource("6_tqpw4")
metadata/_custom_type_script = "uid://diwdxofo6exg3"

View file

@ -0,0 +1,54 @@
[gd_resource type="Resource" script_class="Event" format=3 uid="uid://f7qw65154l20"]
[ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_piiqm"]
[ext_resource type="Resource" uid="uid://dmctedq3pav0t" path="res://currency/inanimate/corpse.tres" id="2_khbdk"]
[ext_resource type="Resource" uid="uid://dn0c1pfq04obw" path="res://currency/sentient/farmer.tres" id="3_4gw5s"]
[ext_resource type="Resource" uid="uid://b5qok0rcalr" path="res://currency/sentient/cow.tres" id="4_rfq60"]
[ext_resource type="Resource" uid="uid://rdrcyvuvrp2m" path="res://currency/sentient/pig.tres" id="5_x0khx"]
[ext_resource type="Resource" uid="uid://dsohovjbf3s2p" path="res://currency/sentient/chicken.tres" id="6_6f6jr"]
[ext_resource type="Script" uid="uid://diwdxofo6exg3" path="res://event.gd" id="7_q4b6l"]
[ext_resource type="Resource" uid="uid://dctqq013bc6rx" path="res://test/from_farmer_to_table.dtl" id="8_khbdk"]
[sub_resource type="Resource" id="Resource_korph"]
script = ExtResource("1_piiqm")
currency = ExtResource("2_khbdk")
amount = 15
metadata/_custom_type_script = "uid://dddyxbkq0ienn"
[sub_resource type="Resource" id="Resource_7vjbg"]
script = ExtResource("1_piiqm")
currency = ExtResource("3_4gw5s")
amount = -15
metadata/_custom_type_script = "uid://dddyxbkq0ienn"
[sub_resource type="Resource" id="Resource_u1m57"]
script = ExtResource("1_piiqm")
currency = ExtResource("3_4gw5s")
amount = 20
metadata/_custom_type_script = "uid://dddyxbkq0ienn"
[sub_resource type="Resource" id="Resource_biffg"]
script = ExtResource("1_piiqm")
currency = ExtResource("4_rfq60")
amount = 20
metadata/_custom_type_script = "uid://dddyxbkq0ienn"
[sub_resource type="Resource" id="Resource_i756o"]
script = ExtResource("1_piiqm")
currency = ExtResource("5_x0khx")
amount = 20
metadata/_custom_type_script = "uid://dddyxbkq0ienn"
[sub_resource type="Resource" id="Resource_uhb4h"]
script = ExtResource("1_piiqm")
currency = ExtResource("6_6f6jr")
amount = 20
metadata/_custom_type_script = "uid://dddyxbkq0ienn"
[resource]
script = ExtResource("7_q4b6l")
modified_resource = SubResource("Resource_7vjbg")
extra_mods = Array[ExtResource("1_piiqm")]([SubResource("Resource_korph")])
timeline = ExtResource("8_khbdk")
requirements = Array[ExtResource("1_piiqm")]([SubResource("Resource_u1m57"), SubResource("Resource_biffg"), SubResource("Resource_i756o"), SubResource("Resource_uhb4h")])
metadata/_custom_type_script = "uid://diwdxofo6exg3"

7
test/a_pig_flew.dtl Normal file
View file

@ -0,0 +1,7 @@
Well the day has finally come {player_name}...
Pigs are flying!\
Cows are jumping over the moon!\
Chickens are.. well they're just doing normal chicken things. But there sure are a lot of them!
The moral of the story is we have a lot more farm animals now for some reason.

1
test/a_pig_flew.dtl.uid Normal file
View file

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

5
test/dino ending.dtl Normal file
View file

@ -0,0 +1,5 @@
Wha-
[wait time="2.0"]
[b]I WALKED AWAY FOR LIKE 2 MINUTES[/b]
[i][b]HOW THE HELL DID YOU GET EATEN BY A DINOSAUR?!!?[/b][/i]
congarjulations,, yourr did it and unlooked the secrt dino ending 🦖🦖🦖🦖🦖

1
test/dino ending.dtl.uid Normal file
View file

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

View file

@ -0,0 +1,3 @@
Sire! There's been a massacre!\
The animals have risen up against our farmers!
Oh well, dangers of the job I s'pose.

View file

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

View file

@ -19,8 +19,13 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_s48qe") script = ExtResource("1_s48qe")
[node name="ProductionChart" parent="." unique_id=1301678172 instance=ExtResource("2_jd86c")] [node name="ScrollContainer2" type="ScrollContainer" parent="." unique_id=872959271]
layout_mode = 0 layout_mode = 0
offset_right = 432.0
offset_bottom = 297.0
[node name="ProductionChart" parent="ScrollContainer2" unique_id=1301678172 instance=ExtResource("2_jd86c")]
layout_mode = 2
[node name="ScrollContainer" parent="." unique_id=587807919 instance=ExtResource("3_n4oyp")] [node name="ScrollContainer" parent="." unique_id=587807919 instance=ExtResource("3_n4oyp")]
layout_mode = 1 layout_mode = 1
@ -51,6 +56,7 @@ grow_horizontal = 0
grow_vertical = 2 grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Control" unique_id=74649172] [node name="VBoxContainer" type="VBoxContainer" parent="Control" unique_id=74649172]
visible = false
layout_mode = 0 layout_mode = 0
offset_right = 40.0 offset_right = 40.0
offset_bottom = 40.0 offset_bottom = 40.0
@ -71,6 +77,7 @@ text = "OpenInbox"
layout_mode = 1 layout_mode = 1
[node name="MemberInspectorPanel" parent="." unique_id=1641024074 instance=ExtResource("5_i7808")] [node name="MemberInspectorPanel" parent="." unique_id=1641024074 instance=ExtResource("5_i7808")]
custom_minimum_size = Vector2(0, 100)
layout_mode = 1 layout_mode = 1
offset_left = -189.0 offset_left = -189.0
offset_right = -189.0 offset_right = -189.0
@ -79,6 +86,7 @@ offset_right = -189.0
layout_mode = 1 layout_mode = 1
[node name="MemberSprite" parent="." unique_id=283117283 instance=ExtResource("6_vua3v")] [node name="MemberSprite" parent="." unique_id=283117283 instance=ExtResource("6_vua3v")]
visible = false
instance_shader_parameters/border_color = Color(1, 0, 0, 1) instance_shader_parameters/border_color = Color(1, 0, 0, 1)
instance_shader_parameters/border_width = 0.16 instance_shader_parameters/border_width = 0.16
instance_shader_parameters/fill_color = Color(1, 0.7529412, 0.79607844, 1) instance_shader_parameters/fill_color = Color(1, 0.7529412, 0.79607844, 1)