Tentative Randomless-Entropy variant.
[tagua/yd.git] / src / variants / randomless-entropy / entropy.cpp
blob8748b5ac71f5c1c7d77bd48c10cae8e4bf705041
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 "behaviour.h"
16 #include "colors.h"
17 //#include "moveserializer.h"
18 #include "state.h"
19 #include "stone.h"
20 //#include "validator.h"
22 #include <KDebug>
24 using namespace RandomlessEntropy;
26 namespace RandomlessEntropy {
27 const unsigned gamesize = 3;
30 extern "C" KDE_EXPORT Repository* taguarandomlessentropy_initrepo(IVariantLoader* loader) {
31 Repository* repo = new Repository;
32 Repository* chess = loader->getRepository("chess");
33 if (!chess) {
34 kError() << "Could not load chess variant";
35 return 0;
38 repo->addComponent("player/0", dynamic_cast<Component*>(COLORS[0]));
39 repo->addComponent("player/1", dynamic_cast<Component*>(COLORS[1]));
41 // FIXME
42 repo->addComponent("type/stone0", Stone::color(0));
43 repo->addComponent("type/stone1", Stone::color(1));
44 repo->addComponent("type/stone2", Stone::color(2));
46 IState* chess_state = requestInterface<IState>(chess->getComponent("state"));
47 const IBehaviour* behaviour = chess_state->behaviour();
48 repo->addComponent("state", new State(behaviour, Point(gamesize, gamesize)));
50 repo->addComponent("validator", chess->getComponent("validator")); // FIXME
51 repo->addComponent("animator_factory", chess->getComponent("animator_factory"));
52 repo->addComponent("namer", chess->getComponent("namer"));
53 repo->addComponent("policy", new DefaultPolicy); // FIXME ?
55 #if 1 // FIXME
56 // set move serializers
57 Repository::ComponentMap serializers = chess->listComponents("move_serializer");
58 for (Repository::ComponentMap::const_iterator it = serializers.begin(),
59 end = serializers.end(); it != end; ++it) {
60 repo->addComponent("move_serializer/" + it.key(), it.value());
62 #else
63 repo->addComponent("move_serializer/simple",
64 new MoveSerializer("simple", validator));
65 #endif
67 return repo;