예제 #1
0
		public FactionDefinition( int sort, int huePrimary, int hueSecondary, int hueJoin, int hueBroadcast, int warHorseBody, int warHorseItem, string friendlyName, string keyword, string abbreviation, TextDefinition name, TextDefinition propName, TextDefinition header, TextDefinition about, TextDefinition cityControl, TextDefinition sigilControl, TextDefinition signupName, TextDefinition factionStoneName, TextDefinition ownerLabel, TextDefinition guardIgnore, TextDefinition guardWarn, TextDefinition guardAttack, StrongholdDefinition stronghold, RankDefinition[] ranks, GuardDefinition[] guards )
		{
			m_Sort = sort;
			m_HuePrimary = huePrimary;
			m_HueSecondary = hueSecondary;
			m_HueJoin = hueJoin;
			m_HueBroadcast = hueBroadcast;
			m_WarHorseBody = warHorseBody;
			m_WarHorseItem = warHorseItem;
			m_FriendlyName = friendlyName;
			m_Keyword = keyword;
			m_Abbreviation = abbreviation;
			m_Name = name;
			m_PropName = propName;
			m_Header = header;
			m_About = about;
			m_CityControl = cityControl;
			m_SigilControl = sigilControl;
			m_SignupName = signupName;
			m_FactionStoneName = factionStoneName;
			m_OwnerLabel = ownerLabel;
			m_GuardIgnore = guardIgnore;
			m_GuardWarn = guardWarn;
			m_GuardAttack = guardAttack;
			m_Stronghold = stronghold;
			m_Ranks = ranks;
			m_Guards = guards;
		}
예제 #2
0
 /// <summary>
 /// Evaluates the rank of each entry of the provided samples.
 /// The rank definition can be specified to be compatible
 /// with an existing system.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
 public static double[] Ranks(this IEnumerable <double?> data, RankDefinition definition = RankDefinition.Default)
 {
     return(Ranks(data.Where(d => d.HasValue).Select(d => d.Value), definition));
 }
예제 #3
0
        /// <summary>
        /// Evaluates the rank of each entry of the provided samples.
        /// The rank definition can be specified to be compatible
        /// with an existing system.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
        public static double[] Ranks(this IEnumerable <double> data, RankDefinition definition = RankDefinition.Default)
        {
            var array = data.ToArray();

            return(ArrayStatistics.RanksInplace(array, definition));
        }
