File indexing completed on 2024-04-28 04:01:56

0001 /***************************************************************************
0002 *   KBlocks, a falling blocks game by KDE                                 *
0003 *   SPDX-FileCopyrightText: 2010 University Freiburg <squall.leonhart.cai@gmail.com> *
0004 *                                                                          *
0005 *   SPDX-License-Identifier: GPL-2.0-or-later
0006 ***************************************************************************/
0007 #ifndef EVALUATIONINTERFACE_H
0008 #define EVALUATIONINTERFACE_H
0009 
0010 #include "../KBlocksField.h"
0011 #include "../KBlocksPiece.h"
0012 
0013 #define DEBUG_EVALUATION
0014 #ifdef  DEBUG_EVALUATION
0015 #define CLASSNAME(class)\
0016     const char* evaluationName()\
0017     override {\
0018         return #class;\
0019     }
0020 #else
0021 #define CLASSNAME(class)
0022 #endif
0023 
0024 class EvaluationInterface
0025 {
0026 public:
0027     EvaluationInterface() {};
0028     virtual ~EvaluationInterface() {};
0029     virtual double evaluate(KBlocksField *) = 0;
0030 #ifdef DEBUG_EVALUATION
0031     virtual const char *evaluationName()
0032     {
0033         return "";
0034     }
0035 #endif
0036 };
0037 
0038 class SpecialEvaluationInterface : public EvaluationInterface
0039 {
0040 public:
0041     SpecialEvaluationInterface()
0042     {
0043         mpPiece = nullptr;
0044         mpField = nullptr;
0045     }
0046     ~SpecialEvaluationInterface() override {};
0047 
0048     double evaluate(KBlocksField *) override = 0;
0049     void setCurrentPiece(KBlocksPiece *piece)
0050     {
0051         mpPiece = piece;
0052     }
0053     void setCurrentBoard(KBlocksField *field)
0054     {
0055         mpField = field;
0056     }
0057 
0058 #ifdef DEBUG_EVALUATION
0059     const char *evaluationName() override
0060     {
0061         return "";
0062     }
0063 #endif
0064 
0065 protected:
0066     KBlocksPiece *mpPiece;
0067     KBlocksField *mpField;
0068 };
0069 
0070 #endif //EVALUATIONINTERFACE_H