示例#1
0
        public static bool AddScoring(string name, IListedScoringMethod scoring)
        {
            if (sScoring.ContainsKey(name))
            {
                return(false);
            }

            sScoring.Add(name, scoring);
            return(true);
        }
示例#2
0
        public int Score(string name)
        {
            IListedScoringMethod scoring = ScoringLookup.GetScoring(name);

            if (scoring == null)
            {
                return(0);
            }

            return(scoring.IScore(this));
        }
示例#3
0
        public static int GetScore(string name, SimDescription scoreAgainst, SimDescription other)
        {
            IListedScoringMethod scoring = GetScoring(name);

            if (scoring == null)
            {
                return(0);
            }

            return(scoring.IScore(new DualSimScoringParameters(scoreAgainst, other)));
        }
示例#4
0
        public static int GetScoring(Sim actor, Sim target, string scoringName, bool checkAffair, bool absolute)
        {
            if (actor == target)
            {
                return(0);
            }

            int score = 0;

            if (scoringName == "Attraction")
            {
                score = (int)RelationshipEx.GetAttractionScore(actor.SimDescription, target.SimDescription, false);
            }
            else
            {
                IListedScoringMethod scoring = null;

                if (checkAffair)
                {
                    if ((actor.Partner != null) && ((target == null) || (actor.Partner != target.SimDescription)))
                    {
                        scoring = ScoringLookup.GetScoring(scoringName + "Affair");
                    }
                    else
                    {
                        scoring = ScoringLookup.GetScoring(scoringName + "Single");
                    }
                }
                else
                {
                    scoring = ScoringLookup.GetScoring(scoringName);
                }

                if (scoring == null)
                {
                    return(1);
                }

                if (scoring is DualSimListedScoringMethod)
                {
                    score = scoring.IScore(new DualSimScoringParameters(target.SimDescription, actor.SimDescription, absolute));
                }
                else
                {
                    score = scoring.IScore(new SimScoringParameters(actor.SimDescription, absolute));
                }
            }

            return(score);
        }
示例#5
0
        public override bool IsHit(SP parameters)
        {
            if (mScoring == null)
            {
                if (string.IsNullOrEmpty(mMethod))
                {
                    return(false);
                }

                mScoring = ScoringLookup.GetScoring(mMethod);
                mMethod  = null; // Stop the system from checking again
                if (mScoring == null)
                {
                    return(false);
                }
            }

            return(mScoring.IScore(parameters) >= mGate.Score(parameters));
        }
示例#6
0
        protected bool Score(string scoringName, SimDescription potential, SimDescription other, bool absolute, out int score)
        {
            if (string.IsNullOrEmpty(scoringName))
            {
                score = 0;
                return(false);
            }
            else
            {
                IListedScoringMethod scoring = ScoringLookup.GetScoring(scoringName);
                if (scoring == null)
                {
                    score = 0;
                    return(false);
                }

                score = scoring.IScore(new ManagerScoringParameters(mManager, potential, other, absolute));
                return(true);
            }
        }
示例#7
0
        protected override void Perform(BooterHelper.BootFile file, XmlDbRow row)
        {
            BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile;
            if (dataFile == null)
            {
                return;
            }

            bool success = false;

            mIndex++;

            try
            {
                string methodName = row.GetString("Name");
                if (string.IsNullOrEmpty(methodName))
                {
                    BooterLogger.AddError(file + " : Method " + mIndex + " Unnamed");
                }
                else if (ScoringLookup.GetScoring(methodName, false) != null)
                {
                    BooterLogger.AddError(methodName + " Name already in use");
                    return;
                }
                else
                {
                    Type classType = row.GetClassType("FullClassName");
                    if (classType == null)
                    {
                        BooterLogger.AddError(methodName + " Unknown FullClassName: " + row.GetString("FullClassName"));
                    }
                    else
                    {
                        IListedScoringMethod scoring = null;
                        try
                        {
                            scoring = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as IListedScoringMethod;
                        }
                        catch
                        { }

                        if (scoring == null)
                        {
                            BooterLogger.AddError(methodName + ": Constructor Fail " + row.GetString("FullClassName"));
                        }
                        else
                        {
                            XmlDbTable scoringTable = dataFile.GetTable(methodName);
                            if (scoringTable == null)
                            {
                                BooterLogger.AddError(methodName + ": Table Missing");
                            }
                            else
                            {
                                if (scoring.Parse(row, scoringTable))
                                {
                                    BooterLogger.AddTrace("Added Scoring : " + methodName);

                                    ScoringLookup.AddScoring(methodName, scoring);

                                    success = true;
                                }
                                else
                                {
                                    BooterLogger.AddError(methodName + ": Parsing Fail");
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                if (!success)
                {
                    foreach (string column in row.ColumnNames)
                    {
                        BooterLogger.AddError(column + "= " + row[column]);
                    }
                }
            }
        }
示例#8
0
 public SimScoringList(string scoring)
 {
     mMethod = ScoringLookup.GetScoring(scoring);
 }
示例#9
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            List <Item> options = new List <Item>();

            foreach (string name in ScoringLookup.ScoringKeys)
            {
                options.Add(new Item(name));
            }

            CommonSelection <Item> .Results choices = new CommonSelection <Item>(Name, options).SelectMultiple();
            if (choices.Count == 0)
            {
                return(OptionResult.SuccessClose);
            }

            StringBuilder msg = new StringBuilder();

            foreach (Item item in choices)
            {
                IListedScoringMethod scoring = ScoringLookup.GetScoring(item.Name);
                if (scoring == null)
                {
                    continue;
                }

                msg.Append(Common.NewLine + "Scoring: " + scoring.Name);

                Selection.Results allSims = new Selection(Household.EverySimDescription(), item.Name).SelectMultiple();

                float totalNegScore = 0, totalPosScore = 0;
                int   totalNegCount = 0, totalPosCount = 0;

                foreach (SimDescription sim in allSims)
                {
                    msg.Append(Common.NewLine + "Actor: " + sim.FullName);

                    if (scoring is DualSimListedScoringMethod)
                    {
                        SimDescription other = Sim.ActiveActor.SimDescription;

                        msg.Append(Common.NewLine + "Other: " + other.FullName);

                        int score = scoring.IScore(new DualSimScoringParameters(sim, other, true));

                        if (score > 0)
                        {
                            totalPosScore += score;
                            totalPosCount++;
                        }
                        else
                        {
                            totalNegScore += score;
                            totalNegCount++;
                        }

                        msg.Append(Common.NewLine + "Score: " + score);
                    }
                    else
                    {
                        int score = scoring.IScore(new SimScoringParameters(sim, true));

                        if (score > 0)
                        {
                            totalPosScore += score;
                            totalPosCount++;
                        }
                        else
                        {
                            totalNegScore += score;
                            totalNegCount++;
                        }

                        msg.Append(Common.NewLine + "Score: " + score);
                    }

                    msg.Append(Common.NewLine);
                }

                msg.Append(Common.NewLine + "Average Scoring: " + scoring.Name);
                msg.Append(Common.NewLine + "Pos: " + totalPosCount + " " + (totalPosScore / totalPosCount));
                msg.Append(Common.NewLine + "Neg: " + totalNegCount + " " + (totalNegScore / totalNegCount));
            }

            Common.WriteLog(msg.ToString());
            return(OptionResult.SuccessRetain);
        }