/usr/include/osl/effect_action/betterToPromote.h is in libosl-dev 0.6.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #ifndef OSL_BETTER_TO_PROMOTE_MOVE_ACTION_H
#define OSL_BETTER_TO_PROMOTE_MOVE_ACTION_H
#include "osl/move_action/concept.h"
namespace osl
{
namespace effect_action
{
/**
* 成った方が良い駒は成る手のみ生成
*/
template<class Action>
class BetterToPromote
{
BOOST_CLASS_REQUIRE(Action,osl::move_action,Concept);
private:
const NumEffectState& state;
Action & ac;
public:
BetterToPromote(const NumEffectState& s, Action& a)
: state(s), ac(a)
{
}
template<Player P,Ptype Type>
void doActionPtype(Piece p1,Square to){
assert(Type == unpromote(p1.ptype()));
Square from=p1.square();
Piece target = state.pieceAt(to);
if (canPromote(Type) &&
!p1.isPromotedNotKingGold() &&
(to.canPromote<P>() || from.canPromote<P>())){
ac.unknownMove(from,to,target,promote(Type),true,P);
}
if (!canPromote(Type) ||
PtypePlayerTraits<Type,P>::canDropTo(to) ||
p1.isPromotedNotKingGold()){
if (! (to.canPromote<P>() || from.canPromote<P>())
|| (! PtypeTraits<Type>::betterToPromote
&& (p1.ptype() != LANCE
|| PtypePlayerTraits<LANCE,P>::canDropTo(to + DirectionPlayerTraits<U,P>::offset()))))
ac.unknownMove(from,to,target,p1.ptype(),false,P);
}
}
/**
* Ptypeをtemplate引数にできない場合
*/
template<Player P>
void doAction(Piece p1,Square to)
{
Square from=p1.square();
Ptype ptype=p1.ptype();
Piece target = state.pieceAt(to);
if(canPromote(ptype))
{
if (to.canPromote<P>())
{
ac.unknownMove(from,to,target,promote(ptype),true,P);
if(Ptype_Table.canDropTo(P, ptype,to)
&& ! Ptype_Table.isBetterToPromote(ptype)
&& (ptype != LANCE
|| PtypePlayerTraits<LANCE,P>::canDropTo(to + DirectionPlayerTraits<U,P>::offset())))
{
ac.unknownMove(from,to,target,ptype,false,P);
}
return;
}
if (from.canPromote<P>())
{
ac.unknownMove(from,to,target,promote(ptype),true,P);
if(! Ptype_Table.isBetterToPromote(ptype)
&& (ptype != LANCE
|| PtypePlayerTraits<LANCE,P>::canDropTo(to + DirectionPlayerTraits<U,P>::offset())))
ac.unknownMove(from,to,target,ptype,false,P);
return;
}
// fall through
}
ac.unknownMove(from,to,target,ptype,false,P);
}
};
} // namespace effect_action
} // namespace osl
#endif // OSL_BETTER_TO_PROMOTE_MOVE_ACTION_H
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|