示例#1
1
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="country">地域</param>
 /// <param name="family_line_num">系統番号</param>
 /// <param name="parent_family_line_num">大元の親系統番号</param>
 /// <param name="data">系統データ</param>
 public FamilyLineInfo( Horse.Area country, UInt32 family_line_num, UInt32 parent_family_line_num, ref HFamilyLineData data )
 {
     this.Coutry = country;
     this.FamilyLineNum = family_line_num;
     this.ParentFamilyLuneNum = parent_family_line_num;
     this.Data = data;
 }
示例#2
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;
            Race myRace = (Race)myhorse.Parent;

            foreach (BrisHorse h in race.Horses)
            {
                Horse myOtherHorse = myRace.GetHorseByProgramNumber(h.ProgramNumber);

                if (null == myOtherHorse || myOtherHorse.Scratched)
                {
                    continue;
                }

                if (h != horse)
                {
                    if (h.QuirinSpeedPoints >= horse.QuirinSpeedPoints)
                    {
                        return false;
                    }
                }
            }

            return horse.BrisRunStyle.Contains('E');
        }
示例#3
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            return horse.BlinkersOn;
        }
示例#4
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race= myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            List<BrisPastPerformance> pp = horse.PastPerformances;

            if (pp.Count <= 1)
            {
                return false;
            }
            else
            {
                string s = horse.PastPerformances[0].TripComment.Trim();

                if (s.Length <= 0)
                {
                    return false;
                }

                foreach (string keyword in KEYWORDS)
                {
                    if (s.Contains(keyword))
                    {
                        return true;
                    }
                }

                return false;
            }
        }
示例#5
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            try
            {
                List<BrisPastPerformance> pp = horse.PastPerformances;

                if (pp.Count <= 0)
                {
                    return false;
                }
                else
                {
                    int finalPosition = Convert.ToInt32(pp[0].FinalPosition.Trim());

                    if (finalPosition == 1 && pp[0].RawFinalCallDistanceFromLeader > LENGTHS_CONSIDERED_AS_BIG_WIN)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch
            {
                return false;
            }
        }
示例#6
0
        private bool TopBrisRating(BrisRace race, BrisHorse horse, Horse myhorse)
        {
            if (myhorse.Scratched || horse.IsFirstTimeOut || horse.BestRating <= 0)
            {
                return false;
            }

            List<BrisHorse> list = new List<BrisHorse>();

            foreach (BrisHorse brisHorse in race.Horses)
            {
                Horse h = myhorse.Parent.GetHorseByProgramNumber(brisHorse.ProgramNumber);

                if ((null != h) && (!h.Scratched) && (brisHorse.BestRating > 0))
                {
                    list.Add(brisHorse);
                }
            }

            list.Sort(CompareBestRating);

            if (list.Count <= 2)
            {
                return false;
            }
            else
            {
                return list[0] == horse;
            }
        }
示例#7
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            if (myhorse.Scratched)
            {
                return false;
            }

            if (horse.BrisAvgClassRatingLastThree < 0)
            {
                return false;
            }

            foreach (BrisHorse h in race.Horses)
            {
                if (h.ProgramNumber.Trim().Length > 0)
                {
                    if (myhorse.Parent.GetHorseByProgramNumber(h.ProgramNumber).Scratched || h == horse)
                    {
                        continue;
                    }
                    else
                    {
                        if (h.BrisAvgClassRatingLastThree+1 >= horse.BrisAvgClassRatingLastThree)
                        {
                            return false;
                        }
                    }
                }
            }

            return true;
        }
示例#8
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            if (myhorse.Scratched || horse.IsFirstTimeOut || horse.BrisCompositeLastThree <= 0)
            {
                return false;
            }

            List<BrisHorse> list = new List<BrisHorse>();

            foreach (BrisHorse brisHorse in race.Horses)
            {
                Horse h = myhorse.Parent.GetHorseByProgramNumber(brisHorse.ProgramNumber);

                if ( (null != h) && (!h.Scratched) && (brisHorse.BrisCompositeLastThree > 0))
                {
                    list.Add(brisHorse);
                }
            }

            list.Sort(Compare);

            if(list.Count <=2)
            {
                return true;
            }
            else
            {
                return list[0] == horse || list[1] == horse || list[2] == horse;
            }
        }
示例#9
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            try
            {
                List<BrisPastPerformance> pp = horse.PastPerformances;

                if (pp.Count <= 1)
                {
                    return false;
                }
                else
                {

                    //int finalPosition1 = Convert.ToInt32(pp[0].FinalPosition.Trim());
                    //int finalPosition2 = Convert.ToInt32(pp[1].FinalPosition.Trim());

                    return pp[0].WasTheWinner && pp[1].WasTheWinner;

                }
            }
            catch
            {
                return false;
            }
        }
示例#10
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            return horse.IsFirstTimeLasix;
        }
        private StarterInfo CreateStarterInfo(Horse horse, Dictionary<Horse, StarterInfo> map)
        {
            if (horse.Scratched)
            {
                return null;
            }

            var dummyStarterInfo = new StarterInfo();

            dummyStarterInfo.RacingDate = horse.Parent.Parent.Date;
            dummyStarterInfo.Distance = horse.Parent.CorrespondingBrisRace.DistanceInYards;

            StarterInfo currentStarterInfo = dummyStarterInfo;

            foreach (var pp in GetPastPerformancesWithValidGoldenFigures(horse))
            {
                StarterInfo si = StarterInfo.CreateFromBrisPastPerformance(pp);
                currentStarterInfo.Previous = si;
                si.Next = currentStarterInfo;
                currentStarterInfo = si;
            }

            if (dummyStarterInfo.CountPreceding < 3)
                return null;
            map.Add(horse, dummyStarterInfo);
            return dummyStarterInfo;
        }
示例#12
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            if (myhorse.Scratched)
            {
                return false;
            }

            int pr = horse.PrimePowerRating - 4;
            Race myRace = myhorse.Parent;

            // TODO Make the find highest prime power in the race faster using a dictionary
            foreach (BrisHorse h in race.Horses)
            {
                Horse myh = myRace.GetHorseByProgramNumber(h.ProgramNumber);

                if (myh.Scratched || h == horse)
                {
                    continue;
                }

                if (h.PrimePowerRating >= pr)
                {
                    return false;
                }
            }

            return true;
        }
示例#13
0
        protected static void AppendStatistics(XmlDocument doc, XmlNode node, string statName, Horse horse)
        {
            if (null == horse || node == null || doc == null)
                return;

            /*

            var stat = horse.GetFactorStats(statName);

            if (null == stat)
                return;

            var node2 = doc.CreateElement("Statistics");
            node2.SetAttribute("Name", "General");

            node2.SetAttribute("Starters", stat.Starters.ToString());
            node2.SetAttribute("WinPercent", string.Format("{0:0}%", (int)stat.WinningPercent));
            node2.SetAttribute("ROI", string.Format("{0:0.00}", stat.Roi));
            node2.SetAttribute("IV", string.Format("{0:0.00}", stat.IV));
            node.AppendChild(node2);

            node2 = doc.CreateElement("Statistics");
            node2.SetAttribute("Name", "Trainer");

            node2.SetAttribute("Starters", stat.TrainerStarters.ToString());
            node2.SetAttribute("WinPercent", string.Format("{0:0}%", (int)stat.TrainerWinningPercent));
            node2.SetAttribute("ROI", string.Format("{0:0.00}", stat.TrainerRoi));
            node2.SetAttribute("IV", string.Format("{0:0.00}", stat.TrainerIV));
            node.AppendChild(node2);
            */
        }
示例#14
0
        protected override void ApplyToHorse(Horse h)
        {
            BrisHorse horse = h.CorrespondingBrisHorse;

            if (horse.IsFirstTimeOut || horse.DaysSinceLastRace < Utilities.LONG_LAYOFF_DAYS)
            {
                return;
            }

            if(horse.TodaysRaceIsMCL || horse.TodaysRaceIsMSW)
            {
                h.IsContenter = false;

                if (horse.Age == 3 && horse.PastPerformances[0].IsMSW && horse.PastPerformances.Count == 1)
                {
                    h.IsContenter = true;
                }
            }
            else if(horse.TodaysRaceIsClaimer)
            {
                if(horse.PastPerformances[0].ClaimingPrice < horse.ClaimingPriceOfTheHorse)
                {
                    h.IsContenter = false;
                }
            }
        }
示例#15
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            if (horse.IsFirstTimeOut)
            {
                return false;
            }

            if (!horse.TodaysRaceIsMCL)
            {
                return false;
            }

            foreach (BrisPastPerformance pp in horse.PastPerformances)
            {
                if (pp.IsMCL)
                {
                    return false;
                }
            }

            return true;
        }
示例#16
0
 public static Horse BuildHorseForDB(EntryFromXML entry)
 {
     var horse = new Horse
         {
             HorseName = entry.Name
         };
     return horse;
 }
示例#17
0
        private void AddRaceInfoToGraph(Horse horse, RaceInfo raceInfo)
        {
            if(!_graph.ContainsKey(horse))
            {
                _graph.Add(horse,new List<RaceInfo>());
            }

            _graph[horse].Add(raceInfo);
        }
示例#18
0
        protected static XmlElement CreateStatisticNode(XmlDocument doc, XmlElement node2, string statName, Horse horse)
        {
            var node3 = doc.CreateElement("Factor");
            node3.SetAttribute("Name", statName);

            node2.AppendChild(node3);
            AppendStatistics(doc, node3, statName, horse);
            return node3;
        }
示例#19
0
        protected override void ApplyToHorse(Horse horse)
        {
            BrisHorse h = horse.CorrespondingBrisHorse;
            int numberOfTurfStarts = h.NumberOfLifeTimeOfTurf;

            if(numberOfTurfStarts <=1)
            {
                string sireName = h.Sire;
                string damSirename = h.DamSire;

                var sire = Sire.CreateSireFromDb(sireName);
                var damSire = Sire.CreateSireFromDb(damSirename);

                if (null != sire)
                {
                    if (sire.TurfStarters.Contains("F") || sire.TurfStarters.Contains("E") || sire.TurfStarters.Contains("D") || sire.TurfStarters.Contains("B"))
                    {
                        horse.IsContenter = false;
                        return;
                    }

                    if (sire.TurfStarters.Contains("A"))
                    {
                        horse.IsBestBet = true;
                        return;
                    }
                }

                if (null != damSire)
                {
                    if (!damSire.TurfStarters.Contains("A") && !damSire.TurfStarters.Contains("B"))
                    {
                        horse.IsContenter = false;
                        horse.IsBestBet = false;
                    }
                }

            }
            else if (numberOfTurfStarts <= 4 && numberOfTurfStarts >=2)
            {
                if(h.NumberOfLifePlacesOfTurf + h.NumberOfLifeShowsOfTurf + h.NumberOfLifeWinsOfTurf == 0)
                {
                    horse.IsContenter = false;
                    horse.IsBestBet = false;
                }
            }

            else
            {
                if (h.NumberOfLifeWinsOfTurf <= 0)
                {
                    horse.IsContenter = false;
                    horse.IsBestBet = false;
                }
            }
        }
示例#20
0
 public override bool AppliesToHorse(Horse myhorse)
 {
     BrisHorse horse = myhorse.CorrespondingBrisHorse;
     if (horse.IsFirstTimeOut)
     {
         return false;
     }
     int daysSinceLast = horse.DaysSinceLastRace;
     return daysSinceLast > 0 && daysSinceLast < 7;
 }
示例#21
0
 public override bool AppliesToHorse(Horse myhorse)
 {
     BrisHorse horse = myhorse.CorrespondingBrisHorse;
     if (horse.IsFirstTimeOut)
     {
         return false;
     }
     int daysSinceLast = horse.DaysSinceLastRace;
     return daysSinceLast >= Utilities.LONG_LAYOFF_DAYS;
 }
示例#22
0
        public void Horse_ActualAge_given_known_dob_today_returns_horses_actual_age()
        {
            var now = DateTime.Now;
              var dateOfBirth = new DateTime(1984, now.Month, now.Day);
              var horse = new Horse();
              horse.DateOfBirth = dateOfBirth;
              int age = horse.ActualAge;

              int expectedAge = now.Year - dateOfBirth.Year;
              Assert.AreEqual(expectedAge, age);
        }
示例#23
0
    public static void Main()
    {
        var tractor = new Tractor();
        if (tractor is IGo) {
            tractor.PullPlough();
        }

        var horse = new Horse();
        if (horse is IGo) {
            horse.PullPlough();
        }
    }
示例#24
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            if (myhorse.Scratched || horse.IsFirstTimeOut)
            {
                return false;
            }

               return TopBrisRating(race, horse, myhorse) || TopTwoPowerRating(race, horse, myhorse);
        }
示例#25
0
        public void Horse_OfficialAge_given_known_dob_returns_horses_official_age()
        {
            var dateOfBirth = new DateTime(1984, 2, 1);
              var horse = new Horse();
              horse.DateOfBirth = dateOfBirth;
              int age = horse.OfficialAge;

              var now = DateTime.Now;
              int expectedAge = now.Year - dateOfBirth.Year;

              Assert.AreEqual(expectedAge, age);
        }
示例#26
0
 public void AddNewHorse(HorseViewModel model)
 {
     using (var unit = new UnitOfWork())
     {
         var horse = new Horse
         {
             Nickname = model.Nickname,
             DateBirth = DateTime.Parse(model.DateBirth)
         };
         unit.Horse.Save(horse);
     }
 }
示例#27
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            if (horse.IsFirstTimeOut || !horse.TodaysRaceIsClaimer)
            {
                return false;
            }

            return horse.PastPerformances[0].ClaimingPrice == 0.0;
        }
示例#28
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            if (horse.IsFirstTimeOut || horse.PastPerformances.Count == 1)
            {
                return false;
            }

            int finalPosition = Convert.ToInt32(horse.PastPerformances[0].FinalPosition);
            BrisPastPerformance.RunningStyleType style0 = horse.PastPerformances[0].RunningStyle;

            if (style0 == BrisPastPerformance.RunningStyleType.Presser)
            {
                return false;
            }
            else if (style0 == BrisPastPerformance.RunningStyleType.Unspecified)
            {
                return false;
            }
            if (finalPosition > 2 && style0 != BrisPastPerformance.RunningStyleType.Early)
            {
                return false;
            }

            bool foundAtLeastOnePerformanceWithDiffentStyle = false;

            for (int i = 1; i < horse.PastPerformances.Count; ++i )
            {
                BrisPastPerformance.RunningStyleType style1 = horse.PastPerformances[i].RunningStyle;

                if (style1 == BrisPastPerformance.RunningStyleType.Unspecified ||
                    style1 == BrisPastPerformance.RunningStyleType.Presser)
                {
                    continue;
                }

                if (style0 == style1)
                {
                    return false;
                }
                else
                {
                    Debug.Assert(style1 == BrisPastPerformance.RunningStyleType.Early || style1 == BrisPastPerformance.RunningStyleType.Sustained);
                    Debug.Assert(style0 == BrisPastPerformance.RunningStyleType.Early || style0 == BrisPastPerformance.RunningStyleType.Sustained);
                    Debug.Assert(style1 != style0);
                    foundAtLeastOnePerformanceWithDiffentStyle = true;
                }
            }

            return foundAtLeastOnePerformanceWithDiffentStyle;
        }
示例#29
0
        public override bool AppliesToHorse(Horse myhorse)
        {
            BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
            BrisHorse horse = myhorse.CorrespondingBrisHorse;

            if (horse.IsFirstTimeOut)
            {
                return false;
            }
            else
            {
                return horse.PastPerformances[0].IsDoubleMove;
            }
        }
示例#30
0
 public override bool AppliesToHorse(Horse myhorse)
 {
     BrisRace race = myhorse.CorrespondingBrisHorse.Parent;
     BrisHorse horse = myhorse.CorrespondingBrisHorse;
     List<BrisPastPerformance> pp = horse.PastPerformances;
     if (pp.Count <= 1)
     {
         return false;
     }
     else
     {
         return RunBadlyInRace(pp, 0) && RunBadlyInRace(pp, 1);
     }
 }