예제 #4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            PlayerMobile pm = sender.Mobile as PlayerMobile;

            if (!IsMember(pm, guild))
            {
                return;
            }

            RankDefinition playerRank = pm.GuildRank;

            switch (info.ButtonID)
            {
            case 1:
            {
                AllianceInfo alliance      = guild.Alliance;
                AllianceInfo otherAlliance = m_Other.Alliance;

                if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                {
                    pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                }
                else if (alliance != null && alliance.Leader != guild)
                {
                    pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                    pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                }
                else if (otherAlliance != null && otherAlliance.Leader != m_Other)
                {
                    pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", m_Other.Name, otherAlliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                    pm.SendLocalizedMessage(1070707, otherAlliance.Leader.Name);                                   // You need to negotiate via ~1_val~ instead.
                }
                else
                {
                    WarDeclaration activeWar = guild.FindActiveWar(m_Other);

                    if (activeWar == null)
                    {
                        WarDeclaration war      = guild.FindPendingWar(m_Other);
                        WarDeclaration otherWar = m_Other.FindPendingWar(guild);

                        //Note: OSI differs from what it says on website.  unlimited war = 0 kills/ 0 hrs.  Not > 999.  (sidenote: they both cap at 65535, 7.5 years, but, still.)
                        TextRelay tKills     = info.GetTextEntry(11);
                        TextRelay tWarLength = info.GetTextEntry(10);

                        int      maxKills  = (tKills == null) ? 0 : Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(11).Text), 0xFFFF), 0);
                        TimeSpan warLength = TimeSpan.FromHours((tWarLength == null) ? 0 : Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(10).Text), 0xFFFF), 0));

                        if (war != null)
                        {
                            war.MaxKills     = maxKills;
                            war.WarLength    = warLength;
                            war.WarRequester = true;
                        }
                        else
                        {
                            guild.PendingWars.Add(new WarDeclaration(guild, m_Other, maxKills, warLength, true));
                        }

                        if (otherWar != null)
                        {
                            otherWar.MaxKills     = maxKills;
                            otherWar.WarLength    = warLength;
                            otherWar.WarRequester = false;
                        }
                        else
                        {
                            m_Other.PendingWars.Add(new WarDeclaration(m_Other, guild, maxKills, warLength, false));
                        }

                        if (war != null)
                        {
                            pm.SendLocalizedMessage(1070752);         // The proposal has been updated.
                                                                      //m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal.
                        }
                        else
                        {
                            m_Other.GuildMessage(1070781, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name));         // ~1_val~ has proposed a war.
                        }
                        pm.SendLocalizedMessage(1070751, ((m_Other.Alliance != null) ? m_Other.Alliance.Name : m_Other.Name));    // War proposal has been sent to ~1_val~.
                    }
                }
                break;
            }

            default:
            {
                pm.SendGump(new OtherGuildInfo(pm, guild, m_Other));
                break;
            }
            }
        }
 /// <summary>
 /// Estimates the pointwise quantile tau from the vectors.
 /// The tau-th quantile is the data value where the cumulative distribution
 /// function crosses tau. The quantile definition can be specified to be compatible
 /// with an existing system.
 /// </summary>
 /// <param name="data">Vector array, where all vectors have the same length.</param>
 /// <param name="x">Quantile value.</param>
 /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
 public static Vector<double> QuantileRank(this Vector<double>[] data, double x, RankDefinition definition = RankDefinition.Default)
 {
     return data.TransposeArrayMap(array =>
     {
         Array.Sort(array);
         return SortedArrayStatistics.QuantileRank(array, x, definition);
     });
 }
        static void RanksTies(double[] ranks, int a, int b, RankDefinition definition)
        {
            // TODO: potential for PERF optimization

            double rank;
            switch (definition)
            {
                case RankDefinition.Average:
                {
                    rank = (b + a - 1)/2d + 1;
                    break;
                }

                case RankDefinition.Min:
                {
                    rank = a + 1;
                    break;
                }

                case RankDefinition.Max:
                {
                    rank = b;
                    break;
                }

                default:
                    throw new NotSupportedException();
            }

            for (int k = a; k < b; k++)
            {
                ranks[k] = rank;
            }
        }
        /// <summary>
        /// Estimates the quantile tau from the sorted data array (ascending).
        /// The tau-th quantile is the data value where the cumulative distribution
        /// function crosses tau. The quantile definition can be specified to be compatible
        /// with an existing system.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        /// <param name="x">Quantile value.</param>
        /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
        public static double QuantileRank(double[] data, double x, RankDefinition definition = RankDefinition.Default)
        {
            if (x < data[0])
            {
                return 0.0;
            }

            if (x >= data[data.Length - 1])
            {
                return 1.0;
            }

            int right = Array.BinarySearch(data, x);
            if (right >= 0)
            {
                int left = right;

                while (left > 0 && data[left - 1] == data[left])
                {
                    left--;
                }

                while (right < data.Length - 1 && data[right + 1] == data[right])
                {
                    right++;
                }

                switch (definition)
                {
                    case RankDefinition.EmpiricalCDF:
                        return (right + 1)/(double)data.Length;

                    case RankDefinition.Max:
                        return right/(double)(data.Length - 1);

                    case RankDefinition.Min:
                        return left/(double)(data.Length - 1);

                    case RankDefinition.Average:
                        return (left/(double)(data.Length - 1) + right/(double)(data.Length - 1))/2;

                    default:
                        throw new NotSupportedException();
                }
            }
            else
            {
                right = ~right;
                int left = right - 1;

                switch (definition)
                {
                    case RankDefinition.EmpiricalCDF:
                        return (left + 1)/(double)data.Length;

                    default:
                    {
                        var a = left/(double)(data.Length - 1);
                        var b = right/(double)(data.Length - 1);
                        return ((data[right] - x)*a + (x - data[left])*b)/(data[right] - data[left]);
                    }
                }
            }
        }
예제 #8
0
 /// <summary>
 /// Estimates the quantile tau from the provided samples.
 /// The tau-th quantile is the data value where the cumulative distribution
 /// function crosses tau. The quantile definition can be specified to be compatible
 /// with an existing system.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
 public static Func <double, double> QuantileRankFunc(this IEnumerable <double?> data, RankDefinition definition = RankDefinition.Default)
 {
     return(QuantileRankFunc(data.Where(d => d.HasValue).Select(d => d.Value), definition));
 }
예제 #9
0
파일: Statistics.cs 프로젝트: EraYaN/EV2020
 /// <summary>
 /// Estimates the quantile tau from the provided samples.
 /// The tau-th quantile is the data value where the cumulative distribution
 /// function crosses tau. The quantile definition can be specificed to be compatible
 /// with an existing system.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
 public static Func<double, double> QuantileRankFunc(this IEnumerable<double> data, RankDefinition definition = RankDefinition.Default)
 {
     var array = data.ToArray();
     Array.Sort(array);
     return x => SortedArrayStatistics.QuantileRank(array, x, definition);
 }
