Example #1
0
 void AddTeam(SportsTeam tpl, Dashboard cats)
 {
     TreeIter iter = store.AppendValues (tpl.TeamName, null);
     foreach (Player p in tpl.List) {
         store.AppendValues (iter, p.Name, p);
     }
 }
Example #2
0
 public void Setup()
 {
     // Initialize LongoMath.Core by using a type, this will call the module initialization
     var st = new SportsTeam ();
     VFS.SetCurrent (new FileSystem ());
     Initialize ();
 }
Example #3
0
 public static void AddTeam(SportsTeam sportsTeam)
 {
     using (var context = new FantasyFootballContext())
     {
         context.SportsTeam.Add(sportsTeam);
         context.SaveChanges();
     }
 }
 public void SetFilter(EventsFilter filter, ProjectLongoMatch project)
 {
     this.local = project.LocalTeamTemplate;
     this.visitor = project.VisitorTeamTemplate;
     localTeam.Name = local.TeamName;
     visitorTeam.Name = visitor.TeamName;
     this.filter = filter;
     FillTree ();
 }
 public void TestColor()
 {
     SportsTeam t = new SportsTeam ();
     Assert.AreEqual (t.Color, t.Colors [0]);
     t.ActiveColor = -1;
     Assert.AreEqual (t.Color, t.Colors [0]);
     t.ActiveColor = t.Colors.Length + 1;
     Assert.AreEqual (t.Color, t.Colors [0]);
     t.ActiveColor = 1;
     Assert.AreEqual (t.Color, t.Colors [1]);
 }
Example #6
0
		/// <summary>
		/// Migrate the specified team to the current version format.
		/// </summary>
		/// <param name="team">team.</param>
		public static void Migrate (SportsTeam team)
		{
			/* Apply all the migration steps starting from the current version*/
			switch (team.Version) {
			case 0:
				Migrate0 (team);
				break;
			default:
				return;
			}
			Migrate (team);
		}
Example #7
0
 public TeamStats(ProjectLongoMatch project, EventsFilter filter, TeamType team)
 {
     this.project = project;
     this.filter = filter;
     this.team = team;
     if (team == TeamType.LOCAL) {
         this.template = project.LocalTeamTemplate;
     } else {
         this.template = project.VisitorTeamTemplate;
     }
     PlayersStats = new List<PlayerStats> ();
     foreach (PlayerLongoMatch p in this.template.List) {
         PlayersStats.Add (new PlayerStats (project, filter, p));
     }
 }
        public IActionResult SportsTeamHtml(int id)
        {
            SportsTeam team = new SportsTeam(id);

            team.gatewayHtml = team.GenerateTeamProductHtml();


            GatewayPageProductBoxModel gatewayModel = new GatewayPageProductBoxModel();

            //gatewayModel.name =

            return(Json(new
            {
                success = true,
                h1 = team.h1,
                message = team.gatewayHtml
            }));
        }
Example #9
0
		#pragma warning disable 0618
		public static void Migrate0 (SportsTeam team, IDictionary<string, Guid> teamNameToID = null)
		{
			if (team.Version != 0) {
				return;
			}

			if (teamNameToID == null) {
				teamNameToID = new Dictionary<string, Guid> ();
			}

			if (team.ID == Guid.Empty) {
				Guid id;

				if (!teamNameToID.TryGetValue (team.Name, out id)) {
					teamNameToID [team.Name] = id = Guid.NewGuid ();
				}
				team.ID = id;
			}
			team.Version = 1;
		}
        public IActionResult GatewayCatalogProducts(string type, int id)
        {
            switch (type)
            {
            case "sportsTeam":

                GatewayPageProductCategoriesModel teamProductBlocks = new GatewayPageProductCategoriesModel();
                var iProductService  = EngineContext.Current.Resolve <IProductService>();
                var iCategoryService = EngineContext.Current.Resolve <ICategoryService>();
                IList <Category> teamCategoryProducts = iCategoryService.GetAllCategoriesByParentCategoryId(id);


                foreach (var category in teamCategoryProducts)
                {
                    SportsTeam customExtendedCategoryData            = new SportsTeam(category.Id);
                    IPagedList <ProductCategory> productCategoryList = iCategoryService.GetProductCategoriesByCategoryId(category.Id);
                    Product featuredProductData = iProductService.GetProductById(customExtendedCategoryData.featuredProductId);

                    GatewayPageProductBoxModel productBox = new GatewayPageProductBoxModel();
                    productBox.name              = category.Name;
                    productBox.mainPicturePath   = customExtendedCategoryData.mainPicturePath;
                    productBox.width             = featuredProductData.Width;
                    productBox.length            = featuredProductData.Length;
                    productBox.designCount       = productCategoryList.Count;
                    productBox.price             = (int)featuredProductData.Price;
                    productBox.isFeatured        = customExtendedCategoryData.isFeatured;
                    productBox.featuredProductId = customExtendedCategoryData.featuredProductId;
                    productBox.productLink       = customExtendedCategoryData.SeName;

                    teamProductBlocks.productBoxes.Add(productBox);
                }

                return(View("GatewayCategoryProducts", teamProductBlocks));

            default:
                return(View());
            }
        }
