コード例 #1
0
ファイル: GameManager.cs プロジェクト: ThatDud3/BowlingGame
        public void Load(string path)
        {
            if (File.Exists(path))
            {
                CustomRulesProcessor customRules = new CustomRulesProcessor();
                customRules.AddCutomRule(new CustomRuleMatchFrameNumber());
                customRules.AddCutomRule(new CustomRuleMatchRolls());

                int lineNum = 0;
                foreach (string line in File.ReadLines(path))
                {
                    if (!string.IsNullOrWhiteSpace(line) && !line.Trim().StartsWith('#'))
                    {
                        customRules = null; // comment out to see custom rules in action
                        IGameScore gameScore = new Game(++lineNum, line, customRules);
                        Console.WriteLine($"Score: {gameScore.Score} ::: Running Score: {gameScore.RunningScore}");
                    }
                    else
                    {
                        Console.WriteLine(line);
                    }
                }
            }
            else
            {
                Console.WriteLine($"File not found: {path}");
            }
        }
コード例 #2
0
        public void CustomRuleMatchRollsTest()
        {
            CustomRulesProcessor customRules = new CustomRulesProcessor();

            customRules.AddCutomRule(new CustomRuleMatchRolls());
            IGameScore gameScore = new Game(1, "10,#; 9,1; 5,5; 7,2; 10,#; 10,#; 10,#; 9,0; 8,2; 9,1,10", customRules);

            Assert.IsTrue(gameScore.Score == 197);
        }
コード例 #3
0
        public void CustomRuleMatchFrameNumberTest()
        {
            CustomRulesProcessor customRules = new CustomRulesProcessor();

            customRules.AddCutomRule(new CustomRuleMatchFrameNumber());
            IGameScore gameScore = new Game(1, "10,#; 10,#; 10,#; 10,#; 10,#; 10,#; 10,#; 10,#; 10,#; 10,#,10,10", customRules);

            Assert.IsTrue(gameScore.Score == 310);
        }