예제 #10
0
파일: Statistics.cs 프로젝트: EraYaN/EV2020
 /// <summary>
 /// Estimates the quantile tau from the provided samples.
 /// The tau-th quantile is the data value where the cumulative distribution
 /// function crosses tau. The quantile definition can be specificed to be compatible
 /// with an existing system.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 /// <param name="x">Quantile value.</param>
 /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
 public static double QuantileRank(this IEnumerable<double?> data, double x, RankDefinition definition = RankDefinition.Default)
 {
     return QuantileRank(data.Where(d => d.HasValue).Select(d => d.Value), x, definition);
 }
예제 #11
0
 /// <summary>
 /// Estimates the quantile tau from the provided samples.
 /// The tau-th quantile is the data value where the cumulative distribution
 /// function crosses tau. The quantile definition can be specified to be compatible
 /// with an existing system.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 /// <param name="x">Quantile value.</param>
 /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
 public static double QuantileRank(this IEnumerable<float> data, float x, RankDefinition definition = RankDefinition.Default)
 {
     float[] array = data.ToArray();
     Array.Sort(array);
     return SortedArrayStatistics.QuantileRank(array, x, definition);
 }
예제 #12
0
        public void CreateAlliance_Callback(Mobile from, string text)
        {
            PlayerMobile pm = from as PlayerMobile;


            AllianceInfo alliance      = guild.Alliance;
            AllianceInfo otherAlliance = m_Other.Alliance;

            if (!IsMember(from, guild) || alliance != null)
            {
                return;
            }


            RankDefinition playerRank = pm.GuildRank;


            if (!playerRank.GetFlag(RankFlags.AllianceControl))
            {
                pm.SendLocalizedMessage(1070747); // You don't have permission to create an alliance.
            }
            else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader))
            {
                //Notes about this: OSI only cares/checks when proposing, you can change your faction all you want later.
                pm.SendLocalizedMessage(1070758); // You cannot propose an alliance to a guild with a different faction allegiance.
            }
            else if (otherAlliance != null)
            {
                if (otherAlliance.IsPendingMember(m_Other))
                {
                    pm.SendLocalizedMessage(1063416, m_Other.Name); // ~1_val~ is currently considering another alliance proposal.
                }
                else
                {
                    pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance.
                }
            }
            else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0)
            {
                pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war.
            }
            else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0)
            {
                pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war.
            }
            else
            {
                string name = Utility.FixHtml(text.Trim());

                if (!BaseGuildGump.CheckProfanity(name))
                {
                    pm.SendLocalizedMessage(1070886); // That alliance name is not allowed.
                }
                else if (name.Length > Guild.NameLimit)
                {
                    pm.SendLocalizedMessage(1070887, Guild.NameLimit.ToString()); // An alliance name cannot exceed ~1_val~ characters in length.
                }
                else if (AllianceInfo.Alliances.ContainsKey(name.ToLower()))
                {
                    pm.SendLocalizedMessage(1063428); // That alliance name is not available.
                }
                else
                {
                    pm.SendLocalizedMessage(1070750, m_Other.Name); // An invitation to join your alliance has been sent to ~1_val~.

                    m_Other.GuildMessage(1070780, guild.Name);      // ~1_val~ has proposed an alliance.

                    new AllianceInfo(guild, name, m_Other);
                }
            }
        }