Example #11
0
        static void Main(string[] args)
        {
            var team = new SportsTeam();

            team.Name          = "St. Louis Cardinals";
            team.Sport         = "Baseball";
            team.Colors        = "Red and White";
            team.Championships = 11;
            Console.WriteLine(team);

            team               = new SportsTeam();
            team.Name          = "Green Bay Packers";
            team.Sport         = "FootBall";
            team.Colors        = "Green and Gold";
            team.Championships = 4;
            Console.WriteLine(team);

            var car = new Vehicle("VolksWagen", "2012");

            car.SUV("Robby Bourne");

            Console.WriteLine(car);
        }
Example #12
0
        public static void TestDatabase()
        {
            bool isRunning = true;

            while (isRunning)
            {
                Console.WriteLine();
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("1. Add a Player");
                Console.WriteLine("2. Add a Team");
                Console.WriteLine("3. View Database");
                Console.WriteLine("4. Clear Database");
                Console.WriteLine("5. Exit");
                var response = int.Parse(Console.ReadLine());

                switch (response)
                {
                case 1:
                    Console.WriteLine("Adding a new Player");
                    BasePlayer newPlayer = new BasePlayer();

                    Console.Write("League Team: ");
                    newPlayer.LeagueTeam = GetLeagueId(Console.ReadLine());

                    Console.Write("Name: ");
                    newPlayer.Name = Console.ReadLine();

                    Console.Write("Team: ");
                    newPlayer.Team = GetTeamId(Console.ReadLine());

                    Console.Write("Position: ");
                    newPlayer.Position = (int)PositionToEnum(Console.ReadLine());

                    Console.Write("Status: ");
                    newPlayer.Status = Console.ReadLine();

                    Console.Write("Bye Week: ");
                    newPlayer.Bye = int.Parse(Console.ReadLine());

                    Console.Write("Fantasy Points: ");
                    newPlayer.FanPts = double.Parse(Console.ReadLine());

                    switch ((Position)newPlayer.Position)
                    {
                    case Position.QB:
                    case Position.WR:
                    case Position.RB:
                    case Position.TE:
                        Console.Write("Passing Yards (Yds): ");
                        newPlayer.PassingYards = int.Parse(Console.ReadLine());

                        Console.Write("Passing Touchdowns (TD): ");
                        newPlayer.PassingTouchdowns = int.Parse(Console.ReadLine());

                        Console.Write("Interceptions (Int): ");
                        newPlayer.PassingInterceptions = int.Parse(Console.ReadLine());

                        Console.Write("Rushing Attempts (Att): ");
                        newPlayer.RushingAttempts = int.Parse(Console.ReadLine());

                        Console.Write("Rushing Yards (Yds): ");
                        newPlayer.RushingYards = int.Parse(Console.ReadLine());

                        Console.Write("Rushing Touchdowns (TD): ");
                        newPlayer.RushingTouchdowns = int.Parse(Console.ReadLine());

                        Console.Write("Targets (Tgt): ");
                        newPlayer.Targets = int.Parse(Console.ReadLine());

                        Console.Write("Receptions (Rec): ");
                        newPlayer.Receptions = int.Parse(Console.ReadLine());

                        Console.Write("Receiving Yards (Yds): ");
                        newPlayer.ReceivingYards = int.Parse(Console.ReadLine());

                        Console.Write("Receiving Touchdowns (TD): ");
                        newPlayer.ReceivingTouchdowns = int.Parse(Console.ReadLine());

                        Console.Write("Return Touchdowns (TD): ");
                        newPlayer.ReturnTouchdowns = int.Parse(Console.ReadLine());

                        Console.Write("2 Point Conversions (2PT): ");
                        newPlayer.TwoPointConversions = int.Parse(Console.ReadLine());

                        Console.Write("Fumbles Lost (LOST): ");
                        newPlayer.Fumbles = int.Parse(Console.ReadLine());
                        break;

                    case Position.K:
                        Console.Write("0-19: ");
                        newPlayer.FieldGoals019 = int.Parse(Console.ReadLine());

                        Console.Write("20-29: ");
                        newPlayer.FieldGoals2029 = int.Parse(Console.ReadLine());

                        Console.Write("30-39: ");
                        newPlayer.FieldGoals3039 = int.Parse(Console.ReadLine());

                        Console.Write("40-49: ");
                        newPlayer.FieldGoals4049 = int.Parse(Console.ReadLine());

                        Console.Write("50+: ");
                        newPlayer.FieldGoals50 = int.Parse(Console.ReadLine());

                        Console.Write("Made: ");
                        newPlayer.Made = int.Parse(Console.ReadLine());
                        break;

                    case Position.DEF:
                        Console.Write("Points Allowed (Pts vs.): ");
                        newPlayer.PointsAllowed = int.Parse(Console.ReadLine());

                        Console.Write("Sack: ");
                        newPlayer.Sack = int.Parse(Console.ReadLine());

                        Console.Write("Safety (Safe): ");
                        newPlayer.Safety = int.Parse(Console.ReadLine());

                        Console.Write("Interceptions (Int): ");
                        newPlayer.Interceptions = int.Parse(Console.ReadLine());

                        Console.Write("Fumble Recovery (Fum Rec): ");
                        newPlayer.FumbleRecovery = int.Parse(Console.ReadLine());

                        Console.Write("Touchdowns (TD): ");
                        newPlayer.Touchdowns = int.Parse(Console.ReadLine());

                        Console.Write("Block Kick (Blk Kick): ");
                        newPlayer.BlockKick = int.Parse(Console.ReadLine());

                        Console.Write("Kickoff and Punt Return Touchdowns (TD): ");
                        newPlayer.KickoffAndPuntReturnTouchdown = int.Parse(Console.ReadLine());
                        break;
                    }

                    AddPlayer(newPlayer);
                    break;

                case 2:
                    Console.WriteLine("Adding a new Team");
                    var newTeam = new SportsTeam();

                    Console.Write("Name: ");
                    newTeam.Name = Console.ReadLine();

                    AddTeam(newTeam);
                    break;

                case 3:
                    Console.WriteLine("Players:");
                    foreach (var player in GetPlayers())
                    {
                        Console.WriteLine(player.Name);
                    }
                    Console.WriteLine();
                    Console.WriteLine("Sports Teams:");
                    foreach (var team in GetTeams())
                    {
                        Console.WriteLine(team.Name);
                    }
                    break;

                case 4:
                    ClearDatabase();
                    break;

                case 5:
                    isRunning = false;
                    break;
                }
            }
        }
 void HandlePlayersSubstitutionEvent(SportsTeam team, PlayerLongoMatch p1, PlayerLongoMatch p2, SubstitutionReason reason, Time time)
 {
     tagger.Substitute (p1, p2, team);
     if (team.ID == homeTeam.ID) {
         homeTeam.List.Swap (p1, p2);
     } else {
         awayTeam.List.Swap (p1, p2);
     }
 }
        void LoadTeams(ProjectLongoMatch project, List<PlayerLongoMatch> homeFieldPlayers, List<PlayerLongoMatch> homeBenchPlayers,
		                List<PlayerLongoMatch> awayFieldPlayers, List<PlayerLongoMatch> awayBenchPlayers)
        {
            List<PlayerLongoMatch> homeTeamPlayers, awayTeamPlayers;

            if (homeFieldPlayers != null) {
                homeTeamPlayers = homeFieldPlayers.Concat (homeBenchPlayers).ToList ();
                homeTeam = new SportsTeam {
                    Colors = project.LocalTeamTemplate.Colors,
                    ActiveColor = project.LocalTeamTemplate.ActiveColor,
                    ID = project.LocalTeamTemplate.ID,
                    Formation = project.LocalTeamTemplate.Formation,
                    List = new ObservableCollection<Player> (homeTeamPlayers)
                };
            }

            if (awayFieldPlayers != null) {
                awayTeamPlayers = awayFieldPlayers.Concat (awayBenchPlayers).ToList ();
                awayTeam = new SportsTeam {
                    Colors = project.VisitorTeamTemplate.Colors,
                    ActiveColor = project.VisitorTeamTemplate.ActiveColor,
                    ID = project.VisitorTeamTemplate.ID,
                    Formation = project.VisitorTeamTemplate.Formation,
                    List = new ObservableCollection<Player> (awayTeamPlayers)
                };
            }

            tagger.LoadTeams (homeTeam, awayTeam, project.Dashboard.FieldBackground);
        }
        public void LoadTeams(SportsTeam homeTeam, SportsTeam awayTeam, Image background)
        {
            int[] homeF = null, awayF = null;
            int playerSize, colSize, border;

            this.homeTeam = homeTeam;
            this.awayTeam = awayTeam;
            this.background = background;
            NTeams = 0;

            if (background != null) {
                field.Height = background.Height;
                field.Width = background.Width;
            } else {
                field.Width = 300;
                field.Height = 250;
            }
            ResetSelection ();
            ClearPlayers ();
            homePlayingPlayers = awayPlayingPlayers = null;
            lastTime = null;

            homePlayers = new List<SportsPlayerObject> ();
            awayPlayers = new List<SportsPlayerObject> ();

            if (homeTeam != null) {
                homeTeam.UpdateColors ();
                homePlayingPlayers = GetPlayers (homeTeam.StartingPlayersList, TeamType.LOCAL);
                homeBenchPlayers = GetPlayers (homeTeam.BenchPlayersList, TeamType.LOCAL);
                homePlayers.AddRange (homePlayingPlayers);
                homePlayers.AddRange (homeBenchPlayers);
                homeF = homeTeam.Formation;
                if (homeTeam.Shield == null) {
                    homeButton.BackgroundImage = Resources.LoadImage (StyleConf.DefaultShield);
                } else {
                    homeButton.BackgroundImage = homeTeam.Shield;
                }
                NTeams++;
            }
            if (awayTeam != null) {
                awayTeam.UpdateColors ();
                awayPlayingPlayers = GetPlayers (awayTeam.StartingPlayersList, TeamType.VISITOR);
                awayBenchPlayers = GetPlayers (awayTeam.BenchPlayersList, TeamType.VISITOR);
                awayPlayers.AddRange (awayPlayingPlayers);
                awayPlayers.AddRange (awayBenchPlayers);
                awayF = awayTeam.Formation;
                if (awayTeam.Shield == null) {
                    awayButton.BackgroundImage = Resources.LoadImage (StyleConf.DefaultShield);
                } else {
                    awayButton.BackgroundImage = awayTeam.Shield;
                }
                NTeams++;
            }

            colSize = ColumnSize;
            playerSize = colSize * 90 / 100;

            BenchWidth (colSize, field.Height, playerSize);
            field.LoadTeams (background, homeF, awayF, homePlayingPlayers,
                awayPlayingPlayers, playerSize, NTeams);
            homeBench.BenchPlayers = homeBenchPlayers;
            awayBench.BenchPlayers = awayBenchPlayers;
            homeBench.Height = awayBench.Height = field.Height;

            border = App.Current.Style.TeamTaggerBenchBorder;
            if (homeTeam == null || awayTeam == null) {
                if (homeTeam != null) {
                    homeBench.Position = new Point (border, 0);
                    field.Position = new Point (border + homeBench.Width + border, 0);
                } else {
                    field.Position = new Point (border, 0);
                    awayBench.Position = new Point (border + field.Width + border, 0);
                }
            } else {
                homeBench.Position = new Point (border, 0);
                field.Position = new Point (homeBench.Width + 2 * border, 0);
                awayBench.Position = new Point (awayBench.Width + field.Width + 3 * border, 0);
            }

            Update ();
        }
 public void Substitute(PlayerLongoMatch p1, PlayerLongoMatch p2, SportsTeam team)
 {
     if (team == homeTeam) {
         Substitute (homePlayers.FirstOrDefault (p => p.Player == p1),
             homePlayers.FirstOrDefault (p => p.Player == p2),
             homePlayingPlayers, homeBenchPlayers);
     } else {
         Substitute (awayPlayers.FirstOrDefault (p => p.Player == p1),
             awayPlayers.FirstOrDefault (p => p.Player == p2),
             awayPlayingPlayers, awayBenchPlayers);
     }
 }
