This commit is contained in:
Dan Baker 2025-12-02 07:45:23 +00:00
parent 7a8ee29dcb
commit 0fe23420ab
800 changed files with 16547 additions and 0 deletions

View file

@ -0,0 +1,7 @@
[gd_resource type="Resource" script_class="InventoryResource" load_steps=2 format=3 uid="uid://yd5y4dkbpa16"]
[ext_resource type="Script" uid="uid://bcnfchjftkkl" path="res://resources/InventoryResource.gd" id="1_5hrsc"]
[resource]
script = ExtResource("1_5hrsc")
metadata/_custom_type_script = "uid://bcnfchjftkkl"

View file

@ -0,0 +1,6 @@
class_name InventoryResource
extends Resource
@export var currency: float = 0
@export var wood: float = 0
@export var stock: float = 0

View file

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

108
resources/UnlockData.tres Normal file
View file

@ -0,0 +1,108 @@
[gd_resource type="Resource" script_class="UnlockDataCollection" load_steps=10 format=3 uid="uid://b4c01yrmp1wf2"]
[ext_resource type="Script" uid="uid://bg1ymgbdcwc0j" path="res://resources/UnlockDataCollection.gd" id="1_gdehu"]
[ext_resource type="Script" uid="uid://biqqffne7dd8r" path="res://resources/UnlockDataResource.gd" id="2_1js7i"]
[sub_resource type="Resource" id="Resource_gdehu"]
script = ExtResource("2_1js7i")
unlock_id = 1
unlock_name = "Marketing"
unlock_description = "Affects the amount people are willing to pay for your whittling"
base_cost = 100
is_scaling = true
cost_scaling_multiplier = 10.0
effect_scaling_multiplier = 1.5
base_modifiers = {
"sale_price_modifier": 1.5
}
metadata/_custom_type_script = "uid://biqqffne7dd8r"
[sub_resource type="Resource" id="Resource_1js7i"]
script = ExtResource("2_1js7i")
unlock_id = 2
unlock_name = "Wood"
unlock_description = "Increases the amount of wood produced per click"
base_cost = 10
is_scaling = true
cost_scaling_multiplier = 2.0
effect_scaling_type = 0
effect_linear_increase = 1.0
base_modifiers = {
"wood_per_click_modifier": 2.0
}
metadata/_custom_type_script = "uid://biqqffne7dd8r"
[sub_resource type="Resource" id="Resource_xbpe0"]
script = ExtResource("2_1js7i")
unlock_id = 3
unlock_name = "Demand"
unlock_description = "How many whittled products can be purchased per tick"
base_cost = 100
is_scaling = true
cost_scaling_multiplier = 5.0
effect_scaling_multiplier = 1.25
base_modifiers = {
"purchase_rate_modifier": 2.0
}
metadata/_custom_type_script = "uid://biqqffne7dd8r"
[sub_resource type="Resource" id="Resource_nbe0w"]
script = ExtResource("2_1js7i")
unlock_id = 4
unlock_name = "Efficiency"
unlock_description = "How many things you can produce per whittle"
base_cost = 1
is_scaling = true
max_rank = 5
cost_scaling_multiplier = 10.0
effect_scaling_type = 0
effect_linear_increase = 1.0
base_modifiers = {
"efficiency_modifier": 2.0
}
metadata/_custom_type_script = "uid://biqqffne7dd8r"
[sub_resource type="Resource" id="Resource_ppuju"]
script = ExtResource("2_1js7i")
unlock_id = 5
unlock_name = "Wholesale"
unlock_description = "Sell multiples of 100 at 20% extra income"
base_cost = 1
base_modifiers = {
"UNLOCK_ONESHOT_WHOLESALE": 1.0
}
metadata/_custom_type_script = "uid://biqqffne7dd8r"
[sub_resource type="Resource" id="Resource_chx6j"]
script = ExtResource("2_1js7i")
unlock_id = 6
unlock_name = "Multicraft"
unlock_description = "Just craft more stuff"
base_cost = 1
max_rank = 2
cost_scaling_multiplier = 10.0
effect_scaling_type = 0
effect_linear_increase = 1.0
base_modifiers = {
"multicraft_increase_modifier": 1.0
}
metadata/_custom_type_script = "uid://biqqffne7dd8r"
[sub_resource type="Resource" id="Resource_f82ch"]
script = ExtResource("2_1js7i")
unlock_id = 7
unlock_name = "Autowood"
unlock_description = "Automatically gather a percent of a clicks wood per tick"
base_cost = 1
is_scaling = true
max_rank = 5
effect_scaling_type = 0
base_modifiers = {
"autowood_modifier": 0.1
}
metadata/_custom_type_script = "uid://biqqffne7dd8r"
[resource]
script = ExtResource("1_gdehu")
unlocks = Array[ExtResource("2_1js7i")]([SubResource("Resource_gdehu"), SubResource("Resource_1js7i"), SubResource("Resource_xbpe0"), SubResource("Resource_nbe0w"), SubResource("Resource_ppuju"), SubResource("Resource_chx6j"), SubResource("Resource_f82ch")])
metadata/_custom_type_script = "uid://bg1ymgbdcwc0j"

