public VoteRequestEventArgs(Mobile from, IVoteSite site, int tokens, bool message) { Mobile = from; Site = site; Tokens = tokens; Message = message; }
public void RegisterTokens(IVoteSite site, int amount) { if (site == null) { return; } var now = DateTime.UtcNow; var when = now; var key = GenerateKey(ref when); if (!History.ContainsKey(key)) { History.Add(key, new List <VoteProfileEntry>()); } var e = GetHistory(now).FirstOrDefault(s => s.VoteSite == site); if (e == null) { History[key].Add(new VoteProfileEntry(now, site, amount)); } else { e.VoteTime = now; e.TokenAmount += amount; } }
public static void Remove(this IVoteSite site) { VoteSites.Remove(site.UID); site.Delete(); Profiles.Values.ForEach( p => p.History.ForEach((t, h) => h.Where(e => e.VoteSite == site).ForEach(e => e.VoteSite = VoteSite.Empty))); }
public void RegisterTokens(IVoteSite site, int amount) { if (site == null) { return; } DateTime now = DateTime.UtcNow; DateTime when = now; TimeStamp key = GenerateKey(ref when); if (!History.ContainsKey(key)) { History.Add(key, new List <VoteProfileEntry>()); } History[key].Add(new VoteProfileEntry(now, site, amount)); }
private static int InternalSiteSort(IVoteSite a, IVoteSite b) { if (a == b) { return(0); } if (a == null) { return(1); } if (b == null) { return(-1); } if (!a.Valid && !b.Valid) { return(0); } if (!a.Valid) { return(1); } if (!b.Valid) { return(-1); } if (a.Interval > b.Interval) { return(1); } if (a.Interval < b.Interval) { return(-1); } return(0); }
public override void OnDoubleClick(Mobile from) { PlayerMobile voter = from as PlayerMobile; if (voter == null || voter.Deleted) { return; } IVoteSite site = Voting.FindSite(SiteUID); if (site != null) { site.Vote(voter); } else if (voter.AccessLevel >= Voting.Access) { SuperGump.Send(new VoteAdminGump(voter)); } }
public override void GetProperties(ObjectPropertyList list) { base.GetProperties(list); IVoteSite site = Voting.FindSite(SiteUID); if (site != null && !site.Deleted) { int color = Color.FromKnownColor(UsageColor).ToArgb(); list.Add( "<basefont color=#{0:X6}>Use: Cast a vote for {1} at {2}<basefont color=#ffffff>", color, ServerList.ServerName, site.Name); } else { list.Add("<basefont color=#{0:X6}>[No Vote Site Available]<basefont color=#ffffff>", Color.Red.ToArgb()); } }
public static void Remove(this IVoteSite site) { VoteSites.Remove(site.UID); foreach (var h in Profiles.Values.SelectMany(p => p.History.Values)) { h.RemoveAll( e => { if (e.VoteSite != site) { return(false); } e.VoteSite = null; return(true); }); } site.Delete(); }
public bool TransferTokens(IVoteSite site, int amount, bool message = true) { if (site == null || Deleted || Owner == null || Owner.Deleted) { return(false); } var limitReached = false; var total = GetTokenTotal(DateTime.UtcNow); if (Voting.CMOptions.DailyLimit > 0) { if (total >= Voting.CMOptions.DailyLimit) { limitReached = true; amount = 0; } else if ((total + amount) > Voting.CMOptions.DailyLimit) { limitReached = true; amount = (total + amount) - Voting.CMOptions.DailyLimit; } } if (amount > 0) { new VoteToken(amount).GiveTo(Owner); } if (limitReached && message) { Owner.SendMessage(0x22, "You have reached your daily token limit of {0:#,0}.", Voting.CMOptions.DailyLimit); } RegisterTokens(site, amount); return(true); }
public bool TransferTokens(IVoteSite site, int amount, bool message = true) { if (site == null || Deleted || Owner == null || Owner.Deleted) { return false; } bool limitReached = false; int total = GetTokenTotal(DateTime.UtcNow); if (Voting.CMOptions.DailyLimit > 0) { if (total >= Voting.CMOptions.DailyLimit) { limitReached = true; amount = 0; } else if ((total + amount) > Voting.CMOptions.DailyLimit) { limitReached = true; amount = (total + amount) - Voting.CMOptions.DailyLimit; } } if (amount > 0) { var token = new VoteToken(amount); string name = token.ResolveName(Owner.GetLanguage()); if (Owner.Backpack.TryDropItem(Owner, token, true)) { if (message) { Owner.SendMessage( 0x55, "{0}{1}{2} {3} been placed in your backpack.", (!name.StartsWith("a") && amount == 1) ? "a" : String.Empty, name, (!name.EndsWith("s") && amount > 1) ? "s" : String.Empty, (amount > 1) ? "have" : "has"); } } else if (Owner.BankBox.TryDropItem(Owner, token, true)) { if (message) { Owner.SendMessage( 0x55, "{0}{1}{2} {3} been placed in your bank.", (!name.StartsWith("a") && amount == 1) ? "a" : String.Empty, name, (!name.EndsWith("s") && amount > 1) ? "s" : String.Empty, (amount > 1) ? "have" : "has"); } } else { if (Owner.NetState == null) { token.MoveToWorld(Owner.LogoutLocation, Owner.LogoutMap); } else { token.MoveToWorld(Owner.Location, Owner.Map); } if (message) { Owner.SendMessage( 0x55, "{0}{1}{2} {3} been placed at your feet.", (!name.StartsWith("a") && amount == 1) ? "a" : String.Empty, name, (!name.EndsWith("s") && amount > 1) ? "s" : String.Empty, (amount > 1) ? "have" : "has"); } } } if (limitReached && message) { Owner.SendMessage(0x22, "You have reached your daily token limit of {0:#,0}.", Voting.CMOptions.DailyLimit); } RegisterTokens(site, amount); return true; }
public VoteProfileEntry(DateTime when, IVoteSite site, int tokens) { VoteTime = when; VoteSite = site; TokenAmount = tokens; }
public bool TransferTokens(IVoteSite site, int amount, bool message = true) { if (site == null || Deleted || Owner == null || Owner.Deleted) { return false; } var limitReached = false; var total = GetTokenTotal(DateTime.UtcNow); if (Voting.CMOptions.DailyLimit > 0) { if (total >= Voting.CMOptions.DailyLimit) { limitReached = true; amount = 0; } else if ((total + amount) > Voting.CMOptions.DailyLimit) { limitReached = true; amount = (total + amount) - Voting.CMOptions.DailyLimit; } } if (amount > 0) { new VoteToken(amount).GiveTo(Owner); } if (limitReached && message) { Owner.SendMessage(0x22, "You have reached your daily token limit of {0:#,0}.", Voting.CMOptions.DailyLimit); } RegisterTokens(site, amount); return true; }
public bool TransferTokens(IVoteSite site, int amount, bool message = true) { if (site == null || Deleted || Owner == null || Owner.Deleted) { return(false); } bool limitReached = false; int total = GetTokenTotal(DateTime.UtcNow); if (Voting.CMOptions.DailyLimit > 0) { if (total >= Voting.CMOptions.DailyLimit) { limitReached = true; amount = 0; } else if ((total + amount) > Voting.CMOptions.DailyLimit) { limitReached = true; amount = (total + amount) - Voting.CMOptions.DailyLimit; } } if (amount > 0) { var token = new VoteToken(amount); string name = token.ResolveName(Owner.GetLanguage()); if (Owner.Backpack.TryDropItem(Owner, token, true)) { if (message) { Owner.SendMessage( 0x55, "{0}{1}{2} {3} been placed in your backpack.", (!name.StartsWith("a") && amount == 1) ? "a" : String.Empty, name, (!name.EndsWith("s") && amount > 1) ? "s" : String.Empty, (amount > 1) ? "have" : "has"); } } else if (Owner.BankBox.TryDropItem(Owner, token, true)) { if (message) { Owner.SendMessage( 0x55, "{0}{1}{2} {3} been placed in your bank.", (!name.StartsWith("a") && amount == 1) ? "a" : String.Empty, name, (!name.EndsWith("s") && amount > 1) ? "s" : String.Empty, (amount > 1) ? "have" : "has"); } } else { if (Owner.NetState == null) { token.MoveToWorld(Owner.LogoutLocation, Owner.LogoutMap); } else { token.MoveToWorld(Owner.Location, Owner.Map); } if (message) { Owner.SendMessage( 0x55, "{0}{1}{2} {3} been placed at your feet.", (!name.StartsWith("a") && amount == 1) ? "a" : String.Empty, name, (!name.EndsWith("s") && amount > 1) ? "s" : String.Empty, (amount > 1) ? "have" : "has"); } } } if (limitReached && message) { Owner.SendMessage( 0x22, "You have reached your daily token limit of {0}.", Voting.CMOptions.DailyLimit.ToString("#,#")); } RegisterTokens(site, amount); return(true); }
private static int InternalSiteSort(IVoteSite a, IVoteSite b) { if (a == b) { return 0; } if (a == null) { return 1; } if (b == null) { return -1; } if (!a.Valid && !b.Valid) { return 0; } if (!a.Valid) { return 1; } if (!b.Valid) { return -1; } if (a.Interval > b.Interval) { return 1; } if (a.Interval < b.Interval) { return -1; } return 0; }
public void RegisterTokens(IVoteSite site, int amount) { if (site == null) { return; } DateTime now = DateTime.UtcNow; DateTime when = now; TimeStamp key = GenerateKey(ref when); if (!History.ContainsKey(key)) { History.Add(key, new List<VoteProfileEntry>()); } History[key].Add(new VoteProfileEntry(now, site, amount)); }
public void RegisterTokens(IVoteSite site, int amount) { if (site == null) { return; } var now = DateTime.UtcNow; var when = now; var key = GenerateKey(ref when); if (!History.ContainsKey(key)) { History.Add(key, new List<VoteProfileEntry>()); } var e = GetHistory(now).FirstOrDefault(s => s.VoteSite == site); if (e == null) { History[key].Add(new VoteProfileEntry(now, site, amount)); } else { e.VoteTime = now; e.TokenAmount += amount; } }