Beispiel #1
0
        public async Task <IActionResult> PutPointAsync(Guid id, [FromBody] RoundPointInputModel model)
        {
            if (default(Guid).Equals(id))
            {
                AddNotification("O Id da pontuação da rodada não foi informado.");
                return(ResponseInvalid());
            }

            if (ModelState.IsValid)
            {
                var roundPoint = new RoundPoint(model.Position, model.Point, model.PlayerId, model.RoundId);
                await _roundPointService.UpdateAsync(id, roundPoint);

                if (ValidOperation())
                {
                    return(NoContent());
                }

                return(ResponseInvalid());
            }

            NotifyModelStateError();

            return(ResponseInvalid());
        }
        public CompetitorTemplate(string filePath,
                                  CompetitorPoint competitor1,
                                  CompetitorPoint competitor2,
                                  CompetitorPoint competitor1Webcam,
                                  CompetitorPoint competitor2Webcam,
                                  ScorePoint score1, ScorePoint score2,
                                  RoundPoint round,
                                  TournamentPoint tournamentNameRound,
                                  DatePoint datePoint)
            : base(filePath)
        {
            if (competitor1 == null)
            {
                throw new Exception("Competitor Template: Competitor 1 must have a point on template");
            }
            if (competitor2 == null)
            {
                throw new Exception("Competitor Template: Competitor 2 must have a point on template");
            }
            if (competitor1Webcam == null)
            {
                throw new Exception("Competitor Template: Competitor 1's Webcam must have a point on template");
            }
            if (competitor2Webcam == null)
            {
                throw new Exception("Competitor Template: Competitor 2's Webcam must have a point on template");
            }
            if (score1 == null)
            {
                throw new Exception("Competitor Template: Score 1 must have a point on template");
            }
            if (score2 == null)
            {
                throw new Exception("Competitor Template: Score 2 must have a point on template");
            }
            if (round == null)
            {
                throw new Exception("Competitor Template: Round must have a point on template");
            }
            if (tournamentNameRound == null)
            {
                throw new Exception("Competitor Template: Tournament Name must have a point on template");
            }
            if (datePoint == null)
            {
                throw new Exception("Competitor Template: Date must have a point on template");
            }

            this.competitor1Point         = competitor1;
            this.competitor2Point         = competitor2;
            this.competitor1WebcamPoint   = competitor1Webcam;
            this.competitor2WebcamPoint   = competitor2Webcam;
            this.score1Point              = score1;
            this.score2Point              = score2;
            this.roundPoint               = round;
            this.tournamentNameRoundPoint = tournamentNameRound;
            this.datePoint = datePoint;
        }
        private async Task <bool> ValidateRoundPointAsync(RoundPoint roundPoint)
        {
            var validationEntity = ValidateEntity(roundPoint);
            var validationPlayer = await ValidatePlayerExistsAsync(roundPoint.PlayerId);

            var validationRound = await ValidateRoundExistsAsync(roundPoint.RoundId);

            return(validationEntity && validationPlayer && validationRound);
        }
        public Bitmap drawTextOnImage(SmashOverlayGenerator form, bool swap, bool camSwap)
        {
            string cam1 = GenFcns.removeWinLoseTags(form.Competitor1);
            string cam2 = GenFcns.removeWinLoseTags(form.Competitor2);

            setFontSizes(form.ResourceType, form.Competitor1, form.Competitor2);

            Bitmap   image = base.getImage();
            Graphics g     = Graphics.FromImage(image);

            if (!swap)
            {
                g.DrawString(form.Competitor1, Name1Font, Brushes.White, Competitor1Point.getPoint(), Player1Format);
                g.DrawString(form.Competitor2, Name2Font, Brushes.White, Competitor2Point.getPoint(), Player2Format);
                g.DrawString(form.Score1, ScoreFont, Brushes.White, Score1Point.getPoint(), ScoreFormat);
                g.DrawString(form.Score2, ScoreFont, Brushes.White, Score2Point.getPoint(), ScoreFormat);
            }
            else
            {
                g.DrawString(form.Competitor1, Name1Font, Brushes.White, Competitor2Point.getPoint(), Player2Format);
                g.DrawString(form.Competitor2, Name2Font, Brushes.White, Competitor1Point.getPoint(), Player1Format);
                g.DrawString(form.Score1, ScoreFont, Brushes.White, Score2Point.getPoint(), ScoreFormat);
                g.DrawString(form.Score2, ScoreFont, Brushes.White, Score1Point.getPoint(), ScoreFormat);
            }

            if (!camSwap)
            {
                g.DrawString(cam1, Name1Font, Brushes.White, Competitor1WebcamPoint.getPoint(), NameFormat);
                g.DrawString(cam2, Name2Font, Brushes.White, Competitor2WebcamPoint.getPoint(), NameFormat);
            }
            else
            {
                g.DrawString(cam2, Name1Font, Brushes.White, Competitor1WebcamPoint.getPoint(), NameFormat);
                g.DrawString(cam1, Name2Font, Brushes.White, Competitor2WebcamPoint.getPoint(), NameFormat);
            }

            if (RoundPoint == null)
            {
                g.DrawString(form.TournamentName + " | " + form.TournamentRound,
                             TournamentFont, Brushes.White, TournamentNameRoundPoint.getPoint(), NameFormat);
            }
            else
            {
                g.DrawString(form.TournamentName, TournamentFont, Brushes.White, TournamentNameRoundPoint.getPoint(), TourneyFormat);

                RoundFont = new Font(FontFamily.GenericSerif, 25, FontStyle.Bold);
                g.DrawString(form.TournamentRound, RoundFont, Brushes.White, RoundPoint.getPoint(), NameFormat);
            }

            if (DatePoint != null)
            {
                g.DrawString(form.CurrentDateTime.ToString("MMMM dd, yyyy"), TournamentFont, Brushes.White, DatePoint.getPoint(), DateFormat);
            }

            return(image);
        }