Example #17
0
        void HandlePlayersSubstitutionEvent(SportsTeam team, PlayerLongoMatch p1, PlayerLongoMatch p2,
		                                     SubstitutionReason reason, Time time)
        {
            App.Current.EventsBroker.Publish<PlayerSubstitutionEvent> (
                new PlayerSubstitutionEvent {
                    Team = team,
                    Player1 = p1,
                    Player2 = p2,
                    SubstitutionReason = reason,
                    Time = time
                }
            );
        }
Example #18
0
 List<ProjectLongoMatch> CreateProjects()
 {
     PlayerLongoMatch andoni = new PlayerLongoMatch { Name = "Andoni" };
     PlayerLongoMatch jorge = new PlayerLongoMatch { Name = "Jorge" };
     PlayerLongoMatch victor = new PlayerLongoMatch { Name = "Victor" };
     PlayerLongoMatch josep = new PlayerLongoMatch { Name = "Josep" };
     PlayerLongoMatch davide = new PlayerLongoMatch { Name = "Davide" };
     PlayerLongoMatch saray = new PlayerLongoMatch { Name = "Saray" };
     PlayerLongoMatch ivan = new PlayerLongoMatch { Name = "Ivan" };
     PlayerLongoMatch adria = new PlayerLongoMatch { Name = "Adria" };
     SportsTeam devteam = new SportsTeam { Name = "DevTeam" };
     SportsTeam qateam = new SportsTeam { Name = "QA" };
     devteam.List.AddRange (new List<PlayerLongoMatch> {
         andoni,
         jorge,
         victor,
         josep,
         davide
     });
     qateam.List.AddRange (new List<PlayerLongoMatch> {
         saray,
         ivan,
         adria
     });
     DashboardLongoMatch dashbaord = DashboardLongoMatch.DefaultTemplate (5);
     var projects = new List<ProjectLongoMatch> ();
     for (int i = 0; i < 5; i++) {
         ProjectLongoMatch p = new ProjectLongoMatch ();
         p.Dashboard = dashbaord.Clone ();
         p.LocalTeamTemplate = devteam;
         p.VisitorTeamTemplate = qateam;
         p.Description = new ProjectDescription ();
         foreach (var player in devteam.List.Concat (qateam.List)) {
             foreach (var button in p.Dashboard.List.OfType<AnalysisEventButton> ()) {
                 TimelineEventLongoMatch evt = p.AddEvent (button.EventType, new Time (0), new Time (10),
                                                   new Time (5), null) as TimelineEventLongoMatch;
                 evt.Players.Add (player);
                 if (qateam.List.Contains (player)) {
                     evt.Teams.Add (qateam);
                 } else {
                     evt.Teams.Add (devteam);
                 }
             }
         }
         projects.Add (p);
         storage.Store (p);
     }
     return projects;
 }
 public ProjectLongoMatch()
 {
     Dashboard = new DashboardLongoMatch ();
     LocalTeamTemplate = new SportsTeam ();
     VisitorTeamTemplate = new SportsTeam ();
 }
