Inheritance: PRoCon.Core.Plugin.PRoConPluginAPI, IPRoConPluginInterface
示例#1
0
        private void ResetSettings()
        {
            MULTIbalancer rhs = new MULTIbalancer();

            /* ===== SECTION 0 - Presets ===== */

            Preset = rhs.Preset;
            // EnableUnstacking = rhs.EnableUnstacking; // don't reset EnableUnstacking

            /* ===== SECTION 1 - Settings ===== */

            DebugLevel = rhs.DebugLevel;
            MaximumServerSize = rhs.MaximumServerSize;
            EnableBattlelogRequests = rhs.EnableBattlelogRequests;
            MaximumRequestRate =  rhs.MaximumRequestRate;
            WaitTimeout = rhs.WaitTimeout;
            WhichBattlelogStats = rhs.WhichBattlelogStats;
            MaxTeamSwitchesByStrongPlayers = rhs.MaxTeamSwitchesByStrongPlayers;
            MaxTeamSwitchesByWeakPlayers = rhs.MaxTeamSwitchesByWeakPlayers;
            UnlimitedTeamSwitchingDuringFirstMinutesOfRound = rhs.UnlimitedTeamSwitchingDuringFirstMinutesOfRound;
            Enable2SlotReserve = rhs.Enable2SlotReserve;
            EnablerecruitCommand = rhs.EnablerecruitCommand;
            EnableWhitelistingOfReservedSlotsList = rhs.EnableWhitelistingOfReservedSlotsList;
            SecondsUntilAdaptiveSpeedBecomesFast = rhs.SecondsUntilAdaptiveSpeedBecomesFast;
            EnableInGameCommands = rhs.EnableInGameCommands;
            // Whitelist = rhs.Whitelist; // don't reset the whitelist
            // DisperseEvenlyList = rhs.DisperseEvenlyList; // don't reset the dispersal list

            /* ===== SECTION 2 - Exclusions ===== */

            OnWhitelist = rhs.OnWhitelist;
            OnFriendsList = rhs.OnFriendsList;
            ApplyFriendsListToTeam = rhs.ApplyFriendsListToTeam;
            TopScorers = rhs.TopScorers;
            SameClanTagsInSquad = rhs.SameClanTagsInSquad;
            SameClanTagsInTeam = rhs.SameClanTagsInTeam;
            SameClanTagsForRankDispersal = rhs.SameClanTagsForRankDispersal;
            LenientRankDispersal = rhs.LenientRankDispersal;
            MinutesAfterJoining = rhs.MinutesAfterJoining;
            MinutesAfterBeingMoved = rhs.MinutesAfterBeingMoved;
            JoinedEarlyPhase = rhs.JoinedEarlyPhase;
            JoinedMidPhase = rhs.JoinedMidPhase;
            JoinedLatePhase = rhs.JoinedLatePhase;

            /* ===== SECTION 3 - Round Phase & Population Settings ===== */

            EarlyPhaseTicketPercentageToUnstack = rhs.EarlyPhaseTicketPercentageToUnstack;
            MidPhaseTicketPercentageToUnstack = rhs.MidPhaseTicketPercentageToUnstack;
            LatePhaseTicketPercentageToUnstack = rhs.LatePhaseTicketPercentageToUnstack;

            EnableTicketLossRateLogging = rhs.EnableTicketLossRateLogging;

            SpellingOfSpeedNamesReminder = rhs.SpellingOfSpeedNamesReminder;

            EarlyPhaseBalanceSpeed = rhs.EarlyPhaseBalanceSpeed;
            MidPhaseBalanceSpeed = rhs.MidPhaseBalanceSpeed;
            LatePhaseBalanceSpeed = rhs.LatePhaseBalanceSpeed;

            /* ===== SECTION 4 - Scrambler ===== */

            OnlyOnNewMaps = rhs.OnlyOnNewMaps;
            OnlyOnFinalTicketPercentage = rhs.OnlyOnFinalTicketPercentage;
            ScrambleBy = rhs.ScrambleBy;
            KeepClanTagsInSameTeam = rhs.KeepClanTagsInSameTeam;
            KeepFriendsInSameTeam = rhs.KeepFriendsInSameTeam;
            DivideBy = rhs.DivideBy;
            ClanTagToDivideBy = rhs.ClanTagToDivideBy;
            DelaySeconds = rhs.DelaySeconds;

            /* ===== SECTION 5 - Messages ===== */

            QuietMode =  rhs.QuietMode;
            YellDurationSeconds = rhs.YellDurationSeconds;
            BadBecauseMovedByBalancer = rhs.BadBecauseMovedByBalancer;
            BadBecauseWinningTeam = rhs.BadBecauseWinningTeam;
            BadBecauseBiggestTeam = rhs.BadBecauseBiggestTeam;
            BadBecauseRank = rhs.BadBecauseRank;
            BadBecauseDispersalList = rhs.BadBecauseDispersalList;
            ChatMovedForBalance = rhs.ChatMovedForBalance;
            YellMovedForBalance = rhs.YellMovedForBalance;
            ChatMovedToUnstack = rhs.ChatMovedToUnstack;
            YellMovedToUnstack = rhs.YellMovedToUnstack;
            ChatDetectedBadTeamSwitch = rhs.ChatDetectedBadTeamSwitch;
            YellDetectedBadTeamSwitch = rhs.YellDetectedBadTeamSwitch;
            ChatDetectedGoodTeamSwitch = rhs.ChatDetectedGoodTeamSwitch;
            YellDetectedGoodTeamSwitch = rhs.YellDetectedGoodTeamSwitch;
            ChatAfterUnswitching = rhs.ChatAfterUnswitching;
            YellAfterUnswitching = rhs.YellAfterUnswitching;

            /* ===== SECTION 6 - Unswitcher ===== */

            ForbidSwitchingAfterAutobalance = rhs.ForbidSwitchingAfterAutobalance;
            ForbidSwitchingToWinningTeam = rhs.ForbidSwitchingToWinningTeam;
            ForbidSwitchingToBiggestTeam = rhs.ForbidSwitchingToBiggestTeam;
            ForbidSwitchingAfterDispersal = rhs.ForbidSwitchingAfterDispersal;
            EnableImmediateUnswitch = rhs.EnableImmediateUnswitch;

            /* ===== SECTION 7 - TBD ===== */

            /* ===== SECTION 8 - Per-Mode Settings ===== */

            List<String> simpleModes = GetSimplifiedModes();

            fPerMode.Clear();

            foreach (String sm in simpleModes) {
            PerModeSettings oneSet = null;
            if (!fPerMode.ContainsKey(sm)) {
            oneSet = new PerModeSettings(sm, fGameVersion == GameVersion.BF4);
            fPerMode[sm] = oneSet;
            }
            }

            /* ===== SECTION 9 - Debug Settings ===== */

            ShowCommandInLog = rhs.ShowCommandInLog;
            LogChat = rhs.LogChat;
            EnableLoggingOnlyMode = rhs.EnableLoggingOnlyMode;
        }
示例#2
0
 public static MULTIbalancer.Speed[] ParseSpeedArray(MULTIbalancer plugin, String s)
 {
     MULTIbalancer.Speed[] speeds = new MULTIbalancer.Speed[3] {
     MULTIbalancer.Speed.Adaptive,
     MULTIbalancer.Speed.Adaptive,
     MULTIbalancer.Speed.Adaptive
     };
     if (String.IsNullOrEmpty(s) || !s.Contains(",")) {
     if (s == null) s = "(null)";
     plugin.ConsoleWarn("Bad balance speed setting: " + s);
     return speeds;
     }
     String[] strs = s.Split(new Char[] {','});
     if (strs.Length != 3) {
     plugin.ConsoleWarn("Wrong number of speeds, should be 3, separated by commas: " + s);
     return speeds;
     }
     for (int i = 0; i < speeds.Length; ++i) {
     try {
         speeds[i] = (MULTIbalancer.Speed)Enum.Parse(typeof(MULTIbalancer.Speed), strs[i]);
     } catch (Exception) {
         plugin.ConsoleWarn("Bad balance speed value: " + strs[i]);
         speeds[i] = MULTIbalancer.Speed.Adaptive;
     }
     }
     return speeds;
 }
示例#3
0
        public static void UpdateSettingsForPreset(MULTIbalancer lhs, MULTIbalancer.PresetItems preset)
        {
            try {
            MULTIbalancer rhs = new MULTIbalancer(preset);

            lhs.DebugWrite("UpdateSettingsForPreset to " + preset, 6);

            lhs.OnWhitelist = rhs.OnWhitelist;
            lhs.OnFriendsList = rhs.OnFriendsList;
            lhs.ApplyFriendsListToTeam = rhs.ApplyFriendsListToTeam;
            lhs.TopScorers = rhs.TopScorers;
            lhs.SameClanTagsInSquad = rhs.SameClanTagsInSquad;
            lhs.SameClanTagsInTeam = rhs.SameClanTagsInTeam;
            lhs.SameClanTagsForRankDispersal = rhs.SameClanTagsForRankDispersal;
            lhs.LenientRankDispersal = rhs.LenientRankDispersal;
            lhs.MinutesAfterJoining = rhs.MinutesAfterJoining;
            lhs.JoinedEarlyPhase = rhs.JoinedEarlyPhase;
            lhs.JoinedMidPhase = rhs.JoinedMidPhase;
            lhs.JoinedLatePhase = rhs.JoinedLatePhase;

            lhs.EarlyPhaseTicketPercentageToUnstack = rhs.EarlyPhaseTicketPercentageToUnstack;
            lhs.MidPhaseTicketPercentageToUnstack = rhs.MidPhaseTicketPercentageToUnstack;
            lhs.LatePhaseTicketPercentageToUnstack = rhs.LatePhaseTicketPercentageToUnstack;

            lhs.EarlyPhaseBalanceSpeed = rhs.EarlyPhaseBalanceSpeed;
            lhs.MidPhaseBalanceSpeed = rhs.MidPhaseBalanceSpeed;
            lhs.LatePhaseBalanceSpeed = rhs.LatePhaseBalanceSpeed;

            lhs.ForbidSwitchingAfterAutobalance = rhs.ForbidSwitchingAfterAutobalance;
            lhs.ForbidSwitchingToWinningTeam = rhs.ForbidSwitchingToWinningTeam;
            lhs.ForbidSwitchingToBiggestTeam = rhs.ForbidSwitchingToBiggestTeam;
            lhs.ForbidSwitchingAfterDispersal = rhs.ForbidSwitchingAfterDispersal;
            lhs.EnableImmediateUnswitch = rhs.EnableImmediateUnswitch;

            } catch (Exception) { }
        }
