Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

KoduConditionScored.h

Go to the documentation of this file.
00001 #ifndef KODU_CONDITION_SCORED_H_
00002 #define KODU_CONDITION_SCORED_H_
00003 
00004 // Kodu Library
00005 #include "Kodu/Generators/KoduGenerators.h"
00006 #include "Kodu/Primitives/KoduCondition.h"
00007 
00008 // TODO
00009 // (28/03/13) implement the random modifier (needs an initial value and increment?)
00010 
00011 /**
00012  * NAME:            KODU CONDITION SCORED
00013  * TYPE:            CONDITION
00014  * KODU EQUIVALENT: SCORED
00015  * DESCRIPTION:
00016  *      This class is used to monitor the global score board.
00017 **/
00018     
00019 namespace Kodu {
00020 
00021     class KoduWorld;
00022 
00023     //! Kodu Condition Scored (derived from Kodu Condition)
00024     class KoduConditionScored : public KoduCondition {
00025     public:
00026         //! How the target score should be compared with the current (global) score
00027         enum CompareType_t {
00028             INVALID         = 0L,       // should never be used
00029             CT_EQUALS       = 1L << 0,  // default choice unless otherwise specified
00030             CT_NOT_EQUALS   = 1L << 1,  // evaluate true if score != target value
00031             CT_GT_EQUAL     = 1L << 2,  // evaluate true if score >= target value
00032             CT_LT_EQUAL     = 1L << 3,  // evaluate true if score <= target value
00033             CT_ABOVE        = 1L << 4,  // evaluate true if score > target value
00034             CT_BELOW        = 1L << 5   // evaluate true if score < target value
00035         };
00036 
00037         //! Constructor
00038         KoduConditionScored(bool useNot, CompareType_t compType, const NumericGenerator& kNumericGen, 
00039             const std::string& kDesignator, bool numericModWasSpecified)
00040           : KoduCondition ("KoduConditionScored", KoduCondition::CT_SCORED),
00041             notModifierEnabled(useNot),
00042             type(compType),
00043             numericGen(kNumericGen),
00044             designator(kDesignator),
00045             numericsWereSpecified(numericModWasSpecified),
00046             lastRecordedValue(0)
00047         { }
00048         
00049         //! Copy constructor
00050         KoduConditionScored(const KoduConditionScored& kCondition)
00051           : KoduCondition(kCondition),
00052             notModifierEnabled(kCondition.notModifierEnabled),
00053             type(kCondition.type),
00054             numericGen(kCondition.numericGen),
00055             designator(kCondition.designator),
00056             numericsWereSpecified(kCondition.numericsWereSpecified),
00057             lastRecordedValue(kCondition.lastRecordedValue)
00058         { }
00059 
00060         //! Destructor
00061         ~KoduConditionScored() {
00062             // no explicit implementation
00063         }
00064 
00065         //! Assignment operator
00066         KoduConditionScored& operator=(const KoduConditionScored& kCondition) {
00067             if (this != &kCondition) {
00068                 KoduCondition::operator=(kCondition);
00069                 notModifierEnabled = kCondition.notModifierEnabled;
00070                 type = kCondition.type;
00071                 numericGen = kCondition.numericGen;
00072                 designator = kCondition.designator;
00073                 numericsWereSpecified = kCondition.numericsWereSpecified;
00074                 lastRecordedValue = kCondition.lastRecordedValue;
00075             }
00076             return *this;
00077         }
00078         
00079         //! Compares the target score against the current (global) score
00080         virtual bool evaluate(const KoduWorld&);
00081         
00082         //! Tests if the primitive argument is the same as the calling class
00083         static bool isSameTypeAs(const KoduPrimitive*);
00084 
00085         //! Used to reinitialize certain variables (e.g. when switching to another page)
00086         virtual void reinitialize();
00087         
00088         //! Prints the attributes of a particular instance
00089         virtual void printAttrs() const;
00090 
00091     private:
00092         bool notModifierEnabled; //!< if true, NOT operator is applied to the evaluate function's result
00093         CompareType_t type;     //!< states how the target value and current score are compared
00094         NumericGenerator numericGen; //!< returns a constant or random numeric value (the target score)
00095         std::string designator; //!< the score type (the key to the Score Keeper map)
00096         bool numericsWereSpecified; //!< if false, this condition returns true when a certin score changes
00097         int lastRecordedValue;//!< used in conjunction with numericsWereSpecified to monitor score changes
00098     };
00099 }
00100 
00101 #endif // KODU_CONDITION_SCORED_H_

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:43 2016 by Doxygen 1.6.3