Example #20
0
        public void TestPlayingPlayers()
        {
            SportsTeam t = new SportsTeam ();
            PlayerLongoMatch p1, p2, p3;

            t.Name = "test";
            t.TeamName = "team";

            Assert.AreEqual (t.PlayingPlayersList.Count, 0);

            p1 = new PlayerLongoMatch { Name = "P1", Playing = true };
            p2 = new PlayerLongoMatch { Name = "P2", Playing = false };
            p3 = new PlayerLongoMatch { Name = "P3", Playing = true };
            t.List.Add (p1);
            Assert.AreEqual (t.PlayingPlayersList.Count, 1);
            t.List.Add (p2);
            Assert.AreEqual (t.PlayingPlayersList.Count, 1);
            t.List.Add (p3);
            Assert.AreEqual (t.PlayingPlayersList.Count, 2);
            Assert.AreEqual (t.PlayingPlayersList [0], p1);
            Assert.AreEqual (t.PlayingPlayersList [1], p3);
        }
 public int GetScore(SportsTeam team)
 {
     return EventsByTeam (team).Where (e => e.EventType is ScoreEventType).
         Sum (e => (e.EventType as ScoreEventType).Score.Points);
 }
        public SubstitutionEvent SubsitutePlayer(SportsTeam team, PlayerLongoMatch playerIn, PlayerLongoMatch playerOut,
		                                          SubstitutionReason reason, Time subsTime)
        {
            LineupEvent lineup;
            SubstitutionEvent se;

            lineup = Timeline.OfType<LineupEvent> ().FirstOrDefault ();
            if (lineup == null) {
                throw new SubstitutionException (Catalog.GetString ("No lineup events found"));
            }
            if (subsTime < lineup.EventTime) {
                throw new SubstitutionException (Catalog.GetString ("A substitution can't happen before the lineup event"));
            }
            se = new SubstitutionEvent ();
            se.EventType = SubstitutionsEventType;
            se.In = playerIn;
            se.Out = playerOut;
            se.Reason = reason;
            se.EventTime = subsTime;
            se.Teams.Add (team);
            Timeline.Add (se);
            return se;
        }
