aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-02 13:18:50 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-02 13:18:50 +0100
commit5a675c5e6833e98b92b55396594bc0d607b98903 (patch)
treeb252fafe921e7734a13d796b950e5ab817a22a1f /backend
parent671a25463419691bc6c8d11bd57d932bdea9632b (diff)
clean up code + implement teleport consumable
Diffstat (limited to 'backend')
-rw-r--r--backend/TeleportConsumableObject.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/backend/TeleportConsumableObject.cpp b/backend/TeleportConsumableObject.cpp
index 5fd4459..7d1803f 100644
--- a/backend/TeleportConsumableObject.cpp
+++ b/backend/TeleportConsumableObject.cpp
@@ -1,6 +1,14 @@
+#include "RNG.h"
#include "TeleportConsumableObject.h"
+#include "Player.h"
+#include "Location.h"
void TeleportConsumableObject::consume(Player & player) {
- // TODO
+ unsigned hops = RNG::get().rand_int(this->get_potency());
+ Location * location = &player.get_location();
+ for (size_t i = 0; i < hops; i++) {
+ location = location->get_exit(random_direction(*location));
+ }
+ player.set_location(*location);
}