public static void RemoveProfile(PvPProfile profile) { if (profile != null && Profiles.GetValue(profile.Owner) == profile && Profiles.Remove(profile.Owner)) { profile.OnRemoved(); } }
public PvPProfileHistory(PvPProfile owner, params PvPProfileHistoryEntry[] entries) : this(owner) { if (entries == null) { Entries = new Dictionary <int, PvPProfileHistoryEntry>(); } else { Entries = new Dictionary <int, PvPProfileHistoryEntry>(entries.Length); foreach (var entry in entries) { PvPSeason season = AutoPvP.EnsureSeason(entry.Season); if (!Entries.ContainsKey(season.Number)) { Entries.Add(season.Number, entry); } else { Entries[season.Number] = entry; } if (Entries[season.Number] == null) { Entries[season.Number] = entry; } } } }
protected virtual void OnTransferStatistics(PvPProfile profile, PvPProfileHistoryEntry stats) { if (Ranked && profile != null && stats != null) { stats.AddTo(profile.Statistics, true); } }
public static void IssueLoserRewards(this PvPSeason season, int rank, PvPProfile profile) { var rewards = CMOptions.Advanced.Seasons.Rewards.Loser.GiveReward(profile.Owner); if (rewards == null) { rewards = new List <Item>(); } else { var fmt = "{0} (Season {1} - Rank {2})"; rewards.ForEach(r => r.Name = String.Format(fmt, r.ResolveName(profile.Owner), season.Number, rank)); } List <Item> list; if (!season.Losers.TryGetValue(profile.Owner, out list) || list == null) { season.Losers[profile.Owner] = rewards; } else { list.AddRange(rewards); rewards.Free(true); } }
public static bool RemoveProfile(PvPProfile profile) { if (profile != null && Profiles.GetValue(profile.Owner) == profile && Profiles.Remove(profile.Owner)) { profile.Remove(); return(true); } return(false); }
public static void RemoveProfile(PvPProfile profile) { if (!Profiles.ContainsKey(profile.Owner)) { return; } Profiles.Remove(profile.Owner); profile.OnRemoved(); }
public static PvPProfile EnsureProfile(PlayerMobile pm, bool replace = false) { if (!Profiles.ContainsKey(pm)) { Profiles.Add(pm, new PvPProfile(pm)); } else if (replace || Profiles[pm] == null || Profiles[pm].Deleted) { Profiles[pm] = new PvPProfile(pm); } return(Profiles[pm]); }
public void TransferStatistics(PlayerMobile pm) { if (!Ranked) { Statistics.Remove(pm); return; } PvPProfile profile = AutoPvP.EnsureProfile(pm); PvPProfileHistoryEntry entry = EnsureStatistics(pm); OnTransferStatistics(pm, profile.Statistics, entry); Statistics.Remove(pm); }
protected virtual void OnConfirmSubscribe(GumpButton button) { if (Selected == null || Selected.Deleted) { Close(); return; } PvPProfile profile = AutoPvP.EnsureProfile(User); if (profile != null && !profile.Deleted) { profile.Subscribe(Selected); User.SendMessage("You have subscribed to {0} notifications.", Selected.Name); Refresh(true); } }
public static long GetSortedValue(PvPProfileRankOrder order, PvPProfile profile, PvPSeason season = null) { switch (order) { case PvPProfileRankOrder.Points: { if (season == null) { return(profile.TotalPointsGained - profile.TotalPointsLost); } var e = profile.History.EnsureEntry(season); return(e.PointsGained - e.PointsLost); } case PvPProfileRankOrder.Wins: { if (season == null) { return(profile.TotalWins - profile.TotalLosses); } var e = profile.History.EnsureEntry(season); return(e.Wins - e.Losses); } case PvPProfileRankOrder.Kills: { if (season == null) { return(profile.TotalKills - profile.TotalDeaths); } var e = profile.History.EnsureEntry(season); return(e.Kills - e.Deaths); } default: return(0); } }
protected virtual void OnTransferPoints(PvPProfile profile, long points) { if (!Ranked || profile == null || points == 0) { return; } profile.RawPoints += points; if (IsOnline(profile.Owner)) { profile.Owner.SendMessage( "You have {0} {1:#,0} Battle Point{2} from {3}!", points > 0 ? "gained" : "lost", points, points != 1 ? "s" : String.Empty, Name); } }
public static void IssueLoserRewards(this PvPSeason season, PvPProfile profile) { if (!season.Losers.ContainsKey(profile.Owner)) { season.Losers.Add(profile.Owner, new List <Item>()); } else if (season.Losers[profile.Owner] == null) { season.Losers[profile.Owner] = new List <Item>(); } int rank = profile.GetRank(season); CMOptions.Advanced.Seasons.Rewards.Loser.GiveReward(profile.Owner).ForEach( reward => { season.Losers[profile.Owner].Add(reward); reward.Name = String.Format("{0} (Season {1} - Rank {2})", reward.ResolveName(profile.Owner), season.Number, rank); }); }
private static bool DeserializeProfiles(GenericReader reader) { int version = reader.GetVersion(); switch (version) { case 0: { reader.ReadBlockDictionary( () => { PlayerMobile key = reader.ReadMobile <PlayerMobile>(); PvPProfile val = reader.ReadTypeCreate <PvPProfile>(reader); return(new KeyValuePair <PlayerMobile, PvPProfile>(key, val)); }, Profiles); } break; } return(true); }
public static long GetSortedValue(PvPProfileRankOrder order, PvPProfile profile, PvPSeason season = null) { switch (order) { case PvPProfileRankOrder.Points: { if (season == null) { return(profile.TotalPoints); } return(profile.History.EnsureEntry(season).Points); } case PvPProfileRankOrder.Wins: { if (season == null) { return(profile.TotalWins); } return(profile.History.EnsureEntry(season).Wins); } case PvPProfileRankOrder.Kills: { if (season == null) { return(profile.TotalKills); } return(profile.History.EnsureEntry(season).Kills); } } return(0); }
public static void IssueLoserRewards(this PvPSeason season, PvPProfile profile) { List <Item> list = null; season.Losers.AddOrReplace(profile.Owner, l => list = l ?? new List <Item>()); if (list == null) { return; } var rank = profile.GetRank(season); var rewards = CMOptions.Advanced.Seasons.Rewards.Loser.GiveReward(profile.Owner); if (rewards == null) { return; } rewards.ForEach( r => r.Name = String.Format("{0} (Season {1} - Rank {2})", r.ResolveName(profile.Owner), season.Number, rank)); list.AddRange(rewards); }
protected override void CompileMenuOptions(MenuGumpOptions list) { list.Clear(); if (Selected != null && !Selected.Deleted) { if (User.AccessLevel >= AutoPvP.Access) { list.AppendEntry( new ListGumpEntry( "Edit Options", b => { Minimize(); User.SendGump( new PropertiesGump(User, Selected) { X = b.X, Y = b.Y }); }, HighlightHue)); list.AppendEntry( new ListGumpEntry( "Edit Advanced Options", b => { Minimize(); User.SendGump( new PropertiesGump(User, Selected.Options) { X = b.X, Y = b.Y }); }, HighlightHue)); if (Selected.State == PvPBattleState.Internal) { list.AppendEntry( new ListGumpEntry( "Edit Spectate Region", b => { if (Selected.SpectateRegion == null) { Selected.SpectateRegion = RegionExtUtility.Create <PvPSpectateRegion>(Selected); } Send(new PvPSpectateBoundsGump(User, Selected, Hide(true))); }, HighlightHue)); list.AppendEntry( new ListGumpEntry( "Edit Battle Region", b => { if (Selected.BattleRegion == null) { Selected.BattleRegion = RegionExtUtility.Create <PvPBattleRegion>(Selected); } Send(new PvPBattleBoundsGump(User, Selected, Hide(true))); }, HighlightHue)); } list.AppendEntry( new ListGumpEntry( "Edit Doors", b => Send(new PvPDoorListGump(User, Selected, Hide(true), UseConfirmDialog)), HighlightHue)); list.AppendEntry( new ListGumpEntry( "Edit Description", b => Send( new TextInputPanelGump <PvPBattle>( User, Hide(true), title: "Battle Description (HTML/BBC Supported)", input: Selected.Description, limit: 1000, callback: s => { s = s.ParseBBCode(); if (!String.IsNullOrWhiteSpace(s)) { Selected.Description = s; } Refresh(true); })), HighlightHue)); } list.AppendEntry( new ListGumpEntry( "View Schedule", b => Send(new ScheduleOverviewGump(User, Selected.Schedule, Hide(true))), (User.AccessLevel >= AutoPvP.Access) ? HighlightHue : TextHue)); list.AppendEntry( new ListGumpEntry( "View Teams", b => Send(new PvPTeamListGump(User, Selected, Hide(true))), (User.AccessLevel >= AutoPvP.Access) ? HighlightHue : TextHue)); if (User.AccessLevel >= AutoPvP.Access) { list.AppendEntry( new ListGumpEntry( "View Rules/Restrictions", b => { MenuGumpOptions opts = new MenuGumpOptions(); opts.AppendEntry( new ListGumpEntry( "Inherit Rules/Restrictions", b2 => { MenuGumpOptions opts2 = new MenuGumpOptions(); AutoPvP.Battles.Values.Where(ba => ba != Selected) .ForEach( ba => opts2.AppendEntry( new ListGumpEntry( ba.Name, () => { var rulesA = Selected.Options.Rules; var rulesB = ba.Options.Rules; rulesA.AllowBeneficial = rulesB.AllowBeneficial; rulesA.AllowHarmful = rulesB.AllowHarmful; rulesA.AllowHousing = rulesB.AllowHousing; rulesA.AllowPets = rulesB.AllowPets; rulesA.AllowSpawn = rulesB.AllowSpawn; rulesA.AllowSpeech = rulesB.AllowSpeech; rulesA.CanBeDamaged = rulesB.CanBeDamaged; rulesA.CanDamageEnemyTeam = rulesB.CanDamageEnemyTeam; rulesA.CanDamageOwnTeam = rulesB.CanDamageOwnTeam; rulesA.CanDie = rulesB.CanDie; rulesA.CanHeal = rulesB.CanHeal; rulesA.CanHealEnemyTeam = rulesB.CanHealEnemyTeam; rulesA.CanHealOwnTeam = rulesB.CanHealOwnTeam; rulesA.CanMount = rulesB.CanMount; rulesA.CanMoveThrough = rulesB.CanMoveThrough; rulesA.CanMountEthereal = rulesB.CanMountEthereal; rulesA.CanResurrect = rulesB.CanResurrect; rulesA.CanUseStuckMenu = rulesB.CanUseStuckMenu; Selected.Options.Restrictions.Items.List = new Dictionary <Type, bool>(ba.Options.Restrictions.Items.List); Selected.Options.Restrictions.Pets.List = new Dictionary <Type, bool>(ba.Options.Restrictions.Pets.List); Selected.Options.Restrictions.Spells.List = new Dictionary <Type, bool>(ba.Options.Restrictions.Spells.List); Selected.Options.Restrictions.Skills.List = new Dictionary <int, bool>(ba.Options.Restrictions.Skills.List); Refresh(true); }))); Send(new MenuGump(User, this, opts2, b)); })); opts.AppendEntry( new ListGumpEntry( "Rules", mb => { Refresh(); PropertiesGump g = new PropertiesGump(User, Selected.Options.Rules) { X = mb.X, Y = mb.Y }; User.SendGump(g); })); opts.AppendEntry( new ListGumpEntry( "Items", mb => Send(new PvPRestrictItemsListGump(User, Selected.Options.Restrictions.Items, Hide(true))))); opts.AppendEntry( new ListGumpEntry( "Pets", mb => Send(new PvPRestrictPetsListGump(User, Selected.Options.Restrictions.Pets, Hide(true))))); opts.AppendEntry( new ListGumpEntry( "Skills", mb => Send(new PvPRestrictSkillsListGump(User, Selected.Options.Restrictions.Skills, Hide(true))))); opts.AppendEntry( new ListGumpEntry( "Spells", mb => Send(new PvPRestrictSpellsListGump(User, Selected.Options.Restrictions.Spells, Hide(true))))); Send(new MenuGump(User, this, opts, b)); }, (User.AccessLevel >= AutoPvP.Access) ? HighlightHue : TextHue)); list.AppendEntry( new ListGumpEntry( "Reset Statistics", b => { if (UseConfirmDialog) { Send( new ConfirmDialogGump( User, this, title: "Reset Battle Statistics?", html: "All data associated with the battle statistics will be transferred to player profiles then cleared.\nThis action can not be reversed!\nDo you want to continue?", onAccept: OnConfirmResetStatistics)); } else { OnConfirmResetStatistics(b); } }, HighlightHue)); if (Selected.State == PvPBattleState.Internal) { if (Selected.Validate(User)) { list.AppendEntry( new ListGumpEntry( "Publish", b => { Selected.State = PvPBattleState.Queueing; Refresh(true); }, HighlightHue)); } } else { list.AppendEntry( new ListGumpEntry( "Internalize", b => { Selected.State = PvPBattleState.Internal; Refresh(true); }, HighlightHue)); if (!Selected.Hidden) { if (Selected.Validate(User)) { list.AppendEntry( new ListGumpEntry( "Hide", b => { Selected.Hidden = true; Refresh(true); }, HighlightHue)); } } else { list.AppendEntry( new ListGumpEntry( "Unhide", b => { Selected.Hidden = false; Refresh(true); }, HighlightHue)); } } list.AppendEntry( new ListGumpEntry( "Delete", b => { if (UseConfirmDialog) { Send( new ConfirmDialogGump( User, this, title: "Delete Battle?", html: "All data associated with this battle will be deleted.\nThis action can not be reversed!\nDo you want to continue?", onAccept: OnConfirmDeleteBattle)); } else { OnConfirmDeleteBattle(b); } }, HighlightHue)); } list.AppendEntry( new ListGumpEntry( "Command List", b => { StringBuilder html = new StringBuilder(); Selected.GetHtmlCommandList(User, html); new HtmlPanelGump <PvPBattle>(User, this, title: "Command List", html: html.ToString(), selected: Selected).Send(); })); PvPProfile profile = AutoPvP.EnsureProfile(User); if (profile != null && !profile.Deleted) { if (profile.IsSubscribed(Selected)) { list.AppendEntry( new ListGumpEntry( "Unsubscribe", b => { profile.Unsubscribe(Selected); User.SendMessage("You have unsubscribed from {0} notifications.", Selected.Name); Refresh(true); })); } else { list.AppendEntry( new ListGumpEntry( "Subscribe", b => { if (UseConfirmDialog) { Send( new ConfirmDialogGump( User, this, title: "Subscriptions", html: "Subscribing to a battle allows you to see its world broadcast notifications.\n\nDo you want to subscribe to " + Selected.Name + "?", onAccept: OnConfirmSubscribe)); } else { OnConfirmSubscribe(b); } })); } } if (Selected.IsParticipant(User)) { list.AppendEntry(new ListGumpEntry("Quit & Leave", b => Selected.Eject(User, true))); } else { if (Selected.IsQueued(User)) { list.AppendEntry(new ListGumpEntry("Leave Queue", b => Selected.Dequeue(User))); } else if (Selected.CanQueue(User)) { list.AppendEntry(new ListGumpEntry("Join Queue", b => Selected.Enqueue(User))); } if (Selected.IsSpectator(User)) { list.AppendEntry(new ListGumpEntry("Leave Spectators", b => Selected.RemoveSpectator(User, true))); } else if (Selected.CanSpectate(User)) { list.AppendEntry(new ListGumpEntry("Join Spectators", b => Selected.AddSpectator(User, true))); } } } base.CompileMenuOptions(list); }
public PvPProfileHistory(PvPProfile owner, GenericReader reader) : this(owner) { Deserialize(reader); }
public PvPProfileHistory(PvPProfile owner, IDictionary <int, PvPProfileHistoryEntry> dictionary) : this(owner) { Entries = new Dictionary <int, PvPProfileHistoryEntry>(dictionary); }
private PvPProfileHistory(PvPProfile owner) { Profile = owner; }