aboutsummaryrefslogtreecommitdiff
path: root/backend/TeleportConsumableObject.cpp
blob: 7d1803fe693bd37f62bfd47b6c9e16fca3f8d514 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "RNG.h"
#include "TeleportConsumableObject.h"
#include "Player.h"
#include "Location.h"

void TeleportConsumableObject::consume(Player & player) {
	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);
}