private static Score GetMatchScore(Match match, ScoreType scoreType)
 {
     return(match.Scores.FirstOrDefault(s => s.ScoreType == scoreType) ?? new Score()
     {
         ScoreType = scoreType, NotApplicable = true
     });
 }
Example #2
0
        /// <summary>
        /// Determines which score calculation must be performed for the type of ScoreType
        /// and passes the face values of the dice to be used in the calculation.
        /// </summary>
        /// <param name="score">The ScoreType that is to be calculated.</param>
        /// <param name="dieFaceValues">An integer array that contains the values of each die.</param>
        public void ScoreCombination(ScoreType score, int[] dieFaceValues)
        {
            switch (score)
            {
            case ScoreType.Ones:
                CalculateCountingCombination(score, dieFaceValues);
                break;

            case ScoreType.Twos:
                CalculateCountingCombination(score, dieFaceValues);
                break;

            case ScoreType.Threes:
                CalculateCountingCombination(score, dieFaceValues);
                break;

            case ScoreType.Fours:
                CalculateCountingCombination(score, dieFaceValues);
                break;

            case ScoreType.Fives:
                CalculateCountingCombination(score, dieFaceValues);
                break;

            case ScoreType.Sixes:
                CalculateCountingCombination(score, dieFaceValues);
                break;

            case ScoreType.ThreeOfAKind:
                CalculateTotalOfDiceCombination(score, dieFaceValues);
                break;

            case ScoreType.FourOfAKind:
                CalculateTotalOfDiceCombination(score, dieFaceValues);
                break;

            case ScoreType.FullHouse:
                CalculatingFixedCombination(score, dieFaceValues);
                break;

            case ScoreType.SmallStraight:
                CalculatingFixedCombination(score, dieFaceValues);
                break;

            case ScoreType.LargeStraight:
                CalculatingFixedCombination(score, dieFaceValues);
                break;

            case ScoreType.Chance:
                CalculateTotalOfDiceCombination(score, dieFaceValues);
                break;

            case ScoreType.Yahtzee:
                CalculatingFixedCombination(score, dieFaceValues);
                break;
            }
            //decrease number of combinations to do and show scores.
            combinationsToDo--;
            CalculateScoreTotals();
        }
Example #3
0
        public void SetBestMove(ChessBoard cb, int bestMove, int alpha, int beta, int bestScore,
                                int depth)
        {
            if (_threadNumber != 0)
            {
                return;
            }

            BestScore = bestScore;
            Depth     = depth;
            if (bestScore <= alpha)
            {
                ScoreType = ScoreType.Upper;
            }
            else if (bestScore >= beta)
            {
                ScoreType = ScoreType.Lower;
            }
            else
            {
                ScoreType = ScoreType.Exact;
            }

            PvUtil.Set(cb, Pv, bestMove);
        }
Example #4
0
        public bool HasScored(ScoreType type)
        {
            switch (type)
            {
            default:
            case ScoreType.Aces: return(Aces > -1);

            case ScoreType.Twos: return(Twos > -1);

            case ScoreType.Threes: return(Threes > -1);

            case ScoreType.Fours: return(Fours > -1);

            case ScoreType.Fives: return(Fives > -1);

            case ScoreType.Sixes: return(Sixes > -1);

            case ScoreType.ThreeOfAKind: return(ThreeOfAKind > -1);

            case ScoreType.FourOfAKind: return(FourOfAKind > -1);

            case ScoreType.FullHouse: return(FullHouse > -1);

            case ScoreType.SmallStraight: return(SmallStraight > -1);

            case ScoreType.LargeStraight: return(LargeStraight > -1);

            case ScoreType.Yahtzee: return(Yahtzee > -1);

            case ScoreType.Chance: return(Chance > -1);
            }
        }
Example #5
0
        }//END EnableScoreButtons

        /// <summary>
        /// Disables all the score buttons
        /// </summary>
        private void DisableAllButtons()
        {
            for (ScoreType i = ScoreType.Ones; i < ScoreType.YahtzeeBonus; i++)
            {
                form.DisableScoreButton(i);
            }
        }//END DisableAllButtons
Example #6
0
        }//END IsGameFinished

        /// <summary>
        /// Enables all the score buttons
        /// </summary>
        private void EnableScoreButtons()
        {
            for (ScoreType i = ScoreType.Ones; i < ScoreType.YahtzeeBonus; i++)
            {
                form.EnableScoreButton(i);
            }
        }//END EnableScoreButtons
Example #7
0
 /// <summary>
 /// Disable specified score button
 /// </summary>
 /// <param name="combo"> Specified score button </param>
 public void DisableScoreButton(ScoreType combo)
 {
     if (scoreButtons[(int)combo] != null)
     {
         scoreButtons[(int)combo].Enabled = false;
     }
 }
Example #8
0
 public GetUserScoresRequest(long userId, ScoreType type, int page = 0, int itemsPerPage = 5, RulesetInfo ruleset = null)
     : base(page, itemsPerPage)
 {
     this.userId  = userId;
     this.type    = type;
     this.ruleset = ruleset;
 }
Example #9
0
    public void IncrementScore(ScoreType scoreType, int value = 1)
    {
        switch (scoreType)
        {
        case ScoreType.Purple:
            _purpleScore += value;
            UpdateScoreText(ScoreType.Purple);
            break;

        case ScoreType.Blue:
            _blueScore += value;
            UpdateScoreText(ScoreType.Blue);
            break;

        case ScoreType.Red:
            _redScore += value;
            UpdateScoreText(ScoreType.Red);
            break;

        case ScoreType.Green:
            _greenScore += value;
            UpdateScoreText(ScoreType.Green);
            break;

        case ScoreType.Lives:
            _lives += value;
            UpdateScoreText(ScoreType.Lives);
            break;
        }
    }
        public virtual void UpdateScore(ScoreType type, uint value)
        {
            switch (type)
            {
            case ScoreType.KillingBlows:
                KillingBlows += value;
                break;

            case ScoreType.Deaths:
                Deaths += value;
                break;

            case ScoreType.HonorableKills:
                HonorableKills += value;
                break;

            case ScoreType.BonusHonor:
                BonusHonor += value;
                break;

            case ScoreType.DamageDone:
                DamageDone += value;
                break;

            case ScoreType.HealingDone:
                HealingDone += value;
                break;

            default:
                Cypher.Assert(false, "Not implemented Battleground score type!");
                break;
            }
        }
