Location: PHPKode > projects > PhpBlock > A9.8/modules/dungeon/tick/gainpa.class.php
<?php
include_once $PATH_TO_CODE."/script/tick/allincludefortick.php";

/**
 * This is not reason to unit to take new decisions after gain PA. If two units are near and one gain PA, so it strikes first but this action awake the other which can counter-strike. On a very fast game, max wait for one unit must be decreased.
 */
class GainPaTick extends Tick {
    public function getName() {
        return "Gain action point";
    }
    public function run() {
        ////Action point
        executer("UPDATE objectInfo currentValue JOIN objectInfo maxValue ON currentValue.objectId=maxValue.objectId
						, object 
            SET currentValue.value = 
                    LEAST(maxValue.value, currentValue.value + maxValue.value*".Constante::$EARN_ACTION_POINT_PER_TURN.")
            WHERE currentValue.type1=".RealObject::$REAL_OBJECT_INFO_TYPE1_ACTION_POINT."
            AND currentValue.type2=".RealObject::$REAL_OBJECT_INFO_TYPE2_ACTION_POINT."
			AND maxValue.type1=".RealObject::$REAL_OBJECT_INFO_TYPE1_ACTION_POINT."
            AND maxValue.type2=".RealObject::$REAL_OBJECT_INFO_TYPE2_MAX_POINT."
            AND currentValue.value < maxValue.value
            AND object.objectId = currentValue.objectId
			AND object.isBattling = 0");

        //Unit are happy at home !
        executer("
			UPDATE objectInfo currentValue JOIN objectInfo maxValue ON currentValue.objectId=maxValue.objectId
			, object JOIN block ON object.blockId = block.blockId					
            SET currentValue.value = 
					LEAST(maxValue.value, currentValue.value + maxValue.value*".Constante::$EARN_ACTION_POINT_PER_TURN."*".DungeonConstante::$UNIT_ARE_HAPPY_AT_HOME_FACTOR.")
            WHERE currentValue.type1=".RealObject::$REAL_OBJECT_INFO_TYPE1_ACTION_POINT."
            AND currentValue.type2=".RealObject::$REAL_OBJECT_INFO_TYPE2_ACTION_POINT."
			AND maxValue.type1=".RealObject::$REAL_OBJECT_INFO_TYPE1_ACTION_POINT."
            AND maxValue.type2=".RealObject::$REAL_OBJECT_INFO_TYPE2_MAX_POINT."
            AND currentValue.value < maxValue.value
            AND object.objectId = currentValue.objectId
            AND block.allianceId = object.allianceId
			AND object.isBattling = 0");

        ////Fight point
        executer("UPDATE objectInfo currentValue JOIN objectInfo maxValue ON currentValue.objectId=maxValue.objectId  
            SET currentValue.value = 
                    LEAST(maxValue.value, currentValue.value + maxValue.value*".Constante::$EARN_FIGHT_ACTION_POINT_PER_TURN.")
            WHERE currentValue.type1=".RealObject::$REAL_OBJECT_INFO_TYPE1_FIGHT_ACTION_POINT."
            AND currentValue.type2=".RealObject::$REAL_OBJECT_INFO_TYPE2_FIGHT_ACTION_POINT."
			AND maxValue.type1=".RealObject::$REAL_OBJECT_INFO_TYPE1_FIGHT_ACTION_POINT."
            AND maxValue.type2=".RealObject::$REAL_OBJECT_INFO_TYPE2_MAX_POINT."
            AND currentValue.value < maxValue.value");

        //Unit are happy at home
        executer("
			UPDATE objectInfo currentValue JOIN objectInfo maxValue ON currentValue.objectId=maxValue.objectId
			, object JOIN block ON object.blockId = block.blockId					
            SET currentValue.value = 
                    LEAST(maxValue.value, currentValue.value + maxValue.value*".Constante::$EARN_FIGHT_ACTION_POINT_PER_TURN."*".DungeonConstante::$UNIT_ARE_HAPPY_AT_HOME_FACTOR.")
            WHERE currentValue.type1=".RealObject::$REAL_OBJECT_INFO_TYPE1_FIGHT_ACTION_POINT."
            AND currentValue.type2=".RealObject::$REAL_OBJECT_INFO_TYPE2_FIGHT_ACTION_POINT."
			AND maxValue.type1=".RealObject::$REAL_OBJECT_INFO_TYPE1_FIGHT_ACTION_POINT."
            AND maxValue.type2=".RealObject::$REAL_OBJECT_INFO_TYPE2_MAX_POINT."
            AND currentValue.value < maxValue.value
            AND object.objectId = currentValue.objectId
            AND block.blockId = object.blockId
            AND block.allianceId = object.allianceId
			AND currentValue.objectId=maxValue.objectId");
    }
}
?>
Return current item: PhpBlock