feature updates
This commit is contained in:
@@ -528,3 +528,100 @@ func test_block_with_dull_card_fails():
|
||||
var result = game_state.declare_block(blocker)
|
||||
|
||||
assert_false(result)
|
||||
|
||||
|
||||
## ============================================
|
||||
## ONLINE GAME STATE SYNCHRONIZATION TESTS
|
||||
## These test that game state can be updated from
|
||||
## network phase change messages
|
||||
## ============================================
|
||||
|
||||
|
||||
func test_turn_manager_player_index_can_be_set():
|
||||
# Simulates receiving network phase_changed message
|
||||
game_state.start_game(0)
|
||||
|
||||
# Manually set player index like network handler would
|
||||
game_state.turn_manager.current_player_index = 1
|
||||
|
||||
assert_eq(game_state.turn_manager.current_player_index, 1)
|
||||
|
||||
|
||||
func test_turn_manager_phase_can_be_set():
|
||||
# Simulates receiving network phase_changed message
|
||||
game_state.start_game(0)
|
||||
|
||||
# Manually set phase like network handler would
|
||||
game_state.turn_manager.current_phase = Enums.TurnPhase.ATTACK
|
||||
|
||||
assert_eq(game_state.turn_manager.current_phase, Enums.TurnPhase.ATTACK)
|
||||
|
||||
|
||||
func test_turn_manager_turn_number_can_be_set():
|
||||
# Simulates receiving network game_state_sync message
|
||||
game_state.start_game(0)
|
||||
|
||||
# Manually set turn number like network handler would
|
||||
game_state.turn_manager.turn_number = 5
|
||||
|
||||
assert_eq(game_state.turn_manager.turn_number, 5)
|
||||
|
||||
|
||||
func test_turn_manager_initial_values():
|
||||
# Verify initial turn manager state
|
||||
game_state.start_game(0)
|
||||
|
||||
assert_eq(game_state.turn_manager.current_player_index, 0)
|
||||
assert_eq(game_state.turn_manager.turn_number, 1)
|
||||
|
||||
|
||||
func test_turn_manager_attack_step_can_be_set():
|
||||
# For online games, attack step is managed by server
|
||||
game_state.start_game(0)
|
||||
game_state.end_main_phase() # Get to ATTACK phase
|
||||
|
||||
# Manually set attack step like network handler would
|
||||
game_state.turn_manager.attack_step = Enums.AttackStep.BLOCK_DECLARATION
|
||||
|
||||
assert_eq(game_state.turn_manager.attack_step, Enums.AttackStep.BLOCK_DECLARATION)
|
||||
|
||||
|
||||
func test_phase_changed_updates_current_player():
|
||||
# Test that changing phase properly reflects in get_current_player()
|
||||
game_state.start_game(0)
|
||||
|
||||
# Simulate switching turns from network
|
||||
game_state.turn_manager.current_player_index = 1
|
||||
|
||||
var current = game_state.get_current_player()
|
||||
assert_eq(current, game_state.players[1])
|
||||
|
||||
|
||||
func test_phase_changed_updates_opponent():
|
||||
# Test that changing phase properly reflects in get_opponent()
|
||||
game_state.start_game(0)
|
||||
|
||||
# Simulate switching turns from network
|
||||
game_state.turn_manager.current_player_index = 1
|
||||
|
||||
var opponent = game_state.get_opponent()
|
||||
assert_eq(opponent, game_state.players[0])
|
||||
|
||||
|
||||
func test_turn_manager_all_phases_valid():
|
||||
# Verify all TurnPhase enum values can be set
|
||||
game_state.start_game(0)
|
||||
|
||||
for phase in Enums.TurnPhase.values():
|
||||
game_state.turn_manager.current_phase = phase
|
||||
assert_eq(game_state.turn_manager.current_phase, phase)
|
||||
|
||||
|
||||
func test_turn_manager_all_attack_steps_valid():
|
||||
# Verify all AttackStep enum values can be set
|
||||
game_state.start_game(0)
|
||||
game_state.end_main_phase() # Get to ATTACK phase
|
||||
|
||||
for step in Enums.AttackStep.values():
|
||||
game_state.turn_manager.attack_step = step
|
||||
assert_eq(game_state.turn_manager.attack_step, step)
|
||||
|
||||
Reference in New Issue
Block a user