Example #11
0
        public void Add(int participantId, ScoreType type, int value)
        {
            var command = Connection.CreateCommand(
                @"
                    insert into Scores (
                        ParticipantId,
                        ScoreType,
                        ScoreValue
                    ) values (
                        @ParticipantId,
                        @ScoreType,
                        @ScoreValue
                    );
                ");

            command.AddParameterWithValue("@ParticipantId", participantId);
            command.AddParameterWithValue("@ScoreType", (int)type);
            command.AddParameterWithValue("@ScoreValue", value);
            try
            {
                command.ExecuteNonQuery();
            }
            catch (DbException e)
            {
                Logger.Error("Failed to add score", e);
                Logger.Error(command.CommandText);
                throw new RepositoryError("Failed to add score", e);
            }

            Logger.Info("Added score");
            Logger.Info(command.CommandText);
        }
Example #12
0
        /// <summary>
        /// Calculates the score for the specified scoring combination
        /// given the five face values of the dice
        /// </summary>
        /// <param name="scoreType"></param>
        /// <param name="dieValues"></param>
        public void ScoreCombination(ScoreType scoreType, int[] dieValues)
        {
            int jokerIndex = 0;

            ((Combination)scores[(int)scoreType]).CalculateScore(dieValues); // scores player
            combinationsToDo--;

            // Applies bonus points if needed
            if (scoreType != ScoreType.Yahtzee && ((Combination)scores[(int)scoreType]).IsYahtzee)
            {
                if (scores[(int)ScoreType.Yahtzee].Done)
                {
                    scores[(int)ScoreType.YahtzeeBonus].Points = 100;
                }
            }

            jokerIndex = ((Combination)scores[(int)scoreType]).YahtzeeNumber - 1;

            if (scores[(int)scoreType] is FixedScore && ((Combination)scores[(int)scoreType]).IsYahtzee && scores[jokerIndex].Done)    // if requirements for Yahtzee joker are met (scoretype is fixed, score is yahtzee
                                                                                                                                       // and required combination is done
            {
                ((FixedScore)scores[(int)scoreType]).PlayYahtzeeJoker();
            }

            // Calculates the totals
            SubTotal();
            TotalUpperSection();
            TotalLowerSection();
            GrandTotal = TotalOfPoints();
        }
Example #13
0
        public void Update(int participantId, ScoreType type, int value)
        {
            var command = Connection.CreateCommand(
                @"
                    update Scores set
                        ScoreValue=@ScoreValue
                    where
                        ParticipantId=@ParticipantId and
                        ScoreType=@ScoreType
                    ;
                ");

            command.AddParameterWithValue("@ScoreValue", value);
            command.AddParameterWithValue("@ParticipantId", participantId);
            command.AddParameterWithValue("@ScoreType", (int)type);

            try
            {
                command.ExecuteNonQuery();
            }
            catch (DbException e)
            {
                Logger.Error("Failed to update score", e);
                Logger.Error(command.CommandText);
                throw new RepositoryError("Failed to update score", e);
            }

            Logger.Info("Updated score");
            Logger.Info(command.CommandText);
        }
        public PaginatedScoreContainer(ScoreType type, Bindable <User> user, string headerText, CounterVisibilityState counterVisibilityState, string missingText = "")
            : base(user, headerText, missingText, counterVisibilityState)
        {
            this.type = type;

            ItemsPerPage = 5;
        }
Example #15
0
        // add a corresponding number of points to a player's score (based on player index)
        public void addPoints(PlayerIndex playerNumber, ScoreType scoreType)
        {
            if(m_players == null) { return; }

            int score = 0;
            switch(scoreType) {
                case ScoreType.BigAsteroid: // add 5 points for big asteroids
                    score = 5;
                    break;
                case ScoreType.SmallAsteroid: // add 10 points for small asteroids
                    score = 10;
                    break;
                case ScoreType.SpaceShip: // add 50 points for space ships (enemy players)
                    score = 50;
                    break;
            }

            // add the points to the appropriate player
            switch(playerNumber) {
                case PlayerIndex.One:
                    m_score[0] += score;
                    break;
                case PlayerIndex.Two:
                    m_score[1] += score;
                    break;
                case PlayerIndex.Three:
                    m_score[2] += score;
                    break;
                case PlayerIndex.Four:
                    m_score[3] += score;
                    break;
            }
        }
Example #16
0
        public static string GetScoreForType(ScoreType type)
        {
            switch (type)
            {
            default:
            case ScoreType.Aces:
            case ScoreType.Twos:
            case ScoreType.Threes:
            case ScoreType.Fours:
            case ScoreType.Fives:
            case ScoreType.Sixes: return(type.ToString());

            case ScoreType.ThreeOfAKind: return("Three of a Kind");

            case ScoreType.FourOfAKind: return("Four of a Kind");

            case ScoreType.FullHouse: return("Full House");

            case ScoreType.SmallStraight: return("Small Straight");

            case ScoreType.LargeStraight: return("Large Straight");

            case ScoreType.Yahtzee: return("Yahtzee");

            case ScoreType.Chance: return("Chance");
            }
        }
Example #17
0
 /// <summary>
 /// Enables specified score button
 /// </summary>
 /// <param name="combo"> Which ScoreType to enable </param>
 public void EnableScoreButton(ScoreType combo)
 {
     if (scoreButtons[(int)combo] != null)
     {
         scoreButtons[(int)combo].Enabled = true;
     }
 }
 public ImageHandler(string username, int limit, int mode, int scoreType)
 {
     _username  = username;
     _limit     = limit;
     _mode      = (Mode)mode;
     _scoreType = (ScoreType)scoreType;
 }
Example #19
0
        public ScoringReward AddScoringEvent(ScoreType @event, GuiBridge g)
        {
            switch (@event)
            {
            case ScoreType.Build:
                ModulesBuilt++;
                break;

            case ScoreType.Craft:
                ItemsCrafted++;
                break;

            case ScoreType.Repair:
                RepairsEffected++;
                break;

            case ScoreType.Science:
                ScienceMissionsCompleted++;
                break;

            case ScoreType.Survivor:

                break;
            }
            var result = ScoringConstants.ScoringRewards[(int)@event];

            g.ShowScoringEvent(result);
            return(result);
        }
Example #20
0
        public async Task ModifyAsync(List <SocketGuildUser> users, ScoreType type, int modifier)
        {
            var sb = new StringBuilder();

            foreach (var user in users)
            {
                var eUser = Context.Server.Users.FirstOrDefault(x => x.UserID == user.Id);
                if (eUser == null)
                {
                    sb.AppendLine("User is not registered");
                    continue;
                }

                int finalValue;
                switch (type)
                {
                case ScoreType.win:
                    eUser.Stats.Wins += modifier;
                    finalValue        = eUser.Stats.Wins;
                    break;

                case ScoreType.loss:
                    eUser.Stats.Losses += modifier;
                    finalValue          = eUser.Stats.Losses;
                    break;

                case ScoreType.draw:
                    eUser.Stats.Draws += modifier;
                    finalValue         = eUser.Stats.Draws;
                    break;

                case ScoreType.kill:
                    eUser.Stats.Kills += modifier;
                    finalValue         = eUser.Stats.Kills;
                    break;

                case ScoreType.death:
                    eUser.Stats.Deaths += modifier;
                    finalValue          = eUser.Stats.Deaths;
                    break;

                case ScoreType.point:
                    eUser.Stats.Points += modifier;
                    finalValue          = eUser.Stats.Points;
                    var nick = Task.Run(() => UserManagement.UserRenameAsync(Context, eUser));
                    var role = Task.Run(() => UserManagement.UpdateUserRanksAsync(Context, eUser));
                    break;

                default:
                    throw new InvalidOperationException("Unable to modify stats with provided type");
                }

                sb.AppendLine($"{user.Mention} {type}'s modified: {finalValue}");
            }

            await Context.Server.Save();

            await SimpleEmbedAsync(sb.ToString());
        }
Example #21
0
        public bool ScoreCombination(ScoreType scores)//don't know if right input
        {
            playersFinished++;
            currentPlayerIndex++;

            //currentPlayer.IsAvailable(scores);
            return(true);
        }
Example #22
0
 // add a corresponding number of points to a player's score (based on space ship object)
 public void addPoints(SpaceShip player, ScoreType scoreType)
 {
     if (player == null)
     {
         return;
     }
     addPoints(player.playerNumber, scoreType);
 }
Example #23
0
        public Score SetScoreValue(int participantId, ScoreType type, int value)
        {
            ScoreRepository.Set(participantId, type, value);
            var score = ScoreRepository.Get(participantId);

            ObserverSetScore(score);
            return(score);
        }
 /// <summary>
 /// Create a new <see cref="WeaponAttackDetails"/>.
 /// </summary>
 /// <param name="target">
 /// What the attack affects.
 /// </param>
 /// <param name="attackBonus">
 /// The <see cref="Score"/> for the attack bonus. If the attack does not use an 
 /// attack roll, this can be null. This is added to Scores if not null.
 /// </param>
 /// <param name="damage">
 /// The power's base damage. If the attack does not deal damage, this can be null.
 /// </param>
 /// <param name="damageBonus">
 /// The <see cref="Score"/> for the damage bonus. If the attack does not deal damage,
 /// this can be null. This is added to Scores if not null.
 /// </param>
 /// <param name="attackedDefense">
 /// The defense attacked. If there is no attack roll, this value is ignored.
 /// </param>
 /// <param name="additionalScores">
 /// Additional scores used by the attack, usually for additional effects like 
 /// "pushes the target Wisdom modifier squares" or "an ally gains Charisma modifier temporary hit points".
 /// </param>
 /// <param name="additionalText">
 /// Additional details of the attack included immediately after the damage bonus. This supports "{0}"
 /// being the attack bonus (if specified), "{1}" the damage (if specified), "{2}" the damage bonus (if specified)
 /// and the values in <paramref name="additionalScores"/> with the first value starting at "{3}" (assuming
 /// attack bonus, damage and damage bonus were all specified).
 /// </param>
 /// <param name="missText">
 /// A description of the effect of the power on a miss or null, if the power does nothing on a miss. This 
 /// supports the same string substitution parameters as <paramref name="additionalText"/>.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Either <paramref name="damage"/> and <paramref name="damageBonus"/> must be supplied or both must be null.
 /// <paramref name="additionalText"/> must also be specified. <paramref name="target"/> cannot be null.
 /// </exception>
 public WeaponAttackDetails(string target, Score attackBonus, PowerDamage damage, Score damageBonus,
     ScoreType attackedDefense, IList<ModifierSource> additionalScores, string additionalText, 
     string missText)
     : base(target, attackBonus, damage, damageBonus, attackedDefense, additionalScores, 
         additionalText, missText)
 {
     // Do nothing
 }
Example #25
0
 private void OnTrailCompleted(ScoreType score)
 {
     // Set position to center of the scene
     GetComponent <RectTransform>().localPosition = Vector3.zero;
     timeText.text   = score.TimeFormatted();
     scoreText.text  = score.Score.ToString();
     healthText.text = player.Health.ToString();
 }
Example #26
0
File: Db.cs Project: Xwilarg/Kyouka
        public async Task AddGameAsync(string name, ScoreType type)
        {
            var score = new Score(name, type);

            _scores.Add(name, score);

            await _r.Db(_dbName).Table("Scores").Insert(score).RunAsync(_conn);
        }
Example #27
0
 public void AddPoints(ScoreType scoreType)
 {
     if (!usedMods)
     {
         metrics.UpdateStats(scoreType);
         OnUpdatedScore(metrics.Score);
     }
 }
Example #28
0
        }//END YahtzeeBonus

        /// <summary>
        /// Calculates if Yahtzee Joker is playable.
        /// </summary>
        /// <param name="type">ScoreType of scored variable</param>
        /// <param name="dieValues">DieValue Array of Rolled dice.</param>
        private void YahtzeeJoker(ScoreType type, int[] dieValues) {
            if (((Combination)(scores[(int)type])).IsYahtzee) {
                int jokerCheck = dieValues[0] - 1; ;
                if ((scores[jokerCheck]).Done && ((int)type == (int)ScoreType.SmallStraight || (int)type == (int)ScoreType.LargeStraight)) {
                    ((FixedScore)scores[(int)type]).PlayYahtzeeJoker();
                }
            }
        }//END YahtzeeJoker
Example #29
0
 /// <summary>
 /// Shows the scores of each score label.
 /// </summary>
 public void ShowScores()
 {
     //for every scoretype show the score
     for (ScoreType i = ScoreType.Ones; i <= ScoreType.GrandTotal; i++)
     {
         scores[(int)i].ShowScore();
     }
 }
Example #30
0
 public SongSelectFilter()
 {
     Field      = SortField.Name;
     Desc       = false;
     Difficulty = SongInformation.AvailableDifficulty.Easy | SongInformation.AvailableDifficulty.Normal |
                  SongInformation.AvailableDifficulty.Hard | SongInformation.AvailableDifficulty.Extreme;
     Type = ScoreType.Normal | ScoreType.AC | ScoreType.ACFT;
 }
Example #31
0
 public void ScoreCombination(ScoreType score)
 {
     int[] faces = new int[Form1.NUM_DICE];
     for (int i = 0; i < Form1.NUM_DICE; i++)
     {
         faces[i] = dice[i].FaceValue;
     }
     players[currentPlayerIndex].ScoreCombination(score, faces);
 }
        void IShowInstructionsUi.InsertScoreSummary(ScoreType scoreType, int playerScore, int computerScore)
        {
            ScoreSummaryView view = new ScoreSummaryView();

            view.Initialize(scoreType, playerScore, computerScore);
            view.Width  = _listHistory.ActualWidth - SCROLLBAR_WIDTH;
            view.Height = (view.Width * HEIGHT_WIDTH_RATIO) * .50;
            _scoreHistoryList.Insert(0, view);
        }
        /// <summary>
        /// Create a new <see cref="AbilityScore"/>.
        /// </summary>
        /// <param name="name">
        /// The ability score name.
        /// </param>
        /// <param name="abbreviation">
        /// An abbreviated ability score.
        /// </param>
        /// <param name="modifierScore">
        /// The <see cref="ScoreType"/> that
        /// </param>
        public AbilityScore(string name, string abbreviation, ScoreType modifierScore)
            : base(name, abbreviation)
        {
            if (!ScoreTypeHelper.AbilityScoreModifiers.Contains((modifierScore)))
            {
                throw new ArgumentException("modifierScore is not an ability score modifier.");
            }

            this.ModifierScore = modifierScore;
        }
Example #34
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="nFeatures">The number of desired features.</param>
 /// <param name="scaleFactor">Coefficient by which we divide the dimensions from one scale pyramid level to the next.</param>
 /// <param name="nLevels">The number of levels in the scale pyramid.</param>
 /// <param name="edgeThreshold">How far from the boundary the points should be.</param>
 /// <param name="firstLevel">The level at which the image is given. If 1, that means we will also look at the image scaleFactor times bigger.</param>
 /// <param name="WTA_K"></param>
 /// <param name="scoreType"></param>
 /// <param name="patchSize"></param>
 public ORB_GPU(int nFeatures = 500, float scaleFactor = 1.2f, int nLevels = 8, int edgeThreshold = 31,
              int firstLevel = 0, int WTA_K = 2, ScoreType scoreType = 0, int patchSize = 31)
 {
     Cv2Gpu.ThrowIfGpuNotAvailable();
     ptr = NativeMethods.gpu_ORB_GPU_new(
         nFeatures, scaleFactor, nLevels, edgeThreshold,
         firstLevel, WTA_K, (int)scoreType, patchSize);
     if (ptr == IntPtr.Zero)
         throw new OpenCvSharpException();
 }
        /// <summary>
        /// Create a new <see cref="AbilityCheck"/>.
        /// </summary>
        /// <param name="abilityScore"></param>
        public AbilityCheck(ScoreType abilityScore)
            : base(GetName(abilityScore), GetName(abilityScore))
        {
            if (!ScoreTypeHelper.IsAbilityScore(abilityScore))
            {
                throw new ArgumentException("Not an ability score", "abilityScore");
            }

            this.abilityScore = abilityScore;
        }
        /// <summary>
        /// Create a new <see cref="Skill"/>.
        /// </summary>
        /// <param name="name">
        /// The skill's name.
        /// </param>
        /// <param name="abilityScore">
        /// The ability score whose modifier will be added to the skill.
        /// </param>
        /// <exception cref="ArgumentException">
        /// abilityScore is not an ability score.
        /// </exception>
        public Skill(string name, ScoreType abilityScore)
            : base(name, name)
        {
            if (!ScoreTypeHelper.IsAbilityScore(abilityScore))
            {
                throw new ArgumentException("Not an ability score", "abilityScore");
            }

            this.abilityScore = abilityScore;
        }
Example #37
0
        public Dart(GroupBox gp, int score, ScoreType type)
        {
            InitializeComponent();

            _type = type;
            Score = score;
            Multiplier = GetMultiplier();

            ProcessInfo();

            addToGroupBox(gp);
        }
        /// <summary>
        /// Create a new <see cref="AttackDetails"/>.
        /// </summary>
        /// <param name="target">
        /// What the attack affects.
        /// </param>
        /// <param name="attackBonus">
        /// The <see cref="Score"/> for the attack bonus. If the attack does not use an 
        /// attack roll, this can be null. This is added to Scores if not null.
        /// </param>
        /// <param name="damage">
        /// The power's base damage. If the attack does not deal damage, this can be null.
        /// </param>
        /// <param name="damageBonus">
        /// The <see cref="Score"/> for the damage bonus. If the attack does not deal damage,
        /// this can be null. This is added to Scores if not null.
        /// </param>
        /// <param name="attackedDefense">
        /// The defense attacked. If there is no attack roll, this value is ignored.
        /// </param>
        /// <param name="additionalScores">
        /// Additional scores used by the attack, usually for additional effects like 
        /// "pushes the target Wisdom modifier squares" or "an ally gains Charisma modifier temporary hit points".
        /// </param>
        /// <param name="additionalText">
        /// Additional details of the attack included immediately after the damage bonus. This supports "{0}"
        /// being the first score in <paramref name="additionalScores"/>, "{1}" being the second and so on.
        /// </param>
        /// <param name="missText">
        /// A description of the effect of the power on a miss or null, if the power does nothing on a miss. This 
        /// supports the same string substitution parameters as <paramref name="additionalText"/>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Either <paramref name="damage"/> and <paramref name="damageBonus"/> must be supplied or both must be null.
        /// <paramref name="additionalText"/> must also be specified. <paramref name="target"/> cannot be null.
        /// </exception>
        public AttackDetails(string target, Score attackBonus, PowerDamage damage, Score damageBonus, ScoreType attackedDefense,
            IList<ModifierSource> additionalScores, string additionalText, string missText)
        {
            if (string.IsNullOrEmpty(target))
            {
                throw new ArgumentNullException("target");
            }
            if ((damage != null && damageBonus == null) || (damage != null && damageBonus == null))
            {
                throw new ArgumentNullException("damage",
                    "Either damage and damageBonus must be supplied or both must be null.");
            }
            if (additionalScores == null)
            {
                throw new ArgumentNullException("additionalScores");
            }
            if (additionalScores.Contains(null))
            {
                throw new ArgumentNullException("additionalScores", "One or more elements are null");
            }
            if (string.IsNullOrEmpty(additionalText))
            {
                throw new ArgumentNullException("additionalText");
            }

            this.attackBonus = attackBonus;
            this.attackedDefense = attackedDefense;
            this.damage = damage;
            this.damageBonus = damageBonus;
            this.additionalText = additionalText;
            this.missText = missText;
            this.modifierSources = new List<ModifierSource>();
            this.target = target;

            if (attackBonus != null)
            {
                AddModifierSource(attackBonus);
            }
            if (damage != null)
            {
                AddModifierSource(damage);
            }
            if (damageBonus != null)
            {
                AddModifierSource(damageBonus);
            }
            this.additionalScores = new List<ModifierSource>();
            this.additionalScores.AddRange(additionalScores);
            this.modifierSources.AddRange(additionalScores);
        }
        /// <summary>
        /// Create an <see cref="AdditionalMovementMode"/>.
        /// </summary>
        /// <param name="name">
        /// The name of the trait. This cannot be null.
        /// </param>
        /// <param name="description">
        /// The description of the trait. This can be null.
        /// </param>
        /// <param name="movementMode">
        /// The name of the movement mode (e.g. "Climb" or "Fly").
        /// </param>
        /// <exception cref="ArgumentException">
        /// <paramref name="movementMode"/> cannot be ScoreType.Speed or a non-movement mode.
        /// </exception>
        public AdditionalMovementMode(string name, string description, ScoreType movementMode)
            : base(name, description)
        {
            if (!ScoreTypeHelper.MovementModes.Contains(movementMode))
            {
                throw new ArgumentException("Not a movement mode", "movementMode");
            }
            if (movementMode == ScoreType.Speed)
            {
                throw new ArgumentException("Cannot be ScoreType.Speed", "movementMode");
            }

            MovementMode = movementMode;
        }
        public void Test_AbilityScore_Creation(ScoreType primaryOriginAbilityScore, ScoreType secondaryOriginAbilityScore,
            int expectedStrength, int expectedConstitution, int expectedDexterity, int expectedIntelligence, int expectedWisdom, int expectedCharisma)
        {
            AbilityScores abilityScores;

            abilityScores = new AbilityScores(new NullOrigin(primaryOriginAbilityScore), new NullOrigin(secondaryOriginAbilityScore),
                new int[]{ 14, 12, 10, 8, 6});

            Assert.That(abilityScores[ScoreType.Strength], Is.EqualTo(expectedStrength), "Incorrect Strength");
            Assert.That(abilityScores[ScoreType.Constitution], Is.EqualTo(expectedConstitution), "Incorrect Constitution");
            Assert.That(abilityScores[ScoreType.Dexterity], Is.EqualTo(expectedDexterity), "Incorrect Dexterity");
            Assert.That(abilityScores[ScoreType.Intelligence], Is.EqualTo(expectedIntelligence), "Incorrect Intelligence");
            Assert.That(abilityScores[ScoreType.Wisdom], Is.EqualTo(expectedWisdom), "Incorrect Wisdom");
            Assert.That(abilityScores[ScoreType.Charisma], Is.EqualTo(expectedCharisma), "Incorrect Charisma");
        }
Example #41
0
	private ScoreUI GetScoreUI(ScoreType scoreType)
	{
		switch (scoreType)
		{
			case ScoreType.Trample:
				return this.trample;
			case ScoreType.Eat:
				return this.eat;
			case ScoreType.Capture:
				return this.capture;
			case ScoreType.Plant:
				return this.plant;
		}
		
        // TODO: gate on team selecting an objective
		throw new InvalidEnumArgumentException("No UI component defined for ScoreType " + scoreType);
	}
        /// <summary>
        /// Create a new <see cref="InternalModifierSource"/>.
        /// </summary>
        /// <param name="trainedSkill">
        /// The skill the character is trained in.
        /// </param>
        /// <param name="primaryPowerSource">
        /// The primary <see cref="Origin"/>'s power source.
        /// </param>
        /// <exception cref="ArgumentException">
        /// <paramref name=" trainedSkill"/> is not a skill.
        /// </exception>
        public InternalModifierSource(ScoreType trainedSkill, PowerSource primaryPowerSource)
            : base("Character", "Character")
        {
            if (!ScoreTypeHelper.IsSkill(trainedSkill))
            {
                throw new ArgumentException("Not a skill", "trainedSkill");
            }

            TrainedSkill = trainedSkill;

            traits = new List<Trait>();
            traits.Add(new Trait("Primary Origin Power Source",
                string.Format("+2 bonus to overcharge {0} Alpha powers", primaryPowerSource.ToString())));

            powers = new List<Power>();
            powers.Add(new BasicAttack());
            powers.Add(new SecondWind());
        }
Example #43
0
    public TeamPlayer ObjectiveUpdated(string controllerAffix, ScoreType objectiveChoosen, out bool isNewPlayer, out bool newObjective)
    {
        TeamPlayer player;

        // update player chosen objective
        isNewPlayer = AllPlayers.Any(p => p.ControllerAffix == controllerAffix) == false;
        if (isNewPlayer)
            player = addPlayer(controllerAffix);
        else
            player = AllPlayers.Where(p => p.ControllerAffix == controllerAffix).First();

        // determine if it's a new objective
        newObjective = false;
        if (player.ObjectiveSelected != objectiveChoosen)
        {
            player.ObjectiveSelected = objectiveChoosen;
            newObjective = true;
        }

        return player;
    }
 private string ScoreToString(ScoreType score)
 {
     switch (score)
     {
     case ScoreType.Overall:
         return "Overall Score";
     case ScoreType.Position:
         return "Position Score";
     case ScoreType.Rotation:
         return "Rotation Score";
     case ScoreType.LinearVelocity:
         return "Linear Velocity Score";
     case ScoreType.AngularVelocity:
         return "Angular Velocity Score";
     case ScoreType.AlignmentDifference:
         return "Alignment Difference Score";
     }
     return "";
 }
Example #45
0
 /// <summary>
 /// Create a ORBDetector using the specific values
 /// </summary>
 /// <param name="numberOfFeatures">The number of desired features. </param>
 /// <param name="scaleFactor">Coefficient by which we divide the dimensions from one scale pyramid level to the next.</param>
 /// <param name="nLevels">The number of levels in the scale pyramid. </param>
 /// <param name="firstLevel">The level at which the image is given. If 1, that means we will also look at the image.<paramref name="scaleFactor"/> times bigger</param>
 /// <param name="edgeThreshold">How far from the boundary the points should be.</param>
 /// <param name="WTK_A">How many random points are used to produce each cell of the descriptor (2, 3, 4 ...).</param>
 /// <param name="scoreType">Type of the score to use.</param>
 /// <param name="patchSize">Patch size.</param>
 /// <param name="fastThreshold">FAST threshold</param>
 public ORBDetector(int numberOfFeatures = 500, float scaleFactor = 1.2f, int nLevels = 8, int edgeThreshold = 31, int firstLevel = 0, int WTK_A = 2, ScoreType scoreType = ScoreType.Harris, int patchSize = 31, int fastThreshold = 20)
 {
    _ptr = CvInvoke.cveOrbDetectorCreate(numberOfFeatures, scaleFactor, nLevels, edgeThreshold, firstLevel, WTK_A, scoreType, patchSize, fastThreshold, ref _feature2D);
 }
Example #46
0
    ///// <summary>
    ///// Get the team's total score in the given category.
    ///// </summary>
    ///// <param name="team"></param>
    ///// <param name="scoreType"></param>
    ///// <returns></returns>
    //private int TeamScore(int team, ScoreType scoreType)
    //{
    //    var rval = 0;
    //    for (var index = 0; index < this.teamToPlayers[team].Count; index++)
    //    {
    //        var playerId = this.teamToPlayers[team][index];
    //        rval += this.playerScores[playerId][scoreType];
    //    }

    //    return rval;
    //}

	private int ScoreModifier(ScoreType scoreType)
	{
		switch (scoreType)
		{
		case ScoreType.Trample:
			return this.tramplePoints;
		case ScoreType.Eat:
			return this.eatPoints;
		case ScoreType.Capture:
			return this.capturePoints;
		case ScoreType.Plant:
			return this.plantPoints;
		}

		throw new InvalidEnumArgumentException("No score modifier defined for ScoreType " + scoreType);
	}
 /// <summary>
 /// Return the name for the ability check.
 /// </summary>
 /// <param name="abilityScore">
 /// The ability score to use in the name.
 /// </param>
 /// <returns>
 /// The score's name.
 /// </returns>
 private static string GetName(ScoreType abilityScore)
 {
     return string.Format("{0} check", abilityScore);
 }
Example #48
0
        private static double CalculateVectorScore(ref List<scoreListItem> DailyscoreList, ref List<scoreListItem> MonthlyscoreList,
                                                   ScoreType scoreType, List<Kids_Scores> userScore, double CalculatedScore)
        {
            int scoreTypeId = scoreType.Id;
            //////////////////////////////Daily///////////////////////////////////////////////////////////////////////////////////
            var Ranges = scoreType.GetRangeScore();

            var userscore_PerDayList = userScore.Where(o => o.ScoreTypeId == scoreTypeId)
                                                .GroupBy(o => o.PersianCreateDateTime);

            double total_Today = 0;
            foreach (var userscore_Day in userscore_PerDayList)
            {
                double TodayScore = 0;
                foreach (Kids_Scores score in userscore_Day)
                {
                    var r = Ranges.FirstOrDefault(o => score.Value >= o.From && score.Value <= o.To);
                    if (r == null)
                        throw new ArgumentOutOfRangeException(string.Format("No Range Found for this Value :{0} --- Value:{1}", scoreType.ScoreEnName, score.Value));
                    TodayScore += score.Value * r.CoefficentValue;
                }
                total_Today += Math.Min(TodayScore, scoreType.MaxPerDay);
                DailyscoreList.Add(new scoreListItem
                {
                    scoreType = scoreType,
                    Date = userscore_Day.Key,
                    Sum_NotFiltered = TodayScore,
                    Sum_Filtered = Math.Min(TodayScore, scoreType.MaxPerDay),
                });

            }


            ///////////////////////////////Monthly//////////////////////////////////////////////////////////////////////////////////


            var userscore_PerMonthList = userScore.Where(o => o.ScoreTypeId == scoreTypeId)
                                                  .GroupBy(o => o.PersianCreateDateTime.Substring(0, 6));

            double total_Month = 0;
            foreach (var userscore_Month in userscore_PerMonthList)
            {
                double ThisMonthScore = 0;
                foreach (Kids_Scores score in userscore_Month)
                {
                    var r = Ranges.FirstOrDefault(o => score.Value >= o.From && score.Value <= o.To);
                    if (r == null)
                        throw new ArgumentOutOfRangeException(string.Format("No Range Found for this Value :{0} --- Value:{1}", scoreType.ScoreEnName, score.Value));
                    ThisMonthScore += score.Value * r.CoefficentValue;
                }
                total_Month += Math.Min(ThisMonthScore, scoreType.MaxPerMonth);
                MonthlyscoreList.Add(new scoreListItem
                {
                    scoreType = scoreType,
                    Date = userscore_Month.Key,
                    Sum_NotFiltered = ThisMonthScore,
                    Sum_Filtered = Math.Min(ThisMonthScore, scoreType.MaxPerDay),
                });

            }
            CalculatedScore += Math.Min(total_Month, total_Today);

            return CalculatedScore;
        }
Example #49
0
    /// <summary>
    /// Update the player's score and calculates the new team score.
    /// </summary>
    /// <param name="playerId"></param>
    /// <param name="scoreType"></param>
	public void Score(PlayerId playerId, ScoreType scoreType)
	{
		if (!this.startTimer)
		{
			return;
		}

        // increment player score
        var teamNumber = Globals.Instance.ManageTeam.GetTeamNumber(playerId);
        this.scores[teamNumber][scoreType] += this.ScoreModifier(scoreType);
		//this.playerScores[playerId][scoreType] += this.ScoreModifier(scoreType);

        // get player's team
        //var team = this.playerToTeam[playerId];

        // aggregate team score 
        //var teamScore = this.TeamScore(team, scoreType);

        // get the text field for this player's team and score type and update it
		if (teamNumber < this.scoreboards.Count && this.scoreboards[teamNumber] != null)
		{
            this.scoreboards[teamNumber].SetScore(scoreType, this.scores[teamNumber][scoreType]);
		}
	}
Example #50
0
        private static bool IsSpecialScoreType(ScoreType scoreType)
        {
            switch (scoreType.ScoreEnName.ToEnumByName<SpecialScoreType>())
            {
                case SpecialScoreType.ACCREMAIN:
                case SpecialScoreType.REGISTRATION:
                case SpecialScoreType.ADDACCOUNT:
                case SpecialScoreType.POLL:

                    return true;
                default:
                    return false;
            }
        }
Example #51
0
 public static void AddScore(KidsUser user, ScoreType scoreType, Double Value)
 {
     Kids_Scores kscore = new Kids_Scores
     {
         KidsUser = user,
         ScoreTypeId = scoreType.Id,
         Value = Value,
         CreateDateTime = DateTime.Now
     };
     Score_DataProvider.SaveScore(kscore);
 }
Example #52
0
        private static double CalculateSpecialScore(KidsUser user, ScoreType scoreType, ref List<scoreListItem> DailyscoreList,
                                                    ref List<scoreListItem> MonthlyscoreList)
        {
            switch (scoreType.ScoreEnName.ToEnumByName<SpecialScoreType>())
            {
                case SpecialScoreType.REGISTRATION:
                    #region
                    {
                        if (user.CurrentStatus == (int)KidsUserStatus.RegisterWithoutConfirmation)
                            return 0;

                        DailyscoreList.Add(new scoreListItem
                            {
                                Date = PersianDateTime.MiladiToPersian(user.CreateDateTime).ToString(),
                                scoreType = scoreType,
                                Sum_Filtered = scoreType.CoefficentValue,
                                Sum_NotFiltered = scoreType.CoefficentValue
                            });

                        MonthlyscoreList.Add(new scoreListItem
                        {
                            Date = PersianDateTime.MiladiToPersian(user.CreateDateTime).ToString(),
                            scoreType = scoreType,
                            Sum_Filtered = scoreType.CoefficentValue,
                            Sum_NotFiltered = scoreType.CoefficentValue
                        });
                        return scoreType.CoefficentValue;
                    }
                    #endregion

                case SpecialScoreType.ADDACCOUNT:
                    #region

                    {
                        if (user != null && !string.IsNullOrWhiteSpace(user.ChildAccNo))
                        {
                            DailyscoreList.Add(new scoreListItem
                                {
                                    Date = PersianDateTime.MiladiToPersian(user.LastUpdateDateTime.Value).ToString(),
                                    scoreType = scoreType,
                                    Sum_Filtered = scoreType.CoefficentValue,
                                    Sum_NotFiltered = scoreType.CoefficentValue
                                });

                            MonthlyscoreList.Add(new scoreListItem
                            {
                                Date = PersianDateTime.MiladiToPersian(user.LastUpdateDateTime.Value).ToString(),
                                scoreType = scoreType,
                                Sum_Filtered = scoreType.CoefficentValue,
                                Sum_NotFiltered = scoreType.CoefficentValue
                            });

                            return scoreType.CoefficentValue;
                        }
                        return 0;
                    }
                    #endregion

                case SpecialScoreType.ACCREMAIN:
                    #region
                    {
                        try
                        {
                            if (user != null && !string.IsNullOrWhiteSpace(user.ChildAccNo))
                            {
                                string tx_date;
                                long Remain = BMICustomer_DataProvider.GetAccRemain(user, out tx_date);
                                var RemainScore = Remain.ToString().ToDouble() * scoreType.CoefficentValue;
                                DailyscoreList.Add(new scoreListItem
                                                  {
                                                      Date = tx_date,
                                                      scoreType = scoreType,
                                                      Sum_NotFiltered = RemainScore,
                                                      Sum_Filtered = Math.Min(RemainScore, scoreType.MaxPerMonth)
                                                  });

                                MonthlyscoreList.Add(new scoreListItem
                                {
                                    Date = tx_date,
                                    scoreType = scoreType,
                                    Sum_NotFiltered = RemainScore,
                                    Sum_Filtered = Math.Min(RemainScore, scoreType.MaxPerMonth)
                                });
                                return Math.Min(RemainScore, scoreType.MaxPerMonth);

                            }
                            return 0;
                        }
                        catch
                        {
                            return 0;
                        }
                    }
                    #endregion

                case SpecialScoreType.POLL:
                    #region
                    {
                        int cnt = user.PollUserResponses.Count(poll => poll.PollQuestion.HasScore);
                        var pollscore = cnt * scoreType.CoefficentValue;


                        var Monthly_PollGroup = user.PollUserResponses.Where(poll => poll.PollQuestion.HasScore)
                                                    .GroupBy(o => PersianDateTime.MiladiToPersian(o.CreateDateTime).ToString().Substring(0, 6)).ToList();

                        var Daily_PollGroup = user.PollUserResponses.Where(poll => poll.PollQuestion.HasScore)
                                                    .GroupBy(o => PersianDateTime.MiladiToPersian(o.CreateDateTime).ToString()).ToList();

                        foreach (var d in Daily_PollGroup)
                        {
                            DailyscoreList.Add(new scoreListItem
                            {
                                Date = d.Key,
                                scoreType = scoreType,
                                Sum_NotFiltered = d.Count() * scoreType.CoefficentValue,
                                Sum_Filtered = d.Count() * scoreType.CoefficentValue
                            });
                        }

                        foreach (var m in Monthly_PollGroup)
                        {
                            MonthlyscoreList.Add(new scoreListItem
                            {
                                Date = m.Key,
                                scoreType = scoreType,
                                Sum_NotFiltered = m.Count() * scoreType.CoefficentValue,
                                Sum_Filtered = Math.Min(m.Count() * scoreType.CoefficentValue, scoreType.MaxPerMonth)
                            });
                        }

                        return Math.Min(pollscore, scoreType.MaxPerMonth);
                    }
                    #endregion

                default:
                    throw new NotImplementedException(scoreType.ScoreEnName);
            }
        }
Example #53
0
        private static double CalculateScalerScore(ref List<scoreListItem> DailyscoreList, ref List<scoreListItem> MonthlyscoreList,
                                                   List<Kids_Scores> userScore, ScoreType scoreType, double CalculatedScore)
        {
            int scoreTypeId = scoreType.Id;
            int MaxPerDay = scoreType.MaxPerDay;
            int MaxPerMonth = scoreType.MaxPerMonth;
            //////////////////////////////Daily///////////////////////////////////////////////////////////////////////////////////
            var scoresPerDay = userScore.Where(o => o.ScoreTypeId == scoreTypeId)
                                        .GroupBy(o => o.PersianCreateDateTime)
                                        .Select(lst => new
                                            {
                                                Date = lst.Key,
                                                Sum = lst.Sum(o => o.Value) * scoreType.CoefficentValue
                                            }).ToList();

            var scoresPerDay_Filtered = userScore.Where(o => o.ScoreTypeId == scoreTypeId)
                                       .GroupBy(o => o.PersianCreateDateTime)
                                       .Select(lst => new
                                       {
                                           Date = lst.Key,
                                           Sum = Math.Min(lst.Sum(o => o.Value) * scoreType.CoefficentValue, MaxPerDay)
                                       }).ToList();

            var totalByDay = scoresPerDay_Filtered.Sum(o => o.Sum);

            foreach (var day in scoresPerDay_Filtered)
            {
                var Date = day.Date;
                var Sum_NotFiltered = scoresPerDay.First(o => o.Date == Date).Sum;
                var a = new scoreListItem { scoreType = scoreType, Date = day.Date, Sum_Filtered = day.Sum, Sum_NotFiltered = Sum_NotFiltered };
                DailyscoreList.Add(a);
            }

            ///////////////////////////////Monthly//////////////////////////////////////////////////////////////////////////////////
            var scoresPerMonth = userScore.Where(o => o.ScoreTypeId == scoreTypeId)
                                          .GroupBy(o => o.PersianCreateDateTime.Substring(0, 6))
                                          .Select(lst => new
                                              {
                                                  Date = lst.Key,
                                                  Sum = lst.Sum(o => o.Value) * scoreType.CoefficentValue,
                                              }).ToList();

            var scoresPerMonth_Filtred = userScore.Where(o => o.ScoreTypeId == scoreTypeId)
                                          .GroupBy(o => o.PersianCreateDateTime.Substring(0, 6))
                                          .Select(lst => new
                                          {
                                              Date = lst.Key,
                                              Sum = Math.Min(lst.Sum(o => o.Value) * scoreType.CoefficentValue, MaxPerMonth)
                                          }).ToList();

            var totalByMonth = scoresPerMonth.Sum(o => o.Sum);

            foreach (var month in scoresPerMonth_Filtred)
            {
                var Month = month.Date;
                var Sum_NotFiltered = scoresPerMonth.First(o => o.Date == Month).Sum;
                var a = new scoreListItem { scoreType = scoreType, Date = month.Date, Sum_Filtered = month.Sum, Sum_NotFiltered = Sum_NotFiltered };
                MonthlyscoreList.Add(a);
            }

            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            var total = Math.Min(totalByDay, totalByMonth);
            CalculatedScore += total;
            return CalculatedScore;
        }
    public string GetPlotFilename(ScoreType score)
    {
        var sts = ScoreToString(score);

        if (PlotFiles == null || PlotFiles.Length == 0)
            return null;

        var elements = AvailablePlots.Where (s => s.Contains(sts));
        if (elements.Count () == 0)
            return null;

        return GetPlotFilename(elements.FirstOrDefault());
    }
Example #55
0
 /// <summary>
 /// Add a new score to the level scoreboard
 /// </summary>
 /// <param name="scoreLine"></param>
 /// <returns>The rank of the score</returns>
 public Int32 AddScore(String map, ScoreType scoreType, ScoreLine scoreLine)
 {
     return save.AddScore(map, scoreType, scoreLine);
 }
Example #56
0
        /// <summary>
        /// Add a new score to the level scoreboard
        /// </summary>
        /// <param name="map">map name</param>
        /// <param name="scoreType"></param>
        /// <param name="newScoreLine"></param>
        /// <returns>The rank of the score</returns>
        public Int32 AddScore(String map, ScoreType scoreType, ScoreLine newScoreLine)
        {
            int rank = ScoreLineNumber + 1;

            bool replace = false;

            ScoreLine[] scoresForThisLevel = null;

            //Access to the score for this level and this mode
            SerializableDictionary<String, ScoreLine[]> score = null;

            if (ScoresBylevel.TryGetValue(scoreType, out score))
            {
                if (score.TryGetValue(map, out scoresForThisLevel))
                {
                    for (int scoreLineIndex = 0; scoreLineIndex < scoresForThisLevel.Length; scoreLineIndex++)
                    {
                        ScoreLine currentLine = scoresForThisLevel[scoreLineIndex];

                        //Look if scores in the top ScoreLineNumber lines
                        if (newScoreLine.Score > currentLine.Score)
                        {
                            replace = true;
                        }
                        else
                        {
                            if (newScoreLine.Score == currentLine.Score)
                            {
                                if (newScoreLine.Date > currentLine.Date)
                                {
                                    replace = true;
                                }
                            }
                        }

                        if (replace)
                        {
                            rank = currentLine.Rank;

                            //HACK Avoid corrupted savegames
                            if (rank == -1) rank = 20;

                            newScoreLine.Rank = rank;

                            ScoreLine last = null;
                            ScoreLine toReplace = newScoreLine;

                            //Move down new lines
                            for (int i = scoreLineIndex; i < scoresForThisLevel.Length - 1; i++)
                            {
                                last = scoresForThisLevel[i];
                                scoresForThisLevel[i] = toReplace;

                                toReplace = last;
                                toReplace.Rank += 1;
                            }

                            break;
                        }
                    }

                }
                else
                {
                    //Create scores data for this map
                    scoresForThisLevel = new ScoreLine[ScoreLineNumber];

                    for (int i = 0; i < scoresForThisLevel.Length; i++)
                    {
                        scoresForThisLevel[i] = ScoreLine.GetDefaultScoreLine(i + 1);
                    }

                    //Player has the best score
                    scoresForThisLevel[0] = newScoreLine;

                    ScoresBylevel[scoreType].Add(map, scoresForThisLevel);
                }
            }
            return rank;
        }
 public override void TestScore(ScoreType scoreType, int expectedValue)
 {
     base.TestScore(scoreType, expectedValue);
 }
Example #58
0
        /// <summary>
        /// Return the highscore for the required level
        /// </summary>
        /// <param name="map"></param>
        /// <returns></returns>
        public ScoreLine GetBestScoreForLevel(String map, ScoreType scoreType)
        {
            try
            {
                ScoreLine[] result = null;
                if (save.ScoresBylevel[scoreType].TryGetValue(map, out result))
                {
                    return result[0];
                }
                else
                {
                    save.AddScore(map, scoreType, ScoreLine.GetDefaultScoreLine(1));

                    return GetBestScoreForLevel(map, scoreType);
                }
            }
            catch (IndexOutOfRangeException)
            {
                this.save = new SaveData();
                this.Save();

                //This exception is throwed only if you have an old savegame
                //For now I just reset scores and options
                throw new Exception(LocalizedStrings.GetString("CorruptedSavegame"));
            }
        }
 public void AddToScore(int modification, Vector3 pos, ScoreType type, bool visual = true)
 {
     if (visual) {
         TextMesh display = ((GameObject)Instantiate(scoreText, pos + new Vector3(0, 5, 0), Quaternion.Euler(Vector3.zero))).GetComponent<TextMesh>();
         display.transform.localScale = new Vector3(Mathf.CeilToInt(modification / 300), Mathf.CeilToInt(modification / 300), 1);
         StartCoroutine(ScoreTextAnim(display.gameObject));
     }
     switch (type) {
         case ScoreType.doubt:
             scoreDoubt += modification;
             break;
         case ScoreType.time:
             scoreTime += modification;
             break;
         case ScoreType.crying:
             scoreCrying += modification;
             break;
         case ScoreType.combo:
             scoreCombo += modification;
             break;
     }
 }
 /// <summary>
 /// Create a <see cref="NullOrigin"/>.
 /// </summary>
 /// <param name="scoreType">
 /// The primary ability score.
 /// </param>
 public NullOrigin(ScoreType scoreType)
     : base("Null", scoreType, PowerSource.Bio, Effect.TheTarget.SuffersDamage(1.D10()))
 {
     NovicePower = new NullPower();
 }