示例#31
0
        public void DownloadData(string url)
        {
            string              MAIN_URL = url;
            HtmlDocument        doc;
            Task <HtmlDocument> tsk = GetData(MAIN_URL);

            doc = tsk.Result;
            Link lnk = new Link();

            lnk.URL = (MAIN_URL);


            HtmlNode node = doc.GetElementbyId("racecard");

            string courseandDate = node.ChildNodes[1].InnerText;


            DateTime raceDate;
            string   raceLocation = "";

            if (courseandDate.Contains('-'))
            {
                raceLocation = courseandDate.Split('-').ElementAt(0).Split(',').ElementAt(0);
                var dateStr = courseandDate.Split('-').ElementAt(1).Split(',').ElementAt(1);
                raceDate = DateTime.Parse(dateStr);
            }
            else
            {
                raceLocation = courseandDate.Split(',').ElementAt(0);
                int tempLen = courseandDate.Split(',').Count();
                raceDate = DateTime.Parse(courseandDate.Split(',').ElementAt(tempLen - 1));
            }


            var allRace    = node.ChildNodes[5].ChildNodes.Where(m => m.OriginalName.Equals("li"));
            int totalRaces = allRace.Count();

            if (totalRaces > 0)
            {
                using (var conn = new RaceContext())
                {
                    conn.Links.Add(lnk);
                    //conn.SaveChanges();
                    lnk.Races = new List <Race>();
                    var tempcontentsRaces = node.ChildNodes[7].ChildNodes[3].ChildNodes[1];
                    var contentsRaces     = tempcontentsRaces.ChildNodes.Where(m => m.Name == "div");

                    List <Race> races = new List <Race>();

                    foreach (var item in contentsRaces)
                    {
                        Race race = new Race();
                        race.Date     = raceDate;
                        race.Location = raceLocation;

                        var itemcontentsRace        = item.ChildNodes.Where(m => m.Attributes.Contains("class") && m.Attributes["class"].Value.Contains("raceDetails")).SingleOrDefault();
                        var itemcontentsRaceRunners = item.ChildNodes.Where(m => m.Attributes.Contains("class") && m.Attributes["class"].Value.Contains("cardFields")).SingleOrDefault();

                        var detailsInfo = itemcontentsRace.ChildNodes.Where(m => m.Attributes.Contains("class") && m.Attributes["class"].Value.Contains("detailInfo")).SingleOrDefault();

                        race.Title = detailsInfo.ChildNodes[1].InnerText;
                        var tempTime = detailsInfo.ChildNodes[3].ChildNodes[1].InnerText;
                        race.Time = race.Date;
                        if (!tempTime.Equals(" : : : "))
                        {
                            race.Time = race.Time.AddHours(double.Parse(tempTime.Split(':')[0]));
                            race.Time = race.Time.AddMinutes(double.Parse(tempTime.Split(':')[1]));
                        }

                        var typeandclass = detailsInfo.ChildNodes[3].ChildNodes[3].InnerText;
                        race.Class       = typeandclass.Split('-')[1];
                        race.Type        = typeandclass.Split('-')[0];
                        race.TrackLength = detailsInfo.ChildNodes[3].ChildNodes[5].InnerText.Split('M')[0] + "M";
                        race.TrackType   = detailsInfo.ChildNodes[3].ChildNodes[5].InnerText.Split('M')[1];

                        var winningPriceCurrency = detailsInfo.ChildNodes[3].ChildNodes[7].InnerText.Split(' ');
                        race.WinningCurrency = winningPriceCurrency.ElementAt(1);

                        string temprice = winningPriceCurrency.ElementAt(19).ToString().Replace(",", "");
                        race.WinningPrice = long.Parse(temprice);

                        var railSafety = detailsInfo.ChildNodes.Where(m => m.Attributes.Contains("class") && m.Attributes["class"].Value.Contains("railSafety")).SingleOrDefault();
                        race.Weather = railSafety.ChildNodes[1].ChildNodes[2].ChildNodes[0].InnerText;

                        race.TrackCondition = railSafety.ChildNodes[3].ChildNodes[2].ChildNodes.Count > 0 ? railSafety.ChildNodes[3].ChildNodes[2].ChildNodes[0].InnerText : "";

                        race.RailPosition = railSafety.ChildNodes[7].ChildNodes[2].ChildNodes.Count > 0 ? railSafety.ChildNodes[7].ChildNodes[2].ChildNodes[0].InnerText : "";

                        race.SafetyLimit = railSafety.ChildNodes[9].ChildNodes[2].ChildNodes.Count > 0 ? railSafety.ChildNodes[9].ChildNodes[2].ChildNodes[0].InnerText : "";

                        var finishTime = detailsInfo.ChildNodes.Where(m => m.Attributes.Contains("class") && m.Attributes["class"].Value.Contains("finishTime")).SingleOrDefault();
                        //finishTime.InnerText.Substring(finishTime.InnerText.IndexOf(@" " "))
                        Regex reg = new Regex("[0-9]{2}:[0-9]{2}:[0-9]{2}");
                        Match mch = reg.Match(finishTime.InnerText);
                        race.RunningTime = mch.Value;

                        //getting null string <span>(Hand Timed)</span> = <span></span>
                        reg = new Regex("[(].*[)]");
                        mch = reg.Match(finishTime.InnerHtml);
                        race.RunningTimeType = mch.Value;
                        //race.RunningTimeType = "Test";
                        var fullConditions = itemcontentsRace.ChildNodes.Where(m => m.Attributes.Contains("class") && m.Attributes["class"].Value.Contains("fullConditions")).SingleOrDefault();
                        var prizeBreak     = fullConditions.ChildNodes.Where(m => m.Attributes.Contains("class") && m.Attributes["class"].Value.Contains("prizeBreak")).SingleOrDefault();


                        var prizeTable = prizeBreak.ChildNodes.Where(m => m.Name == "table").SingleOrDefault();


                        var prizeTableTr = prizeTable.ChildNodes.Where(m => m.Name == "tr");
                        List <WinningPrice> allPrizes  = new List <WinningPrice>();
                        List <Runner>       allRunners = new List <Runner>();

                        int[] pricePosition = { 1, 4, 2, 5, 3, 7 };
                        int   tmp           = 0;

                        foreach (var bodyRow in prizeTableTr)
                        {
                            WinningPrice prize  = new WinningPrice();
                            WinningPrice prize2 = new WinningPrice();

                            var tablePrizestd = bodyRow.ChildNodes.Where(m => m.Name == "td");
                            prize.Position = pricePosition[tmp];
                            prize.Price    = long.Parse(tablePrizestd.ElementAt(1).InnerHtml.Replace(",", ""));
                            prize.Race     = race;
                            conn.WinningPrizes.Add(prize);
                            tmp = tmp + 1;

                            prize2.Position = pricePosition[tmp];
                            prize2.Price    = long.Parse(tablePrizestd.ElementAt(4).InnerHtml.Replace(",", ""));
                            prize2.Race     = race;

                            allPrizes.Add(prize);
                            allPrizes.Add(prize2);
                            tmp = tmp + 1;
                            conn.WinningPrizes.Add(prize2);
                        }
                        var detailedConditions = fullConditions.ChildNodes.Where(m => m.Attributes.Contains("class") && m.Attributes["class"].Value.Contains("detailedConditions")).SingleOrDefault();
                        race.Notes = detailedConditions.InnerText;

                        race.WinningPrices = allPrizes;
                        conn.Races.Add(race);

                        lnk.Races.Add(race);
                        //conn.SaveChanges();



                        var resultsTable     = itemcontentsRaceRunners.ChildNodes.Where(m => m.Attributes.Contains("class") && m.Attributes["class"].Value.Contains("entriesTable resultsTable")).SingleOrDefault();
                        var resultsTableRows = resultsTable.ChildNodes.Where(m => m.Name == "tbody").SingleOrDefault().ChildNodes.Where(m => m.Name == "tr");
                        race.Runners = new List <Runner>();
                        foreach (var runnerRow in resultsTableRows)
                        {
                            Runner tempRunner = new Runner();
                            tempRunner.Name = runnerRow.Attributes["owner"].Value;
                            var tempRunnerCols       = runnerRow.ChildNodes.Where(m => m.Name == "td");
                            var tempPositionValidate = tempRunnerCols.ElementAt(0).InnerText;

                            var tmpPosition = (tempPositionValidate.Contains("nd") ? tempPositionValidate.Replace("nd", "") : tempPositionValidate.Contains("st") ? tempPositionValidate.Replace("st", "") : tempPositionValidate.Contains("th") ? tempPositionValidate.Replace("th", "") : tempPositionValidate.Contains("rd") ? tempPositionValidate.Replace("rd", "") : tempPositionValidate);
                            tempRunner.Position = tmpPosition;
                            tempRunner.Margin   = tempRunnerCols.ElementAt(1).InnerText.ToString();
                            tempRunner.Drawn    = !string.IsNullOrEmpty(tempRunnerCols.ElementAt(2).InnerText) ? int.Parse(tempRunnerCols.ElementAt(2).InnerText) : 0;
                            tempRunner.OR       = tempRunnerCols.ElementAt(3).InnerText;
                            //tempRunner. Horse

                            string horseUrl = "http:/" + tempRunnerCols.ElementAt(4).ChildNodes.Where(m => m.Name == "a").SingleOrDefault().Attributes["href"].Value;

                            Horse tempHorse = new Horse()
                            {
                                URL  = horseUrl,
                                Name = tempRunnerCols.ElementAt(4).ChildNodes.Where(m => m.Name == "a").SingleOrDefault().InnerText,
                            };

                            conn.Horses.Add(tempHorse);
                            tempHorse.Runners = new List <Runner>();
                            tempHorse.Runners.Add(tempRunner);
                            tempRunner.Equipment = tempRunnerCols.ElementAt(6).InnerText;

                            string  trainerURl  = "http:/" + tempRunnerCols.ElementAt(7).ChildNodes.Where(m => m.Name == "a").SingleOrDefault().Attributes["href"].Value;
                            Trainer tempTrainer = new Trainer()
                            {
                                Name = tempRunnerCols.ElementAt(7).ChildNodes.Where(m => m.Name == "a").SingleOrDefault().InnerText,
                                URL  = trainerURl
                            };
                            tempTrainer.Runners = new List <Runner>();
                            tempTrainer.Runners.Add(tempRunner);
                            conn.Trainers.Add(tempTrainer);

                            string jockeyUrl  = "http:/" + tempRunnerCols.ElementAt(8).ChildNodes.Where(m => m.Name == "a").SingleOrDefault().Attributes["href"].Value;
                            Jockey tempJockey = new Jockey()
                            {
                                URL    = jockeyUrl,
                                Name   = tempRunnerCols.ElementAt(8).ChildNodes.Where(m => m.Name == "a").SingleOrDefault().InnerText,
                                Weight = decimal.Parse(tempRunnerCols.ElementAt(5).InnerText)
                            };

                            tempJockey.Runners = new List <Runner>();
                            tempJockey.Runners.Add(tempRunner);
                            conn.Jockeys.Add(tempJockey);
                            tempRunner.Race = race;
                            race.Runners.Add(tempRunner);

                            conn.Runners.Add(tempRunner);
                        }



                        conn.SaveChanges();
                    }
                }
            }
        }
示例#32
0
 /// <summary>Get whether a horse is a tractor.</summary>
 /// <param name="horse">The horse to check.</param>
 private bool IsTractor(Horse horse)
 {
     return(TractorManager.IsTractor(horse));
 }
示例#33
0
        public void HorseExhibitsDomesticBehavior()
        {
            Horse shadowfax = new Horse("Shadowfax");

            Assert.IsType <string>(shadowfax.TrainWith("You"));
        }
示例#34
0
        public static void Initialize(StableContext context)
        {
            context.Database.EnsureCreated();

            if (context.Persons.Any())
            {
                return;   // DB has been seeded
            }

            var roles = new Role[]
            {
                new Role {
                    Name = "default"
                },
                new Role {
                    Name = "admin"
                },
                new Role {
                    Name = "groom"
                },
                new Role {
                    Name = "secretary"
                },
            };

            foreach (var role in roles)
            {
                context.Roles.Add(role);
            }

            context.SaveChanges();

            var persons = new Person[]
            {
                new Person {
                    Name = "Martin", Surname = "Pierre"
                },
                new Person {
                    Name = "Muller", Surname = "Hans"
                },
                new Person {
                    Name = "West", Surname = "Malik"
                },
            };

            foreach (var person in persons)
            {
                context.Persons.Add(person);
            }

            context.SaveChanges();

            var users = new User[]
            {
                new User {
                    Name = "Boss", Surname = "E", UserName = "******", PassHash = "admin", RoleID = 2
                },
                new User
                {
                    Name = "Secretary", Surname = "F", UserName = "******", PassHash = "secretary", RoleID = 4
                },
                new User {
                    Name = "Groom", Surname = "G", UserName = "******", PassHash = "groom", RoleID = 3
                },
                new User {
                    Name = "Doe", Surname = "John", UserName = "******", PassHash = "password", RoleID = 1
                }
            };

            foreach (var user in users)
            {
                context.Users.Add(user);
            }

            context.SaveChanges();

            var stables = new Stable[]
            {
                new Stable {
                    BossID = null
                },
            };

            foreach (var stable in stables)
            {
                context.Stables.Add(stable);
            }

            context.SaveChanges();

            var horses = new Horse[]
            {
                new Horse {
                    OwnerID = 1, Name = "Pataclop"
                },
                new Horse {
                    Owner = new Person {
                        Name = "Owner", Surname = "StarPony"
                    }, Name = "StarPony"
                }
            };

            foreach (var horse in horses)
            {
                context.Horses.Add(horse);
            }

            context.SaveChanges();

            AddMedicEntry(context);

            var stockItems = new StockItem[]
            {
                new StockItem {
                    ItemName = "Helmet"
                },
                new StockItem {
                    ItemName = "Saddle"
                },
                new StockItem {
                    ItemName = "Best Item"
                }
            };

            foreach (var stockItem in stockItems)
            {
                context.StockItems.Add(stockItem);
            }

            context.SaveChanges();

            var stockEntries = new StockEntry[]
            {
                new StockEntry {
                    ItemID = 1, StableID = 1, Quantity = 50
                },
                new StockEntry {
                    ItemID = 2, StableID = 1, Quantity = 70
                },
            };

            foreach (var stockEntry in stockEntries)
            {
                context.StockEntries.Add(stockEntry);
            }

            context.SaveChanges();

            var boxes = new Box[]
            {
                new Box {
                    Active = false, StableID = 1
                },
                new Box {
                    Active = true, StableID = 1, Occupant = new Horse {
                        Name = "Clopclopclop", OwnerID = 2
                    }
                },
                new Box {
                    Active = false, StableID = 1
                },
                new Box {
                    Active = false, StableID = 1
                },
                new Box {
                    Active = false, StableID = 1
                },
                new Box {
                    Active = false, StableID = 1
                },
                new Box {
                    Active = false, StableID = 1
                },
                new Box {
                    Active = false, StableID = 1
                },
                new Box {
                    Active = false, StableID = 1
                },
                new Box {
                    Active = false, StableID = 1
                },
                new Box {
                    Active = false, StableID = 1
                }
            };

            foreach (var box in boxes)
            {
                context.Boxes.Add(box);
            }

            context.SaveChanges();

            var eventTypes = new EventType[]
            {
                new EventType {
                    Label = "Practice"
                },
                new EventType {
                    Label = "Race"
                },
                new EventType {
                    Label = "Meeting"
                },
                new EventType {
                    Label = "Free"
                }
            };

            foreach (var eventType in eventTypes)
            {
                context.EventTypes.Add(eventType);
            }

            context.SaveChanges();

            var calendars = new Calendar[]
            {
                new Calendar {
                    Name = "Staff Planning", StableID = 1
                },
                new Calendar {
                    Name = "Public events", StableID = 1
                }
            };

            foreach (var calendar in calendars)
            {
                context.Calendars.Add(calendar);
            }

            context.SaveChanges();
        }
示例#35
0
        private bool Spawn(PlayerLocation position, EntityType entityType)
        {
            Level world = Level;
            Mob   mob   = null;

            switch (entityType)
            {
            case EntityType.Chicken:
                mob      = new Chicken(world);
                mob.NoAi = true;
                break;

            case EntityType.Cow:
                mob      = new Cow(world);
                mob.NoAi = true;
                break;

            case EntityType.Pig:
                mob      = new Pig(world);
                mob.NoAi = true;
                break;

            case EntityType.Sheep:
                mob      = new Sheep(world);
                mob.NoAi = true;
                break;

            case EntityType.Wolf:
                mob      = new Wolf(world);
                mob.NoAi = true;
                break;

            case EntityType.Horse:
                mob      = new Horse(world);
                mob.NoAi = true;
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(world);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(world);
                break;

            case EntityType.Spider:
                mob = new Spider(world);
                break;

            case EntityType.Zombie:
                mob = new Zombie(world);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(world);
                break;

            case EntityType.Enderman:
                mob = new Enderman(world);
                break;

            case EntityType.Creeper:
                mob = new Creeper(world);
                break;
            }

            if (mob == null)
            {
                return(false);
            }

            mob.DespawnIfNotSeenPlayer = true;
            mob.KnownPosition          = position;
            var bbox = mob.GetBoundingBox();

            if (!SpawnAreaClear(bbox))
            {
                return(false);
            }

            ThreadPool.QueueUserWorkItem(state => mob.SpawnEntity());

            if (Log.IsDebugEnabled)
            {
                Log.Warn($"Spawn mob {entityType}");
            }
            return(true);
        }
示例#36
0
        public override void OnTrigger(object activator, Mobile m)
        {
            if (m == null || Word == null || (RequireIdentification && !m_Identified))
            {
                return;
            }

            if (DateTime.Now < m_EndTime)
            {
                return;
            }

            string msgstr = "Activating the power of " + Word;

            // assign powers to certain words
            switch (Word)
            {
            case "Shoda":
                m.AddStatMod(new StatMod(StatType.Int, "Shoda", 20, Duration));
                m.SendMessage("Your mind expands!");
                break;

            case "Malik":
                m.AddStatMod(new StatMod(StatType.Str, "Malik", 20, Duration));
                m.SendMessage("Your strength surges!");
                break;

            case "Lepto":
                m.AddStatMod(new StatMod(StatType.Dex, "Lepto", 20, Duration));
                m.SendMessage("You are more nimble!");
                break;

            case "Velas":
                Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(Hide_Callback), new object[] { m });
                m.SendMessage("You disappear!");
                break;

            case "Tarda":
                m.AddSkillMod(new TimedSkillMod(SkillName.Tactics, true, 20, Duration));
                m.SendMessage("You are more skillful warrior!");
                break;

            case "Marda":
                m.AddSkillMod(new TimedSkillMod(SkillName.Magery, true, 20, Duration));
                m.SendMessage("You are more skillful mage!");
                break;

            case "Vas Malik":
                m.AddStatMod(new StatMod(StatType.Str, "Vas Malik", 40, Duration));
                m.SendMessage("You are exceptionally strong!");
                break;

            case "Nartor":
                BaseCreature b = new Drake();
                b.MoveToWorld(m.Location, m.Map);
                b.Owners.Add(m);
                b.SetControlMaster(m);
                if (b.Controled)
                {
                    m.SendMessage("You master the beast!");
                }
                break;

            case "Santor":
                b = new Horse();
                b.MoveToWorld(m.Location, m.Map);
                b.Owners.Add(m);
                b.SetControlMaster(m);
                if (b.Controled)
                {
                    m.SendMessage("You master the beast!");
                }
                break;

            default:
                m.SendMessage("There is no effect.");
                break;
            }

            // display activation effects
            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
            Effects.PlaySound(m, m.Map, 0x201);

            // display a message over the item it was attached to
            if (AttachedTo is Item)
            {
                ((Item)AttachedTo).PublicOverheadMessage(MessageType.Regular, 0x3B2, true, msgstr);
            }

            Charges--;

            // remove the attachment after the charges run out
            if (Charges == 0)
            {
                Delete();
            }
            else
            {
                m_EndTime = DateTime.Now + Refractory;
            }
        }
示例#37
0
        private void animateHorse(object sender, EventArgs e)
        {
            // Only fires if callHorseOnZPress found a valid horse
            if (runningHorse != null)
            {
                // Stop if player jumped on horse before animation
                if (runningHorse.rider != null)
                {
                    runningHorse = null;
                    return;
                }

                // Stop if horse reached destination boundingbox is more accurate
                if (runningHorse.GetBoundingBox().X >= positionToRunTo.X)
                {
                    // If horse position is at a fraction the game draws glitches
                    runningHorse.position.X = ( float )Math.Floor(runningHorse.position.X);

                    // Mini animation for flavor!
                    runningHorse.sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame>()
                    {
                        new FarmerSprite.AnimationFrame(21, 600),
                        new FarmerSprite.AnimationFrame(22, 700),
                        new FarmerSprite.AnimationFrame(21, 5600)
                    });

                    var test1     = Game1.player.GetBoundingBox();
                    var horsetest = runningHorse.GetBoundingBox();

                    var horseBound = runningHorse.position.X;

                    runningHorse = null;
                    return;
                }

                // Move horse
                runningHorse.position.X += Math.Max(1, currentRunSpeed);
                runningHorse.SetMovingOnlyRight();

                // Slow horse down if closer to destination
                if (runningHorse.position.X + 600 > positionToRunTo.X && currentRunSpeed > 3)
                {
                    currentRunSpeed -= speedToSlowPerRender;
                }

                // Animates the horse
                if (runningHorse.sprite.currentAnimation == null)
                {
                    runningHorse.sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame>()
                    {
                        // These animate left
                        // new FarmerSprite.AnimationFrame(8, 70, false, true, null, false),
                        // new FarmerSprite.AnimationFrame(9, 70, false, true, new AnimatedSprite.endOfAnimationBehavior(FarmerSprite.checkForFootstep), false),
                        // new FarmerSprite.AnimationFrame(10, 70, false, true, new AnimatedSprite.endOfAnimationBehavior(FarmerSprite.checkForFootstep), false),
                        // new FarmerSprite.AnimationFrame(11, 70, false, true, new AnimatedSprite.endOfAnimationBehavior(FarmerSprite.checkForFootstep), false),
                        // new FarmerSprite.AnimationFrame(12, 70, false, true, null, false),
                        // new FarmerSprite.AnimationFrame(13, 70, false, true, null, false),

                        // These animate right
                        new FarmerSprite.AnimationFrame(8, 70),
                        new FarmerSprite.AnimationFrame(9, 70, false, false, new AnimatedSprite.endOfAnimationBehavior(FarmerSprite.checkForFootstep), false),
                        new FarmerSprite.AnimationFrame(10, 70, false, false, new AnimatedSprite.endOfAnimationBehavior(FarmerSprite.checkForFootstep), false),
                        new FarmerSprite.AnimationFrame(11, 70, false, false, new AnimatedSprite.endOfAnimationBehavior(FarmerSprite.checkForFootstep), false),
                        new FarmerSprite.AnimationFrame(12, 70),
                        new FarmerSprite.AnimationFrame(13, 70)
                    });
                }
            }
        }
