Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
206
Scripts/SubSystem/LotterySystem/Scratchers/CrazedCrafting.cs
Normal file
206
Scripts/SubSystem/LotterySystem/Scratchers/CrazedCrafting.cs
Normal file
@@ -0,0 +1,206 @@
|
||||
using Server;
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
using Server.Engines.LotterySystem;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class CrazedCrafting : BaseLottoTicket
|
||||
{
|
||||
private int[] m_WinAmounts = new int[] { 1000, 2500, 7500, 25000, 150000, 2 };
|
||||
private int[] m_WildCards = new int[] { 0x15AF, 0x15B3, 0x15B7, 0x15CB, 0x15CD };
|
||||
|
||||
public int[] WildCards { get { return m_WildCards; } }
|
||||
|
||||
public static readonly int TicketCost = 1000;
|
||||
|
||||
[Constructable]
|
||||
public CrazedCrafting() : this(null, false)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public CrazedCrafting(Mobile owner, bool quickScratch) : base (owner, TicketType.CrazedCrafting, quickScratch)
|
||||
{
|
||||
Name = "a crazed crafting ticket";
|
||||
LootType = LootType.Blessed;
|
||||
Hue = 0x972;
|
||||
}
|
||||
|
||||
public override bool DoScratch(int scratch, Mobile from)
|
||||
{
|
||||
if (scratch > 3 || scratch < 0 || from == null)
|
||||
return false;
|
||||
|
||||
int pick;
|
||||
int pickAmount;
|
||||
|
||||
try
|
||||
{
|
||||
if (.08 > Utility.RandomDouble())
|
||||
pickAmount = m_WildCards[Utility.Random(m_WildCards.Length)];
|
||||
else
|
||||
{
|
||||
int[] odds = ReturnOdds(from);
|
||||
pick = odds[Utility.Random(odds.Length)];
|
||||
pickAmount = m_WinAmounts[pick];
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (scratch)
|
||||
{
|
||||
case 1: Scratch1 = pickAmount; break;
|
||||
case 2: Scratch2 = pickAmount; break;
|
||||
case 3: Scratch3 = pickAmount; break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
CheckScratches();
|
||||
return true;
|
||||
}
|
||||
|
||||
private int[] ReturnOdds(Mobile from)
|
||||
{
|
||||
if (CraftingSkill(from) > 120 || (CraftingSkill(from) > 100 && Utility.RandomBool()))
|
||||
return new int[] { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 5 };
|
||||
|
||||
return new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 5 };
|
||||
}
|
||||
|
||||
public override void CheckScratches()
|
||||
{
|
||||
/*Multipler = 3 same wildcards = 10x
|
||||
2 same wildcards = 2x*/
|
||||
|
||||
if (Scratch1 > 0 && Scratch2 > 0 && Scratch3 > 0)
|
||||
{
|
||||
Checked = true;
|
||||
|
||||
bool wild1 = false;
|
||||
bool wild2 = false;
|
||||
bool wild3 = false;
|
||||
|
||||
foreach(int num in m_WildCards)
|
||||
{
|
||||
if (Scratch1 == num)
|
||||
wild1 = true;
|
||||
if (Scratch2 == num)
|
||||
wild2 = true;
|
||||
if (Scratch3 == num)
|
||||
wild3 = true;
|
||||
}
|
||||
|
||||
if (Scratch1 == 2 || Scratch2 == 2 || Scratch3 == 2)
|
||||
FreeTicket = true;
|
||||
else if ((Scratch1 == Scratch2 && Scratch2 == Scratch3) || (wild1 && Scratch2 == Scratch3) || (wild2 && Scratch1 == Scratch3)
|
||||
|| (wild3 && Scratch1 == Scratch2) || (wild1 && wild2) || (wild2 && wild3) || (wild1 && wild3))
|
||||
{
|
||||
int payOut = 0;
|
||||
|
||||
if (!wild1)
|
||||
{
|
||||
payOut = Scratch1;
|
||||
if (wild2 && wild3 && Scratch2 == Scratch3)
|
||||
payOut *= 2;
|
||||
}
|
||||
else if (!wild2)
|
||||
{
|
||||
payOut = Scratch2;
|
||||
if (wild1 && wild3 && Scratch1 == Scratch3)
|
||||
payOut *= 2;
|
||||
}
|
||||
else if (!wild3)
|
||||
{
|
||||
payOut = Scratch3;
|
||||
if (wild1 && wild2 && Scratch1 == Scratch2)
|
||||
payOut *= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
payOut = 150000;
|
||||
|
||||
if (Scratch1 == Scratch2 && Scratch2 == Scratch3)
|
||||
payOut *= 10;
|
||||
else if (Scratch1 == Scratch2 || Scratch2 == Scratch3 || Scratch1 == Scratch3)
|
||||
payOut *= 2;
|
||||
|
||||
}
|
||||
|
||||
Payout = payOut;
|
||||
DoWin(Payout);
|
||||
|
||||
if (ScratcherLotto.Stone != null)
|
||||
ScratcherLotto.Stone.GoldSink -= Payout;
|
||||
}
|
||||
}
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
private void DoWin(int amount)
|
||||
{
|
||||
if (Owner != null)
|
||||
Owner.PlaySound(Owner.Female ? 0x337 : 0x449);
|
||||
|
||||
if (amount >= 100000) //Jackpot
|
||||
{
|
||||
new ScratcherStats(Owner, amount, this.Type);
|
||||
|
||||
if (ScratcherLotto.Stone != null)
|
||||
{
|
||||
ScratcherLotto.Stone.InvalidateProperties();
|
||||
ScratcherLotto.Stone.UpdateSatellites();
|
||||
}
|
||||
}
|
||||
|
||||
if (Owner != null)
|
||||
Owner.SendMessage(42, "It looks like you have a winning ticket!");
|
||||
}
|
||||
|
||||
private double CraftingSkill(Mobile from)
|
||||
{
|
||||
double topSkill = from.Skills[SkillName.Alchemy].Value;
|
||||
|
||||
if (from.Skills[SkillName.Fletching].Value > topSkill)
|
||||
topSkill = from.Skills[SkillName.Fletching].Value;
|
||||
if (from.Skills[SkillName.Blacksmith].Value > topSkill)
|
||||
topSkill = from.Skills[SkillName.Blacksmith].Value;
|
||||
if (from.Skills[SkillName.Tailoring].Value > topSkill)
|
||||
topSkill = from.Skills[SkillName.Tailoring].Value;
|
||||
if (from.Skills[SkillName.Inscribe].Value > topSkill)
|
||||
topSkill = from.Skills[SkillName.Inscribe].Value;
|
||||
if (from.Skills[SkillName.Carpentry].Value > topSkill)
|
||||
topSkill = from.Skills[SkillName.Carpentry].Value;
|
||||
if (from.Skills[SkillName.Tinkering].Value > topSkill)
|
||||
topSkill = from.Skills[SkillName.Tinkering].Value;
|
||||
|
||||
return topSkill;
|
||||
}
|
||||
|
||||
public CrazedCrafting(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); //Version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
131
Scripts/SubSystem/LotterySystem/Scratchers/GoldenTicket.cs
Normal file
131
Scripts/SubSystem/LotterySystem/Scratchers/GoldenTicket.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using Server;
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
using Server.Engines.LotterySystem;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class GoldenTicket : BaseLottoTicket
|
||||
{
|
||||
private int[] m_WinAmounts = new int[] { 1000, 5000, 25000, 100000, 250000, 1000000, 2 };
|
||||
|
||||
public static readonly int TicketCost = 1000;
|
||||
|
||||
[Constructable]
|
||||
public GoldenTicket() :this(null, false)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public GoldenTicket(Mobile owner, bool quickScratch) : base (owner, TicketType.GoldenTicket, quickScratch)
|
||||
{
|
||||
Name = "a golden ticket";
|
||||
LootType = LootType.Blessed;
|
||||
Hue = 0x8A5;
|
||||
}
|
||||
|
||||
public override void CheckScratches()
|
||||
{
|
||||
if (Scratch1 > 0 && Scratch2 > 0 && Scratch3 > 0 && !Checked)
|
||||
{
|
||||
Checked = true;
|
||||
if (Scratch1 == 2 || Scratch2 == 2 || Scratch3 == 2)
|
||||
FreeTicket = true;
|
||||
else if (Scratch1 == Scratch2 && Scratch1 == Scratch3)
|
||||
{
|
||||
if (Scratch1 == 2)
|
||||
Payout = 250000;
|
||||
else
|
||||
Payout = Scratch1;
|
||||
|
||||
DoWin();
|
||||
|
||||
if (ScratcherLotto.Stone != null)
|
||||
ScratcherLotto.Stone.GoldSink -= Payout;
|
||||
}
|
||||
}
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public override bool DoScratch(int scratch, Mobile from)
|
||||
{
|
||||
if (scratch > 3 || scratch < 0 || from == null)
|
||||
return false;
|
||||
|
||||
int pick;
|
||||
int pickAmount;
|
||||
|
||||
try
|
||||
{
|
||||
int[] odds = ReturnOdds(from);
|
||||
pick = odds[Utility.Random(odds.Length)];
|
||||
pickAmount = m_WinAmounts[pick];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (scratch)
|
||||
{
|
||||
case 1: Scratch1 = pickAmount; break;
|
||||
case 2: Scratch2 = pickAmount; break;
|
||||
case 3: Scratch3 = pickAmount; break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
CheckScratches();
|
||||
return true;
|
||||
}
|
||||
|
||||
private int[] ReturnOdds(Mobile from)
|
||||
{
|
||||
if (from != null && from.Luck >= 1800 || (from.Luck > 1200 && Utility.RandomBool()))
|
||||
return new int[] { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6 };
|
||||
|
||||
return new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6 };
|
||||
}
|
||||
|
||||
private void DoWin()
|
||||
{
|
||||
if (Owner != null)
|
||||
Owner.PlaySound(Owner.Female ? 0x337 : 0x449);
|
||||
|
||||
if (Payout >= 100000)
|
||||
{
|
||||
new ScratcherStats(Owner, Payout, this.Type);
|
||||
|
||||
if (ScratcherLotto.Stone != null)
|
||||
{
|
||||
ScratcherLotto.Stone.InvalidateProperties();
|
||||
ScratcherLotto.Stone.UpdateSatellites();
|
||||
}
|
||||
}
|
||||
|
||||
if (Owner != null)
|
||||
Owner.SendMessage(42, "It looks like you have a winning ticket!");
|
||||
}
|
||||
|
||||
public GoldenTicket(Serial serial) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); //Version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
using Server.Network;
|
||||
using Server.Misc;
|
||||
using Server.Engines.LotterySystem;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class ScratcherGump : Gump
|
||||
{
|
||||
private const int labelColor = 88;
|
||||
|
||||
private BaseLottoTicket m_Ticket;
|
||||
private Mobile m_From;
|
||||
|
||||
public ScratcherGump(BaseLottoTicket ticket, Mobile from)
|
||||
: base(50, 50)
|
||||
{
|
||||
m_Ticket = ticket;
|
||||
m_From = from;
|
||||
int bg = GetBackGround();
|
||||
|
||||
AddBackground(50, 0, 400, 200, bg);
|
||||
|
||||
AddImage(125, 12, 0xFC4);
|
||||
AddImage(325, 12, 0xFC4);
|
||||
|
||||
AddHtml(50, 20, 400, 30, String.Format("<Center><BASEFONT SIZE=9>{0}</Center>", ScratcherLotto.GetGameType(m_Ticket.Type)), false, false);
|
||||
|
||||
if (m_Ticket.Checked && m_Ticket.Payout > 0)
|
||||
AddHtml(75, 150, 200, 20, String.Format("<Basefont Color=#FFFF00>Winnings: {0}</Basefont>", m_Ticket.Payout), false, false);
|
||||
|
||||
switch (m_Ticket.Type)
|
||||
{
|
||||
case TicketType.GoldenTicket: GoldTicket(); break;
|
||||
case TicketType.CrazedCrafting: CrazedCrafting(); break;
|
||||
case TicketType.SkiesTheLimit: SkiesTheLimit(); break;
|
||||
}
|
||||
|
||||
AddHtml(75, 170, 350, 20, String.Format("<Basefont Size=2>Lotto Association of {0}, All Rights Reserved</Basefont>", ServerList.ServerName), false, false);
|
||||
}
|
||||
|
||||
private void GoldTicket()
|
||||
{
|
||||
int yStart = 90;
|
||||
|
||||
if (m_Ticket.Scratch1 == 0)
|
||||
AddButton(80, yStart, 0x98B, 0x98B, 1, GumpButtonType.Reply, 0);
|
||||
else if (m_Ticket.Scratch1 == 2)
|
||||
AddHtml(60, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#FFFF00><Center>Free</Center></Basefont>"), false, false);
|
||||
else
|
||||
{
|
||||
string num = String.Format("{0:##,###,###}", m_Ticket.Scratch1);
|
||||
AddHtml(60, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#FFFF00><Center>{0}</Center></Basefont>", num), false, false);
|
||||
}
|
||||
|
||||
if (m_Ticket.Scratch2 == 0)
|
||||
AddButton(220, yStart, 0x98B, 0x98B, 2, GumpButtonType.Reply, 0);
|
||||
else if (m_Ticket.Scratch2 == 2)
|
||||
AddHtml(200, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#FFFF00><Center>Free</Center></Basefont>"), false, false);
|
||||
else
|
||||
{
|
||||
string num = String.Format("{0:##,###,###}", m_Ticket.Scratch2);
|
||||
AddHtml(200, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#FFFF00><Center>{0}</Center></Basefont>", num), false, false);
|
||||
}
|
||||
|
||||
if (m_Ticket.Scratch3 == 0)
|
||||
AddButton(360, yStart, 0x98B, 0x98B, 3, GumpButtonType.Reply, 0);
|
||||
else if (m_Ticket.Scratch3 == 2)
|
||||
AddHtml(340, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#FFFF00><Center>Free</Center></Basefont>"), false, false);
|
||||
else
|
||||
{
|
||||
string num = String.Format("{0:##,###,###}", m_Ticket.Scratch3);
|
||||
AddHtml(340, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#FFFF00><Center>{0}</Center></Basefont>", num), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void CrazedCrafting()
|
||||
{
|
||||
int yStart = 75;
|
||||
|
||||
AddImage(70, yStart - 10, 0x589);
|
||||
AddImage(210, yStart - 10, 0x589);
|
||||
AddImage(350, yStart - 10, 0x589);
|
||||
|
||||
CrazedCrafting ticket = null;
|
||||
|
||||
if (m_Ticket is CrazedCrafting)
|
||||
ticket = (CrazedCrafting)m_Ticket;
|
||||
|
||||
if (ticket != null)
|
||||
{
|
||||
if (m_Ticket.Scratch1 == 0)
|
||||
AddButton(79, yStart, 0x15C3, 0x15C4, 1, GumpButtonType.Reply, 0);
|
||||
else if (m_Ticket.Scratch1 == 2)
|
||||
AddHtml(71, yStart + 20, 80, 20, String.Format("<Basefont Size=6 Color=#FFFF00><Center>Free</Center></Basefont>"), false, false);
|
||||
else
|
||||
{
|
||||
bool wildCard = false;
|
||||
foreach (int num in ticket.WildCards)
|
||||
{
|
||||
if (m_Ticket.Scratch1 == num)
|
||||
{
|
||||
AddImage(80, yStart, num, 2);
|
||||
wildCard = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wildCard)
|
||||
{
|
||||
string value = String.Format("{0:##,###,###}", ticket.Scratch1);
|
||||
AddHtml(71, yStart + 20, 80, 20, String.Format("<Basefont Size=6 Color=#FFFF00><Center>{0}</Center></Basefont>", value), false, false);
|
||||
AddImage(80, yStart, 0x15AA, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Ticket.Scratch2 == 0)
|
||||
AddButton(219, yStart, 0x15C3, 0x15C4, 2, GumpButtonType.Reply, 0);
|
||||
else if (m_Ticket.Scratch2 == 2)
|
||||
AddHtml(211, yStart + 20, 80, 20, String.Format("<Basefont Size=6 Color=#FFFF00><Center>Free</Center></Basefont>"), false, false);
|
||||
else
|
||||
{
|
||||
bool wildCard = false;
|
||||
foreach (int num in ticket.WildCards)
|
||||
{
|
||||
if (m_Ticket.Scratch2 == num)
|
||||
{
|
||||
AddImage(220, yStart, num, 2);
|
||||
wildCard = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wildCard)
|
||||
{
|
||||
string value = String.Format("{0:##,###,###}", ticket.Scratch2);
|
||||
AddHtml(211, yStart + 20, 80, 20, String.Format("<Basefont Size=6 Color=#FFFF00><Center>{0}</Center></Basefont>", value), false, false);
|
||||
AddImage(220, yStart, 0x15AA, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Ticket.Scratch3 == 0)
|
||||
AddButton(359, yStart, 0x15C3, 0x15C4, 3, GumpButtonType.Reply, 0);
|
||||
else if (m_Ticket.Scratch3 == 2)
|
||||
AddHtml(351, yStart + 20, 80, 20, String.Format("<Basefont Size=6 Color=#FFFF00><Center>Free</Center></Basefont>"), false, false);
|
||||
else
|
||||
{
|
||||
bool wildCard = false;
|
||||
foreach (int num in ticket.WildCards)
|
||||
{
|
||||
if (m_Ticket.Scratch3 == num)
|
||||
{
|
||||
AddImage(360, yStart, num, 2);
|
||||
wildCard = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wildCard)
|
||||
{
|
||||
string value = String.Format("{0:##,###,###}", ticket.Scratch3);
|
||||
AddHtml(351, yStart + 20, 80, 20, String.Format("<Basefont Size=6 Color=#FFFF00><Center>{0}</Center></Basefont>", value), false, false);
|
||||
AddImage(360, yStart, 0x15AA, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml(110, yStart, 80, 20, "<Basefont Size=6 Color=#FFFF00><Center>Void</Center></Basefont>", false, false);
|
||||
AddHtml(250, yStart, 80, 20, "<Basefont Size=6 Color=#FFFF00><Center>Void</Center></Basefont>", false, false);
|
||||
AddHtml(250, yStart, 80, 20, "<Basefont Size=6 Color=#FFFF00><Center>Void</Center></Basefont>", false, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void SkiesTheLimit()
|
||||
{
|
||||
int yStart = 90;
|
||||
|
||||
if (m_Ticket.Scratch1 == 0)
|
||||
AddButton(80, yStart, 0x98B, 0x98B, 1, GumpButtonType.Reply, 0);
|
||||
else if (m_Ticket.Scratch1 == 2)
|
||||
AddHtml(60, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#0000FF><Center>Free</Center></Basefont>"), false, false);
|
||||
else if (m_Ticket.Scratch1 == 1)
|
||||
{
|
||||
AddImage(100, yStart - 5, 0x265A);
|
||||
AddItem(98, yStart, 0xEEF);
|
||||
AddItem(108, yStart, 0xEEF);
|
||||
}
|
||||
else
|
||||
{
|
||||
string value = String.Format("{0:##,###,###}", m_Ticket.Scratch1);
|
||||
AddHtml(60, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#0000FF><Center>{0}</Center></Basefont>", value), false, false);
|
||||
}
|
||||
|
||||
if (m_Ticket.Scratch2 == 0)
|
||||
AddButton(220, yStart, 0x98B, 0x98B, 2, GumpButtonType.Reply, 0);
|
||||
else if (m_Ticket.Scratch2 == 2)
|
||||
AddHtml(200, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#0000FF><Center>Free</Center></Basefont>"), false, false);
|
||||
else if (m_Ticket.Scratch2 == 1)
|
||||
{
|
||||
AddImage(240, yStart - 5, 0x265A);
|
||||
AddItem(238, yStart, 0xEEF);
|
||||
AddItem(248, yStart, 0xEEF);
|
||||
}
|
||||
else
|
||||
{
|
||||
string value = String.Format("{0:##,###,###}", m_Ticket.Scratch2);
|
||||
AddHtml(200, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#0000FF><Center>{0}</Center></Basefont>", value), false, false);
|
||||
}
|
||||
|
||||
if (m_Ticket.Scratch3 == 0)
|
||||
AddButton(360, yStart, 0x98B, 0x98B, 3, GumpButtonType.Reply, 0);
|
||||
else if (m_Ticket.Scratch3 == 2)
|
||||
AddHtml(340, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#0000FF><Center>Free</Center></Basefont>"), false, false);
|
||||
else if (m_Ticket.Scratch3 == 1)
|
||||
{
|
||||
AddImage(380, yStart - 5, 0x265A);
|
||||
AddItem(378, yStart, 0xEEF);
|
||||
AddItem(388, yStart, 0xEEF);
|
||||
}
|
||||
else
|
||||
{
|
||||
string value = String.Format("{0:##,###,###}", m_Ticket.Scratch3);
|
||||
AddHtml(340, yStart, 100, 60, String.Format("<Basefont Size=8 COLOR=#0000FF><Center>{0}</Center></Basefont>", value), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, RelayInfo info)
|
||||
{
|
||||
int res = info.ButtonID;
|
||||
|
||||
if (res < 4 && res > 0)
|
||||
{
|
||||
if (!m_Ticket.DoScratch(res, m_From))
|
||||
m_From.SendMessage("Put some elbow greese in it next time!");
|
||||
|
||||
m_From.PlaySound(0x249);
|
||||
m_From.SendGump(new ScratcherGump(m_Ticket, m_From));
|
||||
}
|
||||
}
|
||||
|
||||
private int GetBackGround()
|
||||
{
|
||||
if (m_Ticket != null)
|
||||
{
|
||||
switch (m_Ticket.Type)
|
||||
{
|
||||
case TicketType.CrazedCrafting: return 0x2454;
|
||||
case TicketType.SkiesTheLimit: return 0x2486;
|
||||
case TicketType.GoldenTicket: return 0xDAC;
|
||||
}
|
||||
}
|
||||
|
||||
return 9270;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,416 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
using Server.Misc;
|
||||
using Server.Network;
|
||||
using Server.Engines.LotterySystem;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class ScratcherStoneGump : Gump
|
||||
{
|
||||
private const int labelColor = 2106;
|
||||
private const int GMColor = 33;
|
||||
|
||||
private ScratcherLotto m_Stone;
|
||||
private Mobile m_From;
|
||||
|
||||
public ScratcherStoneGump(ScratcherLotto stone, Mobile from) : this( stone, from, true)
|
||||
{
|
||||
}
|
||||
|
||||
public ScratcherStoneGump(ScratcherLotto stone, Mobile from, bool quickScratch)
|
||||
: base(50, 50)
|
||||
{
|
||||
m_Stone = stone;
|
||||
m_From = from;
|
||||
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(50, 0, 350, 350, 9250);
|
||||
|
||||
AddPage(1);
|
||||
|
||||
if (m_From.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
AddLabel(70, 265, GMColor, String.Format("Gold Sink: {0}", m_Stone.GoldSink));
|
||||
|
||||
if (ScratcherLotto.Stone != null)
|
||||
{
|
||||
AddLabel(230, 265, GMColor, "Next Stats Reset:");
|
||||
AddLabel(230, 295, GMColor, String.Format("{0}", ScratcherLotto.Stone.StatStart + ScratcherLotto.Stone.WipeStats));
|
||||
}
|
||||
|
||||
AddLabel(105, 295, GMColor, m_Stone.IsActive ? "Set Game Inactive" : "Set Active");
|
||||
AddButton(70, 295, 0xFBD, 0xFBF, 6, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
AddHtml(70, 20, 300, 16, String.Format("<Center>{0} Lottery Scratchers</Center>", ServerList.ServerName), false, false);
|
||||
|
||||
#region Quick/Normal Scratch Radio
|
||||
AddLabel(110, 40, labelColor, "Quick Scratch");
|
||||
AddLabel(110, 73, labelColor, "Normal Scratch");
|
||||
|
||||
AddRadio(70, 40, 0x25F8, 0x25FB, quickScratch, 0);
|
||||
AddRadio(70, 70, 0x25F8, 0x25FB, !quickScratch, 1);
|
||||
#endregion
|
||||
|
||||
#region Ticket Info
|
||||
AddLabel(60, 117, labelColor, "Buy Ticket");
|
||||
AddLabel(230, 117, labelColor, "Cost");
|
||||
AddLabel(350, 117, labelColor, "Stats");
|
||||
|
||||
AddLabel(110, 140, 0, "Golden Ticket");
|
||||
if (ScratcherLotto.Stone != null && ScratcherLotto.Stone.IsActive)
|
||||
{
|
||||
AddButton(70, 140, 0xFBD, 0xFBF, (int)TicketType.GoldenTicket, GumpButtonType.Reply, 0);
|
||||
AddLabel(230, 140, 0, GoldenTicket.TicketCost.ToString());
|
||||
AddButton(350, 140, 0xFA5, 0xFA7, 0, GumpButtonType.Page, (int)TicketType.GoldenTicket + 1);
|
||||
}
|
||||
else
|
||||
AddLabel(230, 140, GMColor, "Offline");
|
||||
|
||||
AddLabel(110, 170, 0, "Crazed Crafting");
|
||||
if (ScratcherLotto.Stone != null && ScratcherLotto.Stone.IsActive)
|
||||
{
|
||||
AddButton(70, 170, 0xFBD, 0xFBF, (int)TicketType.CrazedCrafting, GumpButtonType.Reply, 0);
|
||||
AddLabel(230, 170, 0, CrazedCrafting.TicketCost.ToString());
|
||||
AddButton(350, 170, 0xFA5, 0xFA7, 0, GumpButtonType.Page, (int)TicketType.CrazedCrafting + 1);
|
||||
}
|
||||
else
|
||||
AddLabel(230, 170, GMColor, "Offline");
|
||||
|
||||
AddLabel(110, 200, 0, "Skies the Limit");
|
||||
if (ScratcherLotto.Stone != null && ScratcherLotto.Stone.IsActive)
|
||||
{
|
||||
AddButton(70, 200, 0xFBD, 0xFBF, (int)TicketType.SkiesTheLimit, GumpButtonType.Reply, 0);
|
||||
AddLabel(230, 200, 0, SkiesTheLimit.TicketCost.ToString());
|
||||
AddButton(350, 200, 0xFA5, 0xFA7, 0, GumpButtonType.Page, (int)TicketType.SkiesTheLimit + 1);
|
||||
}
|
||||
else
|
||||
AddLabel(230, 200, GMColor, "Offline");
|
||||
|
||||
AddLabel(110, 230, 0, "Powerball");
|
||||
if (PowerBall.Instance != null && PowerBall.Game != null && !PowerBall.Game.Deleted && PowerBall.Instance.CanBuyTickets)
|
||||
{
|
||||
AddLabel(230, 230, 0, PowerBall.Game != null ? PowerBall.Game.TicketCost.ToString() : "");
|
||||
AddButton(70, 230, 0xFBD, 0xFBF, (int)TicketType.Powerball, GumpButtonType.Reply, 0);
|
||||
}
|
||||
else
|
||||
AddLabel(230, 230, GMColor, "Offline");
|
||||
|
||||
#endregion
|
||||
|
||||
AddPage(2); //Golden Ticket Stats
|
||||
|
||||
AddLabel(70, 20, labelColor, "Golden Ticket Top 10 Winners");
|
||||
|
||||
int index = 0;
|
||||
for(int i = ScratcherStats.Stats.Count - 1; i >= 0; --i)
|
||||
{
|
||||
if (ScratcherStats.Stats[i].Type == TicketType.GoldenTicket)
|
||||
{
|
||||
string num = String.Format("{0:##,###,###}", ScratcherStats.Stats[i].Payout);
|
||||
string name = "unknown player";
|
||||
|
||||
if (ScratcherStats.Stats[i].Winner != null)
|
||||
name = ScratcherStats.Stats[i].Winner.Name;
|
||||
|
||||
AddHtml(70, 50 + (index * 25), 100, 16, String.Format("<Basefont Color=#FFFFFF>{0}</Basefont>", name), false, false);
|
||||
AddHtml(150, 50 + (index * 25), 100, 16, String.Format("<Basefont Color=#FFFFFF>{0}</Basefont>", num), false, false);
|
||||
AddHtml(270, 50 + (index * 25), 100, 16, String.Format("<Basefont Color=#FFFFFF>{0}</Basefont>", ScratcherStats.Stats[i].WinTime), false, false);
|
||||
index++;
|
||||
}
|
||||
|
||||
if (index >= 9)
|
||||
break;
|
||||
}
|
||||
|
||||
AddButton(350, 300, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1);
|
||||
|
||||
AddPage(3); //Crazed Crafting Stats
|
||||
|
||||
|
||||
AddLabel(70, 20, labelColor, "Crazed Crafting Highest Winners");
|
||||
|
||||
index = 0;
|
||||
for (int i = ScratcherStats.Stats.Count - 1; i >= 0; --i)
|
||||
{
|
||||
if (ScratcherStats.Stats[i].Type == TicketType.CrazedCrafting)
|
||||
{
|
||||
string num = String.Format("{0:##,###,###}", ScratcherStats.Stats[i].Payout);
|
||||
string name = "unknown player";
|
||||
|
||||
if (ScratcherStats.Stats[i].Winner != null)
|
||||
name = ScratcherStats.Stats[i].Winner.Name;
|
||||
|
||||
AddHtml(70, 50 + (index * 25), 100, 16, String.Format("<Basefont Color=#FFFFFF>{0}</Basefont>", name), false, false);
|
||||
AddHtml(150, 50 + (index * 25), 100, 16, String.Format("<Basefont Color=#FFFFFF>{0}</Basefont>", num), false, false);
|
||||
AddHtml(270, 50 + (index * 25), 100, 16, String.Format("<Basefont Color=#FFFFFF>{0}</Basefont>", ScratcherStats.Stats[i].WinTime), false, false);
|
||||
index++;
|
||||
}
|
||||
|
||||
if (index >= 9)
|
||||
break;
|
||||
}
|
||||
|
||||
AddButton(350, 300, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1);
|
||||
|
||||
AddPage(4); //Skies the Limit Stats
|
||||
|
||||
AddLabel(70, 20, labelColor, "Skies the Limit");
|
||||
AddLabel(70, 300, labelColor, String.Format("Progressive Jackpot: {0}", m_Stone.SkiesProgressive));
|
||||
|
||||
index = 0;
|
||||
for (int i = ScratcherStats.Stats.Count - 1; i >= 0; --i)
|
||||
{
|
||||
if (ScratcherStats.Stats[i].Type == TicketType.SkiesTheLimit)
|
||||
{
|
||||
string num = String.Format("{0:##,###,###}", ScratcherStats.Stats[i].Payout);
|
||||
string name = "unknown player";
|
||||
|
||||
if (ScratcherStats.Stats[i].Winner != null)
|
||||
name = ScratcherStats.Stats[i].Winner.Name;
|
||||
|
||||
AddHtml(70, 50 + (index * 25), 100, 16, String.Format("<Basefont Color=#FFFFFF>{0}</Basefont>", name), false, false);
|
||||
AddHtml(150, 50 + (index * 25), 100, 16, String.Format("<Basefont Color=#FFFFFF>{0}</Basefont>", num), false, false);
|
||||
AddHtml(270, 50 + (index * 25), 100, 16, String.Format("<Basefont Color=#FFFFFF>{0}</Basefont>", ScratcherStats.Stats[i].WinTime), false, false);
|
||||
index++;
|
||||
}
|
||||
|
||||
if (index >= 9)
|
||||
break;
|
||||
}
|
||||
|
||||
AddButton(350, 300, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1);
|
||||
}
|
||||
|
||||
private BaseLottoTicket FindFreeTicket(Container pack, Type type)
|
||||
{
|
||||
if (pack == null)
|
||||
return null;
|
||||
|
||||
Item[] items = pack.FindItemsByType(typeof(BaseLottoTicket));
|
||||
|
||||
foreach (Item item in items)
|
||||
{
|
||||
if (item is BaseLottoTicket && item.GetType() == type && ((BaseLottoTicket)item).FreeTicket)
|
||||
return (BaseLottoTicket)item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, RelayInfo info)
|
||||
{
|
||||
if (m_From == null)
|
||||
return;
|
||||
|
||||
Container pack = m_From.Backpack;
|
||||
bool quickScratch = info.IsSwitched(0);
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
default:
|
||||
case 0: break;
|
||||
case 1: //Golden Ticket
|
||||
{
|
||||
int cost = GoldenTicket.TicketCost;
|
||||
|
||||
if (ScratcherLotto.Stone != null && ScratcherLotto.Stone.IsActive)
|
||||
{
|
||||
BaseLottoTicket free = FindFreeTicket(pack, typeof(GoldenTicket));
|
||||
|
||||
if (free != null && free is GoldenTicket)
|
||||
{
|
||||
free.Delete();
|
||||
m_From.SendMessage("You purchase a lottery ticket with your free ticket.", cost);
|
||||
|
||||
DropItem(new GoldenTicket(m_From, quickScratch));
|
||||
}
|
||||
else if (pack != null && pack.GetAmount(typeof(Gold)) >= cost)
|
||||
{
|
||||
pack.ConsumeTotal(typeof(Gold), cost);
|
||||
m_From.SendMessage("You purchase a lottery ticket with {0} gold from your backpack.", cost);
|
||||
|
||||
DropItem(new GoldenTicket(m_From, quickScratch));
|
||||
|
||||
if (m_Stone != null)
|
||||
m_Stone.GoldSink += cost;
|
||||
}
|
||||
else if (Banker.Withdraw(m_From, cost, true))
|
||||
{
|
||||
m_From.SendMessage("You purchase a lottery ticket with {0} gold from your bankbox.", cost);
|
||||
|
||||
DropItem(new GoldenTicket(m_From, quickScratch));
|
||||
|
||||
if (m_Stone != null)
|
||||
m_Stone.GoldSink += cost;
|
||||
}
|
||||
else
|
||||
m_From.SendLocalizedMessage(500191); //Begging thy pardon, but thy bank account lacks these funds.
|
||||
}
|
||||
m_From.SendGump(new ScratcherStoneGump(m_Stone, m_From, quickScratch));
|
||||
break;
|
||||
}
|
||||
case 2: //Crazed Crafting
|
||||
{
|
||||
int cost = CrazedCrafting.TicketCost;
|
||||
|
||||
if (ScratcherLotto.Stone != null && ScratcherLotto.Stone.IsActive)
|
||||
{
|
||||
BaseLottoTicket free = FindFreeTicket(pack, typeof(CrazedCrafting));
|
||||
if (free != null && free is CrazedCrafting)
|
||||
{
|
||||
free.Delete();
|
||||
m_From.SendMessage("You purchase a lottery ticket with your free ticket.", cost);
|
||||
|
||||
DropItem(new CrazedCrafting(m_From, quickScratch));
|
||||
}
|
||||
else if (pack != null && pack.GetAmount(typeof(Gold)) >= cost)
|
||||
{
|
||||
pack.ConsumeTotal(typeof(Gold), cost);
|
||||
m_From.SendMessage("You purchase a lottery ticket with {0} gold from your backpack.", cost);
|
||||
|
||||
DropItem(new CrazedCrafting(m_From, quickScratch));
|
||||
|
||||
if (m_Stone != null)
|
||||
m_Stone.GoldSink += cost;
|
||||
}
|
||||
else if (Banker.Withdraw(m_From, cost, true))
|
||||
{
|
||||
m_From.SendMessage("You purchase a lottery ticket with {0} gold from your bankbox.", cost);
|
||||
|
||||
DropItem(new CrazedCrafting(m_From, quickScratch));
|
||||
|
||||
if (m_Stone != null)
|
||||
m_Stone.GoldSink += cost;
|
||||
}
|
||||
else
|
||||
m_From.SendLocalizedMessage(500191); //Begging thy pardon, but thy bank account lacks these funds.
|
||||
}
|
||||
m_From.SendGump(new ScratcherStoneGump(m_Stone, m_From, quickScratch));
|
||||
break;
|
||||
}
|
||||
case 3: //Skies the Limit
|
||||
{
|
||||
int cost = SkiesTheLimit.TicketCost;
|
||||
|
||||
if (ScratcherLotto.Stone != null && ScratcherLotto.Stone.IsActive)
|
||||
{
|
||||
BaseLottoTicket free = FindFreeTicket(pack, typeof(SkiesTheLimit));
|
||||
if (free != null && free is SkiesTheLimit)
|
||||
{
|
||||
free.Delete();
|
||||
m_From.SendMessage("You purchase a lottery ticket with your free ticket.", cost);
|
||||
|
||||
DropItem(new SkiesTheLimit(m_From, quickScratch));
|
||||
}
|
||||
else if (pack != null && pack.GetAmount(typeof(Gold)) >= cost)
|
||||
{
|
||||
pack.ConsumeTotal(typeof(Gold), cost);
|
||||
m_From.SendMessage("You purchase a lottery ticket with {0} gold from your backpack.", cost);
|
||||
|
||||
DropItem(new SkiesTheLimit(m_From, quickScratch));
|
||||
|
||||
if (m_Stone != null)
|
||||
m_Stone.GoldSink += cost;
|
||||
|
||||
m_Stone.SkiesProgressive += cost / 10;
|
||||
}
|
||||
else if (Banker.Withdraw(m_From, cost, true))
|
||||
{
|
||||
m_From.SendMessage("You purchase a lottery ticket with {0} gold from your bankbox.", cost);
|
||||
|
||||
DropItem(new SkiesTheLimit(m_From, quickScratch));
|
||||
|
||||
if (m_Stone != null)
|
||||
m_Stone.GoldSink += cost;
|
||||
|
||||
m_Stone.SkiesProgressive += cost / 10;
|
||||
}
|
||||
else
|
||||
m_From.SendLocalizedMessage(500191); //Begging thy pardon, but thy bank account lacks these funds.
|
||||
}
|
||||
m_From.SendGump(new ScratcherStoneGump(m_Stone, m_From, quickScratch));
|
||||
break;
|
||||
}
|
||||
case 4: //PowerBall Ticket
|
||||
{
|
||||
if (PowerBall.Instance != null && PowerBall.Game != null && !PowerBall.Game.Deleted && PowerBall.Instance.CanBuyTickets)
|
||||
{
|
||||
int cost = PowerBall.Game.TicketCost;
|
||||
|
||||
if (pack != null && pack.GetAmount(typeof(Gold)) >= cost)
|
||||
{
|
||||
pack.ConsumeTotal(typeof(Gold), cost);
|
||||
m_From.SendMessage("You purchase a Powerball ticket with {0} gold from your backpack.", cost);
|
||||
|
||||
DropItem(new PowerBallTicket(m_From, PowerBall.Game));
|
||||
|
||||
if (PowerBall.Instance != null)
|
||||
PowerBall.Instance.Profit += cost;
|
||||
}
|
||||
else if (Banker.Withdraw(m_From, cost, true))
|
||||
{
|
||||
m_From.SendMessage("You purchase a Powerball ticket with {0} gold from your bankbox.", cost);
|
||||
|
||||
DropItem(new PowerBallTicket(m_From, PowerBall.Game));
|
||||
|
||||
if (PowerBall.Instance != null)
|
||||
PowerBall.Instance.Profit += cost;
|
||||
}
|
||||
else
|
||||
m_From.SendLocalizedMessage(500191); //Begging thy pardon, but thy bank account lacks these funds.
|
||||
}
|
||||
|
||||
m_From.SendGump(new ScratcherStoneGump(m_Stone, m_From, quickScratch));
|
||||
break;
|
||||
}
|
||||
|
||||
case 5:
|
||||
{
|
||||
if (PowerBall.Game != null)
|
||||
m_From.SendGump(new PowerBallStatsGump(PowerBall.Game, m_From));
|
||||
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
if (m_From.AccessLevel == AccessLevel.Player)
|
||||
break;
|
||||
|
||||
if (m_Stone != null)
|
||||
{
|
||||
if (m_Stone.IsActive)
|
||||
{
|
||||
m_From.SendMessage("set to inactive.");
|
||||
m_Stone.IsActive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_From.SendMessage("set to active.");
|
||||
m_Stone.IsActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_From.SendGump(new ScratcherStoneGump(m_Stone, m_From, quickScratch));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DropItem(Item item)
|
||||
{
|
||||
Container pack = m_From.Backpack;
|
||||
|
||||
if (pack == null || !pack.TryDropItem(m_From, item, false))
|
||||
{
|
||||
m_From.SendMessage("Your pack is full, so the ticket has been placed in your bank box!");
|
||||
m_From.BankBox.DropItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Scripts/SubSystem/LotterySystem/Scratchers/ReadMe.txt
Normal file
36
Scripts/SubSystem/LotterySystem/Scratchers/ReadMe.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
Lotto Scratchers
|
||||
|
||||
All scratchers derive from BaseLottoTicket class. You can adjust the odds in the ReturnOdds(...)
|
||||
function of each ticket type. Player luck effects Golden Ticket and Skies the Limit. Player
|
||||
Crafting skill (highest skill) effects Crazed Crafting. Luck/craft skill bumps do not increase
|
||||
the chace of a win, but increased the odds of a higher prize per scratch.
|
||||
|
||||
First, place LottoScratcher, this is the item that controls the stats, progressive jackpots, etc.
|
||||
You can then place LottoScratcherSatellite that acts as the LottoScratcher item, like the PowerBallSatellite.
|
||||
|
||||
ScratcherLotto.cs -
|
||||
DeleteTicketOnLoss defaulted to true. When true, and you purchase a ticket as a quick scratch,
|
||||
the ticket will auto delete if it's not a winner.
|
||||
|
||||
Golden Ticket
|
||||
- Traditional lotto scratch ticket
|
||||
- Prizes range from 1000 to 1,000,000
|
||||
- 1200+ luck and a 50% chance odds will go in favor of higher prize
|
||||
- 1800+ odds will go in favor of a higher price
|
||||
|
||||
Crazed Crafting
|
||||
- This has a lower standard payout, however, wild cards can increase the chances for a win
|
||||
- 2 of the same wild cards give a 2x reward multiplier
|
||||
- 3 of the same wild cards, which always will result in a jackpot, give a 10x multiplier
|
||||
- prizes range from 2,500 to 250,000, or 2,500,000 with a wildcard multiplier
|
||||
- 8% flat chance to get a wildcard
|
||||
|
||||
Skies the Limit
|
||||
- Progressive lotto scrather
|
||||
- Progressive gold amount is saved in the ScratherLotto item
|
||||
- Resets to 500,000 with a win
|
||||
- 3 Treasure chests win the progressive
|
||||
- Normal payout is from 1,000 to 500,000
|
||||
|
||||
Stats reset every 90 days
|
||||
|
||||
261
Scripts/SubSystem/LotterySystem/Scratchers/ScratcherLotto.cs
Normal file
261
Scripts/SubSystem/LotterySystem/Scratchers/ScratcherLotto.cs
Normal file
@@ -0,0 +1,261 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.LotterySystem
|
||||
{
|
||||
public class ScratcherLotto : Item
|
||||
{
|
||||
private bool m_DeleteTicket; //Deletes ticket on quick scratch if it is a losing ticket
|
||||
private bool m_Active;
|
||||
private int m_GoldSink; //Eye candy for GM's!!!
|
||||
private int m_SkiesProgressive; //Progressive for Skies the Limit
|
||||
private DateTime m_StatStart;
|
||||
private TimeSpan m_WipeStats;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool DeleteTicketOnLoss { get { return m_DeleteTicket; } set { m_DeleteTicket = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool IsActive { get { return m_Active; } set { m_Active = value; InvalidateProperties(); UpdateSatellites(); } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int GoldSink { get { return m_GoldSink; } set { m_GoldSink = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int SkiesProgressive { get { return m_SkiesProgressive; } set { m_SkiesProgressive = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public DateTime StatStart { get { return m_StatStart; } set { m_StatStart = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TimeSpan WipeStats { get { return m_WipeStats; } set { m_WipeStats = value; } }
|
||||
|
||||
public bool CanWipe { get { return m_StatStart + m_WipeStats < DateTime.Now; } }
|
||||
|
||||
private static ScratcherLotto m_Stone; //Instanced Stone for easy access
|
||||
public static ScratcherLotto Stone{ get { return m_Stone; } set { m_Stone = value; } }
|
||||
|
||||
private static List<ScratcherLottoSatellite> m_SatList = new List<ScratcherLottoSatellite>();
|
||||
public static List<ScratcherLottoSatellite> SatList { get { return m_SatList; } }
|
||||
|
||||
[Constructable]
|
||||
public ScratcherLotto()
|
||||
: base(0xED4)
|
||||
{
|
||||
if (CheckForScratcherStone())
|
||||
{
|
||||
Console.WriteLine("You can only have one Lotto Scratcher Stone Item.");
|
||||
Delete();
|
||||
return;
|
||||
}
|
||||
|
||||
Name = "Lottery Scratch Tickets";
|
||||
Hue = Utility.RandomSlimeHue();
|
||||
Movable = false;
|
||||
m_Active = true;
|
||||
m_Stone = this;
|
||||
m_SkiesProgressive = 500000;
|
||||
m_DeleteTicket = true;
|
||||
m_WipeStats = TimeSpan.FromDays(90);
|
||||
m_StatStart = DateTime.Now;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!m_Active && from.AccessLevel == AccessLevel.Player)
|
||||
from.SendMessage("Scratch tickets are currenlty inactive at this time.");
|
||||
else if (from.InRange(Location, 3))
|
||||
{
|
||||
if (from.HasGump(typeof(ScratcherStoneGump)))
|
||||
from.CloseGump(typeof(ScratcherStoneGump));
|
||||
|
||||
from.SendGump(new ScratcherStoneGump(this, from));
|
||||
}
|
||||
else if (from.AccessLevel > AccessLevel.Player)
|
||||
from.SendGump( new PropertiesGump( from, this ) );
|
||||
else
|
||||
from.SendLocalizedMessage(500446); // That is too far away.
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (!m_Active)
|
||||
list.Add(1060658, "Status\tOffline");
|
||||
else
|
||||
list.Add(1060658, "Status\tActive");
|
||||
|
||||
if (ScratcherStats.Stats.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
int index = ScratcherStats.Stats.Count - 1;
|
||||
string jackpotAmount = String.Format("{0:##,###,###}", ScratcherStats.Stats[index].Payout);
|
||||
|
||||
list.Add(1060659, "Last Big Win\t{0}", ScratcherStats.Stats[index].Winner.Name);
|
||||
list.Add(1060660, "Date\t{0}", ScratcherStats.Stats[index].WinTime);
|
||||
list.Add(1060661, "Amount\t{0}", jackpotAmount);
|
||||
list.Add(1060662, "Game\t{0}", GetGameType(ScratcherStats.Stats[index].Type));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static string GetGameType(TicketType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
default: return "";
|
||||
case TicketType.GoldenTicket: return "Golden Ticket";
|
||||
case TicketType.CrazedCrafting: return "Crazed Crafting";
|
||||
case TicketType.SkiesTheLimit: return "Skies the Limit";
|
||||
case TicketType.Powerball: return "Powerball";
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoProgressiveMessage(Mobile winner, int amount)
|
||||
{
|
||||
string name = "Somebody";
|
||||
|
||||
if (winner != null)
|
||||
name = winner.Name;
|
||||
|
||||
foreach (NetState netState in NetState.Instances)
|
||||
{
|
||||
Mobile m = netState.Mobile;
|
||||
if (m != null)
|
||||
{
|
||||
m.PlaySound(1460);
|
||||
m.SendMessage(33, "{0} has won {1} gold in the Skies the Limit Progressive Scratcher!", name, amount.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DoWipe()
|
||||
{
|
||||
if (ScratcherStats.Stats != null)
|
||||
ScratcherStats.Stats.Clear();
|
||||
|
||||
UpdateSatellites();
|
||||
InvalidateProperties();
|
||||
m_StatStart = DateTime.Now;
|
||||
}
|
||||
|
||||
public void UpdateSatellites()
|
||||
{
|
||||
foreach (ScratcherLottoSatellite sat in m_SatList)
|
||||
{
|
||||
if (sat != null && !sat.Deleted)
|
||||
sat.InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public ScratcherLotto(Serial serial) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)2); //Version
|
||||
|
||||
writer.Write(m_WipeStats);
|
||||
writer.Write(m_StatStart);
|
||||
writer.Write(m_DeleteTicket);
|
||||
|
||||
writer.Write(m_Active);
|
||||
writer.Write(m_GoldSink);
|
||||
writer.Write(m_SkiesProgressive);
|
||||
|
||||
writer.Write(ScratcherStats.Stats.Count);
|
||||
for (int i = 0; i < ScratcherStats.Stats.Count; ++i)
|
||||
{
|
||||
ScratcherStats.Stats[i].Serialize(writer);
|
||||
}
|
||||
|
||||
if (CanWipe)
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5), new TimerCallback(DoWipe));
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
m_WipeStats = reader.ReadTimeSpan();
|
||||
m_StatStart = reader.ReadDateTime();
|
||||
goto case 1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
m_DeleteTicket = reader.ReadBool();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Active = reader.ReadBool();
|
||||
m_GoldSink = reader.ReadInt();
|
||||
m_SkiesProgressive = reader.ReadInt();
|
||||
|
||||
int statsCount = reader.ReadInt();
|
||||
for (int i = 0; i < statsCount; i++)
|
||||
{
|
||||
new ScratcherStats(reader);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_Stone = this;
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
for (int i = 0; i < m_SatList.Count; ++i)
|
||||
{
|
||||
if (m_SatList[i] != null && !m_SatList[i].Deleted)
|
||||
m_SatList[i].Delete();
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckForScratcherStone()
|
||||
{
|
||||
foreach (Item item in World.Items.Values)
|
||||
{
|
||||
if (item is ScratcherLotto && !item.Deleted && item != this)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddToSatList(ScratcherLottoSatellite satellite)
|
||||
{
|
||||
if (m_SatList != null && !m_SatList.Contains(satellite))
|
||||
m_SatList.Add(satellite);
|
||||
}
|
||||
|
||||
public void RemoveFromSatList(ScratcherLottoSatellite satellite)
|
||||
{
|
||||
if (m_SatList != null && m_SatList.Contains(satellite))
|
||||
m_SatList.Remove(satellite);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Targeting;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.LotterySystem
|
||||
{
|
||||
public class ScratcherLottoSatellite : Item
|
||||
{
|
||||
private ScratcherLotto m_Stone;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public ScratcherLotto LottoStone { get { return m_Stone; } set { m_Stone = value; } }
|
||||
|
||||
[Constructable]
|
||||
public ScratcherLottoSatellite()
|
||||
: base(0xED4)
|
||||
{
|
||||
|
||||
Name = "Lottery Scratch Tickets";
|
||||
Hue = Utility.RandomSlimeHue();
|
||||
Movable = false;
|
||||
|
||||
if (ScratcherLotto.Stone != null)
|
||||
{
|
||||
m_Stone = ScratcherLotto.Stone;
|
||||
m_Stone.AddToSatList(this);
|
||||
}
|
||||
else Delete();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (m_Stone == null || (!m_Stone.IsActive && from.AccessLevel == AccessLevel.Player))
|
||||
from.SendMessage("Scratch tickets are currenlty inactive at this time.");
|
||||
else if (from.InRange(Location, 3))
|
||||
{
|
||||
if (from.HasGump(typeof(ScratcherStoneGump)))
|
||||
from.CloseGump(typeof(ScratcherStoneGump));
|
||||
|
||||
from.SendGump(new ScratcherStoneGump(m_Stone, from));
|
||||
}
|
||||
else if (from.AccessLevel > AccessLevel.Player)
|
||||
from.SendGump( new PropertiesGump( from, m_Stone ) );
|
||||
else
|
||||
from.SendLocalizedMessage(500446); // That is too far away.
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (m_Stone == null || !m_Stone.IsActive)
|
||||
list.Add(1060658, "Status\tOffline");
|
||||
else
|
||||
list.Add(1060658, "Status\tActive");
|
||||
|
||||
if (ScratcherStats.Stats.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
int index = ScratcherStats.Stats.Count - 1;
|
||||
string jackpotAmount = String.Format("{0:##,###,###}", ScratcherStats.Stats[index].Payout);
|
||||
|
||||
list.Add(1060659, "Last Big Win\t{0}", ScratcherStats.Stats[index].Winner.Name);
|
||||
list.Add(1060660, "Date\t{0}", ScratcherStats.Stats[index].WinTime);
|
||||
list.Add(1060661, "Amount\t{0}", jackpotAmount);
|
||||
list.Add(1060662, "Game\t{0}", ScratcherLotto.GetGameType(ScratcherStats.Stats[index].Type));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (m_Stone != null)
|
||||
m_Stone.RemoveFromSatList(this);
|
||||
|
||||
base.OnAfterDelete();
|
||||
}
|
||||
|
||||
public ScratcherLottoSatellite(Serial serial) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); //Version
|
||||
|
||||
writer.Write(m_Stone);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
m_Stone = (ScratcherLotto)reader.ReadItem();
|
||||
if (m_Stone != null)
|
||||
m_Stone.AddToSatList(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
59
Scripts/SubSystem/LotterySystem/Scratchers/ScratcherStats.cs
Normal file
59
Scripts/SubSystem/LotterySystem/Scratchers/ScratcherStats.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.LotterySystem
|
||||
{
|
||||
public class ScratcherStats
|
||||
{
|
||||
private Mobile m_Winner;
|
||||
private TicketType m_Type;
|
||||
private int m_Payout;
|
||||
private DateTime m_WinTime;
|
||||
|
||||
public Mobile Winner { get { return m_Winner; } }
|
||||
public TicketType Type { get { return m_Type; } }
|
||||
public int Payout { get { return m_Payout; } }
|
||||
public DateTime WinTime { get { return m_WinTime; } }
|
||||
|
||||
private static List<ScratcherStats> m_Stats = new List<ScratcherStats>();
|
||||
public static List<ScratcherStats> Stats { get { return m_Stats; } }
|
||||
|
||||
public ScratcherStats(Mobile winner, int amount, TicketType type) : this(winner, amount, type, DateTime.Now)
|
||||
{
|
||||
}
|
||||
|
||||
public ScratcherStats(Mobile winner, int amount, TicketType type, DateTime time)
|
||||
{
|
||||
m_Winner = winner;
|
||||
m_Type = type;
|
||||
m_Payout = amount;
|
||||
m_WinTime = time;
|
||||
|
||||
m_Stats.Add(this);
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write((int)0); //version
|
||||
|
||||
writer.Write(m_Winner);
|
||||
writer.Write((int)m_Type);
|
||||
writer.Write(m_Payout);
|
||||
writer.Write(m_WinTime);
|
||||
}
|
||||
|
||||
public ScratcherStats(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
m_Winner = reader.ReadMobile();
|
||||
m_Type = (TicketType)reader.ReadInt();
|
||||
m_Payout = reader.ReadInt();
|
||||
m_WinTime = reader.ReadDateTime();
|
||||
|
||||
m_Stats.Add(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
143
Scripts/SubSystem/LotterySystem/Scratchers/SkiesTheLimit.cs
Normal file
143
Scripts/SubSystem/LotterySystem/Scratchers/SkiesTheLimit.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
using Server;
|
||||
using System;
|
||||
using Server.Mobiles;
|
||||
using System.Collections.Generic;
|
||||
using Server.Engines.LotterySystem;
|
||||
using Server.Gumps;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class SkiesTheLimit : BaseLottoTicket
|
||||
{
|
||||
private int[] m_WinAmounts = new int[] { 1000, 10000, 50000, 100000, 500000, 1, 2};
|
||||
|
||||
public static readonly int TicketCost = 1000;
|
||||
|
||||
[Constructable]
|
||||
public SkiesTheLimit() : this(null, false)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public SkiesTheLimit(Mobile owner, bool quickScratch) : base (owner, TicketType.SkiesTheLimit, quickScratch)
|
||||
{
|
||||
Name = "skies the limit";
|
||||
LootType = LootType.Blessed;
|
||||
Hue = 0x8AB;
|
||||
|
||||
this.Type = TicketType.SkiesTheLimit;
|
||||
}
|
||||
|
||||
public override void CheckScratches()
|
||||
{
|
||||
if (Scratch1 > 0 && Scratch2 > 0 && Scratch3 > 0)
|
||||
{
|
||||
Checked = true;
|
||||
if (Scratch1 == 2 || Scratch2 == 2 || Scratch3 == 2)
|
||||
FreeTicket = true;
|
||||
else if (Scratch1 == Scratch2 && Scratch1 == Scratch3)
|
||||
{
|
||||
|
||||
int payOut = 0;
|
||||
if (Scratch1 == 2)
|
||||
payOut = 250000;
|
||||
else
|
||||
payOut = Scratch1;
|
||||
|
||||
if (ScratcherLotto.Stone != null && Scratch1 == 1)
|
||||
{
|
||||
payOut = ScratcherLotto.Stone.SkiesProgressive;
|
||||
ScratcherLotto.Stone.SkiesProgressive = 500000;
|
||||
ScratcherLotto.DoProgressiveMessage(Owner, payOut);
|
||||
}
|
||||
|
||||
Payout = payOut;
|
||||
DoWin(payOut);
|
||||
|
||||
if (ScratcherLotto.Stone != null)
|
||||
ScratcherLotto.Stone.GoldSink -= Payout;
|
||||
}
|
||||
}
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public override bool DoScratch(int scratch, Mobile from)
|
||||
{
|
||||
if (scratch > 3 || scratch < 0 || from == null)
|
||||
return false;
|
||||
|
||||
int pick;
|
||||
int pickAmount;
|
||||
|
||||
try
|
||||
{
|
||||
int[] odds = ReturnOdds(from);
|
||||
pick = odds[Utility.Random(odds.Length)];
|
||||
pickAmount = m_WinAmounts[pick];
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (scratch)
|
||||
{
|
||||
case 1: Scratch1 = pickAmount; break;
|
||||
case 2: Scratch2 = pickAmount; break;
|
||||
case 3: Scratch3 = pickAmount; break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
CheckScratches();
|
||||
return true;
|
||||
}
|
||||
|
||||
private int[] ReturnOdds(Mobile from)
|
||||
{
|
||||
if (from != null && from.Luck >= 1800 || (from.Luck > 1200 && Utility.RandomBool()))
|
||||
return new int[] { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6 };
|
||||
|
||||
return new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6 };
|
||||
}
|
||||
|
||||
private void DoWin(int amount)
|
||||
{
|
||||
if (Owner != null)
|
||||
Owner.PlaySound(Owner.Female ? 0x337 : 0x449);
|
||||
|
||||
if (amount >= 100000)
|
||||
{
|
||||
new ScratcherStats(Owner, Payout, this.Type);
|
||||
|
||||
if (ScratcherLotto.Stone != null)
|
||||
{
|
||||
ScratcherLotto.Stone.InvalidateProperties();
|
||||
ScratcherLotto.Stone.UpdateSatellites();
|
||||
}
|
||||
}
|
||||
|
||||
if (Owner != null)
|
||||
Owner.SendMessage(42, "It looks like you have a winning ticket!");
|
||||
}
|
||||
|
||||
public SkiesTheLimit(Serial serial) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int) 0); //Version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user