SHARE
TWEET

Test case: spell kills give XP

Archon May 25th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TEST_CASE("Kills with spells give XP") {
  2.   GIVEN("a high-damage spell and low-health NPC") {
  3.     auto data = R"(
  4.      <spell id="nuke" range=30 >
  5.        <targets enemy=1 />
  6.        <function name="doDirectDamage" i1=99999 />
  7.      </spell>
  8.      <npcType id="critter" maxHealth=1 />
  9.    )";
  10.     auto s = TestServer::WithDataString(data);
  11.     s.addNPC("critter", {10, 15});
  12.  
  13.     WHEN("a user knows the spell") {
  14.       auto c = TestClient::WithDataString(data);
  15.       s.waitForUsers(1);
  16.       auto &user = s.getFirstUser();
  17.       user.getClass().teachSpell("nuke");
  18.  
  19.       AND_WHEN("he kills the NPC with the spell") {
  20.         const auto &critter = s.getFirstNPC();
  21.         c.sendMessage(CL_SELECT_ENTITY, makeArgs(critter.serial()));
  22.         c.sendMessage(CL_CAST, "nuke");
  23.         WAIT_UNTIL(critter.isDead());
  24.  
  25.         THEN("the user has some XP") { CHECK(user.xp() > 0); }
  26.       }
  27.     }
  28.   }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top