Example #23
0
 public void Substitute(PlayerLongoMatch p1, PlayerLongoMatch p2, SportsTeam team)
 {
     tagger.Substitute (p1, p2, team);
 }
        public void SetTeam(SportsTeam template, IEnumerable<TimelineEventLongoMatch> plays)
        {
            Dictionary<Player, TreeIter> playersDict = new Dictionary<Player, TreeIter> ();

            Log.Debug ("Updating teams models with template:" + template);
            team = new TreeStore (typeof(object));

            foreach (var player in template.List) {
                /* Add a root in the tree with the option name */
                var iter = team.AppendValues (player);
                playersDict.Add (player, iter);
                Log.Debug ("Adding new player to the model: " + player);
            }

            foreach (var play in plays) {
                foreach (var player in play.Players) {
                    if (playersDict.ContainsKey (player)) {
                        team.AppendValues (playersDict [player], new object[1] { play });
                        Log.Debug ("Adding new play to player: " + player);
                    }
                }
            }
            playerstreeview.Model = team;
            playerstreeview.Colors = true;
            playerstreeview.Project = Project;
        }
        void HandlePlayersSubstitutionEvent(SportsTeam team, PlayerLongoMatch p1, PlayerLongoMatch p2,
		                                     SubstitutionReason reason, Time time)
        {
            team.List.Swap (p1, p2);
            teamtagger.Substitute (p1, p2, team);
            Edited = true;
        }
