feat(items): add OutfitItem, tap-to-undress, and outfit refs on Character
- Add OutfitItem (extends HoldableItem): applies outfit on drop within 80px of character body, falls back to hand slot attach if no character in range - Add apply_outfit_item / remove_outfit / _handle_outfit_tap to Character - Track item node refs in _outfit_item_refs for restoring visibility - Fix animation state: reset to idle before tap handling in _on_drag_released - Extract _ITEM_DROP_OFFSET constant (replaces magic Vector2(0,60)) - Add 5 tests in test_outfit_item.gd, 14 new tests in test_character_v2.gd
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
## Tests for OutfitItem — applies outfit layer when dropped near a character.
|
||||
extends GutTest
|
||||
|
||||
|
||||
func test_outfit_item_default_layer_is_one() -> void:
|
||||
var item: OutfitItem = OutfitItem.new()
|
||||
add_child_autofree(item)
|
||||
assert_eq(item.outfit_layer, 1)
|
||||
|
||||
|
||||
func test_outfit_item_applies_to_character_on_release_in_range() -> void:
|
||||
var character: Character = preload("res://scenes/characters/Character.tscn").instantiate() as Character
|
||||
add_child_autofree(character)
|
||||
var data: CharacterData = CharacterData.new()
|
||||
character.data = data
|
||||
var item: OutfitItem = OutfitItem.new()
|
||||
add_child_autofree(item)
|
||||
item.item_id = "white_coat"
|
||||
item.outfit_layer = 1
|
||||
item.outfit_sprite = null
|
||||
item.global_position = character.global_position
|
||||
item._on_drag_released(item.global_position)
|
||||
assert_eq(character.get_outfit(1), "white_coat")
|
||||
|
||||
|
||||
func test_outfit_item_hides_after_applying() -> void:
|
||||
var character: Character = preload("res://scenes/characters/Character.tscn").instantiate() as Character
|
||||
add_child_autofree(character)
|
||||
var data: CharacterData = CharacterData.new()
|
||||
character.data = data
|
||||
var item: OutfitItem = OutfitItem.new()
|
||||
add_child_autofree(item)
|
||||
item.item_id = "white_coat"
|
||||
item.outfit_layer = 1
|
||||
item.global_position = character.global_position
|
||||
item._on_drag_released(item.global_position)
|
||||
assert_false(item.visible)
|
||||
|
||||
|
||||
func test_outfit_item_stays_visible_if_no_character_in_range() -> void:
|
||||
var item: OutfitItem = OutfitItem.new()
|
||||
add_child_autofree(item)
|
||||
item.item_id = "white_coat"
|
||||
item.outfit_layer = 1
|
||||
item.global_position = Vector2(9999.0, 9999.0)
|
||||
item._on_drag_released(item.global_position)
|
||||
assert_true(item.visible)
|
||||
assert_false(item.is_in_hand_slot())
|
||||
|
||||
|
||||
func test_outfit_item_does_not_apply_if_far_from_character() -> void:
|
||||
var character: Character = preload("res://scenes/characters/Character.tscn").instantiate() as Character
|
||||
add_child_autofree(character)
|
||||
var data: CharacterData = CharacterData.new()
|
||||
character.data = data
|
||||
var item: OutfitItem = OutfitItem.new()
|
||||
add_child_autofree(item)
|
||||
item.item_id = "white_coat"
|
||||
item.outfit_layer = 1
|
||||
item.global_position = Vector2(9999.0, 9999.0)
|
||||
item._on_drag_released(item.global_position)
|
||||
assert_eq(character.get_outfit(1), "")
|
||||
assert_true(item.visible)
|
||||
Reference in New Issue
Block a user