OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-tps / scenes / test / permissive_state.gd

24 lines · gd ref:
extends Node
## A GameState double that accepts every write.
##
## Exists because world:bots:registry: is role "mod" and a gate holds no room role,
## so the real gate refuses the durable row -- correctly. That refusal is asserted
## against the REAL GameState; this double is for the assertions after it, where
## the subject is the position body and the role would only be in the way.
##
## Deliberately tiny: set/get/has/erase and nothing else. A double that grew
## routing, scoping or channels would start passing tests the real one fails.
var _v: Dictionary = {}

func set_state(key: String, value: Variant) -> void:
	_v[key] = value

func get_state(key: String, default: Variant = null) -> Variant:
	return _v.get(key, default)

func has_state(key: String) -> bool:
	return _v.has(key)

func erase_state(key: String) -> void:
	_v.erase(key)