Use worker for research

This commit is contained in:
2026-04-20 21:57:11 +02:00
parent 623ade6291
commit a10f2f02d7
8 changed files with 166 additions and 17 deletions

View File

@@ -148,10 +148,18 @@ func _grant_cycle_income(cycle_count: int) -> void:
if not _is_research_active(data.research_data.id):
return
var research_workers: int = game_state.get_research_workers()
if research_workers < data.research_data.min_workers_for_xp:
return
var amount_float: float = produced.mantissa * pow(10.0, float(produced.exponent))
var research_xp_amount: BigNumber = BigNumber.from_float(data.research_data.xp_per_currency_produced * amount_float)
if game_state != null and research_xp_amount.mantissa > 0.0:
game_state.add_research_xp(data.research_data.id, research_xp_amount)
var base_xp: BigNumber = BigNumber.from_float(data.research_data.xp_per_currency_produced * amount_float)
var worker_multiplier: float = 1.0 + (float(research_workers) * data.research_data.worker_scaling_factor)
var scaled_xp: BigNumber = base_xp.multiply(BigNumber.from_float(worker_multiplier))
if game_state != null and scaled_xp.mantissa > 0.0:
game_state.add_research_xp(data.research_data.id, scaled_xp)
## Convenience helper for the next single-unit purchase cost.
func get_next_cost() -> BigNumber:
@@ -433,10 +441,18 @@ func _try_grant_click_currency() -> void:
if not _is_research_active(data.research_data.id):
return
var research_workers: int = game_state.get_research_workers()
if research_workers < data.research_data.min_workers_for_xp:
return
var amount_float: float = click_value.mantissa * pow(10.0, float(click_value.exponent))
var research_xp_amount: BigNumber = BigNumber.from_float(data.research_data.xp_per_currency_produced * amount_float)
if game_state != null and research_xp_amount.mantissa > 0.0:
game_state.add_research_xp(data.research_data.id, research_xp_amount)
var base_xp: BigNumber = BigNumber.from_float(data.research_data.xp_per_currency_produced * amount_float)
var worker_multiplier: float = 1.0 + (float(research_workers) * data.research_data.worker_scaling_factor)
var scaled_xp: BigNumber = base_xp.multiply(BigNumber.from_float(worker_multiplier))
if game_state != null and scaled_xp.mantissa > 0.0:
game_state.add_research_xp(data.research_data.id, scaled_xp)
## Resolves click reward from data.