refresh bdc45694d411cad215e68161e75bb9f1a8a39e47
[tagua/yd.git] / src / variants / shogi / shogi.cpp
blob457e500319934dc08b7ddfda2d75f9d47ca4641d
1 #include <core/repository.h>
2 #include <core/variantloader.h>
4 #include "behaviour.h"
5 #include "colors.h"
6 #include "moveserializer.h"
7 #include "types.h"
8 #include "state.h"
9 #include "validator.h"
11 using namespace Shogi;
13 extern "C" KDE_EXPORT Repository*
14 taguashogi_initrepo(IVariantLoader* loader) {
15 Repository* repo = new Repository;
16 Repository* chess = loader->getRepository("chess");
17 if (!chess)
18 // bail out if there is no chess variant
19 return 0;
20 #if 0
21 Repository* crazyhouse = loader->getRepository("crazyhouse");
22 if (!crazyhouse)
23 // bail out if there is no crazyhouse variant
24 return 0;
25 #endif
27 repo->addComponent("player/0", dynamic_cast<Component*>(COLORS[0]));
28 repo->addComponent("player/1", dynamic_cast<Component*>(COLORS[1]));
30 #if 0
31 repo->addComponent("type/king", Types::King::self());
32 repo->addComponent("type/gold", Types::Gold::self());
33 repo->addComponent("type/silver", Types::Silver::self());
34 repo->addComponent("type/knight", Types::Knight::self());
35 repo->addComponent("type/lance", Types::Lance::self());
36 repo->addComponent("type/rook", Types::Rook::self());
37 repo->addComponent("type/bishop", Types::Bishop::self());
38 #else
39 #warning missing piece types
40 #endif
41 repo->addComponent("type/pawn", Types::Pawn::self());
43 #if 0
44 // create crazyhouse behaviour
45 IState* crazyhouse_state = requestInterface<IState>(crazyhouse->getComponent("state"));
46 repo->addComponent("state", new State(crazyhouse_state->behaviour(), Point(9, 9)));
47 #else
48 IState* chess_state = requestInterface<IState>(chess->getComponent("state"));
49 repo->addComponent("state", new State(new Behaviour(chess_state->behaviour()), Point(9, 9)));
50 #endif
52 Validator* validator = new Validator;
53 repo->addComponent("validator", validator);
54 repo->addComponent("animator_factory", chess->getComponent("animator_factory"));
55 repo->addComponent("namer", chess->getComponent("namer"));
56 repo->addComponent("policy", chess->getComponent("policy"));
58 repo->addComponent("move_serializer/simple",
59 new MoveSerializer("simple", validator));
60 repo->addComponent("move_serializer/decorated",
61 new MoveSerializer("decorated", validator));
62 MoveSerializer* san = new MoveSerializer("compact", validator);
63 repo->addComponent("move_serializer/san", san);
64 repo->addComponent("move_serializer/compact", san);
66 return repo;