예제 #13
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            PlayerMobile pm = sender.Mobile as PlayerMobile;

            if (!IsMember(pm, guild))
            {
                return;
            }

            RankDefinition playerRank = pm.GuildRank;

            Guild guildLeader = Guild.GetAllianceLeader(guild);
            Guild otherGuild  = Guild.GetAllianceLeader(m_Other);

            WarDeclaration war       = guildLeader.FindPendingWar(otherGuild);
            WarDeclaration activeWar = guildLeader.FindActiveWar(otherGuild);
            WarDeclaration otherWar  = otherGuild.FindPendingWar(guildLeader);

            AllianceInfo alliance      = guild.Alliance;
            AllianceInfo otherAlliance = otherGuild.Alliance;

            switch (info.ButtonID)
            {
                #region War
            case 5:     //Accept the war
            {
                if (war != null && !war.WarRequester && activeWar == null)
                {
                    if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                    {
                        pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                    }
                    else if (alliance != null && alliance.Leader != guild)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                        pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                    }
                    else
                    {
                        //Accept the war
                        guild.PendingWars.Remove(war);
                        war.WarBeginning = DateTime.UtcNow;
                        guild.AcceptedWars.Add(war);

                        if (alliance != null && alliance.IsMember(guild))
                        {
                            alliance.AllianceMessage(1070769, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name));         // Guild Message: Your guild is now at war with ~1_GUILDNAME~
                            alliance.InvalidateMemberProperties();
                        }
                        else
                        {
                            guild.GuildMessage(1070769, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name));         // Guild Message: Your guild is now at war with ~1_GUILDNAME~
                            guild.InvalidateMemberProperties();
                        }
                        //Technically  SHOULD say Your guild is now at war w/out any info, intentional diff.

                        otherGuild.PendingWars.Remove(otherWar);
                        otherWar.WarBeginning = DateTime.UtcNow;
                        otherGuild.AcceptedWars.Add(otherWar);

                        if (otherAlliance != null && m_Other.Alliance.IsMember(m_Other))
                        {
                            otherAlliance.AllianceMessage(1070769, ((alliance != null) ? alliance.Name : guild.Name));         // Guild Message: Your guild is now at war with ~1_GUILDNAME~
                            otherAlliance.InvalidateMemberProperties();
                        }
                        else
                        {
                            otherGuild.GuildMessage(1070769, ((alliance != null) ? alliance.Name : guild.Name));         // Guild Message: Your guild is now at war with ~1_GUILDNAME~
                            otherGuild.InvalidateMemberProperties();
                        }
                    }
                }

                break;
            }

            case 6:     //Modify war terms
            {
                if (war != null && !war.WarRequester && activeWar == null)
                {
                    if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                    {
                        pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                    }
                    else if (alliance != null && alliance.Leader != guild)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                        pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                    }
                    else
                    {
                        pm.SendGump(new WarDeclarationGump(pm, guild, otherGuild));
                    }
                }
                break;
            }

            case 7:     //Dismiss war
            {
                if (war != null)
                {
                    if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                    {
                        pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                    }
                    else if (alliance != null && alliance.Leader != guild)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                        pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                    }
                    else
                    {
                        //Dismiss the war
                        guild.PendingWars.Remove(war);
                        otherGuild.PendingWars.Remove(otherWar);
                        pm.SendLocalizedMessage(1070752);         // The proposal has been updated.
                                                                  //Messages to opposing guild? (Testing on OSI says no)
                    }
                }
                break;
            }

            case 8:     //Surrender
            {
                if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                {
                    pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                }
                else if (alliance != null && alliance.Leader != guild)
                {
                    pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                    pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                }
                else
                {
                    if (activeWar != null)
                    {
                        if (alliance != null && alliance.IsMember(guild))
                        {
                            alliance.AllianceMessage(1070740, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name));        // You have lost the war with ~1_val~.
                            alliance.InvalidateMemberProperties();
                        }
                        else
                        {
                            guild.GuildMessage(1070740, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name));        // You have lost the war with ~1_val~.
                            guild.InvalidateMemberProperties();
                        }

                        guild.AcceptedWars.Remove(activeWar);

                        if (otherAlliance != null && otherAlliance.IsMember(otherGuild))
                        {
                            otherAlliance.AllianceMessage(1070739, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name));        // You have won the war against ~1_val~!
                            otherAlliance.InvalidateMemberProperties();
                        }
                        else
                        {
                            otherGuild.GuildMessage(1070739, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name));        // You have won the war against ~1_val~!
                            otherGuild.InvalidateMemberProperties();
                        }

                        otherGuild.AcceptedWars.Remove(otherGuild.FindActiveWar(guild));
                    }
                }
                break;
            }

            case 1:     //Declare War
            {
                if (war == null && activeWar == null)
                {
                    if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
                    {
                        pm.SendLocalizedMessage(1063440);         // You don't have permission to negotiate wars.
                    }
                    else if (alliance != null && alliance.Leader != guild)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                        pm.SendLocalizedMessage(1070707, alliance.Leader.Name);                                 // You need to negotiate via ~1_val~ instead.
                    }
                    else if (otherAlliance != null && otherAlliance.Leader != m_Other)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", m_Other.Name, otherAlliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance.
                        pm.SendLocalizedMessage(1070707, otherAlliance.Leader.Name);                                   // You need to negotiate via ~1_val~ instead.
                    }
                    else
                    {
                        pm.SendGump(new WarDeclarationGump(pm, guild, m_Other));
                    }
                }
                break;
            }

                #endregion
            case 2:     //Request Alliance
            {
                #region New alliance
                if (alliance == null)
                {
                    if (!playerRank.GetFlag(RankFlags.AllianceControl))
                    {
                        pm.SendLocalizedMessage(1070747);         // You don't have permission to create an alliance.
                    }
                    else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader))
                    {
                        pm.SendLocalizedMessage(1070758);         // You cannot propose an alliance to a guild with a different faction allegiance.
                    }
                    else if (otherAlliance != null)
                    {
                        if (otherAlliance.IsPendingMember(m_Other))
                        {
                            pm.SendLocalizedMessage(1063416, m_Other.Name);         // ~1_val~ is currently considering another alliance proposal.
                        }
                        else
                        {
                            pm.SendLocalizedMessage(1063426, m_Other.Name);         // ~1_val~ already belongs to an alliance.
                        }
                    }
                    else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0)
                    {
                        pm.SendLocalizedMessage(1063427, m_Other.Name);         // ~1_val~ is currently involved in a guild war.
                    }
                    else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0)
                    {
                        pm.SendLocalizedMessage(1063427, guild.Name);         // ~1_val~ is currently involved in a guild war.
                    }
                    else
                    {
                        pm.SendLocalizedMessage(1063439);         // Enter a name for the new alliance:
                        pm.BeginPrompt(new PromptCallback(CreateAlliance_Callback));
                    }
                }
                #endregion
                #region Existing Alliance
                else
                {
                    if (!playerRank.GetFlag(RankFlags.AllianceControl))
                    {
                        pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                    }
                    else if (alliance.Leader != guild)
                    {
                        pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name));         // ~1_val~ is not the leader of the ~2_val~ alliance.
                    }
                    else if (otherAlliance != null)
                    {
                        if (otherAlliance.IsPendingMember(m_Other))
                        {
                            pm.SendLocalizedMessage(1063416, m_Other.Name);         // ~1_val~ is currently considering another alliance proposal.
                        }
                        else
                        {
                            pm.SendLocalizedMessage(1063426, m_Other.Name);         // ~1_val~ already belongs to an alliance.
                        }
                    }
                    else if (alliance.IsPendingMember(guild))
                    {
                        pm.SendLocalizedMessage(1063416, guild.Name);         // ~1_val~ is currently considering another alliance proposal.
                    }
                    else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0)
                    {
                        pm.SendLocalizedMessage(1063427, m_Other.Name);         // ~1_val~ is currently involved in a guild war.
                    }
                    else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0)
                    {
                        pm.SendLocalizedMessage(1063427, guild.Name);         // ~1_val~ is currently involved in a guild war.
                    }
                    else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader))
                    {
                        pm.SendLocalizedMessage(1070758);         // You cannot propose an alliance to a guild with a different faction allegiance.
                    }
                    else
                    {
                        pm.SendLocalizedMessage(1070750, m_Other.Name); // An invitation to join your alliance has been sent to ~1_val~.

                        m_Other.GuildMessage(1070780, guild.Name);      // ~1_val~ has proposed an alliance.

                        m_Other.Alliance = alliance;                    //Calls addPendingGuild
                                                                        //alliance.AddPendingGuild( m_Other );
                    }
                }
                #endregion
                break;
            }

            case 10:        //Show Alliance Roster
            {
                if (alliance != null && alliance == otherAlliance)
                {
                    pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, guild, alliance));
                }

                break;
            }

            case 11:        //Leave Alliance
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (alliance != null && alliance.IsMember(guild))
                {
                    guild.Alliance = null;          //Calls alliance.Removeguild
                                                    //						alliance.RemoveGuild( guild );

                    m_Other.InvalidateWarNotoriety();

                    guild.InvalidateMemberNotoriety();
                }
                break;
            }

            case 12:        //Remove Guild from alliance
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (alliance != null && alliance.Leader != guild)
                {
                    pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name));         // ~1_val~ is not the leader of the ~2_val~ alliance.
                }
                else if (alliance != null && alliance.IsMember(guild) && alliance.IsMember(m_Other))
                {
                    m_Other.Alliance = null;

                    m_Other.InvalidateMemberNotoriety();

                    guild.InvalidateWarNotoriety();
                }
                break;
            }

            case 13:        //Promote to Alliance leader
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (alliance != null && alliance.Leader != guild)
                {
                    pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name));         // ~1_val~ is not the leader of the ~2_val~ alliance.
                }
                else if (alliance != null && alliance.IsMember(guild) && alliance.IsMember(m_Other))
                {
                    pm.SendLocalizedMessage(1063434, String.Format("{0}\t{1}", m_Other.Name, alliance.Name));         // ~1_val~ is now the leader of ~2_val~.

                    alliance.Leader = m_Other;
                }
                break;
            }

            case 14:        //Withdraw Request
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (alliance != null && alliance.Leader == guild && alliance.IsPendingMember(m_Other))
                {
                    m_Other.Alliance = null;
                    pm.SendLocalizedMessage(1070752);         // The proposal has been updated.
                }
                break;
            }

            case 15:     //Deny Alliance Request
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (alliance != null && otherAlliance != null && alliance.Leader == m_Other && otherAlliance.IsPendingMember(guild))
                {
                    pm.SendLocalizedMessage(1070752);         // The proposal has been updated.
                                                              //m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal.	//Per OSI commented out.

                    guild.Alliance = null;
                }
                break;
            }

            case 16:     //Accept Alliance Request
            {
                if (!playerRank.GetFlag(RankFlags.AllianceControl))
                {
                    pm.SendLocalizedMessage(1063436);         // You don't have permission to negotiate an alliance.
                }
                else if (otherAlliance != null && otherAlliance.Leader == m_Other && otherAlliance.IsPendingMember(guild))
                {
                    pm.SendLocalizedMessage(1070752);         // The proposal has been updated.

                    otherAlliance.TurnToMember(m_Other);      //No need to verify it's in the guild or already a member, the function does this

                    otherAlliance.TurnToMember(guild);
                }
                break;
            }
            }
        }
 public void Apply(RankDefinition definition)
 {
     Rank = definition;
 }
