public bool addNewRoster(int weekNumber, string day, string name) { try { int maxRosterId = 0; //need some code to avoid dulicate usernames //maybe add some logic (busiess rules) about password policy //IUser user = new User(name, password, userType); // Construct a User Object foreach (Roster roster in RosterList) { if (roster.RosterID > maxRosterId) { maxRosterId = roster.RosterID; } } IRoster theRoster = RosterFactory.GetRoster(maxRosterId + 1, weekNumber, day, name); // Using a Factory to create the user entity object. ie seperating object creation from business logic RosterList.Add(theRoster); // Add a reference to the newly created object to the Models UserList DataLayer.addNewRosterToDB(theRoster); //Gets the DataLayer to add the new user to the DB. return(true); } catch (System.Exception excep) { return(false); } }
private static int Compare(IRoster x, IRoster y, string statName) { float?xStat = null; if (x.Stats.ContainsKey(statName)) { xStat = x.Stats[statName]; } float?yStat = null; if (y.Stats.ContainsKey(statName)) { yStat = y.Stats[statName]; } if (xStat.HasValue && yStat.HasValue) { return(yStat.Value.CompareTo(xStat.Value)); } else if (xStat.HasValue) { return(-1); } else if (yStat.HasValue) { return(1); } else { return(0); } }
public override bool Populate(PlayerSeat Seat, int pos) { Outline outty = GetComponent <Outline>(); actionOutline = new UiActionActive(this, outty); seat = Seat; contPlayer = GameData.Instance.RuntimeGame.Players.Find(player => player.Seat == seat); IRoster pRoster = contPlayer.Roster; if (pRoster.MoheRoster.Count <= pos) { return(false); } moheData = pRoster.MoheRoster[pos]; headerTxt = transform.Find("HeaderTxt").GetComponent <TextMeshProUGUI>(); lvlTxt = transform.Find("LvlTxt").GetComponent <TextMeshProUGUI>(); transform.Find("HealthBarImg").GetComponent <UiHealthBarFiller>().Populate(moheData); transform.Find("ExpBarImg").GetComponent <UiExpBarFiller>().Populate(moheData); moheImage = transform.Find("MohePortrait").GetComponent <Image>(); headerTxt.text = moheData.BaseMohe.Data.Name; lvlTxt.text = moheData.BaseExpType.CalculateLevel(moheData.Exp).ToString(); moheImage.sprite = moheData.BaseMohe.Data.Artwork; OnToggle += OnSetSwap; return(true); }
/// <summary> /// Get player stats summaries. One summary is returned per queue type. /// </summary> public static async Task <IEnumerable <IPlayerStatsSummary> > GetPlayerStatsSummariesAsync( this IRoster roster, SeasonEnum?season = null, RegionEnum?region = null) { return(await GetPlayerStatsSummariesAsync(roster, roster.OwnerId, season, region)); }
/// <summary> /// Get ranked stats. Includes statistics for Twisted Treeline and Summoner's Rift. /// </summary> public static async Task <IRankedStats> GetRankedStatsSummariesAsync( this IRoster roster, SeasonEnum?season = null, RegionEnum?region = null) { return(await GetRankedStatsSummariesAsync(roster, roster.OwnerId, season, region)); }
private void EvaluateMoheDeath(PlayerSeat seat) { IRoster roster = GameController.Instance.GetPlayerController(seat).Player.Roster; if (roster.CurrentMohe().MoheDead()) { GameEvents.Instance.Notify <IMoheDeath>(i => i.OnMoheDeath(roster.CurrentMohe().InstanceID)); } }
public static float ExtractTotalPoints(IRoster roster) { float total = 0.0f; foreach (float points in roster.Points.Values) { total += points; } return(total); }
public Player(PlayerSeat seat, IRoster Roster, Battle.Configurations.Configurations configurations = null) { Configurations = configurations; Seat = seat; roster = Roster; StartTurnMechanics = new StartTurnMechanics(this); FinishTurnMechanics = new FinishTurnMechanics(this); SwapTurnMechanics = new SwapTurnMechanics(this); SwapMoheMechanics = new SwapMoheMechanics(this); ChargeAbilityMechanics = new ChargeAbilityMechanics(this); //UseAbilityMechanics = new UseAbilityMechanics(this); GainJewelBonusMechanics = new GainJewelBonusMechanics(this); }
public static void UpdateRosterAnalysisPlayerList(League league, string myTeam, ListView lv, Func <IPlayer, bool> playerPassesFilter) { LeagueConstants lc = LeagueConstants.For(league.FantasyLeague); List <IRoster> baselineTeams = RosterAnalysis.AssignPlayersToTeams(league, p => p.FantasyTeam); RosterAnalysis.AssignStatsAndPoints(baselineTeams, lc.ScoringStatExtractors); IRoster baselineTeam = baselineTeams.Find(t => t.TeamName == myTeam); if (baselineTeam == null) { return; } lv.BeginUpdate(); lv.Items.Clear(); League l = league.Clone(); foreach (IPlayer p in l.AllPlayers) { if (!string.IsNullOrEmpty(p.FantasyTeam) || !playerPassesFilter(p)) { continue; } p.FantasyTeam = baselineTeam.TeamName; List <IRoster> teams = RosterAnalysis.AssignPlayersToTeams(l, pb => pb.FantasyTeam); RosterAnalysis.AssignStatsAndPoints(teams, lc.ScoringStatExtractors); IRoster team = teams.Find(t => t.TeamName == baselineTeam.TeamName); ListViewItem item = new ListViewItem(p.Name); item.Tag = p; item.SubItems.Add(string.Empty); // total delta float totalDelta = 0f; foreach (IStatExtractor extractor in lc.ScoringStatExtractors) { float delta = team.Points[extractor.StatName] - baselineTeam.Points[extractor.StatName]; totalDelta += delta; item.SubItems.Add(delta.ToString()); } item.SubItems[1].Text = totalDelta.ToString(); lv.Items.Add(item); p.FantasyTeam = string.Empty; } lv.EndUpdate(); }
public void OnMoheSwap(PlayerSeat seat, string moheInstanceID) { IPlayer contPlayer = GameData.Instance.RuntimeGame.Players.Find(player => player.Seat == seat); IRoster pRoster = contPlayer.Roster; for (int i = 0; i < pRoster.MoheRoster.Count; i++) { if (moheInstanceID == pRoster.MoheRoster[i].InstanceID) { pRoster.SetRoster(i); // End turn since mohe was swapped player.SwapTurn(); } } // notify ui Notify(); SetBoardState(); }
public void Execute() { if (mohe.MoheDead()) { // Find the player that the mohe belongs to IRoster roster = GameController.Instance.GetPlayerController(mohe.PlayerSeat).Player.Roster; // If the player has no more mohe, end the game if (roster.AllVanquished) { Debug.Log("Move game state ended"); GameData.Instance.RuntimeGame.EndGame(); } else { // If the player has more mohe, swap in an available mohe for the destroyed one Debug.Log("More Mohe! Continue game"); roster.AutoRoster(); } } }
public override async Task <bool> StartClass(IRoster roster) { m_config.AcceptingAnswers = true; // begin HAX if (roster == null) { m_config.NumClickers = 32; } else { m_config.NumClickers = (from student in roster.Students select student.SrsDeviceID).Max(); } // end HAX m_config.PingClickers = true; m_config.PrepareKeypad(); if (!await ISendMsgAndAck(m_config.Serialize())) { m_config.Reset(); m_log.Error("Failed to start class"); return(false); } return(true); }
public RosterCategoryAttribute(string category) { Category = category; roster = Rosters.RegisterRoster(category); }
/// <summary> /// Get recent games /// </summary> public static async Task <IEnumerable <IGame> > GetRecentGamesAsync( this IRoster roster, RegionEnum?region = null) { return(await GetRecentGames(roster, roster.OwnerId, region)); }
static void Main(string[] args) { var testRoster = new Roster("test"); var messages = SchoolLogic.CreateMessages(); Messages.StartMessage(); IRoster studentList = SchoolLogic.CreateRoster("CS114"); testRoster.FullRoster += messages.OnFullRoster; IPerson student = SchoolLogic.CreateStudent(ValidStudent.GetValidName(), ValidStudent.GetValidName(), ValidStudent.ValidateAge()); IPerson teacher = SchoolLogic.CreateStudent(ValidStudent.GetValidName(), ValidStudent.GetValidName(), ValidStudent.ValidateAge()); IPerson person = SchoolLogic.CreateStudent("Just", "Testing", 13); testRoster.AddPerson(person); testRoster.AddPerson(student); testRoster.AddPerson(teacher); Console.WriteLine(); studentList.ToString(); studentList.PrintRoster(); #region Adding and displaying Rosters /* * bool makeSelection = true; * do * { * * keyInput = UserInput.GetUserSelection(keyInput); * if ( keyInput == ConsoleKey.Y) * { * studentList.AddStudent(GetPersonInfo.CreateStudent()); * makeSelection = true; * } * else if (keyInput == ConsoleKey.N) * { * makeSelection = false; * } * } * while (makeSelection); * * Console.WriteLine("Do you want to display the Roster?\n(Y)es or (N)o"); * keyInput = Console.ReadKey(true).Key; * * if (keyInput == ConsoleKey.Y) * { * studentList.PrintRoster(); * } * * var s11 = new Student("Karla", "Jackle", 35); * var s12 = new Student("Jimmy", "Biggie", 112); * new Student("J", "C", 900); * foreach (var student in studentList.StudentRoster) * { * student.PrintStudent(); * } */ #endregion Console.Read(); #region Testing Whole Application /* * var run = true; * Console.WriteLine("Welcome to My Fake School System! Please enter one of the following:\n 1.) Add Student to Roster\n 2.) Change a students last name\n 3.) Search a student by last name\n 4.) Nothing\n 5.)Exit"); * while (run)``` * { * * var option = Console.ReadKey().Key; * * switch(Console.ReadKey(false).Key) * { * case ConsoleKey.D1: * Console.WriteLine("Adding students to roster..."); * Console.ForegroundColor = ConsoleColor.Red; * Console.BackgroundColor = ConsoleColor.Blue; * s11.AddToRoster(studentList); * s12.AddToRoster(studentList); * s13.AddToRoster(CS115); * * Console.WriteLine("List count: " + studentList.StudentRoster.Count()); * foreach (var student in studentList.StudentRoster) * { * student.PrintStudent(); * } * * break; * case ConsoleKey.D2: * s11.LastName = Console.ReadLine(); * Console.WriteLine(s11.LastName); * break; * * case ConsoleKey.D3: * Console.WriteLine("Please enter the last name of the student you want to search"); * var ssLastName = Console.ReadLine(); * foreach (var student in studentList.StudentRoster) * { * if (student.LastName``````````````````````````.Contains(ssLastName)) * { * student.PrintStudent(); * } * else * { * Console.WriteLine($"There is no students that contains {ssLastName}"); * } * } * break; * case ConsoleKey.D4: * * string[] Options = { "NO", "YES" }; * string Title = "Hello"; * Menus newStart = new Menus(Title, Options); * newStart.Display1(); * break; * case ConsoleKey.D5: * run = false; * break; * } * } */ #endregion }
public PilotEntry(IRoster roster) { Roster = roster; }
/// <summary> /// Retrieves teams /// </summary> public static async Task <IEnumerable <ITeam> > GetTeamsBySummonerIdAsync( this IRoster roster, RegionEnum?region = null) { return(await GetTeamsBySummonerIdAsync(roster, roster.OwnerId, region)); }
public bool deleteRoster(IRoster roster) { DataLayer.deleteRosterFromDB(roster); RosterList.Remove(roster); //remove object from collection return(true); }
public static void SetRoster(IRoster aRoster) // This provides a seam in the factory where I can prime the factory with the user it will then cough up. (for test code) { roster = aRoster; }
/// <summary> /// Retrieves leagues data for summoner, including leagues for all of summoner's teams. /// </summary> public static async Task <IEnumerable <ILeague> > RetrievesLeaguesDataAsync( this IRoster roster, RegionEnum?region = null) { return(await RetrievesLeaguesDataAsync(roster, roster.OwnerId, region)); }
/// <summary> /// Get mastery pages /// </summary> public static async Task <IEnumerable <IMasteryPage> > GetMasteryPagesAsync( this IRoster roster, RegionEnum?region = null) { return(await GetMasteryPagesAsync(roster, roster.OwnerId, region)); }
public static string GetTopNFreeAgentPickups(League league, IReadOnlyList <IStatExtractor> extractors, string teamName) { List <IRoster> baselineTeams = RosterAnalysis.AssignPlayersToTeams(league, p => p.FantasyTeam); RosterAnalysis.AssignStatsAndPoints(baselineTeams, extractors); IRoster baselineTeam = baselineTeams.Find(t => t.TeamName == teamName); if (baselineTeam == null) { return(string.Empty); } StringBuilder result = new StringBuilder("<HTML><BODY><TABLE BORDER='1'><TR><TD>Player To Add</TD><TD>Player To Drop</TD><TD>Total Delta</TD>"); foreach (IStatExtractor extractor in extractors) { result.AppendFormat("<TD>{0}</TD>", extractor.StatName); } result.Append("</TR>"); League l = league.Clone(); List <Tuple <float, string> > lines = new List <Tuple <float, string> >(); foreach (IPlayer p in l.AllPlayers) { if (!string.IsNullOrEmpty(p.FantasyTeam)) { continue; } p.FantasyTeam = baselineTeam.TeamName; HashSet <Position> newPlayerPositions = new HashSet <Position>(p.Positions.Where(position => Positions.DisplayPositions.Contains(position))); if (newPlayerPositions.Count > 1) { newPlayerPositions.Remove(Position.Util); } foreach (IPlayer teamPlayerToSwap in baselineTeam.Players.Where(tpts => tpts.Positions.Intersect(newPlayerPositions).Count() > 0)) { List <IRoster> teams = RosterAnalysis.AssignPlayersToTeams(l, pb => pb.ESPNId == teamPlayerToSwap.ESPNId ? string.Empty : pb.FantasyTeam); RosterAnalysis.AssignStatsAndPoints(teams, extractors); IRoster team = teams.Find(t => t.TeamName == baselineTeam.TeamName); float totalDelta = 0f; StringBuilder sb = new StringBuilder(); foreach (IStatExtractor extractor in extractors) { float delta = team.Points[extractor.StatName] - baselineTeam.Points[extractor.StatName]; sb.AppendFormat("<TD>{0}</TD>", delta); totalDelta += delta; } if (totalDelta > 0) { string line = string.Format("<TR><TD>{0}</TD><TD>{1}</TD><TD>{2}</TD>{3}</TR>", p.Name, teamPlayerToSwap.Name, totalDelta, sb.ToString()); lines.Add(new Tuple <float, string>(totalDelta, line)); } } p.FantasyTeam = string.Empty; } lines.Sort((a, b) => b.Item1.CompareTo(a.Item1)); foreach (Tuple <float, string> line in lines) { result.AppendLine(line.Item2); } result.Append("</TABLE></BODY></HTML>"); return(result.ToString()); }
public abstract Task <bool> StartClass(IRoster roster);