Exemple #1
0
            public CollectRateReplacer(Th06Converter parent)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var stage = StageWithTotalParser.Parse(match.Groups[1].Value);
                    var type  = int.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture);

                    Func <CardAttack, bool> findByStage;
                    if (stage == StageWithTotal.Total)
                    {
                        findByStage = (attack => true);
                    }
                    else
                    {
                        findByStage = (attack => CardTable[attack.CardId].Stage == (Stage)stage);
                    }

                    Func <CardAttack, bool> findByType;
                    if (type == 1)
                    {
                        findByType = (attack => attack.ClearCount > 0);
                    }
                    else
                    {
                        findByType = (attack => attack.TrialCount > 0);
                    }

                    return(parent.allScoreData.CardAttacks.Values
                           .Count(Utils.MakeAndPredicate(findByStage, findByType))
                           .ToString(CultureInfo.CurrentCulture));
                });
            }
            public CollectRateReplacer(Th10Converter parent)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var level = LevelWithTotalParser.Parse(match.Groups[1].Value);
                    var chara = CharaWithTotalParser.Parse(match.Groups[2].Value);
                    var stage = StageWithTotalParser.Parse(match.Groups[3].Value);
                    var type  = int.Parse(match.Groups[4].Value, CultureInfo.InvariantCulture);

                    if (stage == StageWithTotal.Extra)
                    {
                        return(match.ToString());
                    }

                    Func <SpellCard, bool> findByStage;
                    if (stage == StageWithTotal.Total)
                    {
                        findByStage = (card => true);
                    }
                    else
                    {
                        findByStage = (card => CardTable[card.Id].Stage == (Stage)stage);
                    }

                    Func <SpellCard, bool> findByLevel = (card => true);
                    switch (level)
                    {
                    case LevelWithTotal.Total:
                        // Do nothing
                        break;

                    case LevelWithTotal.Extra:
                        findByStage = (card => CardTable[card.Id].Stage == Stage.Extra);
                        break;

                    default:
                        findByLevel = (card => card.Level == (Level)level);
                        break;
                    }

                    Func <SpellCard, bool> findByType;
                    if (type == 1)
                    {
                        findByType = (card => card.ClearCount > 0);
                    }
                    else
                    {
                        findByType = (card => card.TrialCount > 0);
                    }

                    return(parent.allScoreData.ClearData[chara].Cards.Values
                           .Count(Utils.MakeAndPredicate(findByLevel, findByStage, findByType))
                           .ToString(CultureInfo.CurrentCulture));
                });
            }