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.
11 #include <core/defaultpolicy.h>
12 #include <core/repository.h>
13 #include <core/variantloader.h>
15 //#include "behaviour.h"
17 //#include "moveserializer.h"
20 //#include "validator.h"
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");
34 kError() << "Could not load chess variant";
38 repo
->addComponent("player/0", dynamic_cast<Component
*>(COLORS
[0]));
39 repo
->addComponent("player/1", dynamic_cast<Component
*>(COLORS
[1]));
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 ?
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());
63 repo
->addComponent("move_serializer/simple",
64 new MoveSerializer("simple", validator
));