public CornerState(Lineup _attTeam, Lineup _defTeam) { attTeam = _attTeam; defTeam = _defTeam; type = State.CORNER; attacker = attTeam.All().ByMax(x => x.SP); }
private static IEnumerable <Lineup> GenerateLineupsForContest(ContestViewModel contest, IEnumerable <PlayerViewModel> includePlayers) { var positions = contest.Contest.Positions; if (includePlayers != null && positions != null) { var combinations = new List <Combinations <PlayerViewModel> >(); foreach (var position in positions) { var playersNeededForPosition = 1; var possiblePlayersForPosition = includePlayers.Where(p => position.EligiblePlayerPositions.Contains(p.Player.Position)).ToList(); combinations.Add(new Combinations <PlayerViewModel>(possiblePlayersForPosition, playersNeededForPosition)); } var totalLineups = combinations.Select(c => c.Count).Aggregate((c1, c2) => c1 * c2); for (long i = 0; i < totalLineups; i++) { var index = i; var lineup = new Lineup(); foreach (var combination in combinations) { var positionPlayers = combination.ElementAt((int)(index % combination.Count)); foreach (var positionPlayer in positionPlayers) { lineup.Players.Add(positionPlayer); } index = index / combination.Count; } if (lineup.Players.Count == positions.Count()) { yield return(lineup); } } } }
public LineupCreate(Lineup lineup) { Name = lineup.Name; Email = lineup.Email; CustomUserIdentifier = lineup.CustomUserIdentifier; CustomFields = lineup.CustomFields; }
protected override void OnStart(string[] args) { #if DEBUG // Debug builds wait for a debugger to attach. while (!Debugger.IsAttached) { Thread.Sleep(100); } #endif try { // Initialize the application. config = new Config(EventLog); lineup = new Lineup(); updater = new Updater(config, lineup); server = new Server(config, lineup, updater); // Begin a lineup/EPG update from the provider. var discard = updater.Update(); // Start the HTTP server. server.Start(); } catch (Exception e) { EventLog.WriteEntry(string.Format("Failed to start: {0}", e.Message), EventLogEntryType.Error); Stop(); } }
public ThrowInState(Lineup _attTeam, Lineup _defTeam, char _side) { attTeam = _attTeam; defTeam = _defTeam; type = State.THROW_IN; if (_side == 'l') { left = true; if (attTeam.IsTherePosition(Position.LB)) { attacker = attTeam.Any(Position.LB); } else { attacker = attTeam.Any(Position.LM); } } else { left = false; if (attTeam.IsTherePosition(Position.RB)) { attacker = attTeam.Any(Position.RB); } else { attacker = attTeam.Any(Position.RM); } } }
private void SourceLineupCombo_SelectedIndexChanged(object sender, EventArgs e) { selected_avail_lineup_ = (Lineup)SourceLineupCombo.SelectedItem; avail_channels_ = selected_avail_lineup_.GetChannels().ToList(); AvailLineupGridView.RowCount = avail_channels_.Count(); AvailLineupGridView.Invalidate(); }
public Lineup AssignLineup(TeamGame teamGame, List <Player> players) { const int playersInAFullLineup = 5; if (players.Count > playersInAFullLineup) { throw new ArgumentException("players"); } DateTime now = Settings.CurrentTime; TimeSpan gameTime = GetGameTime(teamGame.Game).TotalEllapsedTime; Lineup lineup = new Lineup() { Game = teamGame.Game, Players = players, Team = teamGame.Team, StartDateTime = now, StartGameTime = gameTime, EndDateTime = now, EndGameTime = gameTime, }; Lineup oldLineup = teamGame.Lineups.LastOrDefault(); if (oldLineup != null) { oldLineup.EndDateTime = now; oldLineup.EndGameTime = gameTime; } teamGame.Lineups.Add(lineup); return(lineup); }
public void Populate(Lineup lineup) { var team = _teamReader.GetTeam().ToList(); //Get the first var lowestFirst = team.Select(x => x.FirstCount).Min(); var firsts = team.Where(x => x.FirstCount == lowestFirst).ToList(); var first = _randomMemberSelector.GetFrom(firsts); lineup.Add(first.Name); team.Remove(first); //Get the last var lowestLast = team.Select(x => x.LastCount).Min(); var lasts = team.Where(x => x.LastCount == lowestLast).ToList(); var last = _randomMemberSelector.GetFrom(lasts); team.Remove(last); while (team.Any()) { lineup.Add(_randomMemberSelector.GetFrom(team).Name); } lineup.Add(last.Name); }
public AttackCentreState(Lineup _attTeam, Lineup _defTeam, string _counter = "") { attTeam = _attTeam; defTeam = _defTeam; if (_counter == "counter") { counter = true; type = State.COUNTER_ATTACK_CENTRE; attacker = attTeam.Any(Position.CM, Position.AM, Position.CF); } else { counter = false; type = State.ATTACK_CENTRE; if (attTeam.All(Position.CF).Count == 3) { attacker = attTeam.Any(Position.DM, Position.CM, Position.AM, Position.CF); } else { attacker = attTeam.Any(Position.DM, Position.CM, Position.AM); } } defender = defTeam.Any(Position.DM, Position.CB); }
/// <summary> /// Method to create a new training activity in the game table and return the new lineup ID /// </summary> /// <param name="dt">Datetime for the activity</param> /// <param name="oppID">opponent</param> /// <param name="pitchID">pitch</param> /// <param name="gameTypeID">activity type</param> /// <param name="positionID">player position</param> /// <param name="playerID">player ID</param> /// <returns>int, lineup ID of the new activity</returns> private int GetTrainingLineupID(DateTime dt, int oppID, int pitchID, int gameTypeID, int positionID, int playerID) { int lineupID = 0; using (DataClassesDataContext dbContext = new DataClassesDataContext()) { //training, so no previous game would be set, need to make new game object Game game = new Game { //temp date, real training date is pulled from GPX file GameDate = dt, OpponentID = oppID, PitchID = pitchID, GameTypeID = gameTypeID }; dbContext.Games.InsertOnSubmit(game); dbContext.SubmitChanges(); //create new lineup object Lineup lineup = new Lineup { PositionID = positionID, PlayerID = playerID, GameID = game.GameID //gameID direct from new game record }; //write object to database dbContext.Lineups.InsertOnSubmit(lineup); dbContext.SubmitChanges(); //set lineupID to equal that of newly created lineup object lineupID = lineup.LineupID; } return(lineupID); }
/// <summary> /// Event handler to create a new lineup record in the Lineups db table. /// </summary> private void addPlayerToLineupBtn_Click(object sender, EventArgs e) { if (lineupSearchResultsLstBox.SelectedIndex != -1) { int gameID = Convert.ToInt16(lineupSearchResultsLstBox.GetItemText(lineupSearchResultsLstBox.SelectedValue)); int playerID = Convert.ToInt16(lineupPlayerCombo.GetItemText(lineupPlayerCombo.SelectedValue)); int positionID = Convert.ToInt16(lineupPositionCombo.GetItemText(lineupPositionCombo.SelectedValue)); using (DataClassesDataContext dbContext = new DataClassesDataContext()) { Lineup lineup = new Lineup { GameID = gameID, PlayerID = playerID, PositionID = positionID }; dbContext.Lineups.InsertOnSubmit(lineup); dbContext.SubmitChanges(); } PopulateLineupPlayersLstBox(gameID); } else { MessageBox.Show("Please enter all details"); } }
public GKStartState(Lineup _attTeam, Lineup _defTeam) { attTeam = _attTeam; defTeam = _defTeam; type = State.GK_START; goalkeeper = attTeam.Any(Position.GK); }
public TeamLineup AddTeamLineup([FromBody] TeamLineupJson data) { var lineup = GetLineup(data.id); var teamLineup = new TeamLineup(data.teamId, data.players, DateTime.UtcNow); if (lineup?.TeamLineups == null) { lineup = new Lineup(data.id, FplDataProvider.Season); lineup.TeamLineups.Add(teamLineup); _mongoLineupProvider.AddLineup(lineup); } else { if (lineup.TeamLineups.Count(x => x.TeamId == data.teamId) > 0) { lineup.TeamLineups.FirstOrDefault(x => x.TeamId == data.teamId).Players = data.players; lineup.TeamLineups.FirstOrDefault(x => x.TeamId == data.teamId).DateSet = teamLineup.DateSet; } else { lineup.TeamLineups.Add(teamLineup); } _mongoLineupProvider.UpdateLineup(data.id, lineup); } return(teamLineup); }
public TrainerModel GetTrainerFromDB(string name) { var trainer = new TrainerModel() { Handle = name }; var con = new DBConnect().MyConnection; con.Open(); var querystring = $"SELECT * FROM sql3346222.userCredentials WHERE(TrainerName = '{name}');"; MySqlCommand cmd = new MySqlCommand(querystring, con); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { trainer.Id = int.Parse(rdr[0].ToString()); trainer.HighScore = int.Parse(rdr[5].ToString()); trainer.Lineups = Lineup.DeserializeLineupList(rdr[4].ToString()); trainer.Team = Lineup.DeserializeLineup(rdr[6].ToString()); } rdr.Close(); con.Close(); return(trainer); }
public MatchInfo(MatchInfo matchInfo) { playerID = matchInfo.playerID; playerName = matchInfo.playerName; rank = matchInfo.rank; lineup = matchInfo.lineup; }
public MatchInfo(UserInfo player, Lineup PlayerLineup) { playerID = player.playerID; playerName = player.username; rank = player.rank; lineup = PlayerLineup; }
//Get all players in a lineup. //Also returns if the lineup contains a reserve. private (List <Player> players, bool reserveOnLineup) GetPlayersInLineup(Lineup lineup) { var players = new List <Player>(); bool reserveOnLineup = false; foreach (var group in lineup) { foreach (var position in group.Positions) { if (position.Player != null) { players.Add(position.Player); if (position.IsExtra) { reserveOnLineup = true; } } if (Lineup.PositionType.Double.HasFlag(group.Type) && position.OtherPlayer != null) { players.Add(position.OtherPlayer); if (position.OtherIsExtra) { reserveOnLineup = true; } } } } return(players, reserveOnLineup); }
private static MergedLineup GetMergedLineupFromScannedLineup(Lineup scanned_lineup) { MergedLineup merged_lineup = scanned_lineup.PrimaryProvider; if (null == merged_lineup) { merged_lineup = scanned_lineup.SecondaryProvider; if (null == merged_lineup) { merged_lineup = new MergedLineups(object_store).First; if (merged_lineup.GetChannels().Length == 0) { foreach (MergedLineup ml in new MergedLineups(object_store)) { if (ml.GetChannels().Length > 0) { merged_lineup = ml; break; } } } } } return(merged_lineup); }
public GoalKickState(Lineup _attTeam, Lineup _defTeam) { attTeam = _attTeam; defTeam = _defTeam; type = State.GOAL_KICK; goalkeeper = attTeam.Any(Position.GK); }
public static Channel AddUserChannelToLineupWithoutMerge( Lineup lineup, string callsign, int channel_number, int subchannel, ModulationType modulation_type, Service service) { return(AddUserChannelToLineupWithoutMerge(lineup, callsign, channel_number, subchannel, modulation_type, service, null)); }
private static Channel AddUserChannelToLineupWithoutMerge( Lineup lineup, string callsign, int channel_number, int subchannel, List <TuningInfo> tuning_infos, Service service, ChannelType channel_type = ChannelType.UserAdded) { Channel ch = new Channel(); ch.CallSign = callsign; ch.ChannelType = channel_type; ch.Number = channel_number; ch.OriginalNumber = channel_number; ch.SubNumber = subchannel; ch.OriginalSubNumber = subchannel; ch.Visibility = ChannelVisibility.Available; lineup.AddChannel(ch); foreach (ChannelTuningInfo channel_tuning_info in tuning_infos) { object_store.Add(channel_tuning_info); // doesn't seem to be needed, but Reflector shows GuideTool does it... ch.TuningInfos.Add(channel_tuning_info); } if (service == null) { service = new Service(callsign, callsign); service.ServiceType = ServiceType.Unknown; object_store.Add(service); } ch.Service = service; ch.Update(); return(ch); }
public FreeKickState(Lineup _attTeam, Lineup _defTeam) { attTeam = _attTeam; defTeam = _defTeam; type = State.FREE_KICK; attacker = attTeam.All().ByMax(x => x.SP); }
public BoxDribblingState(Lineup _attTeam, Lineup _defTeam, Player _attacker) { type = State.BOX_DRIBBLING; attacker = _attacker; attTeam = _attTeam; defTeam = _defTeam; }
public void ResetLineup(bool returnCards = false) { if (returnCards) { // return cards foreach (KeyValuePair <Location, Collection> pair in lineup.cardLocations) { collectionManager.AddCollection(pair.Value); } foreach (Tactic tactic in new List <Tactic>(lineup.tactics)) { RemoveTactic(tactic); collectionManager.AddCollection(new Collection(tactic)); } collectionManager.ShowCurrentPage(); } lineup = new Lineup(); inputField.text = "Custom Lineup"; current_tactics = totalOreCost = totalGoldCost = 0; tacticAttributes.Clear(); foreach (GameObject obj in tacticObjs) { obj.SetActive(false); } SetTexts(); //boardInfo.Reset(); }
// Use this for initialization void Awake() { lineup = Login.user.lineups[Login.user.lastLineupSelected]; board = Instantiate(Resources.Load <GameObject>("Board/" + lineup.boardName + "/Board")); board.transform.SetSiblingIndex(1); boardSetup = board.GetComponent <BoardSetup>(); boardSetup.Setup(lineup, Login.playerID); // Set up Player Lineup boardSetup.Setup(gameInfo.lineups[gameInfo.TheOtherPlayer()], gameInfo.TheOtherPlayer()); // Set up Enemy Lineup GameEvent.SetBoard(boardSetup.boardAttributes); modeName.text = gameInfo.mode; // Set up Player Info playerName.text = Login.user.username; playerRank.text = "Rank: " + Login.user.rank.ToString(); // Set up Opponent Info opponentName.text = gameInfo.matchInfo[gameInfo.TheOtherPlayer()].playerName; opponentRank.text = "Rank: " + gameInfo.matchInfo[gameInfo.TheOtherPlayer()].rank.ToString(); foreach (var item in gameInfo.triggers) { item.Value.StartOfGame(); } SetOreText(); SetCoinText(); // SetupTactics tacticObjs = new List <Transform>(); tacticButtons = new List <Button>(); tacticTriggers = new List <TacticTrigger>(); for (int i = 0; i < Lineup.tacticLimit; i++) { Transform tacticSlot = tacticBag.Find(String.Format("TacticSlot{0}", i)); tacticButtons.Add(tacticSlot.GetComponent <Button>()); tacticObjs.Add(tacticSlot.Find("Tactic")); tacticObjs[i].GetComponent <TacticInfo>().SetAttributes(Database.FindTacticAttributes(lineup.tactics[i].tacticName)); tacticTriggers.Add(tacticObjs[i].GetComponent <TacticInfo>().trigger); } historySlots = new List <GameObject>(); for (int i = 0; i < history_limit; i++) { historySlots.Add(history.Find("Slot" + i.ToString()).gameObject); } //foreach(var item in gameInfo.triggers) //{ // if (item.Value.passive == "Tactic") // { // foreach (Tactic tactic in lineup.tactics) // if (item.Value.PassiveCriteria(tactic)) // item.Value.Passive(tactic); // } // else if(item.Value.passive == "Piece") // { // foreach (var pair in gameInfo.board) // if (item.Value.PassiveCriteria(pair.Value)) // item.Value.Passive(pair.Value); // } //} StartCoroutine(GameStartAnimation()); StartCoroutine(Timer()); }
public OwnShotState(Lineup _attTeam, Lineup _defTeam, Player _defender) { attTeam = _attTeam; defTeam = _defTeam; defender = _defender; type = State.OWN_SHOT; goalkeeper = defTeam.Any(Position.GK); }
public LineupModel(Lineup lineup, bool fastest) { FirstCharacter = lineup.FirstCharacter; SecondCharacter = lineup.SecondCharacter; ThirdCharacter = lineup.ThirdCharacter; Count = lineup.Count; IsFastest = fastest; }
public ActionResult DeleteConfirmed(int id) { Lineup lineup = db.lineups.Find(id); db.lineups.Remove(lineup); db.SaveChanges(); return(RedirectToAction("Index")); }
public GoalState(Lineup _attTeam, Lineup _defTeam, Player _scorer, Player _assist = null) { attTeam = _attTeam; defTeam = _defTeam; scorer = _scorer; assist = _assist; type = State.GOAL; }
public PenaltyState(Lineup _attTeam, Lineup _defTeam) { attTeam = _attTeam; defTeam = _defTeam; type = State.PENALTY; attacker = attTeam.All().ByMax(x => x.SP + x.FIN); goalkeeper = defTeam.Any(Position.GK); }
private static List<int> GetLineupDvbPropertyValues(Lineup lineup, DvbTuningInfoPropertyGetter property_getter) { List<int> values = new List<int>(); foreach (Channel ch in lineup.GetChannels()) if (ch.TuningInfos != null) foreach (TuningInfo ti in ch.TuningInfos) if (ti is DvbTuningInfo) values.Add(property_getter((DvbTuningInfo)ti)); values = values.Distinct().ToList(); values.Sort(); return values; }
private List<Channel> GetUserChannelsFromLineup(Lineup lineup) { List<Channel> user_channels = new List<Channel>(); foreach (Channel ch in lineup.GetChannels()) { if (ch.ChannelType == ChannelType.UserAdded) { user_channels.Add(ch); } } return user_channels; }
public static bool AreSameLineup(Lineup l1, Lineup l2) { return l1.Id == l2.Id && l1.Name == l2.Name; }
public static bool IsLineupInLineups(Lineups lineups, Lineup lineup) { foreach (Lineup l in lineups) if (AreSameLineup(l, lineup)) return true; return false; }
private static void FillDictionaryFromLineup(Lineup lineup, Dictionary<int, List<Channel>> channels_by_num) { foreach (Channel ch in lineup.GetChannels()) { if (ch.TuningInfos != null && ch.TuningInfos.First != null) { ChannelTuningInfo channel_tuning_info = ch.TuningInfos.First as ChannelTuningInfo; if (channel_tuning_info == null) continue; // skip any TuningInfos that are not ChannelTuningInfo if (channel_tuning_info.IsEncrypted) continue; // don't include encrypted QAM. int key = ChannelNumberToInt(channel_tuning_info.PhysicalNumber, channel_tuning_info.SubNumber); if (!channels_by_num.ContainsKey(key)) channels_by_num.Add(key, new List<Channel>()); channels_by_num[key].Add(ch); } } }
private static Channel FindCCardChannelForMapEntry(ChannelMapEntry entry, Lineup cablecard_lineup) { int key = ChannelNumberToInt(entry.Number, 0); if (ccard_channels_by_num.ContainsKey(key)) return ccard_channels_by_num[key].First(); return null; }
private static List<Channel> FindMatchingQAMChannels(ChannelMapEntry entry, Lineup qam_lineup) { // if the channel has an unsupported modulation, skip it. if (entry.HasUnsupportedModulation()) return new List<Channel>(); int key = ChannelNumberToInt(entry.PhysicalChannel.Number, entry.PhysicalChannel.SubNumber); if (qam_channels_by_num.ContainsKey(key)) { List<Channel> matching_channels = qam_channels_by_num[key]; // remove any where the modulation doesn't match. bool has_unmatched_modulation = false; foreach (Channel ch in matching_channels) { if (ch.TuningInfos == null || ch.TuningInfos.Empty || ((ChannelTuningInfo)ch.TuningInfos.First).ModulationType != entry.Modulation) { has_unmatched_modulation = true; break; } } if (!has_unmatched_modulation) return matching_channels; List<Channel> filtered_matching_channels = new List<Channel>(); foreach (Channel ch in matching_channels) if (ch.TuningInfos != null && !ch.TuningInfos.Empty && ((ChannelTuningInfo)ch.TuningInfos.First).ModulationType == entry.Modulation) { filtered_matching_channels.Add(ch); } return filtered_matching_channels; } return null; }
private static bool FindScannedLineups(out Lineup cablecard_lineup, out Lineup qam_lineup) { cablecard_lineup = null; qam_lineup = null; Lineup[] lineups = ChannelEditing.GetLineups(); foreach (Lineup lineup in lineups) { switch (lineup.Name) { case "Scanned (Digital Cable (CableCARD™))": if (lineup.ScanDevices.Count() > 0) cablecard_lineup = lineup; break; case "Scanned (Digital Cable (ClearQAM))": if (lineup.ScanDevices.Count() > 0) qam_lineup = lineup; break; } } return (cablecard_lineup != null) && (qam_lineup != null); }
private void RemoveWMILineupFromTuner(Lineup lineup, Device tuner) { tuner.WmisLineups.RemoveAllMatching(lineup); // tuner.Update(); }
private void AddWMILineupToTuner(Lineup lineup, Device tuner) { foreach (Lineup l in tuner.WmisLineups) { // Lineup is already there, nothing to do! if (l.Id == lineup.Id) return; } tuner.WmisLineups.Add(lineup); // tuner.Update(); }
private Lineup GetDefaultLineup() { var lineup = new Lineup( this.players.Take(11), this.players.Skip(11).Take(5)); return lineup; }
public Lineup AddNewLineup() { var lu = new Lineup() { Name = "New Lineup" }; SelectedTeam.Lineups.Add(lu); return _selectedLineup = lu; }
private void SelectAndLoadScannedLineup(Lineup lineup) { scanned_lineup_ = lineup; Channel[] channels = scanned_lineup_.GetChannels(); int channel_count = channels.Length; scanned_channels_ = new List<Channel>(); scanned_channels_.AddRange(channels.Distinct()); SortScannedChannels(); ScannedLineupGridView.RowCount = scanned_channels_.Count; ScannedLineupGridView.Invalidate(); }