mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-08 17:13:57 -07:00
refactor: extract shared card insertion algorithm from hand/stack zones
Hand and stack zones had near-identical addCardImpl() implementations, differing only in whether resetState() preserves annotations. Extract the shared pattern into a template function (CardZoneAlgorithms::addCardToList) to eliminate duplication and enable isolated testing without Qt dependencies. Pile, table, and zone-view logic are intentionally excluded — thier post-add behavior (signals, coordinate placement, hidden cards) is materially different.
This commit is contained in:
parent
8180d2e3b0
commit
b49083f8d3
6 changed files with 272 additions and 26 deletions
16
tests/add_card_algorithm/CMakeLists.txt
Normal file
16
tests/add_card_algorithm/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
add_executable(add_card_algorithm_test add_card_algorithm_test.cpp)
|
||||
|
||||
target_include_directories(add_card_algorithm_test
|
||||
PRIVATE ${CMAKE_SOURCE_DIR}/cockatrice/src/game/zones/logic
|
||||
)
|
||||
|
||||
target_link_libraries(add_card_algorithm_test
|
||||
PRIVATE Threads::Threads
|
||||
PRIVATE ${GTEST_BOTH_LIBRARIES}
|
||||
)
|
||||
|
||||
add_test(NAME add_card_algorithm_test COMMAND add_card_algorithm_test)
|
||||
|
||||
if(NOT GTEST_FOUND)
|
||||
add_dependencies(add_card_algorithm_test gtest)
|
||||
endif()
|
||||
Loading…
Add table
Add a link
Reference in a new issue