Exemplo n.º 1
0
        private void startCapturingProcess()
        {
            //Setting the current batsman
            if (rbBatsman1.Checked)
            {
                currentBatsman = batsman1;
            }
            else if (rbBatsman2.Checked)
            {
                currentBatsman = batsman2;
            }

            //Setting the current bowler
            if (rbBowler1.Checked)
            {
                currentBowler = bowler1;
            }
            else if (rbBowler2.Checked)
            {
                currentBowler = bowler2;
            }



            //Enable the runs and extras group boxes
            grpRuns.Enabled         = true;
            grpExtras.Enabled       = true;
            grpBallPosition.Enabled = true;
            grpRunType.Enabled      = true;

            FILENAME     = getFileName();
            BALL_NUMBER += 1;

            //MessageBox.Show(FILENAME);

            clsCapture.setSaveFileName(FILENAME);
            clsCapture.startCapture();

            //Dissable the start capture button and enable the record button
            btnCapture.Enabled = false;
            btnRecord.Enabled  = true;

            //Set picture fram colors
            if (currentBatsman.battingHand == 'L')//Make panel 1 Active
            {
                splitContainer1.Panel1.BackColor = PICFRAM_ACTIVE;
                splitContainer1.Panel2.BackColor = PICFRAM_INACTIVE;

                splitContainer1.Panel1.Enabled = true;
                splitContainer1.Panel2.Enabled = false;
            }
            else if (currentBatsman.battingHand == 'R')// Make panal 2 Active
            {
                splitContainer1.Panel2.BackColor = PICFRAM_ACTIVE;
                splitContainer1.Panel1.BackColor = PICFRAM_INACTIVE;

                splitContainer1.Panel2.Enabled = true;
                splitContainer1.Panel1.Enabled = false;
            }
        }
Exemplo n.º 2
0
        private void txtBowler1Name_TextChanged(object sender, EventArgs e)
        {
            if (txtBowler1Name.Text == "")
            {
                return;
            }

            string bowlerame = txtBowler1Name.Text;

            foreach (clsPlayer player in bowlingTeam.players)
            {
                if (bowlerame == player.fName + " " + player.lName)
                {
                    bowler1 = new Bowler();

                    bowler1.battingHand  = player.battingHand;
                    bowler1.bowlingStyle = player.bowlingStyle;
                    bowler1.country      = player.country;
                    bowler1.dob          = player.dob;
                    bowler1.fName        = player.fName;
                    bowler1.lName        = player.lName;
                    bowler1.playerId     = player.playerId;

                    //Check if the bowler if in the currently utilised bowlers list
                    insertBowlerToTheList(bowler1);

                    break;
                }
            }
            if (rbBatsman1.Checked)
            {
                currentBowler = bowler1;
            }
        }
Exemplo n.º 3
0
        private void txtBowler2Name_TextChanged(object sender, EventArgs e)
        {
            if (txtBowler2Name.Text == "")
            {
                return;
            }

            string bowlerame = txtBowler2Name.Text;

            foreach (clsPlayer player in bowlingTeam.players)
            {
                if (bowlerame == player.fName + " " + player.lName)
                {
                    bowler2 = new Bowler();

                    bowler2.battingHand  = player.battingHand;
                    bowler2.bowlingStyle = player.bowlingStyle;
                    bowler2.country      = player.country;
                    bowler2.dob          = player.dob;
                    bowler2.fName        = player.fName;
                    bowler2.lName        = player.lName;
                    bowler2.playerId     = player.playerId;

                    insertBowlerToTheList(bowler2);

                    break;
                }
            }
            if (rbBatsman2.Checked)
            {
                currentBowler = bowler2;
            }
        }
Exemplo n.º 4
0
 public void BallBowled(string outcome, int runs)
 {
     if (outcome != "Wide" && outcome != "No Ball")
     {
         OnStrike.FaceBall();
         Bowler.BallBowled();
         Overs += 0.1;
         OversConverter();
     }
     if (outcome == "Runs")
     {
         Runs(runs);
     }
     if (outcome == "Byes")
     {
         Batting.AddByes(runs);
         if (runs % 2 != 0)
         {
             BatsmenSwap();
         }
     }
     if (outcome == "Leg Byes")
     {
         Batting.AddLegByes(runs);
         if (runs % 2 != 0)
         {
             BatsmenSwap();
         }
     }
     if (outcome == "Wide")
     {
         Batting.AddWides(runs);
         if (runs - 1 % 2 != 0)
         {
             BatsmenSwap();
         }
         Bowler.ConcedeRuns(runs);
     }
     if (outcome == "No Ball")
     {
         if (runs > 1)
         {
             int batRuns = runs - 1;
             Batting.AddNoBalls(1);
             OnStrike.ScoreRuns(batRuns);
             if (batRuns % 2 != 0)
             {
                 BatsmenSwap();
             }
         }
         else
         {
             Batting.AddNoBalls(runs);
         }
         Bowler.ConcedeRuns(runs);
     }
     Batting.CalcRuns();
     EndOfOverCheck();
     InEndCheck();
 }
Exemplo n.º 5
0
 public void Wicket(string method)
 {
     OnStrike.IsOut     = true;
     OnStrike.MethodOut = method;
     Bowler.GetWicket();
     SetBatsmen();
     Batting.CalcWickets();
 }
Exemplo n.º 6
0
 public void Runs(int runs)
 {
     OnStrike.ScoreRuns(runs);
     Bowler.ConcedeRuns(runs);
     if (runs % 2 != 0)
     {
         BatsmenSwap();
     }
 }
Exemplo n.º 7
0
 public void Wicket(string method, Player player)
 {
     player.IsOut     = true;
     player.MethodOut = method;
     if (method != "Run out")
     {
         Bowler.GetWicket();
     }
     SetBatsmen();
     Batting.CalcWickets();
 }
Exemplo n.º 8
0
        public async Task <IHttpActionResult> PostBowler(Bowler bowler)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await bowlerService.AddBowler(bowler);

            return(CreatedAtRoute("DefaultApi", new { id = bowler.Id }, bowler));
        }
Exemplo n.º 9
0
        public void test_bowling_a_ball_returns_an_outcome()
        {
            Mock <Ball> mockBall;
            Bowler      bowler = new Bowler();

            mockBall = new Mock <Ball>();
            mockBall.Setup(m => m.Bowl()).Returns(() => BOWLED);
            outcomes outcome = bowler.Bowl((Ball)mockBall.Object);

            Assert.Equal(BOWLED, outcome);
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("BowlerID,Name,Group,InActivity, BowlerAverage, RegisterDate, LeaveDate, Bigo")] Bowler bowler)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bowler);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bowler));
        }
Exemplo n.º 11
0
        public async Task <IHttpActionResult> GetBowler(int id)
        {
            Bowler bowler = await bowlerService.GetBowlerAsync(id);

            if (bowler == null)
            {
                return(NotFound());
            }

            return(Ok(bowler));
        }
Exemplo n.º 12
0
        public async Task <IHttpActionResult> GetBowlerMe()
        {
            Guid userId;

            Guid.TryParse(User.Identity.GetUserId(), out userId);

            Bowler bowler = await bowlerService.GetBowlerByUserAsync(userId);

            if (bowler == null)
            {
                return(NotFound());
            }

            return(Ok(bowler));
        }
Exemplo n.º 13
0
        private void insertBowlerToTheList(Bowler bb)
        {
            bool found = false;

            foreach (Bowler b in BOWLERS_CURRENTLY_UNILIZED)
            {
                if (b.playerId == bb.playerId)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                BOWLERS_CURRENTLY_UNILIZED.Add(bowler1);
            }
        }
        public BowlerStats Get(int bowlerId, int teamId)
        {
            if (bowlerId == 0 || teamId == 0)
            {
                return(new BowlerStats());
                //return new HttpResponseMessage(HttpStatusCode.BadRequest);
            }

            //Get all of the scores for the bowler on the team specified
            var bowlerScores = this.unitOfWork.Repository.GetQuery <Score>(x => x.BowlerId == bowlerId && x.TeamId == teamId)
                               .Include(x => x.Team)
                               .Include(x => x.Bowler).ToList();

            //Calculate the stats for
            var bowler = new Bowler();

            return(bowler.CalculateBowlerStats(bowlerScores));
        }