예제 #15
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            PlayerMobile pm = sender.Mobile as PlayerMobile;

            if (pm == null || !IsMember(pm, guild) || !IsMember(m_Member, guild))
            {
                return;
            }

            RankDefinition playerRank = pm.GuildRank;
            RankDefinition targetRank = m_Member.GuildRank;

            switch (info.ButtonID)
            {
            case 1:     //Promote
            {
                if (playerRank.GetFlag(RankFlags.CanPromoteDemote) && ((playerRank.Rank - 1) > targetRank.Rank || (playerRank == RankDefinition.Leader && playerRank.Rank > targetRank.Rank)))
                {
                    targetRank = RankDefinition.Ranks[targetRank.Rank + 1];

                    if (targetRank == RankDefinition.Leader)
                    {
                        if (m_ToLeader)
                        {
                            m_Member.GuildRank = targetRank;
                            pm.SendLocalizedMessage(1063156, m_Member.Name);   // The guild information for ~1_val~ has been updated.
                            pm.SendLocalizedMessage(1063156, pm.Name);         // The guild information for ~1_val~ has been updated.
                            guild.Leader = m_Member;
                        }
                        else
                        {
                            pm.SendLocalizedMessage(1063144);         // Are you sure you wish to make this member the new guild leader?
                            pm.SendGump(new GuildMemberInfoGump(player, guild, m_Member, false, true));
                        }
                    }
                    else
                    {
                        m_Member.GuildRank = targetRank;
                        pm.SendLocalizedMessage(1063156, m_Member.Name);         // The guild information for ~1_val~ has been updated.
                    }
                }
                else
                {
                    pm.SendLocalizedMessage(1063143);         // You don't have permission to promote this member.
                }
                break;
            }

            case 2:     //Demote
            {
                if (playerRank.GetFlag(RankFlags.CanPromoteDemote) && playerRank.Rank > targetRank.Rank)
                {
                    if (targetRank == RankDefinition.Lowest)
                    {
                        if (RankDefinition.Lowest.Name.Number == 1062963)
                        {
                            pm.SendLocalizedMessage(1063333);         // You can't demote a ronin.
                        }
                        else
                        {
                            pm.SendMessage("You can't demote a {0}.", RankDefinition.Lowest.Name);
                        }
                    }
                    else
                    {
                        m_Member.GuildRank = RankDefinition.Ranks[targetRank.Rank - 1];
                        pm.SendLocalizedMessage(1063156, m_Member.Name);         // The guild information for ~1_val~ has been updated.
                    }
                }
                else
                {
                    pm.SendLocalizedMessage(1063146);         // You don't have permission to demote this member.
                }
                break;
            }

            case 3:     //Set Guild title
            {
                if (playerRank.GetFlag(RankFlags.CanSetGuildTitle) && (playerRank.Rank > targetRank.Rank || m_Member == player))
                {
                    pm.SendLocalizedMessage(1011128);         // Enter the new title for this guild member or 'none' to remove a title:

                    pm.BeginPrompt(new PromptCallback(SetTitle_Callback));
                }
                else if (m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0)
                {
                    pm.SendLocalizedMessage(1070746);         // You don't have the permission to set that member's guild title.
                }
                else
                {
                    pm.SendLocalizedMessage(1063148);         // You don't have permission to change this member's guild title.
                }

                break;
            }

            case 4:     //Vote
            {
                if (m_Member == pm.GuildFealty && guild.Leader != m_Member)
                {
                    pm.SendLocalizedMessage(1063158);    // You have cleared your vote for guild leader.
                }
                else if (guild.CanVote(m_Member))        //( playerRank.GetFlag( RankFlags.CanVote ) )
                {
                    if (m_Member == guild.Leader)
                    {
                        pm.SendLocalizedMessage(1063424);         // You can't vote for the current guild leader.
                    }
                    else if (!guild.CanBeVotedFor(m_Member))
                    {
                        pm.SendLocalizedMessage(1063425);         // You can't vote for an inactive guild member.
                    }
                    else
                    {
                        pm.GuildFealty = m_Member;
                        pm.SendLocalizedMessage(1063159, m_Member.Name);         // You cast your vote for ~1_val~ for guild leader.
                    }
                }
                else
                {
                    pm.SendLocalizedMessage(1063149);         // You don't have permission to vote.
                }
                break;
            }

            case 5:     //Kick
            {
                if ((playerRank.GetFlag(RankFlags.RemovePlayers) && playerRank.Rank > targetRank.Rank) || (playerRank.GetFlag(RankFlags.RemoveLowestRank) && targetRank == RankDefinition.Lowest))
                {
                    if (m_toKick)
                    {
                        guild.RemoveMember(m_Member);
                        pm.SendLocalizedMessage(1063157);         // The member has been removed from your guild.
                    }
                    else
                    {
                        pm.SendLocalizedMessage(1063152);         // Are you sure you wish to kick this member from the guild?
                        pm.SendGump(new GuildMemberInfoGump(player, guild, m_Member, true, false));
                    }
                }
                else
                {
                    pm.SendLocalizedMessage(1063151);         // You don't have permission to remove this member.
                }
                break;
            }
            }
        }
