00001 /* unblockableEffect.h 00002 */ 00003 #ifndef _UNBLOCKABLEEFFECT_H 00004 #define _UNBLOCKABLEEFFECT_H 00005 00006 #include "osl/state/numEffectState.h" 00007 #include "osl/container/pieceVector.h" 00008 #include "osl/eval/pieceEval.h" 00009 #include "osl/boardTable.h" 00010 #include "osl/ptypeTraits.h" 00011 namespace osl 00012 { 00013 namespace effect_util 00014 { 00015 struct UnblockableEffect 00016 { 00021 static int find(const NumEffectState& state, 00022 PtypeO ptypeo, Position from, 00023 PieceVector& supported, 00024 PieceVector& unsupported) 00025 { 00026 const int move_mask = Ptype_Table.getMoveMask(getPtype(ptypeo)); 00027 const Player player = getOwner(ptypeo); 00028 const int attacker_value = abs(eval::PieceEval::captureValue(ptypeo)); 00029 for (int i=DIRECTION_MIN; i<=DIRECTION_MAX; ++i) 00030 { 00031 if (! (move_mask & (1<<i))) 00032 continue; 00033 const Direction dir = static_cast<Direction>(i); 00034 const Position to 00035 = Board_Table.nextPosition(player, from, dir); 00036 const Piece target = state.getPieceAt(to); 00037 if (! target.isPiece()) 00038 continue; 00039 if (target.owner() == player) 00040 continue; 00041 if (state.hasEffectBy(alt(player), to)) 00042 { 00043 if (abs(eval::PieceEval::captureValue(target.ptypeO())) 00044 > attacker_value) 00045 supported.push_back(target); 00046 } 00047 else 00048 { 00049 unsupported.push_back(target); 00050 } 00051 } 00052 return attacker_value; 00053 } 00054 }; 00055 00056 } // namespace effect_util 00057 } // namespace osl 00058 00059 #endif /* _UNBLOCKABLEEFFECT_H */ 00060 // ;;; Local Variables: 00061 // ;;; mode:c++ 00062 // ;;; c-basic-offset:2 00063 // ;;; End: