aboutsummaryrefslogtreecommitdiff
path: root/TileBehavior.cpp
blob: 6cabd4024fd19a369e0bf5d518d732324035ade4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "TileBehavior.h"
#include "Exception.h"

using namespace std;

TileBehaviorStrategy & TileBehavior::get_strategy(string type) {
	auto & type_map = TileBehavior::get_collection();

	if (type_map.contains(type))
		return *type_map.at(type);
	
	throw Exception("unknown behavior for tile type \"%s\"", type.c_str());
}

void TileBehavior::register_strategy(string type, TileBehaviorStrategy * strategy) {
	auto & type_map = TileBehavior::get_collection();

	type_map[type] = strategy;
}