Exemple #1
0
        public static void ScoreDart(Player player, Darts darts)
        {
            int score = 0;

            if (darts.tripleRing)
            {
                score = darts.Score * 3;
            }
            else if (darts.doubleRing)
            {
                score = darts.Score * 2;
            }
            else
            {
                score = darts.Score;
            }

            if (darts.Score == 0 && darts.tripleRing)
            {
                score = 50;
            }
            else if (darts.Score == 0)
            {
                score = 25;
            }
            player.Score += score;
        }
Exemple #2
0
 public Player()
 {
     Darts.Add(d1);
     Darts.Add(d2);
     Darts.Add(d3);
     score = 301;
 }
 private void playRound(Player player)
 {
     for (int i = 0; i < 3; i++)
     {
         Darts dart = new Darts(_random);
         dart.Throw();
         Score.ScoreDart(player, dart);
     }
 }
 // Public methods.
 //
 public void ThrowDarts()
 {
     //Random random = new Random();
     Darts dartsGame = new Darts(_random);
     // Loop to represent the 3 darts each player gets to play with
     for (int i = 0; i < 3; i++)
     {
         dartsGame.Throw();
         determineMultiplier(dartsGame);
     }
 }
        // Determine points for a round
        // A player gets 3 throws in a round
        public static int PlayRound(Darts player)
        {
            int _roundScore = 0;

            for (int i = 0; i < 3; i++)
            {
                player.Throw();
                _roundScore += Score.RoundScore(player, player.DartScore);
            }
            return(_roundScore);
        }
        public void ShouldReturnCorrectName()
        {
            //arrange
            AllArmor        allArmor        = new AllArmor();
            AllShields      allShields      = new AllShields();
            Battleaxe       battleaxe       = new Battleaxe();
            BrewersSupplies brewersSupplies = new BrewersSupplies();
            Dagger          dagger          = new Dagger();
            Darts           darts           = new Darts();
            Handaxe         handaxe         = new Handaxe();
            LightArmor      lightArmor      = new LightArmor();
            LightCrossbow   lightCrossbow   = new LightCrossbow();
            Longbow         longbow         = new Longbow();
            Longsword       longsword       = new Longsword();
            MartialWeapons  martialWeapons  = new MartialWeapons();
            MasonsTools     masonsTools     = new MasonsTools();
            MediumArmor     mediumArmor     = new MediumArmor();
            Quarterstaff    quarterstaff    = new Quarterstaff();
            Shortbow        shortbow        = new Shortbow();
            Shortsword      shortsword      = new Shortsword();
            SimpleWeapons   simpleWeapons   = new SimpleWeapons();
            Sling           sling           = new Sling();
            SmithsTools     smithsTools     = new SmithsTools();
            ThrowingHammer  throwingHammer  = new ThrowingHammer();
            Warhammer       warhammer       = new Warhammer();

            //assert
            allArmor.Name().Should().Be(new TextObj("All Armor"));
            allShields.Name().Should().Be(new TextObj("All Shields"));
            battleaxe.Name().Should().Be(new TextObj("Battleaxe"));
            brewersSupplies.Name().Should().Be(new TextObj("Brewer's Supplies"));
            dagger.Name().Should().Be(new TextObj("Dagger"));
            darts.Name().Should().Be(new TextObj("Darts"));
            handaxe.Name().Should().Be(new TextObj("Handaxe"));
            lightArmor.Name().Should().Be(new TextObj("Light Armor"));
            lightCrossbow.Name().Should().Be(new TextObj("Light Crossbow"));
            longbow.Name().Should().Be(new TextObj("Longbow"));
            longsword.Name().Should().Be(new TextObj("Longsword"));
            martialWeapons.Name().Should().Be(new TextObj("Martial Weapons"));
            masonsTools.Name().Should().Be(new TextObj("Mason's Tools"));
            mediumArmor.Name().Should().Be(new TextObj("Medium Armor"));
            quarterstaff.Name().Should().Be(new TextObj("Quarterstaff"));
            shortbow.Name().Should().Be(new TextObj("Shortbow"));
            shortsword.Name().Should().Be(new TextObj("Shortsword"));
            simpleWeapons.Name().Should().Be(new TextObj("Simple Weapons"));
            sling.Name().Should().Be(new TextObj("Sling"));
            smithsTools.Name().Should().Be(new TextObj("Smith's Tools"));
            throwingHammer.Name().Should().Be(new TextObj("Throwing Hammer"));
            warhammer.Name().Should().Be(new TextObj("Warhammer"));
        }
 private void determineMultiplier(Darts darts)
 {
     /*
     Each dart can score from 1 to 20, or the bullseye.
     If the dart lands in the outer band, multiply the dart's score by two.
     If the dart lands in the inner band, multiply the dart's score by three.
     If the dart lands in the outer bullseye, it is scored as 25.
     If the dart lands in the inner bullseye, it is scored as 50.
     */
     if (darts.IsInnerBullseye)
         PlayerScore += darts.Score * 50;
     else if (darts.IsOuterBullseye)
         PlayerScore += darts.Score * 25;
     else if (darts.IsTriple)
         PlayerScore += darts.Score * 3;
     else if (darts.IsDouble)
         PlayerScore += darts.Score * 2;
     else
         PlayerScore += darts.Score;
 }
 // Determine points for a throw
 public static int RoundScore(Darts player, int score)
 {
     if (player.DartPosition == "Inner Bulls-Eye")
     {
         score = 50;
     }
     else if (player.DartPosition == "Outer Bulls-Eye")
     {
         score = 25;
     }
     else if (player.DartPosition == "Outer Ring")
     {
         score *= 2;
     }
     else if (player.DartPosition == "Inner Ring")
     {
         score *= 3;
     }
     return(score);
 }