예제 #16
0
 /// <summary>
 /// Estimates the quantile tau from the provided samples.
 /// The tau-th quantile is the data value where the cumulative distribution
 /// function crosses tau. The quantile definition can be specified to be compatible
 /// with an existing system.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 /// <param name="x">Quantile value.</param>
 /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
 public static double QuantileRank(this IEnumerable <double?> data, double x, RankDefinition definition = RankDefinition.Default)
 {
     return(QuantileRank(data.Where(d => d.HasValue).Select(d => d.Value), x, definition));
 }
예제 #17
0
        /// <summary>
        /// Estimates the quantile tau from the provided samples.
        /// The tau-th quantile is the data value where the cumulative distribution
        /// function crosses tau. The quantile definition can be specified to be compatible
        /// with an existing system.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
        public static Func <double, double> QuantileRankFunc(this IEnumerable <double> data, RankDefinition definition = RankDefinition.Default)
        {
            var array = data.ToArray();

            Array.Sort(array);
            return(x => SortedArrayStatistics.QuantileRank(array, x, definition));
        }
예제 #18
0
파일: Statistics.cs 프로젝트: EraYaN/EV2020
 /// <summary>
 /// Estimates the quantile tau from the provided samples.
 /// The tau-th quantile is the data value where the cumulative distribution
 /// function crosses tau. The quantile definition can be specificed to be compatible
 /// with an existing system.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
 public static Func<double, double> QuantileRankFunc(this IEnumerable<double?> data, RankDefinition definition = RankDefinition.Default)
 {
     return QuantileRankFunc(data.Where(d => d.HasValue).Select(d => d.Value), definition);
 }
