public override void OnEnable() { team = target as Team; teamScroll = Vector2.zero; base.OnEnable(); name = "Team"; }
public void Save(Team team) { if (team.Id == 0) _dataContext.Teams.Add(team); _dataContext.SaveChanges(); }
//show all valid moves for a team public void ShowValidMoves(Team team, List<List<Tile>> board) { foreach (var item in GameObject.FindGameObjectsWithTag("Marker")) { Destroy(item); } //if no moves are available, quit if(!GameObject.Find("Board").GetComponent<BoardManager>().IsMoveAvailable(team, board)) return; MoveLogic logic = GameObject.Find("MoveLogic").GetComponent<MoveLogic>(); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { //setup the hint counter when a valid move is found if (logic.IsValidMove(i, j, team, board)) { //Set tile location float locX = i - (height - 1) / 2.0f; float locY = j - (width - 1) / 2.0f; //Scale up location locX *= 10.0f; locY *= 10.0f; GameObject counter = (GameObject)Instantiate(highlight, new Vector3(locX, 1.5f, locY), highlight.transform.rotation); counter.GetComponent<Player>().setX(i); counter.GetComponent<Player>().setY(j); } } } }
private void addButton_Click(object sender, EventArgs e) { if (teamBox.Text.Equals("")) { toolTip1.ToolTipTitle = "No Team Name!"; toolTip1.Show("You cannot add a team without a name.", teamBox); } else { if (schoolform == null) { if (editorForm.school.Teams.ContainsKey(teamBox.Text)) { ShowDuplicateError(); return; } else { Team team = new Team(editorForm.school, teamBox.Text); editorForm.school.Teams.Add(team.Name, team); editorForm.AddTeamToList(team); } } else { if (schoolform.teams.Contains(teamBox.Text)) { ShowDuplicateError(); return; } else { schoolform.teams.Add(teamBox.Text.Trim()); schoolform.teamListView.Items.Add(teamBox.Text.Trim()); } } Close(); } }
public Class1() { List<Team> GenerateInitialPopulation() { var teams = new List<Team>(); while(teams.Count < GeneticParameters.PopulationSize) { var randomTeam = CreateRandomTeam(PlayerPool); if (IsTeamValid(randomTeam)) { teams.Add(randomTeam); } } return teams; } Team CreateRandomTeam(IList<Player> allPlayers) { var team = new Team(); team.Players.Add(SelectRandomPlayer(allPlayers, Position.Goalkeeper)); team.Players.Add(SelectRandomPlayer(allPlayers, Position.Defender)); team.Players.Add(SelectRandomPlayer(allPlayers, Position.Defender)); //... return team; }
public void GameOver(Team winner = Team.Spectator) { var traits = CurrentStage.GetTraits(); traits.CurrentRound = 0; traits.State = StageState.Standby; traits.Round = RoundState.Prepare; Battle.StageRoundUpdate(traits.Players, traits.StageId, 0, RoundState.Finish); Battle.StageRoundUpdate(traits.Players, traits.StageId, 0, RoundState.Exit); Battle.StageFinish(traits.Players, traits.StageId); traits.DuelQueue = new QueueInfo(); foreach (var client in traits.Players) { client.GetGameStats().Reset(); if (client != traits.Master) client.ClientPlayer.PlayerState = ObjectStageState.NonReady; } Battle.StageRoundUpdate(traits.Players, traits.StageId, 0, RoundState.Prepare); if (_gameType == ObjectStageGameType.DeathMatch && (this as Deathmatch).ItemSpawns != null) (this as Deathmatch).ItemSpawns.Abort(); else if (_gameType == ObjectStageGameType.Berserker && (this as Berserker).ItemSpawns != null) (this as Berserker).ItemSpawns.Abort(); else if (_gameType == ObjectStageGameType.TeamDeathMatchExtreme && (this as TeamDeathmatchExtreme).ItemSpawns != null) (this as TeamDeathmatchExtreme).ItemSpawns.Abort(); }
private static void GiveTurn( Team team ) { currentTeam = team; allUnits.ForEach( u => { if( u.alive ) u.collider.enabled = true; } ); currentTeam.units.ForEach( u => u.OnOurTurnStart() ); God.OnTurnStart(); }
public ActionResult Create(CreateTeamModel model) { var newTeam = new Team() { Name = model.TeamBindingModel.Name, NickName = model.TeamBindingModel.NickName, WebSite = model.TeamBindingModel.Website, DateFounded = model.TeamBindingModel.DateFounded }; this.Data.Teams.Add(newTeam); this.Data.SaveChanges(); Player player = null; foreach (var playerName in model.TeamBindingModel.Players) { player = this.Data.Players.All() .FirstOrDefault(p => p.Name == playerName); newTeam.Players.Add(player); } this.Data.SaveChanges(); return this.RedirectToAction("Index", "Home"); }
public Form1() { InitializeComponent(); t = new Team<Emp>(5); //t = new TeamObj(5); i = 0; }
private void Validate(Team team) { if (team.Players.Count > 11) throw new InvalidEntityException("A team can have a maximum of 11 players."); if (team.Players.Distinct().Count() != 11) throw new InvalidEntityException("Each player can only be selected for one position."); }
public void AddOpponents(Team opposingTeam) { this.Player1.AddOpponents(opposingTeam); this.Player2.AddOpponents(opposingTeam); opposingTeam.Player1.AddOpponents(this); opposingTeam.Player2.AddOpponents(this); }
public static Transform FindNearestTeam(Team team, Vector3 fromPosition, float maxDistance) { Transform target = null; if (_targetables.ContainsKey(team)) { var targetCandidates = _targetables[team]; var smallestDistanceSquared = Mathf.Infinity; if (targetCandidates.Any()) { foreach (var candidate in targetCandidates) { if (candidate != null) { var toTarget = candidate.position - fromPosition; if (toTarget.sqrMagnitude < maxDistance*maxDistance) { if (toTarget.sqrMagnitude < smallestDistanceSquared) { smallestDistanceSquared = toTarget.sqrMagnitude; target = candidate; } } } } } return target; } return null; }
public Match(Team homeTeam, Team awayTeam, Score score, int id) { this.HomeTeam = homeTeam; this.AwayTeam = awayTeam; this.Score = score; this.Id = id; }
/// <summary> /// Gives possesion of the ball to the blue team. /// </summary> public void BlueTeamPossession() { if (isServer) { possessionOfBall = Team.blue; } }
/// <summary> /// Gives possesion of the ball to the red team. /// </summary> public void RedTeamPossession() { if (isServer) { possessionOfBall = Team.red; } }
public TeamDto(Team team) { Id = team.ID; Name = team.Name; UserIDs = team.Users.Select(u => u.ID).ToArray(); Metadata = team.Metadata; }
/** * Generates a label with text, a picturebox and another label. * @parentPanel The panel that should add the created panel to it's controls. * @team The team object containing data that'll be displayed such as the teams name and logo. * @match The match object containing data that should be displayed. **/ private void generateLabel(Panel parentPanel, Team team, Match match) { int _teamScore; if (match._team1 == team) { _teamScore = match._team1Score; } else { _teamScore = match._team2score; } Label labelname = new System.Windows.Forms.Label(); labelname.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel, ((byte)(0))); labelname.Name = team._name; labelname.Size = new System.Drawing.Size(250, 15); labelname.Dock = System.Windows.Forms.DockStyle.Top; labelname.Text = String.Format("{0}", team._name); labelname.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(207)))), ((int)(((byte)(207)))), ((int)(((byte)(207))))); PictureBox pb = new PictureBox(); pb.Size = new System.Drawing.Size(15, 15); pb.Dock = DockStyle.Right; pb.Image = team.getTeamLogo(); Label score = new Label(); score.Text = _teamScore.ToString(); score.Dock = DockStyle.Right; score.Size = new System.Drawing.Size(15, 15); labelname.Controls.Add(score); labelname.Controls.Add(pb); parentPanel.Controls.Add(labelname); }
protected void btnSubmit_Click(object sender, EventArgs e) { Team team = new Team(); //make up participant list from textboxes team.FromTextboxes(pnlTxtBx.Controls.OfType<TextBox>().ToList()); // if no participant if (team.Participants.Count == 0) { lblResult.Text = "Enter atleast one TTID"; lblResult.ForeColor = Color.Red; return; } // check if participants are registered in TT //if (!team.Participants.All(i => Participant.CheckParticipantTTID(i.TTID))) //{ // lblResult.Text = "Invalid TTIDs"; // lblResult.ForeColor = Color.Red; // return; //} // register team in this event int teamID = Event.CreateNewTeam(ev, team); bool teamAdded; // error registering in event if (teamID == -1) { lblResult.Text = "Error! Please try again"; lblResult.ForeColor = Color.Red; return; } team.ID = teamID; if (!ev.IsSinglePlayer) //if multiplayer { teamAdded = Team.AddNewTeam(team); // save team data if (teamAdded) { // success lblResult.Text = "Team Created. Team ID is: " + teamID.ToString(); lblResult.ForeColor = Color.Green; } else { //failure lblResult.Text = "Team NOT Added"; lblResult.ForeColor = Color.Red; } } else// if singleplayer { //success lblResult.Text = "Participant Registered"; lblResult.ForeColor = Color.Green; } //clear textboxes pnlTxtBx.Controls.OfType<TextBox>().ToList().ForEach(i => i.Text = ""); }
public static IList<Player> CreateFuturePlayersForTeam(Team team) { return team.Players.Select(player => new Player { Id = player.Id, Position = player.Position, Name = player.Name, PastFixtures = new List<PastFixture>() }).ToList(); }
public bool CanEnterOnTeam(Team t) { if (t.Equals(Team.Blue)) return BlueTeam.Count < 5; if (t.Equals(Team.Red)) return RedTeam.Count < 5; if (t.Equals(Team.Yellow)) return YellowTeam.Count < 5; return t.Equals(Team.Green) && GreenTeam.Count < 5; }
public GameAction(Status gameStatus, Team actionTeam, Point actionPoint) { ActionTeam = actionTeam; ActionPoint = actionPoint; GameStatus = gameStatus; ThrowRoom = new Rectangle(0, 0, 0, 0); }
public bool IsOnMyTeam(Team team) { if (team == null) { return false; } return team.teamNumber == this.teamNumber; }
public ComputerControlledTank( ISoundManager soundManager, World world, Collection<IDoodad> doodads, Team team, Vector2 position, float rotation, Random random, DoodadFactory doodadFactory, IEnumerable<Waypoint> waypoints) : base(soundManager, world, doodads, team, position, rotation, doodadFactory) { this.world = world; this.random = random; this.states = new Dictionary<Type, ITankState>(); this.states.Add(typeof(MovingState), new MovingState(world, this.Body, this, waypoints, random)); this.states.Add(typeof(AttackingState), new AttackingState(world, this.Body, this)); this.states.Add(typeof(TurningState), new TurningState(this.Body, this)); this.currentState = this.states[typeof(MovingState)]; this.currentState.StateChanged += this.OnStateChanged; this.currentState.NavigateTo(); this.sensor = BodyFactory.CreateBody(world, this.Position); var shape = new CircleShape(6, 0); Fixture sensorFixture = this.sensor.CreateFixture(shape); sensorFixture.Friction = 1f; sensorFixture.IsSensor = true; sensorFixture.CollisionCategories = PhysicsConstants.SensorCategory; sensorFixture.CollidesWith = PhysicsConstants.PlayerCategory | PhysicsConstants.ObstacleCategory | PhysicsConstants.MissileCategory; }
private void RegditDetailScript() { if (!ClientScript.IsClientScriptBlockRegistered(this.GetType(), "RegditDetailScript")) { RM rm = new RM(ResourceFile.Msg); Team team = new Team(); DialogWindow dw = team.DetailDialogWindow; //主键由 tem_id 改变成 team_guid //dw.AddUrlClientObjectParameter("KeyValue", "f_getSelectedNodeID(TVOrg)"); dw.AddUrlClientObjectParameter("KeyValue", "getTeamGuid(TVOrg)"); dw.AddUrlClientObjectParameter("Mode", "mode"); dw.AddUrlClientObjectParameter("TeamId", "f_getSelectedNodeID(TVOrg)");//team_id dw.AddUrlClientObjectParameter("TeamName", "f_getSelectedNodeText(TVOrg)"); dw.AddUrlClientObjectParameter("TeamTypeId", "getTeamTypeId(TVOrg)"); StringBuilder s = new StringBuilder(); s.Append("function ShowDetail(mode,type)"); s.Append("{"); s.AppendFormat("if(mode != 'ADD' && !CheckSelected()) {{alert('{0}');return;}}", rm["PleaseSelectNode"]); s.Append("var returnValue = '';" + dw.GetShowModalDialogScript("returnValue")); s.Append("if(returnValue=='REFRESH'){refreshParentNode(mode,type);}"); s.Append("}\n"); this.ClientScript.RegisterClientScriptBlock(this.GetType(), "RegditDetailScript", s.ToString(), true); } }
public bool Create(TeamModel model) { if (model == null) throw new ArgumentException("team"); if (model.Name == null) throw new ArgumentException("name"); using (var database = new BonoboGitServerContext()) { var team = new Team { Name = model.Name, Description = model.Description }; database.Teams.Add(team); if (model.Members != null) { AddMembers(model.Members, team, database); } try { database.SaveChanges(); } catch (UpdateException) { return false; } } return true; }
public Match(Team home, Team away,int id,int homeTeamGoals, int awayTeamGoals) { this.homeTeam = home; this.awayTeam = away; this.score = new Score(homeTeamGoals,awayTeamGoals); this.id = id; }
private double CalculateTeamLinkAverage( Dictionary<Guid, Dictionary<Guid, Link>> links, Team team ) { var linkValues = new List<double>(); foreach ( User player in team.Members ) { foreach ( User otherPlayer in team.Members ) { if ( player.Id == otherPlayer.Id ) { continue; } if ( !links[player.Id].Keys.Contains( otherPlayer.Id ) ) { linkValues.Add( .5 ); continue; } linkValues.Add( links[player.Id][otherPlayer.Id].GetWinLoss() ); } } if ( linkValues.Count == 0 ) { return .5; } return Enumerable.Average( linkValues ); }
public AddHPCounter(float x, float y, Team team) : base(x, y) { _team = team; if (_team == Team.Blu) ((Text)Graphic).String = Teams.playerBlue._bonusHP.ToString(); else ((Text)Graphic).String = Teams.playerRed._bonusHP.ToString(); }
public IHttpActionResult PutTeam(int id, Team team) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != team.Id) { return BadRequest(); } db.Entry(team).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TeamExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
private static TransferValidity CheckTransferValidity(Transfer transfer, Team currentTeam) { if (transfer.PlayerIn == null || transfer.PlayerOut == null) { return TransferValidity.PlayerIsNull; } if (currentTeam.Players.Any(p => p.Id == transfer.PlayerIn.Id)) { return TransferValidity.PlayerTransferredInAlreadyInTeam; } //player transferred out must have been in original team if (currentTeam.Players.All(p => p.Id != transfer.PlayerOut.Id)) { return TransferValidity.PlayerTransferredOutNotOriginallyInTeam; } if (transfer.PlayerIn.Position != transfer.PlayerOut.Position) { return TransferValidity.TransferedPlayersNotInSamePosition; } return TransferValidity.Valid; }
// return the person who is the youngest of all people whose Lastname starts with startString public Person GetYoungestStartsWith(Team team, string startString) { return(team.People[0]); //return team.People[0]; }
// return the age of the person who is the youngest of all people whose Lastname starts with startString public int GetYoungestAgeStartsWith(Team team, string startString) { return(0); //return team.People[0]; }
// return the number of people who are older than age public int CountAllGreaterThanAge(Team team, int age) { return(0); }
// return all people whose birthdays are in month public IEnumerable <Person> GetPeopleBirthdayMonth(Team team, int month) { return(team.People); }
// return Last person whose Lastname contains pattern // return null if none exists public Person FindLastnamePatternLast(Team team, string pattern) { return(team.People[0]); }
// return the first Person whose Lastname has num letters // return null if none exists public Person FindLastnameLength(Team team, int num) { return(team.People[0]); }
// return all people in a team who are older than age, sorted by Age descending public IEnumerable <Person> FindAllGreaterThanAge(Team team, int age) { return(team.People.Where(people => people.GetAge() > age).OrderBy(people => people)); }
public List <Move> GetCalculatedNextMoves(CellState[,] board, Team team, List <List <Move> > beats, List <List <Move> > moves, CancellationToken token) { var firstPredictions = new List <PredictionNode>(); try { var predictions = new List <PredictionNode>(); foreach (var beat in beats) { if (beat.Count > 0) { var updatedBoard = board.UpdateFromMoves(beat); if (updatedBoard.CountEnemies(team) == 0) { return(beat); } var ranking = _getMoveWeight.CalculateMoveWeight(beat, board, updatedBoard, team, true); var node = new PredictionNode { InitialMoves = beat, NextTeam = team.GetNextTeam(), NextBoard = updatedBoard, Depth = 0, AccumulatedWeight = ranking.weight, StatsForPlayer = ranking.stats }; firstPredictions.Add(node); predictions.AddRange(_predictionBuilder.GetDepthwisePrediction(node, team, 3, token)); } } foreach (var move in moves) { if (token.IsCancellationRequested) { throw new TaskCanceledException(); } var updatedBoard = board.UpdateFromMoves(move); var ranking = _getMoveWeight.CalculateMoveWeight(move, board, updatedBoard, team); var node = new PredictionNode { InitialMoves = move, NextTeam = team.GetNextTeam(), NextBoard = updatedBoard, Depth = 0, AccumulatedWeight = ranking.weight, StatsForPlayer = ranking.stats }; firstPredictions.Add(node); predictions.AddRange(_predictionBuilder.GetDepthwisePrediction(node, team, 3, token)); } return(GetBestForRandom(predictions)); } catch (TaskCanceledException) { Console.WriteLine("Task cancelled"); } return(GetBestForRandom(firstPredictions)); }
public Warrior(string id, int x, int y, int healthPoints, int defensePoints, int attackPoints, Team team, int range) : base(id, x, y, healthPoints, defensePoints, team, range) { this.AttackPoints = attackPoints; }
public IEnumerable <Team> GetTeams() { return(new List <Team> { Team.TeamA(), Team.TeamB() }); }
internal TeamChatEvent(string message, Player source, Team destination) : base(message) { Source = source; Destination = destination; }
public static string GetTeamData(Team team) { return($"Team: {team.Name}\n"); }
async private void Clicked_ConfirmTeamCreation(object sender, EventArgs e) { if (_isBusy) { return; } foreach (Entry x in allboxes) { if (x.Text == null || x.Text.Equals("")) { x.BackgroundColor = Color.Red; entry_error = true; } } if (entry_error) { await DisplayAlert("Input Error", "Please provide all required information", "ok"); entry_error = false; return; } if (!passwordEntry.Text.Equals(re_PasswordEntry.Text)) { re_PasswordEntry.BackgroundColor = Color.Red; errors += "-password and password re-entry are not the same.\n"; entry_error = true; } if (entry_error) { await DisplayAlert("Input Error", errors, "ok"); entry_error = false; return; } _isBusy = true; // HERE WE NEED CODE FROM DATABASE FOR TEAM ID SO WE CAN PASS IT TO THE NEXT PAGE api_result = await Api_Connector.Connect(String.Format(URL, TeamNameEntry.Text, passwordEntry.Text.Trim())); Create_Team_result created = Newtonsoft.Json.JsonConvert.DeserializeObject <Create_Team_result>(api_result); var NewlyCreatedTeam = new Team(created.ID, TeamNameEntry.Text, "Admin", true, false, false, false, false); if (created.result == 1) { await Navigation.PushAsync(new TeamIdPage6(NewlyCreatedTeam, passwordEntry.Text)); } _isBusy = false; //Team NewCreatedTeam = new Team() //{ // Team_Id = "123", //TEAM ID FROM DATABASE // Team_Name = TeamNameEntry.Text, // Admin = 1 // // HOW WILL PASSWORD BE SAVED IN DATABASE? PUT IT HERE SOMEHOW? //}; //TeamsDashboardPage3.test1.Add(NewlyCreatedTeam); Navigation.RemovePage(this); }
public ActionResult SampleDataConfirmed([Bind(Include = "TournamentId,TeamCount,MaxParticipantsInTeam")] SampleDataViewModel _sampleDataViewModel) { if (ModelState.IsValid) { Tournament _tournament = tournamentService.GetById(_sampleDataViewModel.TournamentId); var country = generalUnitService.GetByType(GeneralUnitType.Country).FirstOrDefault(); var ranking = sportUnitService.GetByTypeForGroup(_tournament.GroupId, SportUnitType.Ranking).FirstOrDefault(); Gender participantGender; string FirstName; Random rnd = new Random(); if (country != null && ranking != null) { for (int i = 0; i < _sampleDataViewModel.TeamCount; i++) { List <Participant> participants = new List <Participant>(); int participantCount = rnd.Next(4, _sampleDataViewModel.MaxParticipantsInTeam); for (int j = 0; j < participantCount; j++) { if (j % 4 == 0) { participantGender = Gender.Female; FirstName = "Alla"; } else { participantGender = Gender.Male; FirstName = "Max"; } var participant = new Participant() { FirstName = string.Format("{0}_{1}_{2}", FirstName, i, j), LastName = "Muster", Gender = participantGender, BirthDate = new DateTime(rnd.Next(1992, 2005), rnd.Next(1, 12), rnd.Next(1, 28)), Weight = rnd.Next(20, 50), RankingId = ranking.Id }; participants.Add(participant); } var team = new Team() { Name = "Team_" + i.ToString(), Coach = User.Identity.Name, City = "Berlin", CountryId = country.Id, TournamentId = _sampleDataViewModel.TournamentId, CoachRankingId = ranking.Id, Participants = participants }; teamService.Create(team); } } return(RedirectToAction("Details", new { id = _tournament.Id })); } return(View(_sampleDataViewModel)); }
// return if team choice succeeded and if not, return reason public void TeamChosen(Team team, Action <bool, string> succeeded) { bool choiceSucceeded = false; string errorMessage = "team not found"; // hier checkt ie het team dat de tablet binnen heeft gekregen, // maar de spelsituatie is mogelijk al veranderd, moeten de global // version checken op de server foreach (Team temp in data.teams.teams) { if (temp.teamName == team.teamName) { if (temp.chosen) { choiceSucceeded = false; errorMessage = "this team is already claimed"; break; } else { currentTeam = team; isLoggedIn = true; choiceSucceeded = true; //errorMessage = "team not found"; temp.chosen = true; errorMessage = "success"; teamJoined.Raise(); break; //foreach (Team temp in data.teams.teams) //{ // if (temp.teamName == team.teamName) // { // temp.chosen = true; // errorMessage = "success"; // teamJoined.Raise(); // } //} } } } //if (team.chosen) //{ // choiceSucceeded = false; // errorMessage = "this team is already claimed"; //} //else //{ // currentTeam = team; // isLoggedIn = true; // errorMessage = "team not found"; // foreach (Team temp in data.teams.teams) // { // if (temp.teamName == team.teamName) // { // temp.chosen = true; // errorMessage = "success"; // teamJoined.Raise(); // } // } //} succeeded(choiceSucceeded, errorMessage); }
public static TeamDto Create(Team source) => AutoMapper.Mapper.Map <TeamDto>(source);
public void UpdateTeam(Team team) { _context.Teams.Update(team); _context.SaveChanges(); }
public PointsPerTeamAndGame(Game game, Team selectedTeam) { this.game = game; this.selectedTeam = selectedTeam; }
private static string CreateMessage(Team team) { return($"Het team '{team.Naam}' ({team.Id}) is onbekend in het datamodel."); }
public async Task <IActionResult> SaveTeam(Team team) { var user = await _userService.getUserFromCp(HttpContext.User); var teams = await _teamService.FindAllTeamsWhereTheUserHasRights(HttpContext.User, user); if (team.Id != 0) { if (!teams.Where(x => x.TeamRole == "Admin" || x.TeamRole == "Mod").Select(x => x.Id).Contains(team.Id)) { return(Forbid()); } } if (!ModelState.IsValid) { return(View("Team", team)); } if (team.Id == 0) { var tmp = await _teamService.FindOne(team.Name); if (tmp == null) { var own = await _steamIdentityService.FindOne(user.Id); if (own == null) { ModelState.AddModelError("Name", "You need a steamIdentity to create a team!"); return(await EditTeam(team)); } await _teamService.Upsert(team); await _teamSelectedSteamIdentityService.Insert(new TeamSelectedSteamIdentity { SteamIdentity = own, RoleOverwrite = "Admin", Team = team }); } else { ModelState.AddModelError("Name", "This name is already used!"); } } else { await _teamService.Upsert(team); } if (ModelState.ErrorCount > 0) { return(await EditTeam(team)); } return(await Index()); }
public static void Initialize(MatchContext context) { //context.Database.EnsureDeleted(); context.Database.EnsureCreated(); if (!context.Matches.Any()) { var d = new DataPoint() { X = 1, Y = 1, Z = 2, Time = DateTime.Now }; var d2 = new DataPoint() { X = 3, Y = 9, Z = 2, Time = DateTime.Now }; var d3 = new DataPoint() { X = 1, Y = 6, Z = 2, Time = DateTime.Now }; var d4 = new DataPoint() { X = 8, Y = 0, Z = -3, Time = DateTime.Now }; var player = new Player() { Name = "Bob", Active = true, Matches = new List <Match>() }; var player2 = new Player() { Name = "Bob2", Matches = new List <Match>() }; var team = new Team() { Name = "Red Kangaroos", Players = new List <Player>() }; var team2 = new Team() { Name = "Blue Pandas", Players = new List <Player>() }; team.Players.Add(player); team2.Players.Add(player2); var match1 = new Match() { Start = DateTime.Now, Active = true, Players = new List <Player>(), Teams = new List <Team>(), Data = new List <Data>() }; var match2 = new Match() { Start = DateTime.Now, Players = new List <Player>(), Teams = new List <Team>(), Data = new List <Data>() }; var data = new Data() { Accel = new List <DataPoint>(), Linear = new List <DataPoint>(), Orient = new List <DataPoint>(), Match = match1, Player = player, Hits = 4 }; data.Accel.Add(d4); data.Accel.Add(d); data.Linear.Add(d); data.Linear.Add(d4); data.Orient.Add(d4); data.Orient.Add(d); match1.Data.Add(data); //match2.Data.Add(data); var data2 = new Data() { Accel = new List <DataPoint>(), Linear = new List <DataPoint>(), Orient = new List <DataPoint>(), Match = match1, Player = player2, Hits = 4 }; data2.Accel.Add(d2); data2.Accel.Add(d3); data2.Linear.Add(d3); data2.Linear.Add(d2); data2.Orient.Add(d2); data2.Orient.Add(d3); match1.Data.Add(data2); //match2.Data.Add(data2); match1.Teams.Add(team); match1.Teams.Add(team2); match1.Players.Add(player); match1.Players.Add(player2); context.Matches.Add(match1); match2.Teams.Add(team); match2.Teams.Add(team2); match2.Players.Add(player); match2.Players.Add(player2); context.Matches.Add(match2); /* * var match2 = new Match() * { * Start = DateTime.Now, * Players = new List<Player>() * };*/ //team.Players.Add(player); //match1.Players.Add(player); //match1.Teams[0] = team; /* * player.Team = team; * player.Matches.Add(match1); * context.Players.Add(player); */ context.SaveChanges(); } }
public void AddTeam(Team team) { _context.Add(team); _context.SaveChanges(); }
static void Main() { string key = Console.ReadLine(); string input = Console.ReadLine(); string escapedKey = Regex.Escape(key); string pattern = string.Format(@"(?<={0})(?<teamA>[A-Za-z]*)(?={0})(.*)(?<={0})(?<teamB>[A-Za-z]*)(?={0})([^ ]+) (?<scoreA>\d+):(?<scoreB>\d+)", escapedKey); Regex game = new Regex(pattern); var teams = new Dictionary <string, Team>(); while (input != "final") { Match match = game.Match(input); string teamA = Reverse(match.Groups["teamA"].Value).ToUpper(); string teamB = Reverse(match.Groups["teamB"].Value).ToUpper(); int scoreA = int.Parse(match.Groups["scoreA"].Value); int scoreB = int.Parse(match.Groups["scoreB"].Value); #if DEBUG Console.WriteLine($"{teamA} - {teamB} {scoreA}:{scoreB}"); #endif if (!teams.ContainsKey(teamA)) { teams.Add(teamA, new Team(0, 0)); } if (!teams.ContainsKey(teamB)) { teams.Add(teamB, new Team(0, 0)); } teams[teamA].Goals += scoreA; teams[teamB].Goals += scoreB; if (scoreA > scoreB) { teams[teamA].Points += 3; } else if (scoreA < scoreB) { teams[teamB].Points += 3; } else if (scoreA == scoreB) { teams[teamA].Points += 1; teams[teamB].Points += 1; } input = Console.ReadLine(); } var standings = teams .OrderByDescending(t => t.Value.Points) .ThenBy(t => t.Key); var topScorring = teams .OrderByDescending(t => t.Value.Goals) .ThenBy(t => t.Key) .Take(3); int position = 1; Console.WriteLine("League standings:"); foreach (var team in standings) { string teamName = team.Key; Team stats = team.Value; Console.WriteLine($"{position}. {teamName} {stats.Points}"); position++; } Console.WriteLine("Top 3 scored goals:"); foreach (var team in topScorring) { string teamName = team.Key; Team stats = team.Value; Console.WriteLine($"- {teamName} -> {stats.Goals}"); } }
public TeamOnbekendException(Team team) : base(CreateMessage(team)) { }
public TheGetAllRepositoriesMethod() { var github = Helper.GetAuthenticatedClient(); _team = github.Organization.Team.GetAll(Helper.Organization).Result.First(); }
/// <summary> /// Add a team /// </summary> /// <param name="team"></param> public void Add(Team team) { _dbContext.Teams.Add(team); }
public ActionResult Create(Team newTeam) { db.Teams.Add(newTeam); db.SaveChanges(); return(RedirectToAction("Index")); }
public TheGetMembershipMethod() { var github = Helper.GetAuthenticatedClient(); team = github.Organization.Team.GetAll(Helper.Organization).Result.First(); }
public IActionResult Edit(Team team) { db.Entry(team).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public Healer(string id, int x, int y, Team team) : base(id, x, y, healthDefaultPoints, defenseDefaultPoints, team, defaultRange) { this.HealingPoints = healingPoints; }