コード例 #1
0
            public ClearTimeReplacer(Th145Converter parent)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var level = LevelWithTotalParser.Parse(match.Groups[1].Value);
                    var chara = CharaWithTotalParser.Parse(match.Groups[2].Value);

                    Func <Dictionary <Chara, int>, int> getValueByChara;
                    if (chara == CharaWithTotal.Total)
                    {
                        getValueByChara = (dict => dict.Values.Sum());
                    }
                    else
                    {
                        getValueByChara = (dict => dict[(Chara)chara]);
                    }

                    Func <Dictionary <Level, Dictionary <Chara, int> >, int> getValueByLevel;
                    if (level == LevelWithTotal.Total)
                    {
                        getValueByLevel = (dict => dict.Values.Sum(getValueByChara));
                    }
                    else
                    {
                        getValueByLevel = (dict => getValueByChara(dict[(Level)level]));
                    }

                    return(new Time(getValueByLevel(parent.allScoreData.ClearTimes)).ToString());
                });
            }
コード例 #2
0
            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));
                });
            }
コード例 #3
0
            public CharaExReplacer(Th10Converter parent)
            {
                this.evaluator = new MatchEvaluator(match =>
                {
                    var level = LevelWithTotalParser.Parse(match.Groups[1].Value);
                    var chara = CharaWithTotalParser.Parse(match.Groups[2].Value);
                    var type  = int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture);

                    Func <ClearData, long> getValueByType;
                    Func <long, string> toString;
                    if (type == 1)
                    {
                        getValueByType = (data => data.TotalPlayCount);
                        toString       = Utils.ToNumberString;
                    }
                    else if (type == 2)
                    {
                        getValueByType = (data => data.PlayTime);
                        toString       = (value => new Time(value).ToString());
                    }
                    else
                    {
                        if (level == LevelWithTotal.Total)
                        {
                            getValueByType = (data => data.ClearCounts.Values.Sum());
                        }
                        else
                        {
                            getValueByType = (data => data.ClearCounts[(Level)level]);
                        }
                        toString = Utils.ToNumberString;
                    }

                    Func <AllScoreData, long> getValueByChara;
                    if (chara == CharaWithTotal.Total)
                    {
                        getValueByChara = (allData => allData.ClearData.Values
                                           .Where(data => data.Chara != chara).Sum(getValueByType));
                    }
                    else
                    {
                        getValueByChara = (allData => getValueByType(allData.ClearData[chara]));
                    }

                    return(toString(getValueByChara(parent.allScoreData)));
                });
            }