simpleMove.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
simpleMove.h
Go to the documentation of this file.
1 #ifndef _SIMPLE_ALWAYS_MOVE_ACTION_H
2 #define _SIMPLE_ALWAYS_MOVE_ACTION_H
3 #include "osl/piece.h"
4 #include "osl/square.h"
5 #include "osl/move_action/concept.h"
6
7 namespace osl
8 {
9 namespace effect_action
10 {
14 template <class Action>
15 class SimpleMove
16 {
17 BOOST_CLASS_REQUIRE(Action,osl::move_action,Concept);
18 private:
19 Action & ac;
20 public:
21 SimpleMove(Action & a) :ac(a){}
22 template<Player P,Ptype Type>
23 void doActionPtype(Piece p1,Square to){
24 Square from=p1.square();
25 if(canPromote(Type) &&
26 !p1.isPromotedNotKingGold() &&
27 (to.canPromote<P>() || from.canPromote<P>())){
28 ac.simpleMove(from,to,promote(Type),true,P);
29 }
30 if(!canPromote(Type) ||
31 PtypePlayerTraits<Type,P>::canDropTo(to) ||
32 p1.isPromotedNotKingGold()){
33 ac.simpleMove(from,to,p1.ptype(),false,P);
34 }
35 }
36 template<Player P>
37 void doAction(Piece p1,Square to){
38 Square from=p1.square();
39 Ptype ptype=p1.ptype();
40 if(canPromote(ptype)){
41 if (to.canPromote<P>()){
42 ac.simpleMove(from,to,promote(ptype),true,P);
43 if(Ptype_Table.canDropTo(P, ptype,to)){
44 ac.simpleMove(from,to,ptype,false,P);
45 }
46 }
47 else if (from.canPromote<P>()){
48 ac.simpleMove(from,to,promote(ptype),true,P);
49 ac.simpleMove(from,to,ptype,false,P);
50 }
51 else{
52 ac.simpleMove(from,to,ptype,false,P);
53 }
54 }
55 else{
56 ac.simpleMove(from,to,ptype,false,P);
57 }
58 }
59 bool done() const{ return false;}
60 };
61 } // namespace effect_action
62 } // namespace osl
63 #endif
64 // ;;; Local Variables:
65 // ;;; mode:c++
66 // ;;; c-basic-offset:2
67 // ;;; End: