コード例 #1
0
ファイル: FightResultBuilder.cs プロジェクト: minskowl/MY
        /// <summary>
        /// Builds this instance.
        /// </summary>
        /// <returns></returns>
        public FightResult Build()
        {
            var result = new FightResult();

            result.Rival = CreateRival();

            var table = GetResultTable();

            result.FightUrl = browser.Url;
            result.Date     = ParseTime(table.TableRows[0].TableCells[0].Text);
            result.Date     = result.Date.AddHours(-1);

            var winnerRow = FindWinnerRow(table);

            if (winnerRow < 0)
            {
                return(result);
            }

            var winner = ParseWinner(table.TableRows[winnerRow].TableCells[1].Text);

            result.Win = result.Rival.Name != winner;
            ParseWinnigs(result, table.TableRows[winnerRow + 1].TableCells[1].InnerHtml);

            result.RivalInjuryHealth = int.Parse(table.TableRows[2].TableCells[2].Text);
            result.RivalHealth       = int.Parse(table.TableRows[3].TableCells[3].Text);
            result.Rival.UserType    = result.Win ? UserType.Cow : UserType.Fighter;

            return(result);
        }
コード例 #2
0
ファイル: UserImporter.cs プロジェクト: minskowl/MY
 /// <summary>
 /// Imports the specified result.
 /// </summary>
 /// <param name="result">The result.</param>
 public void Import(FightResult result)
 {
     Import(result.Rival);
     if (ObjectProvider.Instance.GetFight(result.Rival.UserID, result.Date) == null)
     {
         ObjectProvider.Instance.AddFight(result);
     }
 }
コード例 #3
0
ファイル: FightResultBuilder.cs プロジェクト: minskowl/MY
        /// <summary>
        /// Parses the winnigs.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="html">The HTML.</param>
        private void ParseWinnigs(FightResult result, string html)
        {
            if (string.IsNullOrEmpty(html))
            {
                return;
            }

            var money   = GetWinnigsValue(html, regMoney);
            var exp     = GetWinnigsValue(html, regExp);
            var cristal = GetWinnigsValue(html, regCristal);
            var sign    = result.Win ? 1 : -1;

            result.Money      = money * sign;
            result.Expirience = exp * sign;
            result.Crystals   = cristal * sign;
        }