new 33c0e9569b8825f53d773343cc90e4377118edca
[tagua/yd.git] / src / core / delegators / defaultstate.h
blob35e93a9f5d218b11d260c58106965f0b35e65070
1 #ifndef DELEGATORS__DEFAULT_STATE_H
2 #define DELEGATORS__DEFAULT_STATE_H
4 #include "state.h"
5 #include "../defaultstate.h"
7 #include <KDebug>
9 #include <typeinfo>
11 namespace Delegators {
13 class DefaultState : public State, public ::DefaultState {
14 protected:
15 ::DefaultState* m_state;
16 public:
17 DefaultState(IState* state)
18 : State(state) {
19 ::DefaultState* dstate = dynamic_cast< ::DefaultState*>(state);
20 if (dstate == NULL) {
21 kError() << "Delegators::DefaultState needs a ::DefaultState, cannot use a"
22 << typeid(state).name();
23 abort();
26 m_state = dstate;
27 m_state->setDelegator(this);
29 virtual ~DefaultState() { delete m_state; }
31 virtual std::vector<const Point*> theoreticalMoves(const Piece& piece,
32 const Point& src) const
33 { return m_state->theoreticalMoves(piece, src); }
36 } // namespace Delegators
38 #endif // DELEGATORS__DEFAULT_STATE_H