예제 #19
0
        /// <summary>
        /// Evaluates the rank of each entry of the unsorted data array.
        /// The rank definition can be specificed to be compatible
        /// with an existing system.
        /// WARNING: Works inplace and can thus causes the data array to be reordered.
        /// </summary>
        public static double[] RanksInplace(double[] data, RankDefinition definition = RankDefinition.Default)
        {
            var ranks = new double[data.Length];
            var index = new int[data.Length];
            for (int i = 0; i < index.Length; i++)
            {
                index[i] = i;
            }

            if (definition == RankDefinition.First)
            {
                Sorting.SortAll(data, index);
                for (int i = 0; i < ranks.Length; i++)
                {
                    ranks[index[i]] = i + 1;
                }
                return ranks;
            }

            Sorting.Sort(data, index);
            int previousIndex = 0;
            for (int i = 1; i < data.Length; i++)
            {
                if (Math.Abs(data[i] - data[previousIndex]) <= 0d)
                {
                    continue;
                }

                if (i == previousIndex + 1)
                {
                    ranks[index[previousIndex]] = i;
                }
                else
                {
                    RanksTies(ranks, index, previousIndex, i, definition);
                }

                previousIndex = i;
            }

            RanksTies(ranks, index, previousIndex, data.Length, definition);
            return ranks;
        }
