unblockableEffect.h
Go to the documentation of this file.
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, Square 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 Square to
00035             = Board_Table.nextSquare(player, from, dir);
00036           const Piece target = state.pieceAt(to);
00037           if(!target.isOnBoardByOwner(alt(player)))
00038             continue;
00039           if (state.hasEffectAt(alt(player), to))
00040           {
00041             if (abs(eval::PieceEval::captureValue(target.ptypeO()))
00042                 > attacker_value)
00043               supported.push_back(target);
00044           }
00045           else
00046           {
00047             unsupported.push_back(target);
00048           }
00049         }
00050         return attacker_value;
00051       }
00052     };
00053     
00054   } // namespace effect_util
00055 } // namespace osl
00056 
00057 #endif /* _UNBLOCKABLEEFFECT_H */
00058 // ;;; Local Variables:
00059 // ;;; mode:c++
00060 // ;;; c-basic-offset:2
00061 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines