/*
* Match at least one of these buffs, by default.
*
* Do not have these buffs
*
*/
using System.Linq;
public class DialogRequirementNPCHasBuffSDX : BaseDialogRequirement
{
public override bool CheckRequirement(EntityPlayer player, EntityNPC talkingTo)
{
//Log.Out("DialogRequirementNPCHasBuffSDX-CheckRequirement START");
//Log.Out("DialogRequirementNPCHasBuffSDX-CheckRequirement, Value: " + Value);
var matches = -1;
// If there's more than one buff listed, loop around, recording how many we match.
string[] array = Value.Split(new char[]
{
','
});
if (Value.Contains(","))
{
//Log.Out("DialogRequirementNPCHasBuffSDX-CheckRequirement 1");
matches = array.Count(t => talkingTo.Buffs.HasBuff(t));
if (matches > 0)
return true;
return false;
}
else
{
//Log.Out("DialogRequirementNPCHasBuffSDX-CheckRequirement 2");
// Reverse condition on the buff.
if (Value.StartsWith("!"))
{
//Log.Out("DialogRequirementNPCHasBuffSDX-CheckRequirement 3");
var tempBuff = Value.Replace("!", "");
if (!talkingTo.Buffs.HasBuff(tempBuff))
return true;
}
// If no operator, just check if we have it
if (talkingTo.Buffs.HasBuff(Value))
{
//Log.Out("DialogRequirementNPCHasBuffSDX-CheckRequirement 4");
return true;
}
}
//Log.Out("DialogRequirementNPCHasBuffSDX-CheckRequirement END");
return false;
}
}