Make component interfaces inherit Component.
[tagua/yd.git] / src / variants / chess / chess.cpp
blobba15e82131c97ad590ea0068c8dc5ffbeddb5595
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 <core/defaultpolicy.h>
12 #include <core/repository.h>
13 #include <core/variantloader.h>
15 #include "animator.h"
16 #include "behaviour.h"
17 #include "castlingrules.h"
18 #include "colors.h"
19 #include "moveserializer.h"
20 #include "namer.h"
21 #include "types.h"
22 #include "state.h"
23 #include "validator.h"
25 using namespace Chess;
27 extern "C" KDE_EXPORT Repository* taguachess_initrepo(IVariantLoader*) {
28 Repository* repo = new Repository;
30 repo->addComponent("player/0", dynamic_cast<Component*>(COLORS[0]));
31 repo->addComponent("player/1", dynamic_cast<Component*>(COLORS[1]));
33 repo->addComponent("type/king", King::self());
34 repo->addComponent("type/queen", Queen::self());
35 repo->addComponent("type/rook", Rook::self());
36 repo->addComponent("type/bishop", Bishop::self());
37 repo->addComponent("type/knight", Knight::self());
38 repo->addComponent("type/pawn", Pawn::self());
40 CastlingRules* castling_rules = new CastlingRules;
41 repo->addComponent("extra/castling_rules", castling_rules);
43 Behaviour* behaviour = new Behaviour;
44 repo->addComponent("behaviour", behaviour);
46 repo->addComponent("state", new State(behaviour, castling_rules, Point(8, 8)));
47 Validator* validator = new Validator;
48 repo->addComponent("validator", validator);
49 repo->addComponent("animator_factory", new AnimatorFactory);
50 repo->addComponent("namer", new Namer);
51 repo->addComponent("policy", new DefaultPolicy);
53 repo->addComponent("move_serializer/simple",
54 new MoveSerializer("simple", validator));
55 repo->addComponent("move_serializer/decorated",
56 new MoveSerializer("decorated", validator));
57 MoveSerializer* san = new MoveSerializer("compact", validator);
58 repo->addComponent("move_serializer/san", san);
59 repo->addComponent("move_serializer/compact", san);
60 King::self()->setCastlingRules(castling_rules);
62 return repo;