Beispiel #5
0
        public static CompetitorTemplate GetCompTemplate(string fileName)
        {
            string qry =
                "SELECT * FROM tbl_CompetitorTemplates WHERE FileName = '" + fileName + "';";
            SQLiteCommand cmd = new SQLiteCommand(qry, conn);

            try
            {
                DBOpen();
                SQLiteDataReader cur = cmd.ExecuteReader();
                while (cur.Read())
                {
                    string name  = cur.GetString(0);
                    int    tpx   = cur.GetInt32(1);
                    int    tpy   = cur.GetInt32(2);
                    int    rpx   = cur.GetInt32(3);
                    int    rpy   = cur.GetInt32(4);
                    int    p1px  = cur.GetInt32(5);
                    int    p1py  = cur.GetInt32(6);
                    int    p2px  = cur.GetInt32(7);
                    int    p2py  = cur.GetInt32(8);
                    int    p1cpx = cur.GetInt32(9);
                    int    p1cpy = cur.GetInt32(10);
                    int    p2cpx = cur.GetInt32(11);
                    int    p2cpy = cur.GetInt32(12);
                    int    p1spx = cur.GetInt32(13);
                    int    p1spy = cur.GetInt32(14);
                    int    p2spx = cur.GetInt32(15);
                    int    p2spy = cur.GetInt32(16);
                    int    dpx   = cur.GetInt32(17);
                    int    dpy   = cur.GetInt32(18);
                    string opt   = cur.GetString(19).Replace("\n", "");

                    CompetitorPoint player1pt    = new CompetitorPoint(p1px, p1py);
                    CompetitorPoint player2pt    = new CompetitorPoint(p2px, p2py);
                    CompetitorPoint player1CamPt = new CompetitorPoint(p1cpx, p1cpy);
                    CompetitorPoint player2CamPt = new CompetitorPoint(p2cpx, p2cpy);
                    ScorePoint      score1pt     = new ScorePoint(p1spx, p1spy);
                    ScorePoint      score2pt     = new ScorePoint(p2spx, p2spy);
                    RoundPoint      roundpt      = new RoundPoint(rpx, rpy);
                    TournamentPoint tourneypt    = new TournamentPoint(tpx, tpy);
                    DatePoint       datePoint    = new DatePoint(dpx, dpy);

                    DBClose();
                    return(new CompetitorTemplate(name, player1pt, player2pt, player1CamPt, player2CamPt, score1pt, score2pt, roundpt, tourneypt, datePoint, opt));
                }
                return(null);
            }
            catch (Exception ex)
            {
                DBClose();
                return(null);
            }
        }