示例#38
0
        public static Entity Create(this EntityType entityType, Level world)
        {
            Entity entity = null;

            switch (entityType)
            {
            case EntityType.None:
                return(null);

            case EntityType.Chicken:
                entity = new Chicken(world);
                break;

            case EntityType.Cow:
                entity = new Cow(world);
                break;

            case EntityType.Pig:
                entity = new Pig(world);
                break;

            case EntityType.Sheep:
                entity = new Sheep(world);
                break;

            case EntityType.Wolf:
                entity = new Wolf(world);
                break;

            case EntityType.Villager:
                entity = new Villager(world);
                break;

            case EntityType.MushroomCow:
                entity = new MushroomCow(world);
                break;

            case EntityType.Squid:
                entity = new Squid(world);
                break;

            case EntityType.Rabbit:
                entity = new Rabbit(world);
                break;

            case EntityType.Bat:
                entity = new Bat(world);
                break;

            case EntityType.IronGolem:
                entity = new IronGolem(world);
                break;

            case EntityType.SnowGolem:
                entity = new SnowGolem(world);
                break;

            case EntityType.Ocelot:
                entity = new Ocelot(world);
                break;

            case EntityType.Zombie:
                entity = new Zombie(world);
                break;

            case EntityType.Creeper:
                entity = new Creeper(world);
                break;

            case EntityType.Skeleton:
                entity = new Skeleton(world);
                break;

            case EntityType.Spider:
                entity = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                entity = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                entity = new Slime(world);
                break;

            case EntityType.Enderman:
                entity = new Enderman(world);
                break;

            case EntityType.Silverfish:
                entity = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                entity = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                entity = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                entity = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                entity = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                entity = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                entity = new Witch(world);
                break;

            case EntityType.Stray:
                entity = new Stray(world);
                break;

            case EntityType.Husk:
                entity = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                entity = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                entity = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                entity = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                var random = new Random();
                entity = new Horse(world, random.NextDouble() < 0.10, random);
                break;

            case EntityType.PolarBear:
                entity = new PolarBear(world);
                break;

            case EntityType.Shulker:
                entity = new Shulker(world);
                break;

            case EntityType.Dragon:
                entity = new Dragon(world);
                break;

            case EntityType.SkeletonHorse:
                entity = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                entity = new Wither(world);
                break;

            case EntityType.Evoker:
                entity = new Evoker(world);
                break;

            case EntityType.Vindicator:
                entity = new Vindicator(world);
                break;

            case EntityType.Vex:
                entity = new Vex(world);
                break;

            case EntityType.Npc:
                entity = new PlayerMob("test", world);
                break;

            default:
                return(null);
            }

            return(entity);
        }
示例#39
0
 /// <summary>Get whether the given horse should be treated as a tractor.</summary>
 /// <param name="horse">The horse to check.</param>
 public static bool IsTractor(Horse horse)
 {
     return(horse != null && horse.Name.StartsWith("tractor/"));
 }
示例#40
0
        public void Summon(Player player, EntityTypeEnum entityType, bool noAi = true, BlockPos spawnPos = null)
        {
            EntityType petType;

            try
            {
                petType = (EntityType)Enum.Parse(typeof(EntityType), entityType.Value, true);
            }
            catch (ArgumentException e)
            {
                return;
            }

            if (!Enum.IsDefined(typeof(EntityType), petType))
            {
                player.SendMessage("No entity found");
                return;
            }

            var coordinates = player.KnownPosition;

            if (spawnPos != null)
            {
                if (spawnPos.XRelative)
                {
                    coordinates.X += spawnPos.X;
                }
                else
                {
                    coordinates.X = spawnPos.X;
                }

                if (spawnPos.YRelative)
                {
                    coordinates.Y += spawnPos.Y;
                }
                else
                {
                    coordinates.Y = spawnPos.Y;
                }

                if (spawnPos.ZRelative)
                {
                    coordinates.Z += spawnPos.Z;
                }
                else
                {
                    coordinates.Z = spawnPos.Z;
                }
            }

            var world = player.Level;

            Mob mob = null;

            EntityType type = (EntityType)(int)petType;

            switch (type)
            {
            case EntityType.Chicken:
                mob = new Chicken(world);
                break;

            case EntityType.Cow:
                mob = new Cow(world);
                break;

            case EntityType.Pig:
                mob = new Pig(world);
                break;

            case EntityType.Sheep:
                mob = new Sheep(world);
                break;

            case EntityType.Wolf:
                mob = new Wolf(world)
                {
                    Owner = player
                };
                break;

            case EntityType.Villager:
                mob = new Villager(world);
                break;

            case EntityType.MushroomCow:
                mob = new MushroomCow(world);
                break;

            case EntityType.Squid:
                mob = new Squid(world);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(world);
                break;

            case EntityType.Bat:
                mob = new Bat(world);
                break;

            case EntityType.IronGolem:
                mob = new IronGolem(world);
                break;

            case EntityType.SnowGolem:
                mob = new SnowGolem(world);
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(world);
                break;

            case EntityType.Zombie:
                mob = new Zombie(world);
                break;

            case EntityType.Creeper:
                mob = new Creeper(world);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(world);
                break;

            case EntityType.Spider:
                mob = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                mob = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                mob = new Slime(world);
                break;

            case EntityType.Enderman:
                mob = new Enderman(world);
                break;

            case EntityType.Silverfish:
                mob = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                mob = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                mob = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                mob = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                mob = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                mob = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                mob = new Witch(world);
                break;

            case EntityType.Stray:
                mob = new Stray(world);
                break;

            case EntityType.Husk:
                mob = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                mob = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                mob = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                mob = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                mob = new Horse(world);
                break;

            case EntityType.PolarBear:
                mob = new PolarBear(world);
                break;

            case EntityType.Shulker:
                mob = new Shulker(world);
                break;

            case EntityType.Dragon:
                mob = new Dragon(world);
                break;

            case EntityType.SkeletonHorse:
                mob = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                mob = new Mob(EntityType.Wither, world);
                break;

            case EntityType.Npc:
                mob = new PlayerMob("test", world);
                break;
            }

            if (mob == null)
            {
                return;
            }
            mob.NoAi = noAi;
            var direction = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f;

            mob.KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw, coordinates.Yaw);
            mob.SpawnEntity();
        }
示例#41
0
    private void Run_horse(int playerNumber)
    {
        int currentsquare = horsePicking.GetSquareUnder();                                  //o hien tai dang dung
        int tmp           = (currentsquare + DiceNumberTextScript.diceNumber - 1) % 48 + 1; // o tiep theo se di den

        Debug.Log("currentsquare " + currentsquare);
        Debug.Log("tmp " + tmp);
        if (horsePicking.GetCanRun() == 1)
        {
            //xuat chuong
            if (playerNumber == 1)
            {
                tmp = 1;
                horsePicking.MoveTo(square[1].getPosition());
                square[1].SetHasHorse();
            }
            if (playerNumber == 2)
            {
                tmp = 13;
                horsePicking.MoveTo(square[13].getPosition());
                square[13].SetHasHorse();
            }
            if (playerNumber == 3)
            {
                tmp = 25;
                square[25].SetHasHorse();
                horsePicking.MoveTo(square[25].getPosition());
            }
            if (playerNumber == 4)
            {
                tmp = 37;
                square[37].SetHasHorse();
                horsePicking.MoveTo(square[37].getPosition());
            }
            horsePicking.Xuat_chuong();
        }
        if (horsePicking.GetCanRun() == 2)
        {
            // di binh thuong
            Debug.Log("di binh thuong");
            if (square[tmp].HasHorse())
            { // neu co quan cua thang khac thi da
                Debug.Log("da chet cmm di");
                Horse   dieHorse = HorseOfSquare(tmp);
                Vector3 tmpVec   = Chuong[(dieHorse.getplayerNumber() - 1) * 4 + dieHorse.gethorseNumber()];
                dieHorse.MoveTo(new Vector3(tmpVec.x, tmpVec.y - 3.5f, tmpVec.z));
                dieHorse.Nhap_chuong();
            }// da

            square[tmp].SetHasHorse();
            horsePicking.MoveTo(square[tmp].getPosition()); // mac dinh la di binh thuong


            square[currentsquare].resetAll();
        }

        if (horsePicking.GetCanRun() == 3)
        {
            //di trong chuong dich
            Chuong chuong = null;
            if (horsePicking.GetSquareUnder() > 0)
            {
                chuong = chuongDich[playerNumber, DiceNumberTextScript.diceNumber];
                horsePicking.SetChuongUnder(DiceNumberTextScript.diceNumber);
                chuongDich[currentPlayer, DiceNumberTextScript.diceNumber].SetHasHorse();
            }
            if (horsePicking.GetSquareUnder() == 0)
            {
                chuong = chuongDich[playerNumber, horsePicking.GetChuongUnder() + 1];
                horsePicking.SetChuongUnder(horsePicking.GetChuongUnder() + 1);
                chuongDich[currentPlayer, horsePicking.GetChuongUnder() + 1].SetHasHorse();
            }

            if (chuong != null)
            {
                horsePicking.MoveTo(new Vector3(chuong.getPosition().x, chuong.getPosition().y - 1.8f, chuong.getPosition().z));
            }
        }

        if (horsePicking.GetCanRun() != 3)
        {
            UpdateSquareOfHorse(playerNumber, horsePicking.gethorseNumber(), tmp);
        }
        return;
    }
 /* 서버로부터 메시지를 전달 받습니다. */
 private void read()
 {
     while (true)
     {
         byte[] buf      = new byte[1024];
         int    bufBytes = stream.Read(buf, 0, buf.Length);
         string message  = Encoding.ASCII.GetString(buf, 0, bufBytes);
         /* 접속 성공 (메시지: [Enter]) */
         if (message.Contains("[Enter]"))
         {
             this.status.Text = "[" + this.roomTextBox.Text + "]번 방에 접속했습니다.";
             /* 게임 시작 처리 */
             this.roomTextBox.Enabled = false;
             this.enterButton.Enabled = false;
             entered = true;
         }
         /* 방이 가득 찬 경우 (메시지: [Full]) */
         if (message.Contains("[Full]"))
         {
             this.status.Text = "이미 가득 찬 방입니다.";
             closeNetwork();
         }
         /* 게임 시작 (메시지: [Play]{Horse}) */
         if (message.Contains("[Play]"))
         {
             refresh();
             string horse = message.Split(']')[1];
             if (horse.Contains("Black"))
             {
                 this.status.Text = "당신의 차례입니다.";
                 nowTurn          = true;
                 nowPlayer        = Horse.BLACK;
             }
             else
             {
                 this.status.Text = "상대방의 차례입니다.";
                 nowTurn          = false;
                 nowPlayer        = Horse.WHITE;
             }
             playing = true;
         }
         /* 상대방이 나간 경우 (메시지: [Exit]) */
         if (message.Contains("[Exit]"))
         {
             this.status.Text = "상대방이 나갔습니다.";
             refresh();
         }
         /* 상대방이 돌을 둔 경우 (메시지: [Put]{X,Y}) */
         if (message.Contains("[Put]"))
         {
             string position    = message.Split(']')[1];
             int    x           = Convert.ToInt32(position.Split(',')[0]);
             int    y           = Convert.ToInt32(position.Split(',')[1]);
             Horse  enemyPlayer = Horse.none;
             if (nowPlayer == Horse.BLACK)
             {
                 enemyPlayer = Horse.WHITE;
             }
             else
             {
                 enemyPlayer = Horse.BLACK;
             }
             if (board[x, y] != Horse.none)
             {
                 continue;
             }
             board[x, y] = enemyPlayer;
             Graphics   g = this.boardPicture.CreateGraphics();
             SolidBrush brush;
             if (enemyPlayer == Horse.BLACK)
             {
                 brush = new SolidBrush(Color.Black);
             }
             else
             {
                 brush = new SolidBrush(Color.White);
             }
             g.FillEllipse(brush, x * rectSize, y * rectSize, rectSize, rectSize);
             g.DrawEllipse(new Pen(Color.Black, 1), x * rectSize, y * rectSize, rectSize, rectSize);
             if (judge(enemyPlayer))
             {
                 status.Text        = "패배했습니다.";
                 playing            = false;
                 playButton.Text    = "재시작";
                 playButton.Enabled = true;
             }
             else
             {
                 status.Text = "당신이 둘 차례입니다.";
             }
             nowTurn = true;
         }
     }
 }
