public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Player == null)
{
return;
}
bool closeGump = true;
CaptchaPersistance.CheckAndCreateCaptchaAccountEntry(m_Player);
CaptchaAccountData captchaData = m_Player.m_CaptchaAccountData;
switch (info.ButtonID)
{
//Guide
case 1:
closeGump = false;
break;
//Confirm
case 2:
if (captchaData.m_ConfirmPrompt)
{
bool correct = false;
if (captchaData.m_Row1CorrectIndex == captchaData.m_SelectedRow1Index && captchaData.m_Row2CorrectIndex == captchaData.m_SelectedRow2Index && captchaData.m_Row3CorrectIndex == captchaData.m_SelectedRow3Index)
{
correct = true;
}
if (correct)
{
captchaData.m_NextCaptchaTime = DateTime.UtcNow + TimeSpan.FromMinutes((double)Utility.RandomMinMax(CaptchaAccountData.MinimumCaptchaDelay, CaptchaAccountData.MaximumCaptchaDelay));
captchaData.m_CaptchaRequired = false;
captchaData.m_CaptchaAttempt = 0;
captchaData.m_ConfirmPrompt = false;
m_Player.SendSound(0x5B6);
m_Player.SendMessage("Captcha successful.");
switch (captchaData.m_CaptchaSourceType)
{
case CaptchaSourceType.Fishing:
FishingPole fishingPole = m_Player.FindItemOnLayer(Layer.TwoHanded) as FishingPole;
if (fishingPole != null)
{
Fishing.System.StartHarvesting(m_Player, fishingPole, null, true);
}
break;
case CaptchaSourceType.Lumberjacking:
Hatchet hatchet = m_Player.FindItemOnLayer(Layer.TwoHanded) as Hatchet;
if (hatchet != null)
{
Lumberjacking.System.StartHarvesting(m_Player, hatchet, null, true);
}
break;
case CaptchaSourceType.Mining:
Pickaxe pickaxe = m_Player.FindItemOnLayer(Layer.OneHanded) as Pickaxe;
if (pickaxe != null)
{
Mining.System.StartHarvesting(m_Player, pickaxe, null, true);
}
break;
case CaptchaSourceType.DungeonChest:
Lockpick lockpick = (Lockpick)m_Player.Backpack.FindItemByType(typeof(Lockpick));
//TEST
if (lockpick != null)
{
lockpick.OnDoubleClick(m_Player);
}
break;
}
return;
}
else
{
captchaData.m_CaptchaAttempt++;
if (captchaData.m_CaptchaAttempt == 3)
{
string responseMessage = "";
if (captchaData.m_PreviousPenalty != CaptchaAccountData.PenaltyLevelType.None && captchaData.m_PenaltyProbationExpiration > DateTime.UtcNow)
{
switch (captchaData.m_PreviousPenalty)
{
case CaptchaAccountData.PenaltyLevelType.None:
captchaData.m_CurrentPenalty = CaptchaAccountData.PenaltyLevelType.Minor;
captchaData.m_CurrentPenaltyExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyDuration(captchaData.m_CurrentPenalty);
captchaData.m_PreviousPenalty = captchaData.m_CurrentPenalty;
captchaData.m_PenaltyProbationExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyProbationDuration(captchaData.m_PreviousPenalty);
responseMessage = "You have failed a captcha response and your account will now be prevented from gathering resources for ";
responseMessage += Utility.CreateTimeRemainingString(DateTime.UtcNow, captchaData.m_CurrentPenaltyExpiration, false, true, true, true, false) + ".";
m_Player.SendMessage(2115, responseMessage);
break;
case CaptchaAccountData.PenaltyLevelType.Minor:
captchaData.m_CurrentPenalty = CaptchaAccountData.PenaltyLevelType.Major;
captchaData.m_CurrentPenaltyExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyDuration(captchaData.m_CurrentPenalty);
captchaData.m_PreviousPenalty = captchaData.m_CurrentPenalty;
captchaData.m_PenaltyProbationExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyProbationDuration(captchaData.m_PreviousPenalty);
responseMessage = "You have failed a second captcha response within one day, and your account will now be prevented from gathering resources for ";
responseMessage += Utility.CreateTimeRemainingString(DateTime.UtcNow, captchaData.m_CurrentPenaltyExpiration, false, true, true, true, false) + ".";
m_Player.SendMessage(2115, responseMessage);
break;
case CaptchaAccountData.PenaltyLevelType.Major:
captchaData.m_CurrentPenalty = CaptchaAccountData.PenaltyLevelType.Epic;
captchaData.m_CurrentPenaltyExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyDuration(captchaData.m_CurrentPenalty);
captchaData.m_PreviousPenalty = captchaData.m_CurrentPenalty;
captchaData.m_PenaltyProbationExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyProbationDuration(captchaData.m_PreviousPenalty);
responseMessage = "You have failed a third captcha response within one week, and your account will now be prevented from gathering resources for ";
responseMessage += Utility.CreateTimeRemainingString(DateTime.UtcNow, captchaData.m_CurrentPenaltyExpiration, false, true, true, true, false) + ".";
m_Player.SendMessage(2115, responseMessage);
break;
case CaptchaAccountData.PenaltyLevelType.Epic:
captchaData.m_CurrentPenalty = CaptchaAccountData.PenaltyLevelType.Permanent;
captchaData.m_CurrentPenaltyExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyDuration(captchaData.m_CurrentPenalty);
captchaData.m_PreviousPenalty = captchaData.m_CurrentPenalty;
captchaData.m_PenaltyProbationExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyProbationDuration(captchaData.m_PreviousPenalty);
responseMessage = "You have failed a fourth captcha response within one month, and your account will now be permanently prevented from gathering resources.";
m_Player.SendMessage(2115, responseMessage);
break;
case CaptchaAccountData.PenaltyLevelType.Permanent:
captchaData.m_CurrentPenalty = CaptchaAccountData.PenaltyLevelType.Permanent;
captchaData.m_CurrentPenaltyExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyDuration(captchaData.m_CurrentPenalty);
captchaData.m_PreviousPenalty = captchaData.m_CurrentPenalty;
captchaData.m_PenaltyProbationExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyProbationDuration(captchaData.m_PreviousPenalty);
responseMessage = "You have failed a fourth captcha response within one month, and your account will now be permanently prevented from gathering resources.";
m_Player.SendMessage(2115, responseMessage);
break;
}
}
else
{
captchaData.m_CurrentPenalty = CaptchaAccountData.PenaltyLevelType.Minor;
captchaData.m_CurrentPenaltyExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyDuration(captchaData.m_CurrentPenalty);
captchaData.m_PreviousPenalty = captchaData.m_CurrentPenalty;
captchaData.m_PenaltyProbationExpiration = DateTime.UtcNow + CaptchaAccountData.GetPenaltyProbationDuration(captchaData.m_PreviousPenalty);
responseMessage = "You have failed a captcha response and your account will now be blocked from gathering resources for " + Utility.CreateTimeRemainingString(DateTime.UtcNow, captchaData.m_CurrentPenaltyExpiration, false, true, true, true, false) + ".";
m_Player.SendMessage(2115, responseMessage);
}
captchaData.m_NextCaptchaTime = DateTime.UtcNow + TimeSpan.FromMinutes((double)Utility.RandomMinMax(CaptchaAccountData.MinimumCaptchaDelay, CaptchaAccountData.MaximumCaptchaDelay));
captchaData.m_CaptchaRequired = false;
captchaData.m_CaptchaAttempt = 0;
captchaData.m_ConfirmPrompt = false;
m_Player.SendSound(0x5B3);
return;
}
else
{
switch (captchaData.m_CaptchaAttempt)
{
case 1: m_Player.SendMessage(55, "Captcha response incorrect. You have two more attempts."); break;
case 2: m_Player.SendMessage(1256, "Captcha response incorrect. You have one more attempt."); break;
}
captchaData.m_NextCaptchaTime = DateTime.UtcNow + TimeSpan.FromMinutes((double)Utility.RandomMinMax(CaptchaAccountData.MinimumCaptchaDelay, CaptchaAccountData.MaximumCaptchaDelay));
captchaData.GenerateIDs();
captchaData.m_ConfirmPrompt = false;
}
}
}
else
{
captchaData.m_ConfirmPrompt = true;
}
closeGump = false;
break;
//Row 1 Previous
case 3:
captchaData.m_SelectedRow1Index--;
if (captchaData.m_SelectedRow1Index < 0)
{
captchaData.m_SelectedRow1Index = CaptchaAccountData.ItemsPerRow - 1;
}
captchaData.m_ConfirmPrompt = false;
m_Player.SendSound(SelectionSound);
closeGump = false;
break;
//Row 1 Next
case 4:
captchaData.m_SelectedRow1Index++;
if (captchaData.m_SelectedRow1Index >= CaptchaAccountData.ItemsPerRow)
{
captchaData.m_SelectedRow1Index = 0;
}
captchaData.m_ConfirmPrompt = false;
m_Player.SendSound(SelectionSound);
closeGump = false;
break;
//Row 2 Previous
case 5:
captchaData.m_SelectedRow2Index--;
if (captchaData.m_SelectedRow2Index < 0)
{
captchaData.m_SelectedRow2Index = CaptchaAccountData.ItemsPerRow - 1;
}
captchaData.m_ConfirmPrompt = false;
m_Player.SendSound(SelectionSound);
closeGump = false;
break;
//Row 2 Next
case 6:
captchaData.m_SelectedRow2Index++;
if (captchaData.m_SelectedRow2Index >= CaptchaAccountData.ItemsPerRow)
{
captchaData.m_SelectedRow2Index = 0;
}
captchaData.m_ConfirmPrompt = false;
m_Player.SendSound(SelectionSound);
closeGump = false;
break;
//Row 3 Previous
case 7:
captchaData.m_SelectedRow3Index--;
if (captchaData.m_SelectedRow3Index < 0)
{
captchaData.m_SelectedRow3Index = CaptchaAccountData.ItemsPerRow - 1;
}
captchaData.m_ConfirmPrompt = false;
m_Player.SendSound(SelectionSound);
closeGump = false;
break;
//Row 3 Next
case 8:
captchaData.m_SelectedRow3Index++;
if (captchaData.m_SelectedRow3Index >= CaptchaAccountData.ItemsPerRow)
{
captchaData.m_SelectedRow3Index = 0;
}
captchaData.m_ConfirmPrompt = false;
m_Player.SendSound(SelectionSound);
closeGump = false;
break;
}
if (!closeGump)
{
m_Player.CloseGump(typeof(CaptchaGump));
m_Player.SendGump(new CaptchaGump(m_Player));
}
else
{
m_Player.SendSound(CloseGumpSound);
}
}