Beispiel #6
0
    // Update player's total money count
    public void PurchaseItem()
    {
        if (PlayerData.money >= cost)
        {
            if (playerMoveUpgrade)
            {
                PlayerData.AddMoney(-cost);
                PlayerMoveUpgrade.Activate();
                Destroy(this.gameObject);
                SoundControl.PlayPurchaseSound();
            }

            if (plantGrowthUpgrade)
            {
                PlayerData.AddMoney(-cost);
                PlantGrowthUpgrade.Activate();
                Destroy(this.gameObject);
                SoundControl.PlayPurchaseSound();
            }

            if (roundPoint)
            {
                //Only charge if an order was succesfully removed
                if (RoundPoint.Activate())
                {
                    PlayerData.AddMoney(-cost);
                    SoundControl.PlayPurchaseSound();
                }
            }

            if (plowField)
            {
                PlayerData.AddMoney(-cost);
                PlayerData2.localPlayer.GetComponent <PlowField>().Activate();
                SoundControl.PlayPurchaseSound();
                Destroy(this.gameObject);
            }

            if (bearTrap)
            {
                PlayerData.AddMoney(-cost);
                SoundControl.PlayPurchaseSound();
                GameObject bearTrapItemClone = Instantiate(ObjectData.bearTrapItemPrefab, Vector2.zero, Quaternion.identity);
                PlayerData2.localPlayer.GetComponent <PlayerInventory2>().AddItem(bearTrapItemClone.GetComponent <Item2>());
                GameObject bearTrapItemClone1 = Instantiate(ObjectData.bearTrapItemPrefab, Vector2.zero, Quaternion.identity);
                PlayerData2.localPlayer.GetComponent <PlayerInventory2>().AddItem(bearTrapItemClone1.GetComponent <Item2>());
            }
        }
        GameObject.Find("Shop").GetComponent <ShopSystem>().UpdateText();
    }
        public async Task AddAsync(RoundPoint roundPoint)
        {
            var roundsPoints = await GetAllAsync();

            if (roundsPoints.Any(x => x.PlayerId == roundPoint.PlayerId && x.RoundId == roundPoint.RoundId))
            {
                AddNotification("Esse jogador já tem posição para essa rodada.");
            }

            if (await ValidateRoundPointAsync(roundPoint))
            {
                _roundPointRepository.Add(roundPoint);

                if (!await CommitAsync())
                {
                    AddNotification("Não foi possível cadastrar a pontuação da rodada.");
                }
            }
        }
Beispiel #8
0
        public async Task <IActionResult> PostPointAsync([FromBody] RoundPointInputModel model)
        {
            if (ModelState.IsValid)
            {
                var roundPoint = new RoundPoint(model.Position, model.Point, model.PlayerId, model.RoundId);
                await _roundPointService.AddAsync(roundPoint);

                if (ValidOperation())
                {
                    return(Created(GetRouteById(roundPoint.Id), new { id = roundPoint.Id }));
                }

                return(ResponseInvalid());
            }

            NotifyModelStateError();

            return(ResponseInvalid());
        }
        public async Task UpdateAsync(Guid id, RoundPoint roundPoint)
        {
            var existingRoundPoint = await _roundPointRepository.GetByIdAsync(id);

            if (existingRoundPoint == null)
            {
                AddNotification("Partida do jogador não encontrada.");
            }

            existingRoundPoint.Update(
                roundPoint.Position, roundPoint.Point, roundPoint.PlayerId, roundPoint.RoundId);
            if (await ValidateRoundPointAsync(existingRoundPoint))
            {
                _roundPointRepository.Update(existingRoundPoint);

                if (!await CommitAsync())
                {
                    AddNotification("Não foi possível atualizar a pontuação da rodada.");
                }
            }
        }
Beispiel #10
0
 public static RoundPointDTO ToRoundPointDTO(RoundPoint roundPoint)
 {
     return(new RoundPointDTO(roundPoint.Id, roundPoint.Position, roundPoint.Point, roundPoint.PlayerId, roundPoint.RoundId));
 }
 public void Update(RoundPoint roundPoint)
 {
     _context.RoundsPoints.Update(roundPoint);
 }
 public void Add(RoundPoint roundPoint)
 {
     _context.RoundsPoints.Add(roundPoint);
 }