Ejemplo n.º 1
0
        private static void SetMartianBowlingRules(Bowling martianBowling)
        {
            DelBonusRuleForFrame martianStrikeRule = ((x, i) =>
                                                          {
                                                              if (x[i].Rolls[0] == 10)
                                                              {
                                                                  return x[x.Length - 1].Rolls.Sum();
                                                              }
                                                              return 0;
                                                          });

            DelBonusRuleForFrame lastFrameMartianBonus = (x, i) => 0;

            List<DelBonusRuleForFrame> strike = new List<DelBonusRuleForFrame>{martianStrikeRule};

            martianBowling.SetDelBonusRulesForFrame(strike,0);
            martianBowling.SetDelBonusRulesForFrame(strike,1);
            martianBowling.SetDelBonusRulesForFrame(new List<DelBonusRuleForFrame>{lastFrameMartianBonus}, 2);
        }
Ejemplo n.º 2
0
        private static void SetTerrestrianBonusRules(Bowling terrestrialBowling)
        {
            DelBonusRuleForFrame delSpareRule = (( x, i) =>
                                                     {
                                                         if (x[i].Rolls.Sum() == 10 && x[i].Rolls[0] != 10)
                                                             return x[i + 1].Rolls[0];
                                                         return 0;
                                                     });
            DelBonusRuleForFrame delBonusRule = ((x, i) =>
                                                     {
                                                         if (x[i].Rolls[0] == 10)
                                                             return x.NextTwoRolls(i);
                                                         return 0;
                                                     });

            DelBonusRuleForFrame delBonusLastFrame = ((x, i) => 0);

            List<DelBonusRuleForFrame> bonusOrSpare = new List<DelBonusRuleForFrame> {delBonusRule, delSpareRule};

            for (int i=0;i<9;i++)
            {
                terrestrialBowling.SetDelBonusRulesForFrame(bonusOrSpare,i);
            }
            terrestrialBowling.SetDelBonusRulesForFrame(new List<DelBonusRuleForFrame>{delBonusLastFrame},9);
        }