diff --git a/economy/economy.gd b/economy/economy.gd deleted file mode 100644 index 7d3b713..0000000 --- a/economy/economy.gd +++ /dev/null @@ -1,79 +0,0 @@ -# Economy is a game entity that tracks money. - -# How money is minted, how money changes hands, and which -# money is valid is all controlled by Economy. When an -# in-game item is purchased, the money does not disappear -# but rather goes to the Market, an economic entity which -# can give back to players through investments or other means. - -# Economy also tracks GDP, which is the total amount of -# money that has changed hands so far during the game. -class_name Economy extends Node - -# Participant in the game economy -@abstract class Participant: - var participant_name = "Unnamed participant" - var _tokens = PackedInt32Array() - - func balance(): - return _tokens.size() - - func hold_tokens(tokens): - _tokens.append_array(tokens) - on_balance_update(balance()) - - func pop_tokens(amount): - if balance() < amount: - return [] - - var dropped = [] - for i in range(amount): - dropped.append(_tokens[_tokens.size() - 1]) - _tokens.remove_at(_tokens.size() - 1) - on_balance_update(balance()) - return dropped - - @abstract func message(string) - @abstract func on_balance_update(bal) - -class Market extends Participant: - func _init(): - participant_name = "Market" - func message(_s): - pass - func on_balance_update(_bal): - pass - -const max_money_supply = 1_000_000 - -var _gdp = 0 -var _market = Market.new() -var _participants = [] -var _token_ptr = 0 - -# register a Participant to receive benefits -func register(p: Participant): - _participants.append(p) - -func transfer(amount, sender: Participant, recipient: Participant): - if sender.balance() < amount: - return false - recipient.hold_tokens(sender.pop_tokens(amount)) - _gdp += amount - -func mint(amount): - var tokens = PackedInt32Array() - if _token_ptr + amount > max_money_supply: - return false - for i in range(amount): - tokens.append(_token_ptr) - _token_ptr += 1 - _market.hold_tokens(tokens) - return true - -func _ready(): - while true: - if len(_participants) > 0: - mint(1000) - transfer(1000, _market, _participants[0]) - break diff --git a/economy/economy.tscn b/economy/economy.tscn deleted file mode 100644 index e966432..0000000 --- a/economy/economy.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://cenj3dcweigwt"] - -[ext_resource type="Script" uid="uid://dl1jbgt83gocy" path="res://economy/economy.gd" id="1_n84lp"] - -[node name="Economy" type="Node"] -script = ExtResource("1_n84lp") diff --git a/main.tscn b/main.tscn index e5af29a..ae10ae9 100644 --- a/main.tscn +++ b/main.tscn @@ -1,11 +1,10 @@ -[gd_scene load_steps=10 format=3 uid="uid://eiaw4xbs3suk"] +[gd_scene load_steps=9 format=3 uid="uid://eiaw4xbs3suk"] [ext_resource type="PackedScene" uid="uid://qb8cbljxgnub" path="res://world/killbrick.tscn" id="1_h2yge"] [ext_resource type="PackedScene" uid="uid://cfceg80unq0pe" path="res://player/player.tscn" id="1_ig7tw"] [ext_resource type="PackedScene" uid="uid://bcmrj6qkemrll" path="res://world/radiohead_cube.tscn" id="2_0xm2m"] [ext_resource type="PackedScene" uid="uid://of6tq8gpjxtu" path="res://gears/gear_pickup.tscn" id="3_lquwl"] [ext_resource type="PackedScene" uid="uid://bafl8q0r61xrg" path="res://gears/gear.tscn" id="4_7mycd"] -[ext_resource type="PackedScene" uid="uid://cenj3dcweigwt" path="res://economy/economy.tscn" id="6_7mycd"] [sub_resource type="BoxShape3D" id="BoxShape3D_7dm0k"] size = Vector3(100, 2, 100) @@ -53,5 +52,3 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 2, -21) [node name="Gear" parent="GearPickup" instance=ExtResource("4_7mycd")] transform = Transform3D(1, 0, 0, 0, -0.012967386, 0.9999159, 0, -0.9999159, -0.012967386, 0, 0.5, 0) - -[node name="Economy" parent="." instance=ExtResource("6_7mycd")] diff --git a/player/player.gd b/player/player.gd index 6e9f274..48f08e0 100644 --- a/player/player.gd +++ b/player/player.gd @@ -10,7 +10,6 @@ const gear_slots = ["1", "2", "3"] var starting_gear = preload("res://gears/ball.tscn") -var ep = PlayerParticipant.new(self) var suspended = false var direction = Vector3.ZERO var target_velocity = Vector3.ZERO @@ -28,17 +27,13 @@ func resize_ui(): $HUD.position.x = 0 $HUD.position.y = size.y - hud_h -func make_hud(balance = ep.balance()): - if suspended: # TODO: CHANGE TO DEAD! - return - +func make_hud(): var text = "" for node in $Backpack.get_children(): if not node is Gear: continue text += "%s (%s)\n" % [node.gear_name(), node.name] text += "Holding " + $Pivot/Container/Gear.gear_name() + "\n" - text += str(balance) + " ₹ (rupees)\n" text += str(health()) + " hp" $HUD.text = text @@ -152,18 +147,6 @@ func equip(gear: Gear): message("Backpack full") return false -# Economy participant definition - -class PlayerParticipant extends Economy.Participant: - var player: Player - func _init(p: Player): - player = p - participant_name = "Player participant" - func message(string): - player.message(string) - func on_balance_update(bal): - player.make_hud(bal) - # Player mechanics func move_player(x, z): @@ -234,7 +217,6 @@ func do_gears(): # Engine callbacks func _ready(): - get_tree().current_scene.get_node("Economy").register(ep) get_viewport().size_changed.connect(resize_ui) resize_ui() respawn()