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 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 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; }