mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-21 20:00:22 +00:00
40 lines
1.5 KiB
INI
40 lines
1.5 KiB
INI
# wmllint: no translatables
|
|
|
|
#####
|
|
# API(s) being tested: wesnoth.simulate_combat
|
|
##
|
|
# Actions:
|
|
# Start with Alice and Bob on separate keeps (the GENERIC_UNIT_TEST macro).
|
|
# Make a private-to-Lua clone of Alice, move her next to Bob.
|
|
# Simulate combat.
|
|
##
|
|
# Expected end state:
|
|
# The simulation with the original Alice shows that neither can reach the other.
|
|
# The simulation with the cloned Alice shows combat stats.
|
|
#####
|
|
{GENERIC_UNIT_TEST simulate_combat_clone_adjacent (
|
|
[event]
|
|
name=start
|
|
|
|
[lua]
|
|
code=<<
|
|
local alice = wesnoth.units.find({id="alice"})[1]
|
|
local bob = wesnoth.units.find({id="bob"})[1]
|
|
local clone_alice = alice:clone()
|
|
clone_alice.x = bob.x
|
|
clone_alice.y = bob.y + 1
|
|
|
|
local att_stats, def_stats = wesnoth.simulate_combat(clone_alice, bob)
|
|
unit_test.assert_approx_equal(att_stats.untouched, 1.0, 0.01, "Alice should have used her ranged attack")
|
|
unit_test.assert_approx_equal(def_stats.untouched, 0.6 ^ 4, 0.01, "Bob should be on 60% def")
|
|
|
|
att_stats, def_stats = wesnoth.simulate_combat(alice, bob)
|
|
unit_test.assert_approx_equal(att_stats.untouched, 1.0, 0.01, "Alice should be out of reach of combat")
|
|
unit_test.assert_approx_equal(def_stats.untouched, 1.0, 0.01, "Bob should be out of reach of combat")
|
|
>>
|
|
[/lua]
|
|
|
|
{SUCCEED}
|
|
[/event]
|
|
)}
|