示例#43
0
    private bool CheckAllHorseofPlayer(int playerNumber, int diceNumber)
    {
        int cnt             = 0;
        int squareMaxPlayer = (playerNumber - 1) * 12 + 48;       // o toi da co the den cua playerNumber


        for (int i = 1; i <= 4; i++)
        {
            Horse horse = player[playerNumber].getHorse(i);
            if (horse.Check_trong_chuong())
            {
                continue;
            }
            if (horse.GetChuongUnder() != 0)
            {
                continue;
            }
            horse.SetCanRun(2);
            int squareUnder = horse.GetSquareUnder();
            if (playerNumber == 2 && 1 <= squareUnder && squareUnder <= 12)
            {
                squareUnder += 48;
            }
            if (playerNumber == 3 && 1 <= squareUnder && squareUnder <= 24)
            {
                squareUnder += 48;
            }
            if (playerNumber == 4 && 1 <= squareUnder && squareUnder <= 36)
            {
                squareUnder += 48;
            }

            Debug.Log(squareUnder.ToString());
            if (squareUnder + diceNumber > squareMaxPlayer && squareUnder < squareMaxPlayer)
            {
                horse.SetCanRun(0);
            }
            else
            {
                for (int j = squareUnder + 1; j <= diceNumber + squareUnder - 1; j++)
                {
                    //int k = (j - 1) % 48 + 1;// fix vuot qua gioi han 48 o
                    if (square[(j - 1) % 48 + 1].GetPlayerOnThisSquare() != 0) // neu tren o nay co con ngua dang dung
                    {
                        Debug.Log(i.ToString() + "bi chan");
                        horse.SetCanRun(0);
                        break;
                    }
                }
            }

            if (square[(squareUnder + diceNumber - 1) % 48 + 1].GetPlayerOnThisSquare() == playerNumber)
            {
                horse.SetCanRun(0);
            }

            if (squareUnder == squareMaxPlayer)     // kiem tra di chuyen o o toi da cua player
            {
                horse.SetCanRun(3);
                for (int j = 1; j <= diceNumber; j++)
                {
                    if (chuongDich[playerNumber, j].HasHorse())
                    {
                        horse.SetCanRun(0);
                    }
                }
            }
        }

        Debug.Log(cnt);
        for (int i = 1; i <= 4; i++)
        {
            if (player[playerNumber].getHorse(i).GetCanRun() > 0)
            {
                return(true);
            }
        }
        return(false);
    }
示例#44
0
        private static List <string> ProcessMultiple(Horse scrape, string page)
        {
            var ret = new List <string>();

            var regex_table =
                new Regex("<table cellspacing=0 width=600><tr><td class=header><b>Horse.*?</tr>(.*?)</table>",
                          RegexOptions.Singleline);
            Match match_table = regex_table.Match(page);

            if (match_table.Success)
            {
                string table = match_table.Groups[1].ToString();

                var   regex_row = new Regex("<tr>(.*?)</tr", RegexOptions.Singleline);
                Match match_row = regex_row.Match(table);
                while (match_row.Success)
                {
                    string row = match_row.Groups[1].ToString();

                    string pqid    = "";
                    string country = "";
                    int    year    = 0;
                    string sire    = "";
                    string dam     = "";

                    int col_num = 0;

                    var   regex_col = new Regex("<td[^>]*>(.*?)</td", RegexOptions.Singleline);
                    Match match_col = regex_col.Match(row);
                    while (match_col.Success)
                    {
                        string col = match_col.Groups[1].ToString();

                        col_num++;
                        switch (col_num)
                        {
                        case 1:
                            var   regex = new Regex(@"<a href='/([^']*)'", RegexOptions.Singleline);
                            Match match = regex.Match(col);
                            if (match.Success)
                            {
                                pqid = match.Groups[1].ToString();
                            }

                            regex = new Regex(@"\(([A-Z]+)\)", RegexOptions.Singleline);
                            match = regex.Match(col);
                            if (match.Success)
                            {
                                country = match.Groups[1].ToString();
                            }
                            break;

                        case 2:
                            regex = new Regex(@"(\d\d\d\d)", RegexOptions.Singleline);
                            match = regex.Match(col);
                            if (match.Success)
                            {
                                year = Convert.ToInt32(match.Groups[1].ToString());
                            }
                            break;

                        case 5:
                            regex = new Regex(@"<a href=[^>]*>([^<]*)</a>", RegexOptions.Singleline);
                            match = regex.Match(col);
                            if (match.Success)
                            {
                                sire = match.Groups[1].ToString();
                            }
                            break;

                        case 6:
                            regex = new Regex(@"<a href=[^>]*>([^<]*)</a>", RegexOptions.Singleline);
                            match = regex.Match(col);
                            if (match.Success)
                            {
                                dam = match.Groups[1].ToString();
                            }
                            break;
                        }

                        match_col = match_col.NextMatch();
                    }

                    ret.Add(pqid);
                    match_row = match_row.NextMatch();
                }
            }

            return(ret);
        }
示例#45
0
        /// <summary>The method invoked when <see cref="Game1.timeOfDay"/> changes.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void TimeEvents_TimeOfDayChanged(object sender, EventArgsIntChanged e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            try
            {
                // transition morning light more realistically
                if (this.Config.MorningLightTransition && Game1.timeOfDay > 400 && Game1.timeOfDay < 600)
                {
                    float colorMod = (1300 - Game1.timeOfDay) / 1000f;
                    Game1.outdoorLight = Game1.ambientLight * colorMod;
                }

                // transition to next morning
                if (this.Config.StayUp && Game1.timeOfDay == 2550)
                {
                    Game1.isRaining = false; // remove rain, otherwise lighting gets screwy
                    Game1.updateWeatherIcon();
                    Game1.timeOfDay = 150;   //change it from 1:50 am late, to 1:50 am early
                    foreach (FarmAnimal animal in Game1.getFarm().getAllFarmAnimals())
                    {
                        this.oldAnimalHappiness.Add(animal.happiness);
                    }
                }

                // collapse player at 6am to save & reset
                if (Game1.timeOfDay == 550)
                {
                    this.IsUpLate = true;
                }
                if (this.IsUpLate && Game1.timeOfDay == 600 && !this.JustCollapsed)
                {
                    if (Game1.player.isRidingHorse())
                    {
                        foreach (var character in Game1.player.currentLocation.characters)
                        {
                            try
                            {
                                if (character is Horse)
                                {
                                    (character as Horse).dismount();
                                    horse           = (character as Horse);
                                    shouldWarpHorse = true;
                                }
                            }
                            catch (Exception err)
                            {
                            }
                        }
                    }
                    this.JustCollapsed = true;

                    this.ShouldResetPlayerAfterCollapseNow = true;
                    this.PreCollapseTile    = new Point(Game1.player.getTileX(), Game1.player.getTileY());
                    this.PreCollapseMap     = Game1.player.currentLocation.Name;
                    this.PreCollapseStamina = Game1.player.stamina;
                    this.PreCollapseHealth  = Game1.player.health;
                    this.PreCollapseMoney   = Game1.player.money;
                    this.isInSwimSuit       = Game1.player.bathingClothes.Value;
                    this.isBathing          = Game1.player.swimming.Value;



                    if (Game1.currentMinigame != null)
                    {
                        Game1.currentMinigame = null;
                    }

                    if (Game1.activeClickableMenu != null)
                    {
                        Game1.activeClickableMenu.exitThisMenu(true); //Exit menus.
                    }
                    Game1.timeOfDay += 2400;                          //Recalculate for the sake of technically being up a whole day.

                    //Reset animal happiness since it drains over night.
                    for (int i = 0; i < oldAnimalHappiness.Count; i++)
                    {
                        Game1.getFarm().getAllFarmAnimals()[i].happiness.Value = oldAnimalHappiness[i].Value;
                    }

                    Game1.player.startToPassOut();
                }
            }
            catch (Exception ex)
            {
                this.Monitor.Log(ex.ToString(), LogLevel.Error);
                this.WriteErrorLog();
            }
        }
