From a5455be5c3c075c36c1acc7f8b32624606e7cb93 Mon Sep 17 00:00:00 2001
From: Paolo Capriotti
Date: Sat, 28 Jul 2007 19:42:23 +0200
Subject: [PATCH] Replaced Always and Never turn policies with a Simple policy.
---
src/turnpolicy.cpp | 18 +++++++-----------
src/turnpolicy.h | 21 ---------------------
2 files changed, 7 insertions(+), 32 deletions(-)
diff --git a/src/turnpolicy.cpp b/src/turnpolicy.cpp
index 618a5f0..4c7a57e 100644
--- a/src/turnpolicy.cpp
+++ b/src/turnpolicy.cpp
@@ -14,13 +14,12 @@ namespace TurnPolicy {
Abstract::~Abstract() { }
- boost::shared_ptr always() {
- return boost::shared_ptr(new Always);
- }
-
- boost::shared_ptr never() {
- return boost::shared_ptr(new Never);
- }
+ class Simple : public Abstract {
+ bool m_value;
+ public:
+ Simple(bool value) : m_value(value) { }
+ bool check() const { return m_value; }
+ };
Premove::~Premove() { }
@@ -39,10 +38,7 @@ namespace TurnPolicy {
}
void Collection::setSimplePolicy(int turn, bool value) {
- if (value)
- setPolicy(turn, always());
- else
- setPolicy(turn, never());
+ setPolicy(turn, boost::shared_ptr(new Simple(value)));
}
void Collection::clear() {
diff --git a/src/turnpolicy.h b/src/turnpolicy.h
index 05a8ea3..bf24573 100644
--- a/src/turnpolicy.h
+++ b/src/turnpolicy.h
@@ -27,27 +27,6 @@ namespace TurnPolicy {
};
/**
- * The user can always move in this turn.
- */
- class Always : public Abstract {
- public:
- virtual bool check() const { return true; }
- };
-
- boost::shared_ptr always();
-
- /**
- * The user cannot move in this turn. A null pointer in turn test
- * has the same effect of this class.
- */
- class Never : public Abstract {
- public:
- virtual bool check() const { return false; }
- };
-
- boost::shared_ptr never();
-
- /**
* Premove policy. Used to check whether premoving is allowed.
* It is a global policy.
*/
--
2.11.4.GIT