00001
00002
00003 #ifndef _SENDOFFPOSITION_H
00004 #define _SENDOFFPOSITION_H
00005
00006 #include "osl/state/numEffectState.h"
00007 #include "osl/container/position8.h"
00008 namespace osl
00009 {
00010 namespace effect_util
00011 {
00012 struct Offset8 : public FixedCapacityVector<Offset,8>
00013 {
00014 };
00016 struct SendOffPosition
00017 {
00018 template <Player Attack>
00019 static bool onlyOneSupport(const NumEffectState& state, Position target)
00020 {
00021 const Piece p = state.getPieceAt(target);
00022 if (! p.isOnBoardByOwner<PlayerTraits<Attack>::opponent>())
00023 return false;
00024 return state.hasEffectBy<Attack>(target)
00025 && (state.countEffect(alt(Attack), target) == 1);
00026 }
00027 template <Player Attack>
00028 static void find(const NumEffectState& state, Position king_position,
00029 Position8& out);
00030 static void find(Player attack,
00031 const NumEffectState& state, Position king_position,
00032 Position8& out);
00033 struct Table
00034 {
00035 CArray<Offset,8> normal;
00036 CArray<Offset8,8> reverse;
00037 CArray<Offset8,256> reverse_all;
00038 Table();
00039 };
00040 private:
00041 static const Table table;
00042 template <Player Attack>
00043 static void testPosition(const NumEffectState& state, Position candidate,
00044 int id, int& out)
00045 {
00046 if (onlyOneSupport<Attack>(state, candidate))
00047 {
00048 out |= (1<<id);
00049 }
00050 }
00051 };
00052 }
00053 }
00054
00055 #endif
00056
00057
00058
00059