示例#46
0
        public void RebuiltPiecesMoved(string data)
        {
            var jsonDoc   = JsonDocument.Parse(data);
            var lists     = jsonDoc.RootElement.EnumerateArray();
            var datalist  = new List <Tile>();
            var superList = new List <List <Tile> >();

            foreach (var list in lists)
            {
                var list2 = list.EnumerateArray();
                foreach (var pieceX in list2)
                {
                    JsonElement test;
                    var         element = pieceX.TryGetProperty("Piece", out test);
                    var         flag    = test.GetRawText();
                    if (element && !string.IsNullOrEmpty(flag) && flag != "null")
                    {
                        var Tile = new Tile()
                        {
                            Description = pieceX.GetProperty("Description").GetString(),
                            Id          = pieceX.GetProperty("Id").GetInt32(),
                            IsEmpty     = false,
                            Piece       = null,
                            Xpos        = pieceX.GetProperty("Xpos").GetInt32(),
                            Ypos        = pieceX.GetProperty("Ypos").GetInt32()
                        };

                        var color        = test.GetProperty("Color").GetInt32() == 0 ? Color.White : Color.Black;
                        var currentPos   = test.GetProperty("CurrentPos");
                        var img          = currentPos.GetProperty("Image").GetString();
                        var newPIeceData = new PieceData()
                        {
                            Description = currentPos.GetProperty("Description").GetString(),
                            PieceName   = currentPos.GetProperty("PieceName").GetString(),
                            Xpos        = currentPos.GetProperty("Xpos").GetInt32(),
                            Ypos        = currentPos.GetProperty("Ypos").GetInt32(),
                            Image       = img
                        };
                        var moveCount = test.GetProperty("MoveCount").GetInt32();
                        switch (newPIeceData.PieceName)
                        {
                        case "rook":
                            var rook = new Rook(color, newPIeceData);
                            rook.MoveCount = moveCount;
                            Tile.Piece     = rook;
                            break;

                        case "pawn":
                            var pawn = new Pawn(color, newPIeceData);
                            pawn.MoveCount = moveCount;
                            Tile.Piece     = pawn;
                            break;

                        case "bishop":
                            var bishop = new Bishop(color, newPIeceData);
                            bishop.MoveCount = moveCount;
                            Tile.Piece       = bishop;
                            break;

                        case "king":
                            var king = new King(color, newPIeceData);
                            king.MoveCount = moveCount;
                            Tile.Piece     = king;
                            break;

                        case "queen":
                            var queen = new Queen(color, newPIeceData);
                            queen.MoveCount = moveCount;
                            Tile.Piece      = queen;
                            break;

                        case "horse":
                            var horse = new Horse(color, newPIeceData);
                            horse.MoveCount = moveCount;
                            Tile.Piece      = horse;
                            break;
                        }
                        datalist.Add(Tile);
                    }
                }

                superList.Add(datalist);
            }
        }
示例#47
0
        /// <summary>
        /// Removes your horse from its current location and places it next to the player
        /// </summary>
        private void callHorseOnButtonPress(object sender, EventArgsKeyPressed e)
        {
            // Do nothing
            // If riding horse
            // If player is indoors
            // If horse is already being called
            // If event up
            // If menu up
            // If keypress is not configured key ( defaults to z )
            if (Game1.player.isRidingHorse() || Game1.currentLocation.isOutdoors == false || runningHorse != null || Game1.eventUp || Game1.activeClickableMenu != null || e.KeyPressed.ToString() != ModEntry.modConfig.summonHorseKey)
            {
                return;
            }

            Horse        tempHorse     = null;
            GameLocation horseLocation = null;

            // Find horse
            foreach (var location in Game1.locations)
            {
                foreach (var npc in location.characters)
                {
                    // Only call horse if horse is in a different location
                    if (location == Game1.currentLocation)
                    {
                        //continue;
                    }

                    if (npc is Horse)
                    {
                        if (tempHorse == null)
                        {
                            tempHorse     = ( Horse )npc;
                            horseLocation = location;
                        }
                        else
                        {
                            ModEntry.Log($"There are multiple horses! Calling {tempHorse.name} from {tempHorse.currentLocation.name}");
                        }
                    }
                }
            }

            // No horse found
            if (tempHorse == null)
            {
                return;
            }

            // Do nothing if horse is close to farmer
            if (Utility.distance(tempHorse.position.X, Game1.player.position.X, tempHorse.position.Y, Game1.player.position.Y) < 600)
            {
                ModEntry.Log("Your horse is right next to you... don't be lazy, go walk up to it!");
                return;
            }

            // Change horse location
            if (Game1.currentLocation.characters.Contains(tempHorse) == false && horseLocation.characters.Remove(tempHorse))
            {
                Game1.currentLocation.characters.Add(tempHorse);
                tempHorse.currentLocation = Game1.currentLocation;
            }

            runningHorse = tempHorse;

            // Set horse start position
            int positionXToRunTo = Game1.player.getTileX() * Game1.tileSize;
            int positionYToRunTo = Game1.player.getTileY() * Game1.tileSize;

            positionToRunTo = new Vector2(positionXToRunTo, positionYToRunTo);

            //Game1.currentLocation.tile

            /*
             * int differenceBetweenPlayerAndHorse = ( Game1.player.sprite.spriteWidth - runningHorse.sprite.spriteWidth ) / 2 * Game1.pixelZoom + 6;
             * positionToRunTo = Game1.player.position;
             * positionToRunTo.X += differenceBetweenPlayerAndHorse;
             * runningHorse.position.Y = positionToRunTo.Y;
             * runningHorse.position.X = Game1.viewport.X - runningHorse.sprite.getWidth() * Game1.pixelZoom;
             */

            float boundingBoxOffset = runningHorse.position.X - runningHorse.GetBoundingBox().X;

            runningHorse.position.X = positionToRunTo.X + boundingBoxOffset;
            //runningHorse.position.X = Game1.viewport.X - runningHorse.sprite.getWidth() * Game1.pixelZoom;
            runningHorse.position.Y = positionToRunTo.Y;

            // Set horse moving right
            runningHorse.facingDirection = 1;

            // Set starting variables
            currentRunSpeed      = 30;
            speedToSlowPerRender = 1;
            runningHorse.sprite.currentAnimation = null;
            poofAnimator.position = runningHorse.position;
            poofAnimator.deathAnimation();
            runningHorse = null;
        }
示例#48
0
        public void RebuiltBoard()
        {
            var jsonDoc = JsonDocument.Parse(GameState);

            board = JsonConvert.DeserializeObject <Board>(GameState);
            var         myString = jsonDoc.RootElement.GetProperty("Tiles"); // Get a string from a JsonElement
            var         list     = myString.EnumerateObject();
            List <Tile> tiles    = new List <Tile>();
            var         dict     = new Dictionary <int, Tile>();

            foreach (var item in list)
            {
                var keyID = Convert.ToInt32(item.Name);
                var empty = item.Value.GetProperty("IsEmpty").GetBoolean();
                var Tile  = new Tile()
                {
                    Description = item.Value.GetProperty("Description").GetString(),
                    Id          = item.Value.GetProperty("Id").GetInt32(),
                    IsEmpty     = empty,
                    Piece       = null,
                    Xpos        = item.Value.GetProperty("Xpos").GetInt32(),
                    Ypos        = item.Value.GetProperty("Ypos").GetInt32()
                };
                if (!empty)
                {
                    var pieceX       = item.Value.GetProperty("Piece");
                    var color        = pieceX.GetProperty("Color").GetInt32() == 0 ? Color.White : Color.Black;
                    var currentPos   = pieceX.GetProperty("CurrentPos");
                    var img          = currentPos.GetProperty("Image").GetString();
                    var newPIeceData = new PieceData()
                    {
                        Description = currentPos.GetProperty("Description").GetString(),
                        PieceName   = currentPos.GetProperty("PieceName").GetString(),
                        Xpos        = currentPos.GetProperty("Xpos").GetInt32(),
                        Ypos        = currentPos.GetProperty("Ypos").GetInt32(),
                        Image       = img
                    };
                    // var isPawnfistMove = newPIeceData.PieceName == "pawn" ? pieceX.GetProperty("isFirstMove").GetBoolean() : pieceX.GetProperty("isFirstMove").GetBoolean();
                    var moveCount = pieceX.GetProperty("MoveCount").GetInt32();
                    switch (newPIeceData.PieceName)
                    {
                    case "rook":
                        var rook = new Rook(color, newPIeceData);
                        Tile.Piece           = rook;
                        Tile.Piece.MoveCount = moveCount;
                        break;

                    case "pawn":
                        var pawn = new Pawn(color, newPIeceData);
                        Tile.Piece           = pawn;
                        Tile.Piece.MoveCount = moveCount;
                        break;

                    case "bishop":
                        var bishop = new Bishop(color, newPIeceData);
                        Tile.Piece           = bishop;
                        Tile.Piece.MoveCount = moveCount;
                        break;

                    case "king":
                        var king = new King(color, newPIeceData);
                        Tile.Piece           = king;
                        Tile.Piece.MoveCount = moveCount;
                        break;

                    case "queen":
                        var queen = new Queen(color, newPIeceData);
                        Tile.Piece           = queen;
                        Tile.Piece.MoveCount = moveCount;
                        break;

                    case "horse":
                        var horse = new Horse(color, newPIeceData);
                        Tile.Piece           = horse;
                        Tile.Piece.MoveCount = moveCount;
                        break;
                    }
                }
                board.Tiles[keyID] = Tile;
            }
        }
