aboutsummaryrefslogtreecommitdiff
path: root/examples/basic/src/bootstrap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/basic/src/bootstrap.cpp')
-rw-r--r--examples/basic/src/bootstrap.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/examples/basic/src/bootstrap.cpp b/examples/basic/src/bootstrap.cpp
index 38edcc3..7a78aec 100644
--- a/examples/basic/src/bootstrap.cpp
+++ b/examples/basic/src/bootstrap.cpp
@@ -2,11 +2,13 @@
// Interfaces
#include "interfaces/enemy.hpp"
+#include "interfaces/enemy_creator.hpp"
#include "interfaces/hero.hpp"
#include "interfaces/weapon.hpp"
// Concretes
#include "enemy.hpp"
+#include "enemy_creator.hpp"
#include "hero.hpp"
#include "sword.hpp"
@@ -16,13 +18,25 @@ yacppdic::Container bootstrap()
container.bind<IHero>().to<Hero>();
container.bind<IWeapon>().to<Sword>();
+ container.bind<IEnemyCreator>().to<EnemyCreator>();
- container.bind<IEnemyFactory>().to_factory(
- []()
- {
- return std::make_unique<Enemy>();
- }
- );
+ container.bind<IEnemyFactory>()
+ .to_factory(
+ []()
+ {
+ return std::make_unique<Enemy>(65);
+ }
+ )
+ .when_tagged(SMALL_ENEMY_TAG);
+
+ container.bind<IEnemyFactory>()
+ .to_factory(
+ []()
+ {
+ return std::make_unique<Enemy>(130);
+ }
+ )
+ .when_tagged(BIG_ENEMY_TAG);
return container;
}