void EntertainingSessionImplementation::addEntertainerBuffStrength(CreatureObject* creature, int performanceType, float strength) {
	ManagedReference<CreatureObject*> entertainer = this->entertainer.get();

	int buffStrength = getEntertainerBuffStrength(creature, performanceType);


	float newBuffStrength = buffStrength + strength;

	float maxBuffStrength = 0.0f;	//cap based on enhancement skill
	if(dancing) {
		maxBuffStrength = (float) entertainer->getSkillMod("healing_dance_mind");
	}
	else if (playingMusic) {
		maxBuffStrength = (float) entertainer->getSkillMod("healing_music_mind");
	}

	if(maxBuffStrength > 125.0f)
		maxBuffStrength = 125.0f;	//cap at 125% power

	//add xp based on % added to buff strength
	if (newBuffStrength  < maxBuffStrength) {
		healingXp += strength;
	}
	else {
		healingXp += maxBuffStrength - buffStrength;
		newBuffStrength = maxBuffStrength;
	}

	//newBuffStrength = newBuffStrength;

	setEntertainerBuffStrength(creature, performanceType, newBuffStrength);
}
void EntertainingSessionImplementation::addEntertainerBuffStrength(CreatureObject* creature, int performanceType, float strength) {
	ManagedReference<CreatureObject*> entertainer = this->entertainer.get();

	int buffStrength = getEntertainerBuffStrength(creature, performanceType);


	float newBuffStrength = buffStrength + strength;

	float maxBuffStrength = 0.0f;	//cap based on enhancement skill
	if(dancing) {
		maxBuffStrength = (float) entertainer->getSkillMod("healing_dance_mind");
	}
	else if (playingMusic) {
		maxBuffStrength = (float) entertainer->getSkillMod("healing_music_mind");
	}

	if(maxBuffStrength > 125.0f)
		maxBuffStrength = 125.0f;	//cap at 125% power

	float factionPerkStrength = entertainer->getSkillMod("private_faction_buff_mind");

	ManagedReference<BuildingObject*> building = entertainer->getRootParent().get().castTo<BuildingObject*>();

	if (building != NULL && factionPerkStrength > 0 && building->isPlayerRegisteredWithin(entertainer->getObjectID())) {
		unsigned int buildingFaction = building->getFaction();
		unsigned int entFaction = entertainer->getFaction();
		PlayerObject* ghost = entertainer->getPlayerObject();

		if (ghost != NULL && entFaction != 0 && entFaction == buildingFaction && ghost->getFactionStatus() == FactionStatus::OVERT) {
			maxBuffStrength += factionPerkStrength;
		}
	}

	//add xp based on % added to buff strength
	if (newBuffStrength  < maxBuffStrength) {
		healingXp += strength;
	}
	else {
		healingXp += maxBuffStrength - buffStrength;
		newBuffStrength = maxBuffStrength;
	}

	//newBuffStrength = newBuffStrength;

	setEntertainerBuffStrength(creature, performanceType, newBuffStrength);
}
void EntertainingSessionImplementation::activateEntertainerBuff(CreatureObject* creature, int performanceType) {
	ManagedReference<CreatureObject*> entertainer = this->entertainer.get();

	try {
		//Check if on Deny Service list
		if(isInDenyServiceList(creature)) {
			return;
		}

		ManagedReference<PlayerObject*> entPlayer = entertainer->getPlayerObject();
		//Check if the patron is a valid buff target
		//Whether it be passive(in the same group) or active (/setPerform target)
		if ((!entertainer->isGrouped() || entertainer->getGroupID() != creature->getGroupID())
				&& entPlayer->getPerformanceBuffTarget() != creature->getObjectID()) {
			return;
		}

		if(!canGiveEntertainBuff())
			return;

		// Returns the Number of Minutes for the Buff Duration
		float buffDuration = getEntertainerBuffDuration(creature, performanceType);

		if (buffDuration * 60 < 10.0f) { //10 sec minimum buff duration
			return;
		}

		//1 minute minimum listen/watch time
		int timeElapsed = time(0) - getEntertainerBuffStartTime(creature, performanceType);
		if(timeElapsed < 60) {
			creature->sendSystemMessage("You must listen or watch a performer for at least 1 minute in order to gain the entertainer buffs.");
			return;
		}

		// Returns a % of base stat
		int campModTemp = 100;


		float buffStrength = getEntertainerBuffStrength(creature, performanceType) / 100.0f;

		if(buffStrength == 0)
			return;

		ManagedReference<PerformanceBuff*> oldBuff = NULL;
		switch (performanceType){
		case PerformanceType::MUSIC:
		{
			uint32 focusBuffCRC = STRING_HASHCODE("performance_enhance_music_focus");
			uint32 willBuffCRC = STRING_HASHCODE("performance_enhance_music_willpower");
			oldBuff = cast<PerformanceBuff*>(creature->getBuff(focusBuffCRC));
			if (oldBuff != NULL && oldBuff->getBuffStrength() > buffStrength)
				return;
			ManagedReference<PerformanceBuff*> focusBuff = new PerformanceBuff(creature, focusBuffCRC, buffStrength, buffDuration * 60, PerformanceBuffType::MUSIC_FOCUS);
			ManagedReference<PerformanceBuff*> willBuff = new PerformanceBuff(creature, willBuffCRC, buffStrength, buffDuration * 60, PerformanceBuffType::MUSIC_WILLPOWER);

			Locker locker(focusBuff);
			creature->addBuff(focusBuff);
			locker.release();

			Locker locker2(willBuff);
			creature->addBuff(willBuff);
			break;
		}
		case PerformanceType::DANCE:
		{
			uint32 mindBuffCRC = STRING_HASHCODE("performance_enhance_dance_mind");
			oldBuff = cast<PerformanceBuff*>(creature->getBuff(mindBuffCRC));
			if (oldBuff != NULL && oldBuff->getBuffStrength() > buffStrength)
				return;
			ManagedReference<PerformanceBuff*> mindBuff = new PerformanceBuff(creature, mindBuffCRC, buffStrength, buffDuration * 60, PerformanceBuffType::DANCE_MIND);

			Locker locker(mindBuff);
			creature->addBuff(mindBuff);
			break;
		}
		}


	} catch(Exception& e) {

	}

}