My Project
sendOffSquare.h
Go to the documentation of this file.
1/* sendOffSquare.h
2 */
3#ifndef OSL_SENDOFFPOSITION_H
4#define OSL_SENDOFFPOSITION_H
5
8namespace osl
9{
10 namespace effect_util
11 {
12 struct Offset8 : public FixedCapacityVector<int,8>
13 {
14 };
17 {
18 typedef uint8_t SendOff8;
19 template <Player Attack>
20 static bool onlyOneSupport(const NumEffectState& state, Square target)
21 {
22 const Piece p = state.pieceAt(target);
23 if (! p.isOnBoardByOwner<alt(Attack)>())
24 return false;
25 return state.hasEffectAt<Attack>(target)
26 && (state.countEffect(alt(Attack), target) == 1);
27 }
28 template <Player Attack>
29 static SendOff8 find(const NumEffectState& state, Square king_position,
30 Square8& out);
31 static SendOff8 find(Player attack,
32 const NumEffectState& state, Square king_position,
33 Square8& out);
34 static SendOff8 invalidData() { return 0xff; }
35 static void unpack(SendOff8, Square king, Square8& out);
43 static void init() { table.init(); }
44 private:
45 static Table table;
46 template <Player Attack>
47 static void testSquare(const NumEffectState& state, Square candidate,
48 int id, int& out)
49 {
50 if (onlyOneSupport<Attack>(state, candidate))
51 {
52 out |= (1<<id);
53 }
54 }
55 };
56 } // namespace effect_util
57 using effect_util::SendOffSquare;
58} // namespace osl
59
60#endif /* OSL_SENDOFFPOSITION_H */
61// ;;; Local Variables:
62// ;;; mode:c++
63// ;;; c-basic-offset:2
64// ;;; coding:utf-8
65// ;;; End:
利きを持つ局面
int countEffect(Player player, Square target) const
利きの数を数える.
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition basic_type.h:852
const Piece pieceAt(Square sq) const
Player
Definition basic_type.h:8
constexpr Player alt(Player player)
Definition basic_type.h:13
送り金のような玉で取ると利きがはずれる駒が発生するマスを調査
static void unpack(SendOff8, Square king, Square8 &out)
static SendOff8 find(const NumEffectState &state, Square king_position, Square8 &out)
static bool onlyOneSupport(const NumEffectState &state, Square target)
static void testSquare(const NumEffectState &state, Square candidate, int id, int &out)