示例#4
0
        public static bool EqualArrays(MULTIbalancer.Speed[] lhs, MULTIbalancer.Speed[] rhs)
        {
            if (lhs == null && rhs == null) return true;
            if (lhs == null || rhs == null) return false;
            if (lhs.Length != rhs.Length) return false;

            for (int i = 0; i < lhs.Length; ++i) {
            if (lhs[i] != rhs[i]) return false;
            }
            return true;
        }
示例#5
0
 public static bool IsEqual(MULTIbalancer lhs, MULTIbalancer.PresetItems preset)
 {
     MULTIbalancer rhs = new MULTIbalancer(preset);
     return (lhs.CheckForEquality(rhs));
 }
示例#6
0
 public static String ArrayToString(MULTIbalancer.Speed[] a)
 {
     String ret = String.Empty;
     bool first = true;
     if (a == null || a.Length == 0) return ret;
     for (int i = 0; i < a.Length; ++i) {
     if (first) {
         ret = Enum.GetName(typeof(MULTIbalancer.Speed), a[i]);
         first = false;
     } else {
         ret = ret + ", " + Enum.GetName(typeof(MULTIbalancer.Speed), a[i]);
     }
     }
     return ret;
 }
示例#7
0
 public PriorityQueue(MULTIbalancer plugin)
     : this()
 {
     fPlugin = plugin;
 }
示例#8
0
 public PriorityQueue()
 {
     TagQueue = new Queue<String>();
     StatsQueue = new Queue<String>();
     fPlugin = null;
 }
