Make crab behavior reflect catch quality
This commit is contained in:
parent
abedd64782
commit
13fc64b80c
4 changed files with 161 additions and 11 deletions
|
|
@ -28,7 +28,7 @@ func _run_host() -> void:
|
|||
assert(session.start_dedicated_host(TEST_PORT, 8, "127.0.0.1"))
|
||||
assert(session.set_host_open(true))
|
||||
await _wait_for_population(service)
|
||||
_validate_population(service)
|
||||
_validate_population(service, true)
|
||||
|
||||
var remote_peer_id: int = 0
|
||||
var join_deadline: int = Time.get_ticks_msec() + 20000
|
||||
|
|
@ -51,7 +51,7 @@ func _run_host() -> void:
|
|||
):
|
||||
await process_frame
|
||||
assert(not session.is_authenticated_peer(remote_peer_id))
|
||||
_validate_population(service)
|
||||
_validate_population(service, true)
|
||||
_validate_respawn_budget(service)
|
||||
print("World spawn multiplayer host validation: PASS")
|
||||
session.disconnect_session("")
|
||||
|
|
@ -82,7 +82,7 @@ func _run_client() -> void:
|
|||
NetworkProtocol.WORLD_SPAWN_CAPABILITY
|
||||
))
|
||||
await _wait_for_population(service)
|
||||
_validate_population(service)
|
||||
_validate_population(service, false)
|
||||
print("World spawn multiplayer client validation: PASS")
|
||||
session.disconnect_session("")
|
||||
main.queue_free()
|
||||
|
|
@ -101,7 +101,7 @@ func _wait_for_population(service: Node) -> void:
|
|||
assert(false, "Timed out waiting for the world spawn population.")
|
||||
|
||||
|
||||
func _validate_population(service: Node) -> void:
|
||||
func _validate_population(service: Node, expect_authoritative_state: bool) -> void:
|
||||
var entities: Dictionary = service.get("_entities")
|
||||
var presentations: Dictionary = service.get("_presentations")
|
||||
assert(entities.size() == EXPECTED_POPULATION)
|
||||
|
|
@ -112,6 +112,13 @@ func _validate_population(service: Node) -> void:
|
|||
assert(typeof(position) == TYPE_VECTOR3)
|
||||
assert((position as Vector3).is_finite())
|
||||
assert((position as Vector3).y > 0.08)
|
||||
if expect_authoritative_state:
|
||||
var quality: int = int(state.get("quality", -1))
|
||||
assert(FishQuality.is_valid(quality))
|
||||
var entry := state.get("data") as GatherableData
|
||||
assert(entry != null)
|
||||
assert(entry.get_movement_speed_for_quality(quality) > 0.0)
|
||||
assert(entry.get_scare_radius_for_quality(quality) > 0.0)
|
||||
|
||||
|
||||
func _validate_respawn_budget(service: Node) -> void:
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ func _validate_catalog_statuses() -> void:
|
|||
assert(brown.catch_data.logbook_section == FishData.LogbookSection.SHELLFISH)
|
||||
assert(brown.population == 2)
|
||||
assert(is_equal_approx(brown.charge_duration, 2.0))
|
||||
_validate_quality_behavior(brown)
|
||||
assert(is_equal_approx(brown.capture_respawn_min_seconds, 480.0))
|
||||
assert(is_equal_approx(brown.capture_respawn_max_seconds, 720.0))
|
||||
assert(is_equal_approx(brown.scare_respawn_min_seconds, 45.0))
|
||||
|
|
@ -63,6 +64,57 @@ func _validate_catalog_statuses() -> void:
|
|||
assert(scared_delay >= 45.0 and scared_delay <= 90.0)
|
||||
|
||||
|
||||
func _validate_quality_behavior(entry: GatherableData) -> void:
|
||||
var prior_speed: float = -1.0
|
||||
var prior_scare_radius: float = -1.0
|
||||
for quality: int in FishQuality.TIER_COUNT:
|
||||
var movement_speed: float = entry.get_movement_speed_for_quality(
|
||||
quality
|
||||
)
|
||||
var scare_radius: float = entry.get_scare_radius_for_quality(quality)
|
||||
assert(movement_speed > prior_speed)
|
||||
assert(scare_radius > prior_scare_radius)
|
||||
prior_speed = movement_speed
|
||||
prior_scare_radius = scare_radius
|
||||
assert(
|
||||
is_equal_approx(
|
||||
entry.get_movement_speed_for_quality(FishQuality.Tier.BORING),
|
||||
entry.movement_speed,
|
||||
)
|
||||
)
|
||||
assert(
|
||||
is_equal_approx(
|
||||
entry.get_movement_speed_for_quality(FishQuality.Tier.SHINY),
|
||||
entry.movement_speed * 2.0,
|
||||
)
|
||||
)
|
||||
assert(
|
||||
is_equal_approx(
|
||||
entry.get_scare_radius_for_quality(FishQuality.Tier.SHINY),
|
||||
entry.scare_radius * 1.7,
|
||||
)
|
||||
)
|
||||
var service := NetworkWorldSpawnService.new()
|
||||
var spawned_catch := service.call(
|
||||
"_create_catch_for_state",
|
||||
entry,
|
||||
{"quality": FishQuality.Tier.EXCEPTIONAL},
|
||||
) as FishCatch
|
||||
assert(spawned_catch != null and spawned_catch.is_valid())
|
||||
assert(spawned_catch.quality == FishQuality.Tier.EXCEPTIONAL)
|
||||
assert(
|
||||
spawned_catch.sale_value
|
||||
== FishQuality.apply_sale_value(
|
||||
entry.catch_data.get_sale_value_for_weight(
|
||||
spawned_catch.weight_lb
|
||||
),
|
||||
FishQuality.Tier.EXCEPTIONAL,
|
||||
)
|
||||
)
|
||||
spawned_catch = null
|
||||
service.free()
|
||||
|
||||
|
||||
func _validate_envelopes() -> void:
|
||||
var entity: Dictionary = {
|
||||
"entity_id": "world:sample",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue