public bool buyTicket(Mobile from) { if (from == null || from.Deleted || from.Backpack == null || !from.Alive) { return(false); /* pedantic check */ } if (mode == LotteryBasketMode.Disabled) { from.SendMessage("The lottery is currently disabled, sorry."); return(false); } if (!takeMoney(from, (int)LotteryConstants.TicketPrice)) { return(false); } LotteryTicket ticket = new LotteryTicket(); if (!from.AddToBackpack(ticket)) { ticket.Delete(); return(false); } from.SendMessage("A new lottery ticket has been placed into your backpack."); return(true); }
private LotteryTicketGump(LotteryTicket _ticket, bool[] _data) : base(250, 250) { ticket = _ticket; data = _data; foreach (bool f in data) if (f) numSelected++; constructGump(); }
public LotteryTicketGump(LotteryTicket _ticket) : base(250, 250) { ticket = _ticket; uint[] td = ticket.Data; if (td != null) { foreach (uint i in td) { if (i >= 1 && i <= LotteryConstants.Range && !data[i - 1] && numSelected < LotteryConstants.Picks) { data[i - 1] = true; numSelected++; } } } constructGump(); }
public bool submitTicket(LotteryTicket ticket) { if (ticket == null || ticket.Deleted || mode != LotteryBasketMode.Open || !ticket.Writable || ticket.Data == null) { return(false); } /* register the ticket */ ticket.Drawing = drawing; RegisteredTicket rt = new RegisteredTicket(ticket); incoming[(int)ticket.Serial] = rt; /* half the value of a submitted ticket goes to the * jackpot, the other half is destroyed */ award += LotteryConstants.TicketPrice / 2; destroyed += LotteryConstants.TicketPrice / 2; return(true); }
public override bool OnDragDrop(Mobile from, Item dropped) { if (from == null || from.Deleted || dropped == null || dropped.Deleted) { return(false); /* pedantic check */ } if (!(dropped is LotteryTicket)) { from.SendMessage("Only lottery tickets are accepted"); return(false); } LotteryTicket ticket = (LotteryTicket)dropped; if (mode != LotteryBasketMode.Open) { from.SendMessage("The lottery is currently closed."); return(false); } if (ticket.Data == null) { from.SendMessage("Please fill out your ticket first."); return(false); } else if (ticket.Writable) { /* submit ticket */ if (submitTicket(ticket)) { from.SendMessage("Your lottery ticket was submitted. Good luck!"); } return(false); } else if (ticket.Drawing == drawing) { from.SendMessage("This lottery ticket is already submitted. Please wait for the drawing."); return(false); } else if (ticket.Drawing == drawing - 1) { /* hand out the award */ RegisteredTicket rt = (RegisteredTicket)tickets[(int)ticket.Serial]; bool mainwinning = false; if (rt.Class == 0) { mainwinning = true; } ulong award = rt == null || rt.Class == -1 ? 0 : awards[rt.Class]; if (award == 0) { ticket.Delete(); from.SendMessage("Sorry, you havn't won. Better luck next time."); return(false); } else { if (debug) { Console.WriteLine("Checking winners ticket: Class " + rt.Class); } if (!giveMoney(from, (int)award, mainwinning)) { return(false); } ticket.Delete(); if (mainwinning && itemPrize) { from.SendMessage("Congratulations! You won the main prize! A Deed has placed in your Bagpack."); destroyed += award; } else { from.SendMessage("Congratulations! You won " + award + " gold!"); given += award; } return(false); } } else { ticket.Delete(); from.SendMessage("Sorry, your lottery ticket has expired."); return(false); } }
public RegisteredTicket(LotteryTicket ticket) { ticketId = (int)ticket.Serial; data = ticket.Data; }
public bool submitTicket(LotteryTicket ticket) { if (ticket == null || ticket.Deleted || mode != LotteryBasketMode.Open || !ticket.Writable || ticket.Data == null) return false; /* register the ticket */ ticket.Drawing = drawing; RegisteredTicket rt = new RegisteredTicket(ticket); incoming[(int)ticket.Serial] = rt; /* half the value of a submitted ticket goes to the jackpot, the other half is destroyed */ award += LotteryConstants.TicketPrice / 2; destroyed += LotteryConstants.TicketPrice / 2; return true; }
public bool buyTicket(Mobile from) { if (from == null || from.Deleted || from.Backpack == null || !from.Alive) return false; /* pedantic check */ if (mode == LotteryBasketMode.Disabled) { from.SendMessage("The lottery is currently disabled, sorry."); return false; } if (!takeMoney(from, (int)LotteryConstants.TicketPrice)) return false; LotteryTicket ticket = new LotteryTicket(); if (!from.AddToBackpack(ticket)) { ticket.Delete(); return false; } from.SendMessage("A new lottery ticket has been placed into your backpack."); return true; }
public LotteryTicketGump(LotteryTicket m) : base(50, 50) { m_lotteryticket = m; Closable = false; Disposable = false; Dragable = true; Resizable = false; AddPage(0); AddBackground(0, 0, 316, 416, 9380); AddLabel(84, 34, 57, @"Official Lottery Ticket"); AddLabel(40, 70, 94, @"Ticket Number : " + m_lotteryticket.TicketNumbers); AddLabel(40, 90, 94, @"Draw Date : " + m_lotteryticket.DateOfDrawOnTickets); AddLabel(40, 130, 94, @"Ticket Status : " + m_lotteryticket.TicketStatus); AddLabel(64, 150, 35, @"Lottery Terms and Conditions"); AddLabel(35, 170, 47, @"The status will show if the ticket was"); AddLabel(35, 190, 47, @"a winner or not. Winning claims must be"); AddLabel(35, 209, 47, @"made before the next lottery is drawn."); AddImage(50, 314, 9004); AddLabel(35, 230, 35, @"Un-claimed tickets will become void."); AddLabel(35, 270, 47, @"Management will not be held accountable"); AddLabel(35, 290, 47, @"for muggings, deaths or looted tickets."); AddButton(151, 315, 9723, 9724, 1, GumpButtonType.Reply, 0); // Exit AddButton(151, 350, 9723, 9724, 2, GumpButtonType.Reply, 0); // Claim Prize AddLabel(185, 319, 47, @"Close / Exit."); AddLabel(185, 354, 47, @"Claim Winnings."); AddLabel(40, 110, 94, @"Lottery Numbers : " + m_lotteryticket.LotteryNumber1Ticket + ", " + m_lotteryticket.LotteryNumber2Ticket + ", " + m_lotteryticket.LotteryNumber3Ticket + ", " + m_lotteryticket.LotteryNumber4Ticket + ", " + m_lotteryticket.LotteryNumber5Ticket); }