Exemple #9
0
 public void A_dart_lands_in_the_bullseye_with_a_coord_of_negative_x_and_negative_y()
 {
     Assert.Equal(10, Darts.CalculateScore(-0.3422, -0.7));
 }
Exemple #10
0
 public void A_dart_lands_outside_with_a_coord_of_negative_x_and_positive_y()
 {
     Assert.Equal(0, Darts.CalculateScore(-30, 49));
 }
Exemple #11
0
 public void A_dart_lands_in_the_middle_circle()
 {
     Assert.Equal(5, Darts.CalculateScore(3, 3.7));
 }
Exemple #12
0
 public void A_dart_lands_outside_the_target()
 {
     Assert.Equal(0, Darts.Score(-9, 9));
 }
Exemple #13
0
 public void A_dart_lands_right_in_the_border_between_middle_and_inner_circles()
 {
     Assert.Equal(10, Darts.Score(0, -1));
 }
Exemple #14
0
 public void A_dart_lands_right_in_the_border_between_outer_and_middle_circles()
 {
     Assert.Equal(5, Darts.Score(5, 0));
 }
Exemple #15
0
 public void A_dart_lands_just_in_the_border_of_the_target()
 {
     Assert.Equal(1, Darts.Score(0, 10));
 }
Exemple #16
0
 public void Near_the_centre()
 {
     Assert.Equal(10, Darts.Score(-0.1, -0.1));
 }
Exemple #17
0
 public void SampleTest(double[] test, int expected)
 {
     Assert.AreEqual(expected, Darts.ScoreThrows(test));
 }
Exemple #18
0
 public void Just_within_the_inner_circle()
 {
     Assert.Equal(10, Darts.Score(0.7, 0.7));
 }
Exemple #19
0
 public void A_dart_lands_in_the_outer_circle()
 {
     Assert.Equal(1, Darts.Score(4, 4));
 }
Exemple #20
0
 public void Just_outside_the_inner_circle()
 {
     Assert.Equal(5, Darts.Score(0.8, -0.8));
 }
Exemple #21
0
 public void A_dart_lands_in_the_middle_circle()
 {
     Assert.Equal(5, Darts.Score(0.8, -0.8));
 }
Exemple #22
0
 public void Just_within_the_middle_circle()
 {
     Assert.Equal(5, Darts.Score(-3.5, 3.5));
 }
Exemple #23
0
 public void A_dart_lands_in_the_inner_circle()
 {
     Assert.Equal(10, Darts.Score(-0.1, -0.1));
 }
Exemple #24
0
 public void Just_outside_the_middle_circle()
 {
     Assert.Equal(1, Darts.Score(-3.6, -3.6));
 }
Exemple #25
0
 public void A_dart_lands_just_in_the_border_of_the_target()
 {
     Assert.Equal(1, Darts.CalculateScore(10, 0));
 }
Exemple #26
0
 public void Just_within_the_outer_circle()
 {
     Assert.Equal(1, Darts.Score(-7, 7));
 }
Exemple #27
0
 public void A_dart_lands_right_in_the_border_between_outside_and_middle_circles()
 {
     Assert.Equal(5, Darts.CalculateScore(0, 5));
 }
Exemple #28
0
 public void Missed_target()
 {
     Assert.Equal(0, Darts.Score(-9, 9));
 }
Exemple #29
0
 public void A_dart_lands_in_the_middle_with_a_coord_of_negative_x_and_zero_y()
 {
     Assert.Equal(5, Darts.CalculateScore(-3.4, 0));
 }
Exemple #30
0
 public void Just_outside_the_outer_circle()
 {
     Assert.Equal(0, Darts.Score(7.1, -7.1));
 }
Exemple #31
0
 public void A_dart_lands_outside_the_target()
 {
     Assert.Equal(0, Darts.CalculateScore(15.3, 13.2));
 }
Exemple #32
0
 public void Asymmetric_position_between_the_inner_and_middle_circles()
 {
     Assert.Equal(5, Darts.Score(0.5, -4));
 }