All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sendOffSquare.h
Go to the documentation of this file.
1 /* sendOffSquare.h
2  */
3 #ifndef OSL_SENDOFFPOSITION_H
4 #define OSL_SENDOFFPOSITION_H
5 
8 namespace 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);
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);
36  struct Table
37  {
38  CArray<Offset,8> normal;
39  CArray<Offset8,8> reverse;
40  CArray<Offset8,256> reverse_all;
41  Table();
42  };
43  private:
44  static const Table table;
45  template <Player Attack>
46  static void testSquare(const NumEffectState& state, Square candidate,
47  int id, int& out)
48  {
49  if (onlyOneSupport<Attack>(state, candidate))
50  {
51  out |= (1<<id);
52  }
53  }
54  };
55  } // namespace effect_util
56  using effect_util::SendOffSquare;
57 } // namespace osl
58 
59 #endif /* OSL_SENDOFFPOSITION_H */
60 // ;;; Local Variables:
61 // ;;; mode:c++
62 // ;;; c-basic-offset:2
63 // ;;; coding:utf-8
64 // ;;; End: