new 4475edb243ed4627f4c5f2c470ca40b3def034d4
[tagua/yd.git] / src / variants / chess5x5 / chess5x5.cpp
blobd93523e057f6fe87b3eea26ad9fe9d295242cc70
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include <KDebug>
13 #include <core/point.h>
14 #include <core/repository.h>
15 #include <core/variantloader.h>
16 #include <core/state.h>
18 class IBehaviour;
20 extern "C" KDE_EXPORT Repository*
21 taguachess5x5_initrepo(IVariantLoader* loader) {
22 Repository* repo = new Repository;
23 Repository* chess = loader->getRepository("chess");
24 if (!chess)
25 // bail out if there is no chess variant
26 return 0;
28 repo->setProxy(chess);
30 // set state factory
31 Component* chess_state_comp = chess->getComponent("state");
32 IState* chess_state = requestInterface<IState>(chess_state_comp);
33 Q_ASSERT(chess_state);
35 const IBehaviour* behaviour = chess_state->behaviour();
37 Component* state = 0;
38 bool ok = QMetaObject::invokeMethod(chess_state_comp, "clone",
39 Q_RETURN_ARG(Component*, state),
40 Q_ARG(const IBehaviour*, behaviour),
41 Q_ARG(Component*, 0),
42 Q_ARG(Point, Point(5, 5)));
43 Q_ASSERT(ok);
44 Q_ASSERT(state);
46 repo->addComponent("state", state);
48 return repo;