Exemplo n.º 15
0
        public void UpdateCurrentOverShouldSetOver()
        {
            //Act
            this._inning.UpdateCurrentOver(this._bowler, this._striker, this._nonStriker);

            //Assert
            this._inning.CurrentOver !.Bowler
            .Should()
            .Be(this._bowler);

            this._inning.CurrentOver !.Striker
            .Should()
            .Be(this._striker);

            this._inning.CurrentOver !.NonStriker
            .Should()
            .Be(this._nonStriker);
        }
Exemplo n.º 16
0
        public HttpResponseMessage Post(Bowler bowler)
        {
            if (bowler == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not read bowler information from the request"));
            }

            var result = this.unitOfWork.Repository.Add(bowler);

            this.unitOfWork.Save();
            if (result != null && result.Id != 0)
            {
                return(Request.CreateResponse(HttpStatusCode.Created, result));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not save to the database."));
            }
        }
Exemplo n.º 17
0
        private void rbBowler1_CheckedChanged(object sender, EventArgs e)
        {
            if (rbBowler1.Checked)
            {
                currentBowler = bowler1;

                txtbowler1ER.BackColor      = ACTIVECOLOR;
                txtbowler1Maidn.BackColor   = ACTIVECOLOR;
                txtBowler1Name.BackColor    = ACTIVECOLOR;
                txtbowler1Overs.BackColor   = ACTIVECOLOR;
                txtbowler1Runs.BackColor    = ACTIVECOLOR;
                txtbowler1Wickets.BackColor = ACTIVECOLOR;

                txtbowler2ER.BackColor      = DEACTIVECOLOR;
                txtbowler2Maidn.BackColor   = DEACTIVECOLOR;
                txtBowler2Name.BackColor    = DEACTIVECOLOR;
                txtbowler2Overs.BackColor   = DEACTIVECOLOR;
                txtbowler2Runs.BackColor    = DEACTIVECOLOR;
                txtbowler2Wickets.BackColor = DEACTIVECOLOR;
            }
            else
            {
                currentBowler = bowler2;

                txtbowler1ER.BackColor      = DEACTIVECOLOR;
                txtbowler1Maidn.BackColor   = DEACTIVECOLOR;
                txtBowler1Name.BackColor    = DEACTIVECOLOR;
                txtbowler1Overs.BackColor   = DEACTIVECOLOR;
                txtbowler1Runs.BackColor    = DEACTIVECOLOR;
                txtbowler1Wickets.BackColor = DEACTIVECOLOR;

                txtbowler2ER.BackColor      = ACTIVECOLOR;
                txtbowler2Maidn.BackColor   = ACTIVECOLOR;
                txtBowler2Name.BackColor    = ACTIVECOLOR;
                txtbowler2Overs.BackColor   = ACTIVECOLOR;
                txtbowler2Runs.BackColor    = ACTIVECOLOR;
                txtbowler2Wickets.BackColor = ACTIVECOLOR;
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Start Innings
        /// </summary>
        /// <param name="teamBatting">Team object containing the team batting</param>
        /// <param name="teamBowling">Team object containing the team bowling</param>
        /// <param name="scoreKeeper">Scorekeeper object</param>
        public void Start(Team teamBatting, Team teamBowling, Scorekeeper scoreKeeper)
        {
            // TODO Play and innnings
            bool endOfInnings   = false;
            var  currentBatsman = new Batsman();
            var  outcomeFactory = new ConcreteOutcomeFactory();

            do
            {
                Bowler currentBowler = teamBowling.GetNextBowler();
                int    ballsBowled   = 0;
                do
                {
                    var      ball        = currentBowler.bowl();
                    IOutcome ballOutcome = currentBatsman.Play(ball, outcomeFactory);
                    if (ballOutcome.IsValidBall())
                    {
                        ballsBowled++;
                    }

                    scoreKeeper.UpdateScoreboard(ballOutcome);
                } while (!endOfInnings & ballsBowled != EndOfOver);
            } while (!endOfInnings);
        }
Exemplo n.º 19
0
 public Task AddBowler(Bowler bowler)
 {
     bowlers.Add(bowler);
     return(UnitOfWork.CommitAsync());
 }
Exemplo n.º 20
0
 public void SetUp()
 {
     _bowler = new Bowler();
 }