示例#9
0
 public bool CheckForEquality(MULTIbalancer rhs)
 {
     return (this.OnWhitelist == rhs.OnWhitelist
      && this.OnFriendsList == rhs.OnFriendsList
      && this.ApplyFriendsListToTeam == rhs.ApplyFriendsListToTeam
      && this.TopScorers == rhs.TopScorers
      && this.SameClanTagsInSquad == rhs.SameClanTagsInSquad
      && this.SameClanTagsInTeam == rhs.SameClanTagsInTeam
      && this.SameClanTagsForRankDispersal == rhs.SameClanTagsForRankDispersal
      && this.LenientRankDispersal == rhs.LenientRankDispersal
      && this.MinutesAfterJoining == rhs.MinutesAfterJoining
      && this.JoinedEarlyPhase == rhs.JoinedEarlyPhase
      && this.JoinedMidPhase == rhs.JoinedMidPhase
      && this.JoinedLatePhase == rhs.JoinedLatePhase
      && MULTIbalancerUtils.EqualArrays(this.EarlyPhaseTicketPercentageToUnstack, rhs.EarlyPhaseTicketPercentageToUnstack)
      && MULTIbalancerUtils.EqualArrays(this.MidPhaseTicketPercentageToUnstack, rhs.MidPhaseTicketPercentageToUnstack)
      && MULTIbalancerUtils.EqualArrays(this.LatePhaseTicketPercentageToUnstack, rhs.LatePhaseTicketPercentageToUnstack)
      && MULTIbalancerUtils.EqualArrays(this.EarlyPhaseBalanceSpeed, rhs.EarlyPhaseBalanceSpeed)
      && MULTIbalancerUtils.EqualArrays(this.MidPhaseBalanceSpeed, rhs.MidPhaseBalanceSpeed)
      && MULTIbalancerUtils.EqualArrays(this.LatePhaseBalanceSpeed, rhs.LatePhaseBalanceSpeed)
      && this.ForbidSwitchingAfterAutobalance == rhs.ForbidSwitchingAfterAutobalance
      && this.ForbidSwitchingToWinningTeam == rhs.ForbidSwitchingToWinningTeam
      && this.ForbidSwitchingToBiggestTeam == rhs.ForbidSwitchingToBiggestTeam
      && this.ForbidSwitchingAfterDispersal == rhs.ForbidSwitchingAfterDispersal
      && this.EnableImmediateUnswitch == rhs.EnableImmediateUnswitch
     );
 }
示例#10
0
            public void Format(MULTIbalancer plugin, String fmt, bool isYell, bool isBefore)
            {
                String expanded = fmt;

                if (String.IsNullOrEmpty(expanded)) return;

                String reason = String.Empty;

                if (For == MoveType.Unswitch) {
                switch (this.Because) {
                    case ForbidBecause.MovedByBalancer:
                        reason = plugin.BadBecauseMovedByBalancer;
                        break;
                    case ForbidBecause.DisperseByList:
                        reason = plugin.BadBecauseDispersalList;
                        break;
                    case ForbidBecause.DisperseByRank:
                        reason = plugin.BadBecauseRank;
                        break;
                    case ForbidBecause.ToBiggest:
                        reason = plugin.BadBecauseBiggestTeam;
                        break;
                    case ForbidBecause.ToWinning:
                        reason = plugin.BadBecauseWinningTeam;
                        break;
                    case ForbidBecause.None:
                    default:
                        reason = "(no reason)";
                        break;
                }

                if (expanded.Contains("%reason%")) expanded = expanded.Replace("%reason%", reason);
                }

                if (expanded.Contains("%name%")) expanded = expanded.Replace("%name%", Name);
                if (expanded.Contains("%tag%")) expanded = expanded.Replace("%tag%", Tag);
                if (expanded.Contains("%fromTeam%")) expanded = expanded.Replace("%fromTeam%", SourceName);
                if (expanded.Contains("%toTeam%")) expanded = expanded.Replace("%toTeam%", DestinationName);

                if (isYell) {
                if (isBefore) {
                    YellBefore = expanded;
                } else {
                    YellAfter = expanded;
                }
                } else {
                if (isBefore) {
                    ChatBefore = expanded;
                } else {
                    ChatAfter = expanded;
                }
                }
            }