View file

@ -0,0 +1,4 @@
class_name UnlockDataCollection
extends Resource
@export var unlocks: Array[UnlockDataResource] = []

View file

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

View file

@ -0,0 +1,218 @@
class_name UnlockDataResource
extends Resource
@export var unlock_id: int = 0
@export var unlock_name: String = ""
@export var unlock_description: String = ""
@export var base_cost: int = 0
@export var is_unlocked: bool = false
@export_group("Scaling Settings")
@export var is_scaling: bool = false
@export var current_rank: int = 0
@export var max_rank: int = -1 # -1 means infinite scaling
@export_subgroup("Cost Scaling")
@export_enum("Linear", "Exponential") var cost_scaling_type: int = 1 # Default to Exponential
@export var cost_scaling_multiplier: float = 1.5 # Exponential: multiplier per rank, Linear: flat increase
@export var cost_linear_increase: int = 100 # Only used if cost_scaling_type is Linear
@export_subgroup("Effect Scaling")
@export_enum("Linear", "Exponential") var effect_scaling_type: int = 1 # Default to Exponential
@export var effect_scaling_multiplier: float = 1.2 # Exponential: multiplier per rank
@export var effect_linear_increase: float = 0.1 # Linear: flat increase per rank (e.g., 0.1 = +10% per rank)
@export_group("Base Modifiers")
@export var base_modifiers: Dictionary = {}
## Returns the cost for the next rank/unlock
func get_next_cost() -> int:
if not is_scaling:
return base_cost
# Cost scaling should start from rank 0 (first purchase at base_cost)
if cost_scaling_type == 0: # Linear
return base_cost + (cost_linear_increase * current_rank)
else: # Exponential
return int(base_cost * pow(cost_scaling_multiplier, current_rank))
## Returns the current modifiers based on rank
func get_current_modifiers() -> Dictionary:
# If not unlocked yet, return empty modifiers
if not is_unlocked or current_rank == 0:
return {}
# Rank 1 should give base modifiers without scaling
if current_rank == 1:
return base_modifiers.duplicate()
# Rank 2+ applies scaling
return get_modifiers_at_rank(current_rank)
## Returns modifiers for a specific rank (useful for preview)
func get_modifiers_at_rank(rank: int) -> Dictionary:
if not is_scaling or rank == 0:
return base_modifiers.duplicate()
# Rank 1 returns base modifiers without scaling
if rank == 1:
return base_modifiers.duplicate()
var scaled_modifiers = {}
for key in base_modifiers.keys():
var base_value = base_modifiers[key]
if effect_scaling_type == 0: # Linear scaling
# Linear: add flat increase per rank above 1
# e.g., base 1.5 (+50%), linear 0.1 (+10%), rank 2 = 1.6 (+60%), rank 3 = 1.7 (+70%)
var additional_ranks = rank - 1
scaled_modifiers[key] = base_value + (effect_linear_increase * additional_ranks)
else: # Exponential scaling
# Exponential: scale the bonus part from rank 1
# The bonus at rank 1 is (base_value - 1.0)
# At higher ranks, multiply this bonus by multiplier^(rank-1)
var base_bonus = base_value - 1.0
var scaled_bonus = base_bonus * pow(effect_scaling_multiplier, rank - 1)
scaled_modifiers[key] = 1.0 + scaled_bonus
return scaled_modifiers
## Convert a modifier value to a percentage string
func _modifier_to_percentage(value: float) -> String:
var percentage = (value - 1.0) * 100.0
if percentage >= 0:
return "+%.1f%%" % percentage
else:
return "%.1f%%" % percentage
## Get a formatted string of current modifiers with percentages
func get_current_modifiers_string() -> String:
var modifiers = get_current_modifiers()
if modifiers.is_empty():
return "No modifiers"
var lines = []
for key in modifiers.keys():
var display_name = key.replace("_", " ").capitalize()
var percentage = _modifier_to_percentage(modifiers[key])
lines.append("%s: %s" % [display_name, percentage])
return "\n".join(lines)
## Get a formatted string of next rank modifiers with percentages
func get_next_modifiers_string() -> String:
if not can_rank_up():
return "Max rank reached"
var next_rank = get_next_rank()
var modifiers = get_modifiers_at_rank(next_rank)
if modifiers.is_empty():
return "No modifiers"
var lines = []
for key in modifiers.keys():
var display_name = key.replace("_", " ").capitalize()
var percentage = _modifier_to_percentage(modifiers[key])
lines.append("%s: %s" % [display_name, percentage])
return "\n".join(lines)
## Get comparison string showing current -> next modifiers
func get_modifiers_comparison_string() -> String:
if not can_rank_up():
return get_current_modifiers_string()
var current = get_current_modifiers()
var next_rank = get_next_rank()
var next = get_modifiers_at_rank(next_rank)
# If no current modifiers (not unlocked yet), show next only
if current.is_empty():
var lines = []
for key in next.keys():
var display_name = key.replace("_", " ").capitalize()
var next_pct = _modifier_to_percentage(next[key])
lines.append("%s: %s" % [display_name, next_pct])
return "\n".join(lines)
var lines = []
for key in current.keys():
var display_name = key.replace("_", " ").capitalize()
var current_pct = _modifier_to_percentage(current[key])
var next_pct = _modifier_to_percentage(next[key])
lines.append("%s: %s%s" % [display_name, current_pct, next_pct])
return "\n".join(lines)
## Get a single-line summary of modifiers
func get_modifiers_summary() -> String:
var modifiers = get_current_modifiers()
if modifiers.is_empty():
return "No effects"
var parts = []
for key in modifiers.keys():
var display_name = key.replace("_modifier", "").replace("_", " ").capitalize()
var percentage = _modifier_to_percentage(modifiers[key])
parts.append("%s %s" % [display_name, percentage])
return ", ".join(parts)
## Check if the unlock can be purchased/ranked up
func can_rank_up() -> bool:
# Non-scaling: can only unlock once
if not is_scaling:
return not is_unlocked
# Scaling: check if we haven't hit max rank
if max_rank > 0 and current_rank >= max_rank:
return false
return true
## Check if this is a one-off unlock (non-scaling)
func is_one_off() -> bool:
return not is_scaling
## Check if max rank has been reached (for scaling unlocks)
func is_max_rank() -> bool:
if not is_scaling:
return is_unlocked
if max_rank <= 0: # Infinite scaling
return false
return current_rank >= max_rank
## Unlock or rank up the unlock
func unlock() -> bool:
if not can_rank_up():
return false
if not is_scaling:
# Simple one-off unlock
is_unlocked = true
current_rank = 1
else:
# Scaling unlock - increase rank
current_rank += 1
is_unlocked = true
return true
## Get the next rank number (for display purposes)
func get_next_rank() -> int:
if not is_scaling:
return 1 if not is_unlocked else 1
return current_rank + 1
## Get display text for current status
func get_rank_display() -> String:
if not is_scaling:
return "Unlocked" if is_unlocked else "Locked"
if max_rank > 0:
return "Rank %d/%d" % [current_rank, max_rank]
else:
return "Rank %d" % current_rank

View file

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