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

using namespace std;

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

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

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

	type_map[type] = strategy;
}