示例#49
0
 /* Nhan thong diep tu may chu */
 private void read()
 {
     while (true)
     {
         byte[] buf      = new byte[1024];
         int    bufBytes = stream.Read(buf, 0, buf.Length);
         string message  = Encoding.ASCII.GetString(buf, 0, bufBytes);
         /* Ket noi toi may chu thanh cong (Ma thong diep: [Enter]) */
         if (message.Contains("[Enter]"))
         {
             this.status.Text         = "[" + this.roomTextBox.Text + "] co client truy cap";
             this.roomTextBox.Enabled = false;
             this.enterButton.Enabled = false;
             entered = true;
         }
         /* Trang thai phong day: (Ma thong diep: [Full]) */
         if (message.Contains("[Full]"))
         {
             this.status.Text = "Phòng đã đầy, không thể vào";
             closeNetwork();
         }
         /* Bat dau tro choi: (Ma thong diep: [Play] */
         if (message.Contains("[Play]"))
         {
             refresh();  //ve lai ban co khi bat dau choi
             string horse = message.Split(']')[1];
             if (horse.Contains("Black"))
             {
                 this.status.Text = "Đến lượt bạn";
                 nowTurn          = true;
                 nowPlayer        = Horse.BLACK;
             }
             else
             {
                 this.status.Text = "Đến lươt đối thủ của bạn";
                 nowTurn          = false;
                 nowPlayer        = Horse.WHITE;
             }
             playing = true;
         }
         /* Khi mot client roi phong: (Ma thong diep: [Exit]) */
         if (message.Contains("[Exit]"))
         {
             this.status.Text = "Đối thủ đã rời phòng";
             refresh();
         }
         /* Neu den luot doi thu danh (Ma thong diep: [Put]) */
         if (message.Contains("[Put]"))
         {
             string position    = message.Split(']')[1];
             int    x           = Convert.ToInt32(position.Split(',')[0]);
             int    y           = Convert.ToInt32(position.Split(',')[1]);
             Horse  enemyPlayer = Horse.none;
             if (nowPlayer == Horse.BLACK)
             {
                 enemyPlayer = Horse.WHITE;
             }
             else
             {
                 enemyPlayer = Horse.BLACK;
             }
             if (board[x, y] != Horse.none)
             {
                 continue;                               //khi vi tri danh da co con co khac danh tu truoc
             }
             board[x, y] = enemyPlayer;
             Graphics g = this.boardPicture.CreateGraphics();
             if (enemyPlayer == Horse.BLACK)
             {
                 SolidBrush brush = new SolidBrush(Color.Black);
                 g.FillEllipse(brush, x * rectSize, y * rectSize, rectSize, rectSize);
             }
             else
             {
                 SolidBrush brush = new SolidBrush(Color.White);
                 g.FillEllipse(brush, x * rectSize, y * rectSize, rectSize, rectSize);
             }
             if (judge(enemyPlayer))
             {
                 status.Text = "Bạn đã bị đánh bại";
                 MessageBox.Show("Bạn đã thua", "YOU LOSE", MessageBoxButtons.OK);
                 playing            = false;
                 playButton.Text    = "Bắt đầu lại";
                 playButton.Enabled = true;
             }
             else
             {
                 status.Text = "Đến lượt bạn";
             }
             nowTurn = true;
         }
     }
 }
示例#50
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            Horse horse1 = (Horse)gameObject1;

            horse1.Location = new Vector2(horse1.Location.X, gameObject2.Location.Y - horse1.Destination.Height);
        }
示例#51
0
 public static bool IsNotATractor(Horse horse)
 {
     return(!horse.Name.StartsWith("tractor/"));
 }
 // Start is called before the first frame update
 void Start()
 {
     _resultHorse = new Horse();
     CreateResultHorseButton();
     CreateHorseOptions();
 }
 public Horse InsertHorse(Horse obj)
 {
     db.Horses.Add(obj);
     db.SaveChanges();
     return(obj);
 }
示例#54
0
 private void MoveToChuong(Horse horse, int playerNumber, int horseNumber)
 {
     horse.MoveTo(Chuong[(playerNumber - 1) * 4 + horseNumber]);
 }
示例#55
0
        public void HorseExhibitsAnimalBehavior()
        {
            Horse pinkiepie = new Horse("Pinkie Pie");

            Assert.Equal(0, pinkiepie.Age);
        }
示例#56
0
 void Stat_Changes(Horse entryHorse, int placement)
 {
     Debug.Log("Stat Changes Here");
 }
 public DataHorseShould()
 {
     _sut = new Horse();
 }
示例#58
0
        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            Log.WarnFormat("Player {0} trying to spawn Mob #{1}.", player.Username, Metadata);

            var coordinates = GetNewCoordinatesFromFace(blockCoordinates, face);

            Mob mob = null;

            EntityType type = (EntityType)Metadata;

            switch (type)
            {
            case EntityType.Chicken:
                mob = new Chicken(world);
                break;

            case EntityType.Cow:
                mob = new Cow(world);
                break;

            case EntityType.Pig:
                mob = new Pig(world);
                break;

            case EntityType.Sheep:
                mob = new Sheep(world);
                break;

            case EntityType.Wolf:
                mob = new Wolf(world)
                {
                    Owner = player
                };
                break;

            case EntityType.Villager:
                mob = new Villager(world);
                break;

            case EntityType.MushroomCow:
                mob = new MushroomCow(world);
                break;

            case EntityType.Squid:
                mob = new Squid(world);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(world);
                break;

            case EntityType.Bat:
                mob = new Bat(world);
                break;

            case EntityType.IronGolem:
                mob = new IronGolem(world);
                break;

            case EntityType.SnowGolem:
                mob = new SnowGolem(world);
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(world);
                break;

            case EntityType.Zombie:
                mob = new Zombie(world);
                break;

            case EntityType.Creeper:
                mob = new Creeper(world);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(world);
                break;

            case EntityType.Spider:
                mob = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                mob = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                mob = new Slime(world);
                break;

            case EntityType.Enderman:
                mob = new Enderman(world);
                break;

            case EntityType.Silverfish:
                mob = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                mob = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                mob = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                mob = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                mob = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                mob = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                mob = new Witch(world);
                break;

            case EntityType.Stray:
                mob = new Stray(world);
                break;

            case EntityType.Husk:
                mob = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                mob = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                mob = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                mob = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                mob = new Horse(world);
                break;

            case EntityType.PolarBear:
                mob = new PolarBear(world);
                break;

            case EntityType.Shulker:
                mob = new Shulker(world);
                break;

            case EntityType.Dragon:
                mob = new Dragon(world);
                break;

            case EntityType.SkeletonHorse:
                mob = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                mob = new Mob(EntityType.Wither, world);
                break;

            case EntityType.Npc:
                mob = new PlayerMob("test", world);
                break;
            }

            if (mob == null)
            {
                return;
            }

            mob.KnownPosition = new PlayerLocation(coordinates.X, coordinates.Y, coordinates.Z);
            mob.SpawnEntity();

            Log.WarnFormat("Player {0} spawned Mob #{1}.", player.Username, Metadata);
        }
示例#59
0
 private void OnDayStarted(object o, DayStartedEventArgs e)
 {
     if (this.restoreData)
     {
         if (M.Config.keepFarmer)
         {
             Monitor.Log("Restore player position.");
             LocationRequest request = Game1.getLocationRequest(map);
             request.OnWarp += delegate {
                 Game1.fadeToBlackAlpha = M.Config.smoothSaving ? 1 : -.2f; // Hide fading from black
                 if (this.pos != null)                                      // Restore exact position if it's not mine or dungeon.
                 {
                     Game1.player.Position = this.pos.Value;
                 }
                 if (this.sitted != null) // Sit down
                 {
                     this.sitted.AddSittingFarmer(Game1.player);
                     Game1.player.sittingFurniture = this.sitted;
                     Game1.player.isSitting.Value  = true;
                 }
             };
             // Place player at the entrance if it's mine or dungeon.
             if (request.Location is VolcanoDungeon dungeon)
             {
                 this.pos = null;
                 Point point = dungeon.startPosition.Value;
                 Game1.warpFarmer(request, point.X, point.Y, 2);
             }
             else if (request.Location is MineShaft)
             {
                 this.pos = null;
                 Game1.warpFarmer(request, 6, 6, 2);
             }
             else
             {
                 Game1.warpFarmer(request, 0, 0, this.facing);
             }
             Game1.fadeToBlackAlpha = 1.2f;  // Hide fading to black
             if (Game1.player.mount != null) // Remove the orphaned horse.
             {
                 Game1.getFarm().characters.Remove(Game1.getFarm().getCharacterFromName(Game1.player.horseName));
             }
         }
         else
         {
             Monitor.Log("Discard player position.");
             Horse mountedHorse = Game1.player.mount;
             if (mountedHorse != null) // Dismount and remove horse
             {
                 mountedHorse.dismount();
                 mountedHorse.currentLocation.characters.Remove(mountedHorse);
             }
             Game1.player.changeOutOfSwimSuit(); // Reset from bathhub
             Game1.player.swimming.Value = false;
         }
         if (M.Config.keepStamina)
         {
             Monitor.Log("Restore player stamina.");
             Game1.player.stamina = this.stamina;
         }
         if (M.Config.keepHealth)
         {
             Monitor.Log("Restore player health.");
             Game1.player.health = this.health;
         }
         if (M.Config.keepHorse && this.horse != null)
         {
             Monitor.Log("Restore horse position.");
             Game1.warpCharacter(this.horse, this.horseMap, this.horsePos / 64);
             this.horse.faceDirection(this.horseFacing);
         }
         this.restoreData = false;
     }
     this.canCallNewDay = false;
 }
 private void SetEating(Horse horse, bool isEating)
 {
     horse.IsEating = isEating;
     horse.BroadcastSetEntityData();
 }