feat: deliver emergent Jajce commitments
This commit is contained in:
@@ -2,6 +2,7 @@ class_name SocialCommitmentSystem
|
||||
extends RefCounted
|
||||
|
||||
const REASON_FACT_FULFILLED := &"world_fact_fulfilled"
|
||||
const REASON_FACT_RESOLVED_BY_OTHER := &"world_fact_resolved_by_other"
|
||||
const REASON_DEADLINE_MISSED := &"deadline_missed"
|
||||
const REASON_SITUATION_EXPIRED := &"situation_expired"
|
||||
const REASON_SITUATION_SUPERSEDED := &"situation_superseded"
|
||||
@@ -70,11 +71,28 @@ func maintain(
|
||||
situation, world_events, state_facts, situation.get_selected_alternative_id()
|
||||
)
|
||||
if progress.resolved:
|
||||
var resolution_event := (
|
||||
world_events.get_by_id(progress.matched_event_id) if world_events != null else null
|
||||
)
|
||||
var resolver := (
|
||||
resolution_event.get_participant(WorldEventRecord.ROLE_ACTOR)
|
||||
if resolution_event != null
|
||||
else null
|
||||
)
|
||||
var debtor_resolved := resolver != null and resolver.equals(commitment.get_debtor())
|
||||
var resolution_status := (
|
||||
CommitmentStateRecord.STATUS_FULFILLED
|
||||
if debtor_resolved
|
||||
else CommitmentStateRecord.STATUS_SUPERSEDED
|
||||
)
|
||||
var resolution_reason := (
|
||||
REASON_FACT_FULFILLED if debtor_resolved else REASON_FACT_RESOLVED_BY_OTHER
|
||||
)
|
||||
if _close(
|
||||
commitment,
|
||||
CommitmentStateRecord.STATUS_FULFILLED,
|
||||
resolution_status,
|
||||
current_tick,
|
||||
REASON_FACT_FULFILLED,
|
||||
resolution_reason,
|
||||
progress.matched_event_id
|
||||
):
|
||||
closed.append(commitment)
|
||||
@@ -98,7 +116,7 @@ func maintain(
|
||||
closed.append(commitment)
|
||||
continue
|
||||
var deadline := commitment.get_deadline_tick()
|
||||
if deadline >= 0 and current_tick > deadline:
|
||||
if deadline >= 0 and current_tick >= deadline:
|
||||
if _close(
|
||||
commitment,
|
||||
CommitmentStateRecord.STATUS_BROKEN,
|
||||
@@ -164,6 +182,10 @@ func get_active_sorted() -> Array[CommitmentStateRecord]:
|
||||
return records
|
||||
|
||||
|
||||
func get_next_commitment_id() -> int:
|
||||
return _next_commitment_id
|
||||
|
||||
|
||||
func _close(
|
||||
commitment: CommitmentStateRecord,
|
||||
status: StringName,
|
||||
|
||||
Reference in New Issue
Block a user