Misc cleanups.
[tagua/yd.git] / src / core / turnpolicy.h
blob893efb5d59c9a476268c3d3b7fbcb2676ceaac46
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 #ifndef TURNPOLICY_H
12 #define TURNPOLICY_H
14 #include <map>
15 #include <boost/shared_ptr.hpp>
16 #include "export.h"
18 class IColor;
20 /**
21 * @brief XXX
23 namespace TurnPolicy {
25 /**
26 * An abstract class encapsulating the user ability
27 * to move in a given turn.
29 class TAGUA_EXPORT Abstract {
30 public:
31 virtual ~Abstract();
32 virtual bool check() const = 0;
35 /**
36 * Premove policy. Used to check whether premoving is allowed.
37 * It is a <i>global</i> policy.
39 class TAGUA_EXPORT Premove {
40 public:
41 virtual ~Premove();
42 virtual bool check() const = 0;
45 class TAGUA_EXPORT Collection {
46 typedef boost::shared_ptr<Abstract> PolicyPtr;
47 typedef std::map<const IColor*, PolicyPtr> Policies;
48 typedef boost::shared_ptr<Premove> PremovePolicyPtr;
49 Policies m_policies;
51 PremovePolicyPtr m_premove;
52 public:
53 bool operator()(const IColor* turn) const;
54 void setPolicy(const IColor* turn, const PolicyPtr& policy);
55 void setSimplePolicy(const IColor* turn, bool value);
56 void clear();
58 void setPremovePolicy(const PremovePolicyPtr& policy);
59 bool premove() const;
63 typedef TurnPolicy::Collection TurnTest;
65 #endif // TURNPOLICY_H