League CreateLeague() { var league = new League(Path.Combine(Path.GetTempPath(), "TestLeague1.Torn")); var team = new LeagueTeam() { Name = "Team A" }; league.AddTeam(team); league.Players.Add(new LeaguePlayer() { Name = "One", Id = "001", Comment = "one" }); team.Players.Add(league.Players[0]); league.Players.Add(new LeaguePlayer() { Name = "<&>' \"", Id = "002", Comment = "two" }); team.Players.Add(league.Players[1]); league.Players.Add(new LeaguePlayer() { Name = "Three", Id = "003" }); team.Players.Add(league.Players[2]); team = new LeagueTeam() { Name = "Team B" }; league.AddTeam(team); league.Players.Add(new LeaguePlayer() { Name = "Four", Id = "004", Comment = "one" }); team.Players.Add(league.Players[3]); league.Players.Add(new LeaguePlayer() { Name = "One", Id = "001" }); team.Players.Add(league.Players[4]); team = new LeagueTeam() { Name = "Team C" }; league.AddTeam(team); return(league); }
/// <summary>This Parse is used to read team names from an input form.</summary> public void Parse(string s, League league) { string[] lines = s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < lines.Length; i++) { FixtureTeam ft = new FixtureTeam { Name = lines[i] }; if (league != null) { ft.LeagueTeam = league.Teams.Find(x => x.Name == ft.Name); if (ft.LeagueTeam == null) { var team = new LeagueTeam { Name = ft.Name }; league.AddTeam(team); ft.LeagueTeam = team; } } Add(ft); } }
private static void AddTeam(string name, string nickName, DateTime dateFounded) { Team newTeam = new Team(name, nickName, dateFounded); League.AddTeam(newTeam); Console.WriteLine(string.Format("Team {0} ({1}) successfully added to league.", name, nickName)); }
public ActionResult AddTeam(Team team) { if (ModelState.IsValid) { var response = _league.AddTeam(team); return(RedirectToAction("GetAllTeams", response)); } return(View(team)); }
public void CanAddTeam(string name, bool expectedResults) { League league = new League(); Team team = new Team(); team.Name = name; var response = league.AddTeam(team); Assert.AreEqual(response.Success, expectedResults); }
public HttpResponseMessage Post(Team team) { League league = new League(); league.AddTeam(team); var response = Request.CreateResponse(HttpStatusCode.Created, team); string uri = Url.Link("DefaultApi", new { id = team.Name }); response.Headers.Location = new Uri(uri); return(response); }
private static void AddTeam(string name, string nick, DateTime foundedIn) { var team = new Team(name, nick, foundedIn); if (League.Teams.Any((t => t.Name == team.Name))) { throw new InvalidOperationException("Team already exists in the league"); } League.AddTeam(team); Console.WriteLine("Team Added"); }
private static void AddPlayerToTeam(string firstName, string lastName, DateTime dateOfBirth, decimal salary, string name) { Player player = new Player(firstName, lastName, salary, dateOfBirth); Team team = League.Teams.First(t => t.Name.Equals(name)); if (!League.Teams.Contains(team)) { League.AddTeam(team); } team.AddPlayer(player); Console.WriteLine("Successful added player {0} {1} to team {2}", firstName, lastName, name); }
void ButtonAddTeamClick(object sender, EventArgs e) { string name = null; if (InputDialog.ConditionalInput("Add Team", "Choose a name for the new team", ref name)) { var team = new LeagueTeam(); team.Name = name; League.AddTeam(team); var node = new TreeNode(name); node.Tag = team; treeView1.Nodes.Add(node); treeView1.SelectedNode = node; } }
public void RememberTeam() { LeagueTeam = new LeagueTeam(); foreach (var serverPlayer in Players()) { var leaguePlayer = League.LeaguePlayer(serverPlayer) ?? League.Players.Find(p => p.Id == serverPlayer.PlayerId); if (leaguePlayer == null) { leaguePlayer = new LeaguePlayer(); leaguePlayer.Name = serverPlayer.Alias; leaguePlayer.Id = serverPlayer.PlayerId; League.Players.Add(leaguePlayer); } LeagueTeam.Players.Add(leaguePlayer); } League.AddTeam(LeagueTeam); }
static void Main() { League league = new League(); string input; while ((input = Console.ReadLine()) != "END") { try { string[] tokens = ReadData(input); string command = tokens[0]; string teamName = tokens[1]; switch (command) { case "Team": league.AddTeam(teamName); break; case "Add": string playerName = tokens[2]; int[] stats = tokens.Skip(3).Select(int.Parse).ToArray(); league.AddPlayerToTeam(teamName, playerName, stats); break; case "Remove": playerName = tokens[2]; league.RemovePlayer(teamName, playerName); break; case "Rating": league.RatingTeam(teamName); break; default: throw new InvalidOperationException("Invalid command."); } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } } }
public static void HandleInput(string input) { var inputArgs = input.Split(); switch (inputArgs[0]) { case "AddTeam": Team team = new Team(inputArgs[1], inputArgs[2], DateTime.Parse(inputArgs[3])); League.AddTeam(team); break; case "AddMatch": string homeTeamName = inputArgs[2]; Team homeTeam = League.Teams.First(t => t.Name == homeTeamName); string awayTeamName = inputArgs[3]; Team awayTeam = League.Teams.First(t => t.Name == awayTeamName); League.AddMatch(new Match(homeTeam, awayTeam, new Score(int.Parse(inputArgs[4]), int.Parse(inputArgs[5])), int.Parse(inputArgs[1]))); break; case "AddPlayerToTeam": string playerTeamName = inputArgs[5]; Team playerTeam = League.Teams.First(t => t.Name == playerTeamName); Player player = new Player(inputArgs[1], inputArgs[2], DateTime.Parse(inputArgs[3]), decimal.Parse(inputArgs[4]), playerTeamName); playerTeam.AddPlayer(player); break; case "ListTeams": Console.WriteLine(); foreach (var t in League.Teams) { Console.WriteLine(t.ToString()); } Console.WriteLine(); break; case "ListMatches": Console.WriteLine(); foreach (var match in League.Matches) { Console.WriteLine(match.ToString()); } break; } }
public static void HandleInput(string input) { var inputArgs = input.Split(); switch (inputArgs[0]) { case "AddTeam": League.AddTeam(new Team(inputArgs[1], inputArgs[2], DateTime.Parse(inputArgs[3]))); break; case "AddMatch": var homeTeam = League.Teams.First(t => t.Name == inputArgs[2]); var awayTeam = League.Teams.First(t => t.Name == inputArgs[3]); League.AddMatch(new Match(homeTeam, awayTeam, new Score(int.Parse(inputArgs[4]), int.Parse(inputArgs[5])), int.Parse(inputArgs[1]))); break; case "AddPlayerToTeam": var team = League.Teams.First(t => t.Name == inputArgs[5]); League.AddPlayerToTeam(new Player(inputArgs[1], inputArgs[2], DateTime.Parse(inputArgs[3]), decimal.Parse(inputArgs[4]), team)); break; case "ListTeams": foreach (var team1 in League.Teams) { Console.WriteLine(team1.ToString()); } break; case "ListMatches": foreach (var match in League.Matches) { Console.WriteLine(match.ToString()); } break; } }
static void Main(string[] args) { #region Liverpool Team liverpool = new Team("Liverpool"); Player playerLiv1 = new Player("Anderson", "Anderson", 1, Position.Gk); Player playerLiv2 = new Player("Virgil", "Van Dyke", 4, Position.Def); Player playerLiv3 = new Player("Henderson", "Henderson", 8, Position.Mid, true); Player playerLiv4 = new Player("Mo", "Salah", 11, Position.Att); liverpool.AddPlayer(playerLiv1); liverpool.AddPlayer(playerLiv2); liverpool.AddPlayer(playerLiv3); liverpool.AddPlayer(playerLiv4); for (int i = 0; i < 10; i++) { liverpool.AddPoints(GetRandomResult()); } #endregion #region Man Utd Team man = new Team("Man Utd"); Player playerMan1 = new Player("David", "De Gea", 1, Position.Gk, true); Player playerMan2 = new Player("Phil", "Jones", 2, Position.Def); Player playerMan3 = new Player("Juan", "Mata", 8, Position.Mid); Player playerMan4 = new Player("Marcus", "Rashford", 10, Position.Att); man.AddPlayer(playerMan1); man.AddPlayer(playerMan2); man.AddPlayer(playerMan3); man.AddPlayer(playerMan4); for (int i = 0; i < 10; i++) { man.AddPoints(GetRandomResult()); } #endregion #region Man City Team city = new Team("Man City"); Player playerCity1 = new Player("Ederson", "Ederson", 1, Position.Gk); Player playerCity2 = new Player("Vincent", "Kompany", 2, Position.Def, true); Player playerCity3 = new Player("Frank", "De Bruyne", 5, Position.Mid); Player playerCity4 = new Player("Kun", "Aguero", 11, Position.Att); city.AddPlayer(playerCity1); city.AddPlayer(playerCity2); city.AddPlayer(playerCity3); city.AddPlayer(playerCity4); for (int i = 0; i < 10; i++) { city.AddPoints(GetRandomResult()); } #endregion #region Chelsea Team chelsea = new Team("Chelsea"); Player playerChelsea1 = new Player("Kepa", "Arizabalaga", 1, Position.Gk); Player playerChelsea2 = new Player("Kurt", "Zouma", 3, Position.Def); Player playerChelsea3 = new Player("N'golo", "Kante", 8, Position.Mid, true); Player playerChelsea4 = new Player("Tammy", "Abhram", 19, Position.Att); chelsea.AddPlayer(playerChelsea1); chelsea.AddPlayer(playerChelsea2); chelsea.AddPlayer(playerChelsea3); chelsea.AddPlayer(playerChelsea4); for (int i = 0; i < 10; i++) { chelsea.AddPoints(GetRandomResult()); } #endregion #region League League premierLeague = new League("Premier League"); premierLeague.AddTeam(liverpool); premierLeague.AddTeam(man); premierLeague.AddTeam(city); premierLeague.AddTeam(chelsea); #endregion #region Printing Console.WriteLine(premierLeague.GetTable()); Console.WriteLine(liverpool.GetDetails()); Console.WriteLine(man.GetDetails()); Console.WriteLine(city.GetDetails()); Console.WriteLine(chelsea.GetDetails()); #endregion }
private static void AddTeam(string name, string nickname, DateTime dateFounded) { League.AddTeam(new Team(name, nickname, dateFounded)); Console.WriteLine("Cuccessful added team: {0}", name); }
public bool AddTeam(League league, Team team) { return(league.AddTeam(team) == null); }
static void Main(string[] args) { try { Console.WriteLine("Comenzando el proceso."); var sessionFactory = SessionFactory.CreateSessionFactoryBuildSchema(); //var sessionFactory = SessionFactory.CreateSessionFactory(); //// create our NHibernate session factory //var sessionFactory = SessionFactory.CreateSessionFactory(); using (var session = sessionFactory.OpenSession()) { // populate the database using (var transaction = session.BeginTransaction()) { // create a couple of Stores each with some Products and Employees var oLigaClausura2010 = new League { Name = "Clausura 2010" }; oLigaClausura2010.AbGoal = 0; oLigaClausura2010.AbAssist = 0; oLigaClausura2010.AbVictoryRandom = 0; oLigaClausura2010.AbDefeatRandom = 0; oLigaClausura2010.AbCleanSheet = 0; oLigaClausura2010.AbKeyTackling = 0; oLigaClausura2010.AbKeyPasses = 0; oLigaClausura2010.AbShotsOn = 0; oLigaClausura2010.AbShotsOff = 0; oLigaClausura2010.AbSaves = 0; oLigaClausura2010.AbConceded = 0; oLigaClausura2010.AbYellow = 0; oLigaClausura2010.AbRed = 0; oLigaClausura2010.MaxInjuryLength = 9; oLigaClausura2010.CupMatch = 0; oLigaClausura2010.WinPoint = 3; oLigaClausura2010.DrawPoint = 1; oLigaClausura2010.Debug = false; var oEquipoNOB = new Team { AbbrName = "NOB", Name = "Newells" }; var oEquipoRC = new Team { AbbrName = "CARC", Name = "Rosario Central" }; var oEquipoBoca = new Team { AbbrName = "CABJ", Name = "Boca Juniors" }; var oEquipoRiver = new Team { AbbrName = "CARP", Name = "River Plate" }; oLigaClausura2010.AddTeam(oEquipoNOB); oLigaClausura2010.AddTeam(oEquipoRC); oLigaClausura2010.AddTeam(oEquipoBoca); oLigaClausura2010.AddTeam(oEquipoRiver); oEquipoNOB.AddPlayer(new Player { Name = "Perata", Age = 30, Nationality = "ARG", ShootStopping = 1, Tackling = 1, Passing = 1, Shooting = 1, Aggression = 1, ShootStoppingAbility = 1, TacklingAbility = 1, PassingAbility = 1, ShootingAbility = 1, Games = 1, Saves = 1, KeyTackles = 1, KeyPasses = 1, Shots = 1, Goals = 1, Assists = 1, Dps = 1, Injury = 1, Suspension = 1 }); oEquipoNOB.AddPlayer(new Player { Name = "Schiavi", Age = 30, Nationality = "ARG", ShootStopping = 1, Tackling = 1, Passing = 1, Shooting = 1, Aggression = 1, ShootStoppingAbility = 1, TacklingAbility = 1, PassingAbility = 1, ShootingAbility = 1, Games = 1, Saves = 1, KeyTackles = 1, KeyPasses = 1, Shots = 1, Goals = 1, Assists = 1, Dps = 1, Injury = 1, Suspension = 1 }); oEquipoNOB.AddPlayer(new Player { Name = "Boghosian", Age = 30, Nationality = "ARG", ShootStopping = 1, Tackling = 1, Passing = 1, Shooting = 1, Aggression = 1, ShootStoppingAbility = 1, TacklingAbility = 1, PassingAbility = 1, ShootingAbility = 1, Games = 1, Saves = 1, KeyTackles = 1, KeyPasses = 1, Shots = 1, Goals = 1, Assists = 1, Dps = 1, Injury = 1, Suspension = 1 }); session.SaveOrUpdate(oLigaClausura2010); // transaction.Commit(); //} //// populate the database //using (var transaction = session.BeginTransaction()) //{ // create a couple of Stores each with some Products and Employees var TacticN = new Tactic { Name = "N" }; var TacticD = new Tactic { Name = "D" }; var TacticA = new Tactic { Name = "A" }; var TacticC = new Tactic { Name = "C" }; var TacticL = new Tactic { Name = "L" }; var TacticP = new Tactic { Name = "P" }; TacticN.AddTeam(oEquipoNOB); TacticD.AddTeam(oEquipoRC); TacticA.AddTeam(oEquipoBoca); TacticC.AddTeam(oEquipoRiver); //TacticL.AddTeam(oEquipoNOB); //TacticP.AddTeam(oEquipoNOB); TacticN.AddMult(new Mult { Position = "DF", Skill = "TK", Multiplier = 1.0 }); TacticN.AddMult(new Mult { Position = "DF", Skill = "PS", Multiplier = 0.5 }); TacticN.AddMult(new Mult { Position = "DF", Skill = "SH", Multiplier = 0.3 }); TacticN.AddMult(new Mult { Position = "MF", Skill = "TK", Multiplier = 0.3 }); TacticN.AddMult(new Mult { Position = "MF", Skill = "PS", Multiplier = 1.0 }); TacticN.AddMult(new Mult { Position = "MF", Skill = "SH", Multiplier = 0.3 }); TacticN.AddMult(new Mult { Position = "FW", Skill = "TK", Multiplier = 0.3 }); TacticN.AddMult(new Mult { Position = "FW", Skill = "PS", Multiplier = 0.3 }); TacticN.AddMult(new Mult { Position = "FW", Skill = "SH", Multiplier = 1.0 }); TacticD.AddMult(new Mult { Position = "DF", Skill = "TK", Multiplier = 1.25 }); TacticD.AddMult(new Mult { Position = "DF", Skill = "PS", Multiplier = 0.75 }); TacticD.AddMult(new Mult { Position = "DF", Skill = "SH", Multiplier = 0.25 }); TacticD.AddMult(new Mult { Position = "MF", Skill = "TK", Multiplier = 1.0 }); TacticD.AddMult(new Mult { Position = "MF", Skill = "PS", Multiplier = 0.75 }); TacticD.AddMult(new Mult { Position = "MF", Skill = "SH", Multiplier = 0.25 }); TacticD.AddMult(new Mult { Position = "FW", Skill = "TK", Multiplier = 0.5 }); TacticD.AddMult(new Mult { Position = "FW", Skill = "PS", Multiplier = 0.25 }); TacticD.AddMult(new Mult { Position = "FW", Skill = "SH", Multiplier = 0.75 }); TacticA.AddMult(new Mult { Position = "DF", Skill = "TK", Multiplier = 1.0 }); TacticA.AddMult(new Mult { Position = "DF", Skill = "PS", Multiplier = 0.5 }); TacticA.AddMult(new Mult { Position = "DF", Skill = "SH", Multiplier = 0.5 }); TacticA.AddMult(new Mult { Position = "MF", Skill = "TK", Multiplier = 0.0 }); TacticA.AddMult(new Mult { Position = "MF", Skill = "PS", Multiplier = 1.0 }); TacticA.AddMult(new Mult { Position = "MF", Skill = "SH", Multiplier = 0.75 }); TacticA.AddMult(new Mult { Position = "FW", Skill = "TK", Multiplier = 0.0 }); TacticA.AddMult(new Mult { Position = "FW", Skill = "PS", Multiplier = 0.75 }); TacticA.AddMult(new Mult { Position = "FW", Skill = "SH", Multiplier = 1.5 }); TacticC.AddMult(new Mult { Position = "DF", Skill = "TK", Multiplier = 1.0 }); TacticC.AddMult(new Mult { Position = "DF", Skill = "PS", Multiplier = 0.5 }); TacticC.AddMult(new Mult { Position = "DF", Skill = "SH", Multiplier = 0.25 }); TacticC.AddMult(new Mult { Position = "MF", Skill = "TK", Multiplier = 0.5 }); TacticC.AddMult(new Mult { Position = "MF", Skill = "PS", Multiplier = 1.0 }); TacticC.AddMult(new Mult { Position = "MF", Skill = "SH", Multiplier = 0.25 }); TacticC.AddMult(new Mult { Position = "FW", Skill = "TK", Multiplier = 0.5 }); TacticC.AddMult(new Mult { Position = "FW", Skill = "PS", Multiplier = 0.5 }); TacticC.AddMult(new Mult { Position = "FW", Skill = "SH", Multiplier = 1.0 }); TacticL.AddMult(new Mult { Position = "DF", Skill = "TK", Multiplier = 1.0 }); TacticL.AddMult(new Mult { Position = "DF", Skill = "PS", Multiplier = 0.25 }); TacticL.AddMult(new Mult { Position = "DF", Skill = "SH", Multiplier = 0.25 }); TacticL.AddMult(new Mult { Position = "MF", Skill = "TK", Multiplier = 0.5 }); TacticL.AddMult(new Mult { Position = "MF", Skill = "PS", Multiplier = 1.0 }); TacticL.AddMult(new Mult { Position = "MF", Skill = "SH", Multiplier = 0.5 }); TacticL.AddMult(new Mult { Position = "FW", Skill = "TK", Multiplier = 0.25 }); TacticL.AddMult(new Mult { Position = "FW", Skill = "PS", Multiplier = 0.5 }); TacticL.AddMult(new Mult { Position = "FW", Skill = "SH", Multiplier = 1.3 }); TacticP.AddMult(new Mult { Position = "DF", Skill = "TK", Multiplier = 1.0 }); TacticP.AddMult(new Mult { Position = "DF", Skill = "PS", Multiplier = 0.75 }); TacticP.AddMult(new Mult { Position = "DF", Skill = "SH", Multiplier = 0.3 }); TacticP.AddMult(new Mult { Position = "MF", Skill = "TK", Multiplier = 0.25 }); TacticP.AddMult(new Mult { Position = "MF", Skill = "PS", Multiplier = 1.0 }); TacticP.AddMult(new Mult { Position = "MF", Skill = "SH", Multiplier = 0.25 }); TacticP.AddMult(new Mult { Position = "FW", Skill = "TK", Multiplier = 0.25 }); TacticP.AddMult(new Mult { Position = "FW", Skill = "PS", Multiplier = 0.75 }); TacticP.AddMult(new Mult { Position = "FW", Skill = "SH", Multiplier = 1.0 }); TacticD.AddBonus(new Bonus { OppTactic = "L", Position = "DF", Skill = "TK", Multiplier = 0.25 }); TacticA.AddBonus(new Bonus { OppTactic = "D", Position = "FW", Skill = "SH", Multiplier = 0.5 }); TacticC.AddBonus(new Bonus { OppTactic = "A", Position = "MF", Skill = "SH", Multiplier = 0.5 }); TacticC.AddBonus(new Bonus { OppTactic = "A", Position = "DF", Skill = "PS", Multiplier = 0.25 }); TacticC.AddBonus(new Bonus { OppTactic = "A", Position = "DF", Skill = "SH", Multiplier = 0.25 }); TacticC.AddBonus(new Bonus { OppTactic = "P", Position = "MF", Skill = "SH", Multiplier = 0.5 }); TacticC.AddBonus(new Bonus { OppTactic = "P", Position = "DF", Skill = "PS", Multiplier = 0.25 }); TacticC.AddBonus(new Bonus { OppTactic = "P", Position = "DF", Skill = "SH", Multiplier = 0.25 }); TacticL.AddBonus(new Bonus { OppTactic = "C", Position = "DF", Skill = "TK", Multiplier = 0.25 }); TacticL.AddBonus(new Bonus { OppTactic = "C", Position = "DF", Skill = "PS", Multiplier = 0.5 }); TacticP.AddBonus(new Bonus { OppTactic = "L", Position = "MF", Skill = "SH", Multiplier = 0.5 }); TacticP.AddBonus(new Bonus { OppTactic = "L", Position = "MF", Skill = "TK", Multiplier = 0.5 }); TacticP.AddBonus(new Bonus { OppTactic = "L", Position = "DW", Skill = "SH", Multiplier = 0.25 }); session.SaveOrUpdate(TacticN); session.SaveOrUpdate(TacticD); session.SaveOrUpdate(TacticA); session.SaveOrUpdate(TacticC); session.SaveOrUpdate(TacticL); session.SaveOrUpdate(TacticP); transaction.Commit(); } } using (var session = sessionFactory.OpenSession()) { // retreive all stores and display them using (session.BeginTransaction()) { var Ligas = session.CreateCriteria(typeof(League)).List <League>(); foreach (var liga in Ligas) { WriteLeagueData(liga); } } } Console.WriteLine("Fin del proceso."); } catch (Exception x) { Console.WriteLine(x.ToString()); } Console.ReadKey(); }