Example #26
0
        void HandlePlayersSubstitutionEvent(SportsTeam team, PlayerLongoMatch p1, PlayerLongoMatch p2,
		                                     SubstitutionReason reason, Time time)
        {
            widget?.ReDraw ();
            if (PlayersSubstitutionEvent != null) {
                PlayersSubstitutionEvent (team, p1, p2, reason, time);
            }
        }
Example #27
0
        public void TestSerialization()
        {
            SportsTeam t = new SportsTeam ();

            Utils.CheckSerialization (t);

            t.Name = "test";
            t.TeamName = "team";
            t.Shield = Utils.LoadImageFromFile ();
            t.List.Add (new PlayerLongoMatch { Name = "P1" });
            t.List.Add (new PlayerLongoMatch { Name = "P2" });
            t.List.Add (new PlayerLongoMatch { Name = "P3" });

            Utils.CheckSerialization (t);

            SportsTeam newt = Utils.SerializeDeserialize (t);

            Assert.AreEqual (t.ID, newt.ID);
            Assert.AreEqual (t.Name, newt.Name);
            Assert.AreEqual (t.TeamName, newt.TeamName);
            Assert.AreEqual (t.Shield.Width, 16);
            Assert.AreEqual (t.Shield.Height, 16);
            Assert.AreEqual (t.Players.Count, newt.Players.Count);
            Assert.AreEqual (t.Players [0].Name, newt.Players [0].Name);
            Assert.AreEqual (t.Players [1].Name, newt.Players [1].Name);
            Assert.AreEqual (t.Players [2].Name, newt.Players [2].Name);
        }
        public void CurrentLineup(Time currentTime,
		                           out List<PlayerLongoMatch> homeFieldPlayers,
		                           out List<PlayerLongoMatch> homeBenchPlayers,
		                           out List<PlayerLongoMatch> awayFieldPlayers,
		                           out List<PlayerLongoMatch> awayBenchPlayers)
        {
            SportsTeam homeTeam, awayTeam;
            List<PlayerLongoMatch> homeTeamPlayers, awayTeamPlayers;

            homeTeamPlayers = Lineup.HomeStartingPlayers.Concat (Lineup.HomeBenchPlayers).ToList ();
            awayTeamPlayers = Lineup.AwayStartingPlayers.Concat (Lineup.AwayBenchPlayers).ToList ();

            foreach (var ev in Timeline.OfType<SubstitutionEvent> ().
                Where (e => e.EventTime <= currentTime)) {
                if (ev.In != null && ev.Out != null) {
                    if (ev.Teams.Contains (LocalTeamTemplate)) {
                        homeTeamPlayers.Swap (ev.In, ev.Out);
                    } else {
                        awayTeamPlayers.Swap (ev.In, ev.Out);
                    }
                }
            }

            homeTeam = new SportsTeam {
                Formation = LocalTeamTemplate.Formation,
                List = new ObservableCollection<Player> (homeTeamPlayers)
            };
            awayTeam = new SportsTeam {
                Formation = VisitorTeamTemplate.Formation,
                List = new ObservableCollection<Player> (awayTeamPlayers)
            };

            homeFieldPlayers = homeTeam.StartingPlayersList;
            homeBenchPlayers = homeTeam.BenchPlayersList;
            awayFieldPlayers = awayTeam.StartingPlayersList;
            awayBenchPlayers = awayTeam.BenchPlayersList;
        }
        public void TestCopyOverwrite()
        {
            TemplatesService ts = new TemplatesService (storage);
            ts.Start ();
            ITeamTemplatesProvider teamtemplateprovider = ts.TeamTemplateProvider;
            SportsTeam teamB = SportsTeam.DefaultTemplate (5);
            teamB.Name = "B";
            teamB.TeamName = "Template B";
            teamB.FormationStr = "1-4";
            teamB.List [0].Name = "Paco";
            teamtemplateprovider.Save (teamB);
            SportsTeam teamA = new SportsTeam ();
            teamA.Name = "A";
            teamA.TeamName = "Template A";
            teamA.FormationStr = "1-4-3-3";
            teamtemplateprovider.Save (teamA);

            SportsTeam auxdelete = teamA;
            teamtemplateprovider.Copy (teamB, "A");
            teamtemplateprovider.Delete (auxdelete);
            teamA = teamtemplateprovider.Templates [0];

            Assert.AreEqual (4, teamtemplateprovider.Templates.Count);
            Assert.AreEqual ("A", teamA.Name);
            Assert.AreEqual ("Template B", teamA.TeamName);
            Assert.AreEqual (teamB.List.Count, teamA.List.Count);
            Assert.AreEqual ("1-4", teamA.FormationStr);
            Assert.AreEqual ("Paco", teamA.List [0].Name);
        }
 public IEnumerable<TimelineEventLongoMatch> EventsByTeam(SportsTeam team)
 {
     var timelineEventsLongomatch = new ObservableCollection<TimelineEventLongoMatch> ();
     foreach (var timeLineEvent in Timeline) {
         timelineEventsLongomatch.Add (timeLineEvent as TimelineEventLongoMatch);
     }
     return timelineEventsLongomatch.Where (e => e.Teams.Contains (team) || e.Players.Intersect (team.List).Any ());
 }
Example #31
0
 public void LoadTeams(SportsTeam homeTeam, SportsTeam awayTeam, Image background)
 {
     tagger.LoadTeams (homeTeam, awayTeam, background);
     widget?.ReDraw ();
 }