예제 #20
0
파일: Statistics.cs 프로젝트: EraYaN/EV2020
 /// <summary>
 /// Evaluates the rank of each entry of the provided samples.
 /// The rank definition can be specificed to be compatible
 /// with an existing system.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
 public static double[] Ranks(this IEnumerable<double> data, RankDefinition definition = RankDefinition.Default)
 {
     var array = data.ToArray();
     return ArrayStatistics.RanksInplace(array, definition);
 }
        /// <summary>
        /// Evaluates the rank of each entry of the sorted data array (ascending).
        /// The rank definition can be specified to be compatible
        /// with an existing system.
        /// </summary>
        public static double[] Ranks(double[] data, RankDefinition definition = RankDefinition.Default)
        {
            var ranks = new double[data.Length];

            if (definition == RankDefinition.First)
            {
                for (int i = 0; i < ranks.Length; i++)
                {
                    ranks[i] = i + 1;
                }

                return ranks;
            }

            int previousIndex = 0;
            for (int i = 1; i < data.Length; i++)
            {
                if (Math.Abs(data[i] - data[previousIndex]) <= 0d)
                {
                    continue;
                }

                if (i == previousIndex + 1)
                {
                    ranks[previousIndex] = i;
                }
                else
                {
                    RanksTies(ranks, previousIndex, i, definition);
                }

                previousIndex = i;
            }

            RanksTies(ranks, previousIndex, data.Length, definition);
            return ranks;
        }
예제 #22
0
파일: Statistics.cs 프로젝트: EraYaN/EV2020
 /// <summary>
 /// Evaluates the rank of each entry of the provided samples.
 /// The rank definition can be specificed to be compatible
 /// with an existing system.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
 public static double[] Ranks(this IEnumerable<double?> data, RankDefinition definition = RankDefinition.Default)
 {
     return Ranks(data.Where(d => d.HasValue).Select(d => d.Value), definition);
 }
예제 #23
0
        /// <summary>
        /// Estimates the quantile tau from the sorted data array (ascending).
        /// The tau-th quantile is the data value where the cumulative distribution
        /// function crosses tau. The quantile definition can be specificed to be compatible
        /// with an existing system.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        /// <param name="x">Quantile value.</param>
        /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
        public static double QuantileRank(double[] data, double x, RankDefinition definition = RankDefinition.Default)
        {
            if (x < data[0])
            {
                return(0.0);
            }
            if (x >= data[data.Length - 1])
            {
                return(1.0);
            }

            int right = Array.BinarySearch(data, x);

            if (right >= 0)
            {
                int left = right;
                while (left > 0 && data[left - 1] == data[left])
                {
                    left--;
                }
                while (right < data.Length - 1 && data[right + 1] == data[right])
                {
                    right++;
                }

                switch (definition)
                {
                case RankDefinition.EmpiricalCDF:
                    return((right + 1) / (double)(data.Length));

                case RankDefinition.Max:
                    return(right / (double)(data.Length - 1));

                case RankDefinition.Min:
                    return(left / (double)(data.Length - 1));

                case RankDefinition.Average:
                    return((left / (double)(data.Length - 1) + right / (double)(data.Length - 1)) / 2);

                default:
                    throw new NotSupportedException();
                }
            }
            else
            {
                right = ~right;
                int left = right - 1;

                switch (definition)
                {
                case RankDefinition.EmpiricalCDF:
                    return((left + 1) / (double)(data.Length));

                default:
                {
                    var a = left / (double)(data.Length - 1);
                    var b = right / (double)(data.Length - 1);
                    return(((data[right] - x) * a + (x - data[left]) * b) / (data[right] - data[left]));
                }
                }
            }
        }
예제 #24
0
 public static double QuantileRank(this IEnumerable <double> data, double x, RankDefinition definition = RankDefinition.Default)
 {
     double[] array = data.ToArray();
     Array.Sort(array);
     return(SortedArrayStatistics.QuantileRank(array, x, definition));
 }