refresh d7e71a93da39c621828977f6616ccc46c4b52116
[tagua/yd.git] / src / core / delegators / behaviour.h
blob7d43ecc75aade3b095aa4caf428664027a2d7e44
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 */
10 #ifndef DELEGATORS__BEHAVIOUR_H
11 #define DELEGATORS__BEHAVIOUR_H
13 #include "../behaviour.h"
15 #include <KDebug>
17 namespace Delegators {
19 class Behaviour : virtual public IBehaviour {
20 protected:
21 IBehaviour* m_dgate_behaviour;
22 public:
23 Behaviour(IBehaviour* delegate): m_dgate_behaviour(delegate) {
24 Q_ASSERT(delegate);
25 m_dgate_behaviour->setDelegator(this);
26 kDebug() << this << "m_dgate_behaviour=" << m_dgate_behaviour;
28 virtual ~Behaviour() { delete m_dgate_behaviour; }
30 virtual void captureOn(IState* state, const Point& square) const {
31 m_dgate_behaviour->captureOn(state, square);
33 virtual void move(IState* state, const Move& m) const {
34 m_dgate_behaviour->move(state, m);
36 virtual void advanceTurn(IState* state) const { m_dgate_behaviour->advanceTurn(state); }
37 virtual Point captureSquare(const IState* state, const Move& m) const {
38 return m_dgate_behaviour->captureSquare(state, m);
40 virtual const IColor* opponent(const IColor* player) const {
41 return m_dgate_behaviour->opponent(player);
43 virtual Point direction(const IColor* player) const {
44 return m_dgate_behaviour->direction(player);
46 virtual void setDelegator(IBehaviour* behaviour) {
47 m_dgate_behaviour->setDelegator(behaviour);
48 kDebug() << this << "m_dgate_behaviour=" << m_dgate_behaviour;
54 #endif // DELEGATORS__BEHAVIOUR_H