Exemplo n.º 1
0
        public DoubleChance getDoubleChanceFoEvent(HtmlNode node, string eventId)
        {
            DoubleChance doubleChance = new DoubleChance();

            try
            {
                foreach (HtmlNode node2 in node.ChildNodes)
                {
                    if (node2.OriginalName == "div" && this.GetAtributeValueByName(node2, "id").StartsWith(eventId) == true)
                    {
                        var result = this._htmlOddsParse.GetLineThree(node2.ChildNodes[1]);

                        doubleChance.HomeDraw = result.k1;
                        doubleChance.HomeAway = result.k2;
                        doubleChance.AwayDraw = result.k3;
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }

            return(doubleChance);
        }
 private void SetDoubleChanceToDatabasePrices(DoubleChance doubleChance)
 {
     this.pinaccle.HOMEAWAY           = doubleChance.HomeAway;
     this.pinaccle.HOMEDRAW           = doubleChance.HomeDraw;
     this.pinaccle.DRAWAWAY           = doubleChance.AwayDraw;
     this.pinaccle.HOMEAWAY_computed_ = doubleChance.HomeAwayComputed;
     this.pinaccle.HOMEDRAW_computed_ = doubleChance.HomeDrawComputed;
     this.pinaccle.DRAWAWAY_computed_ = doubleChance.AwayDrawComputed;
     this.pinaccle.HOMEAWAY_disc      = doubleChance.HomeAwayDisc;
     this.pinaccle.HOMEDRAW_disc      = doubleChance.HomeDrawDisc;
     this.pinaccle.DRAWAWAY_disc      = doubleChance.AwayDrawDisc;
 }
Exemplo n.º 3
0
        private void CheckIfSpecialSquare(MapSection[][] map, int i, int j, int positionNumber, Character character, int roomId)
        {
            //Character moves back by 3 positions if he is on GoBackSquare
            if (map[i][j].isGoBackSquare)
            {
                Console.WriteLine("Oops, it seems you stopped on a special square...");
                positionNumber -= 3;
                if (j >= 3)
                {
                    if (j == 3)
                    {
                        j = 0;
                    }
                    else
                    {
                        j -= 3;
                    }
                }
                else
                {
                    var toTakeDown = 3 - j;
                    if (i == 0)
                    {
                        throw new ArgumentException($"Cannot move back from {i}{j}");
                    }
                    else

                    {
                        i -= 1;
                        j  = map[i].Length - 1;
                        toTakeDown--;
                        j -= toTakeDown;
                    }
                }
                positionNumber = map[i][j].Number;
                UpdateCharacterPositionInDb(character, map[i][j].X, map[i][j].Y, positionNumber, roomId);
                Console.WriteLine($"{character.Name} moves back by 3 positions to square number {positionNumber} :)");
                CheckIfSpecialSquare(map, i, j, positionNumber, character, roomId);
            }
            //Character goes forward by 3 positions if he is on GoBackSquare
            else if (map[i][j].isGoForwardSquare)
            {
                Console.WriteLine("Oops, it seems you stopped on a special square...");
                positionNumber += 3;
                if (j <= 6)
                {
                    j += 3;
                }
                else //if(j != 9)
                {
                    var thisRowAdd = 9 - j;
                    var nextRowAdd = 3 - thisRowAdd;
                    if (i == map.Length - 1)
                    {
                        throw new ArgumentException($"Cannot move forward from {i}{j}");
                    }
                    else
                    {
                        i += 1;
                        j  = 0;
                        if (j == 0)
                        {
                            nextRowAdd--;
                        }
                        j += nextRowAdd;
                    }
                }
                positionNumber = map[i][j].Number;
                UpdateCharacterPositionInDb(character, map[i][j].X, map[i][j].Y, positionNumber, roomId);
                Console.WriteLine($"{character.Name} moves forward with 3 positions to square number {positionNumber} ^.^");
                CheckIfSpecialSquare(map, i, j, positionNumber, character, roomId);
            }
            //ToDo
            else if (map[i][j].isMysterySquare)
            {
                Console.WriteLine("Oops, it seems you stopped on a special square...");

                var num = numberGenerator.GenerateNumber(1, 3);
                if (num == 1)
                {
                    //play mini game
                    //Can be found in Miscellaneous/SpecialSquares/MysterySquare/MiniGameAction.cs
                    MiniGameAction msa = new MiniGameAction();
                    msa.PlayMiniGame(isSingle);
                    if (msa.DemolitionFalcons)
                    {
                        //All characters return to the first square
                        var characters = context.GameCharacters.Where(g => g.GameId == roomId).ToList();
                        foreach (var charche in characters)
                        {
                            context.GameCharacters.FirstOrDefault(c => c.CharacterId == charche.CharacterId).CharacterPositionX = map[0][0].X;
                            context.GameCharacters.FirstOrDefault(c => c.CharacterId == charche.CharacterId).CharacterPositionY = map[0][0].Y;
                            context.GameCharacters.FirstOrDefault(c => c.CharacterId == charche.CharacterId).MapSectionNumber   = map[0][0].Number;
                            context.SaveChanges();
                        }
                    }
                    else if (msa.GoBack)
                    {
                        var toGoBackWith = msa.GoBackWith;
                        positionNumber -= toGoBackWith;
                        if (j >= toGoBackWith)
                        {
                            if (j == toGoBackWith)
                            {
                                j = 0;
                            }
                            else
                            {
                                j -= toGoBackWith;
                            }
                        }
                        else
                        {
                            var toTakeDown = toGoBackWith - j;
                            if (i == 0)
                            {
                                throw new ArgumentException($"Cannot move back from {i}{j}");
                            }
                            else

                            {
                                i -= 1;
                                j  = map[i].Length - 1;
                                toTakeDown--;
                                j -= toTakeDown;
                            }
                        }
                        positionNumber = map[i][j].Number;
                        UpdateCharacterPositionInDb(character, map[i][j].X, map[i][j].Y, positionNumber, roomId);
                        Console.WriteLine($"{character.Name} moves back by {toGoBackWith} positions to square number {positionNumber} :)");
                        CheckIfSpecialSquare(map, i, j, positionNumber, character, roomId);
                    }
                    else if (msa.MoveForward)
                    {
                        var toMoveForwardWith = msa.MoveForwardWith;

                        positionNumber += toMoveForwardWith;
                        if (j < map[i].Length - toMoveForwardWith)
                        {
                            j += toMoveForwardWith;
                        }
                        else //if(j != 9)
                        {
                            var thisRowAdd = 9 - j;
                            var nextRowAdd = toMoveForwardWith - thisRowAdd;
                            if (i == map.Length - 1)
                            {
                                throw new ArgumentException($"Cannot move forward from {i}{j}");
                            }
                            else
                            {
                                i += 1;
                                j  = 0;
                                if (j == 0)
                                {
                                    nextRowAdd--;
                                }
                                j += nextRowAdd;
                            }
                        }
                        positionNumber = map[i][j].Number;
                        UpdateCharacterPositionInDb(character, map[i][j].X, map[i][j].Y, positionNumber, roomId);
                        Console.WriteLine($"{character.Name} moves forward with {toMoveForwardWith} positions to square number {positionNumber} ^.^");
                        CheckIfSpecialSquare(map, i, j, positionNumber, character, roomId);
                    }
                }
                else
                {
                    var doubleChance = new DoubleChance();
                    var isSingle     = true;
                    doubleChance.StartDoubleChance(context, roomId, character, positionNumber, map, i, j, isSingle);
                }
            }
            //ToDo
            else if (map[i][j].isBonusSquare)
            {
                Console.WriteLine("Oops, it seems you stopped on a special square...");
                Console.WriteLine($"{character.Name} is on a bonus square :)");
                BonusSquareAction bsa = new BonusSquareAction(context, roomId, character);
                //Gets a random spell drawn with a special algorythm that allow the character to atack another character
                bsa.GetSpell("");
            }
        }
Exemplo n.º 4
0
        public async Task <OlimpOddEvent> GetOddsByEventId(OlimpEvent olimpEvent)
        {
            string   url          = "/en/sports/match/" + olimpEvent.EventId;
            HtmlNode documentNode = this.GetDocumentNodeByUrl(url);

            if (documentNode != null)
            {
                HtmlNode oddsContainer = documentNode.QuerySelector(".coef");

                MoneyLine       moneyLine    = new MoneyLine();
                DoubleChance    doubleChance = new DoubleChance();
                List <Total>    totals       = new List <Total>();
                List <Handicap> handicaps    = new List <Handicap>();

                List <Total> homeTotals = new List <Total>();
                List <Total> awayTotals = new List <Total>();

                OlimpOddEvent olimpOddEvent = new OlimpOddEvent();



                try
                {
                    foreach (HtmlNode node in oddsContainer.ChildNodes)
                    {
                        if (node.OriginalName == "div" && this.GetAtributeValueByName(node, "class") == "")
                        {
                            foreach (HtmlNode htmlNode in node.ChildNodes)
                            {
                                if (htmlNode.OriginalName == "div" && this.GetAtributeValueByName(htmlNode, "class") == "livelineheader")
                                {
                                    string type = this.GetMarketTypeByLiveheaderNode(htmlNode);

                                    if (type == "FULL TIME RESULT")

                                    {
                                        moneyLine = this.getMoneylineFoEvent(node, olimpEvent.EventId);
                                    }


                                    if (type == "DOUBLE CHANCE")
                                    {
                                        doubleChance = this.getDoubleChanceFoEvent(node, olimpEvent.EventId);
                                    }
                                    if (type == "TOTAL GOALS")
                                    {
                                        Total t = this.GetTotalForEvent(node, olimpEvent.EventId);
                                        if (t != null)
                                        {
                                            totals.Add(t);
                                        }
                                    }

                                    if (type == "ALTERNATIVE TOTAL GOALS")
                                    {
                                        List <Total> totals2 = this.GetTotalGoals(node, olimpEvent.EventId);
                                        if (totals2 != null)
                                        {
                                            totals.AddRange(totals2);
                                        }
                                    }
                                    if (type == "HANDICAP RESULT")
                                    {
                                        Handicap h = this.GetHandicap(node, olimpEvent.EventId);
                                        if (h != null)
                                        {
                                            handicaps.Add(h);
                                        }
                                    }

                                    if (type == "ALTERNATIVE HANDICAP RESULT")
                                    {
                                        List <Handicap> hdps = this.GetHandicaps(node, olimpEvent.EventId);
                                        if (hdps != null)
                                        {
                                            handicaps.AddRange(hdps);
                                        }
                                    }


                                    if (type == "TEAM TOTAL")
                                    {
                                        var result = this.GetTeamTotals(node, olimpEvent);
                                        if (result.home != null)
                                        {
                                            awayTotals = result.away;
                                            homeTotals = result.home;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    return(null);
                }



                olimpOddEvent.moneyLine    = moneyLine;
                olimpOddEvent.doubleChance = doubleChance;
                olimpOddEvent.Totals       = totals;
                olimpOddEvent.Handicaps    = handicaps;
                olimpOddEvent.AwayTotals   = awayTotals;
                olimpOddEvent.HomeTotals   = homeTotals;


                olimpOddEvent.EventId    = olimpEvent.EventId;
                olimpOddEvent.HomeTeam   = olimpEvent.HomeTeam;
                olimpOddEvent.AwayTeam   = olimpEvent.AwayTeam;
                olimpOddEvent.LeagueName = olimpEvent.LeagueName;
                olimpOddEvent.StartDate  = olimpEvent.StartDate;
                olimpOddEvent.DateAdded  = DateTime.Now.ToString();

                return(olimpOddEvent);
            }
            else
            {
                return(null);
            }
        }
        public PinacclePrices ConvertPinnacleEventToDatabasePrices(OddEvent oddEvent)
        {
            eventDiscs.Clear();
            this.pinaccle = new PinacclePrices();



            this.pinaccle.IsLive    = oddEvent.IsLive;
            this.pinaccle.DateAdded = oddEvent.DateAdded;

            this.pinaccle.EventId   = oddEvent.EventId.ToString();
            this.properties         = this.pinaccle.GetType().GetProperties();
            this.pinaccle.HomeTeam  = oddEvent.HomeTeam;
            this.pinaccle.AwayTeam  = oddEvent.AwayTeam;
            this.pinaccle.StartTime = oddEvent.StartTime;
            OddPeriod oddPeriod = oddEvent.Periods[0];

            MoneyLine moneyLine = oddPeriod.MoneyLine;

            List <Handicap> handicaps = oddPeriod.Handicaps;

            List <Total> totals = oddPeriod.Totals;

            DoubleChance doubleChance = oddPeriod.DoubleChance;

            if (oddPeriod.TeamTotal != null)
            {
                Total homeTotal = oddPeriod.TeamTotal.Home;

                Total awayTeamTotal = oddPeriod.TeamTotal.Away;
                if (homeTotal != null)
                {
                    this.SetHomeTeamTotalPricesTodatabase(homeTotal);
                }

                if (awayTeamTotal != null)
                {
                    this.SetAwayTeamTotalPricesToDatabase(awayTeamTotal);
                }
            }


            this.SetMoneyLinePricesToDatabase(moneyLine);
            //this.SetDoubleChanceToDatabasePrices(doubleChance);

            this.SetTotalPricesToDatabase(totals);

            //this.SetHomeTeamTotalPricesTodatabase(homeTotal);

            //this.SetAwayTeamTotalPricesToDatabase(awayTeamTotal);

            this.SetHandicapPricesToDatabase(handicaps);

            //var result = MathClass.GetStatsForMarket(this.eventDiscs);

            //this.pinaccle.EventDiscMax = result.maxDisc;

            //this.pinaccle.EventDiscAverage = result.averageDisc;

            //this.pinaccle.EventMediana = MathClass.GetMedForMarket(this.eventDiscs);

            return(this.pinaccle);
        }