public Developer(string name, int id, bool license, TeamName teamname) { Name = name; ID = id; License = license; NameOfTeam = teamname; }
private int CalculateScore(BoardPosition[,] boardState, TeamName teamName) { OptionBuilder optionBuilder = new OptionBuilder(teamName); List <BoardPosition> ownedBoardPositions = new List <BoardPosition>(); int totalScore = 0; foreach (var bp in boardState) { if (bp.Owner == teamName) { ownedBoardPositions.Add(bp); } } foreach (var pos in ownedBoardPositions) { Option option = optionBuilder.BuildOption(pos, boardState); foreach (var target in option.Targets) { if (target.CheckIfTargetValid(boardState, teamName)) { int score = target.FourChance(boardState, teamName); if (score == 6 && IsBlockable(target)) { score /= 4; } totalScore += score; } } } return(totalScore); }
protected override void Execute(CodeActivityContext executionContext) { #region Boilerplate IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); var tracing = executionContext.GetExtension <ITracingService>(); #endregion var entityIdString = EntityId.Get(executionContext); Guid entityId = Guid.Empty; if (!Guid.TryParse(entityIdString, out entityId)) { Succeeded.Set(executionContext, false); ErrorMessage.Set(executionContext, $"Guid {entityIdString} is not a valid GUID."); return; } var teamName = TeamName.Get(executionContext); using (var ctx = new XrmServiceContext(service)) { var team = (from t in ctx.CreateQuery <Team>() where t.Name == teamName select t).FirstOrDefault(); if (team == null) { Succeeded.Set(executionContext, false); ErrorMessage.Set(executionContext, $"Team {teamName} not found."); return; } var logicalName = EntityName.Get(executionContext); var reference = (from r in ctx.CreateQuery(logicalName) where (Guid)r[$"{logicalName}id"] == entityId select r).FirstOrDefault(); if (reference == null) { Succeeded.Set(executionContext, false); ErrorMessage.Set(executionContext, $"Entity Reference with logical name {logicalName} and id {entityIdString} wasn't found."); return; } //Assign otherwise var assignRequest = new AssignRequest() { Assignee = team.ToEntityReference(), Target = reference.ToEntityReference() }; service.Execute(assignRequest); } Succeeded.Set(executionContext, true); }
public Developer(string name, int idNumber, bool pluralSightAccess, TeamName team) { Name = name; IdNumber = idNumber; PluralSightLicense = pluralSightAccess; NameOfTeam = team; }
public TeamStats(TeamName teamName, IEnumerable <Game> allCompetitionGames, IEnumerable <ITable> seasonEndTables) { Name = teamName; teamsGames = allCompetitionGames.Where(Name.PlayedIn).ToList(); this.seasonEndTables = seasonEndTables; wins = teamsGames.Where(g => Name.Matches(g.Winner)); }
public int ScoreBoard(BoardPosition[,] currentBoard, TeamName team) { _currentBoard = currentBoard; _myTeam = team; _enemy = team.GetOppositeTeam(); int totalScore = CheckForWin(); if (totalScore != 0) { return(totalScore); } totalScore = OneMoveWinScore(); if (totalScore != 0) { return(totalScore); } int enemyScore = CalculateScore(currentBoard, _enemy); int myScore = CalculateScore(currentBoard, _myTeam); totalScore += myScore - enemyScore; if (Mathf.Abs(totalScore) > 100) { Debug.Log("Score greater than 100"); } return(totalScore); }
public int[,] GetTargets(GameState gameState, TeamName myTeam) { //Init here since can't use constructors currentBoardState = gameState.CurrentBoardState; _myTeam = myTeam; _gameState = gameState; var targetCount = new int[7, 6]; for (var v = 0; v < 6; v++) { for (var h = 0; h < 7; h++) { //If unoccupied, get sequences to check if (!gameState.CurrentBoardState[h, v].IsOccupied) { var targets = 0; targets += GetHorizontalTargets(gameState.CurrentBoardState[h, v]); targets += GetVerticalTargets(gameState.CurrentBoardState[h, v]); targets += GetDiagonalTargetsA(gameState.CurrentBoardState[h, v]); targets += GetDiagonalTargetsB(gameState.CurrentBoardState[h, v]); targetCount[h, v] = targets; } } } return(targetCount); }
public void TeamNameTryParseCanOutNullValue() { TeamName result; TeamName.TryParse("Ifk Götebor/", out result); Assert.IsNull(result); }
private void StartCapturing(TeamName teamName) { if (teamName == TeamName.Team1 && progress > -progressMax) { progress -= progressSpeed * ListTeam1.Count * Time.deltaTime; if (progress <= -progressMax) { progress = -progressMax; SetTeam(teamName); } textMesh.text = "TeamOfTurret 1: " + (progress * -1).ToString("F0") + " / " + progressMax; } if (teamName == TeamName.Team2 && progress < progressMax) { progress += progressSpeed * ListTeam2.Count * Time.deltaTime; if (progress >= progressMax) { progress = progressMax; SetTeam(teamName); } textMesh.text = "TeamOfTurret 2: " + progress.ToString("F0") + " / " + progressMax; } }
public void Edit(Team team, TeamName newTeamName, IEnumerable <Player> players, Coach coach) { team.Name = newTeamName; team.PlayerIds = players.Select(x => x.Id).ToList(); team.CoachId = coach.Id; Save(_teamPath, _teams); }
public void TeamNameTryParseCanOutValidResult() { TeamName result; TeamName.TryParse("Ifk Göteborg", out result); Assert.IsTrue(result.Value == "Ifk Göteborg"); }
public Team(TeamName teamName, ICollection <Starter> starters, ICollection <Substitute> substitutes, uint teamPoints = 0) { this.teamName = teamName; this.starters = starters; this.substitutes = substitutes; this.TeamPoints = teamPoints; }
public void TeamNameIsComparableByValue() { var nameOne = new TeamName("Ifk Göteborg"); var nameTwo = new TeamName("Ifk Göteborg"); Assert.AreEqual(nameOne, nameTwo); Assert.IsTrue(nameOne == nameTwo); }
public void TeamNameCanChange() { var teamName = new TeamName("Häcken"); Assert.IsFalse(this.team.Name == teamName); this.team.Name = teamName; Assert.IsTrue(this.team.Name == teamName); }
public Developer(string firstName, string lastName, double idNumber, bool pluralSightAccess, TeamName teamName) { FirstName = firstName; LastName = lastName; IdNumber = idNumber; PluralSightAccess = pluralSightAccess; NameOfTeam = teamName; }
public Player(string name, string number, Position position, TeamName team, Rating rating) { Name = name; Number = number; Position = position; Rating = rating; Team = team; }
public void SetTeam(TeamName teamName) { _myTeam = teamName; if (_myName == "Human") { _myName = teamName.ToString(); } }
public static TeamName GetOppositeTeam(this TeamName teamName) { if (teamName == TeamName.RedTeam) { return(TeamName.BlackTeam); } return(TeamName.RedTeam); }
void Start() { _gameBoard = GetComponent <GameBoard>(); piecePlacer = GetComponent <PiecePlacer>(); CurrentTeam = TeamName.RedTeam; _startingTeam = CurrentTeam; }
public TeamTest() { var teamName = new TeamName("Ifk Göteborg"); var arena = new ArenaName("Ullevi"); var email = new EmailAddress("*****@*****.**"); this.team = new Team(teamName, arena, email); }
public UIHealth(GameObject followGameObject, TeamName team) : base(team == TeamName.RED ? Constants.RedHealth : Constants.BlueHealth, new Vector2(100, 100), new Vector2(50, 10), 0) { FollowGameObject = followGameObject; UITexture.Size.X = 50 * (FollowGameObject.Health / Constants.PLAYER_HEALTH); UITexture.Size.Y = 10; UITexture.Position = GraphicsManager.WorldToScreenPoint(FollowGameObject.Transform.Position) - new Vector2(UITexture.Size.X / 2f, UITexture.Size.Y + delta); }
protected override void ProcessRecord() { var TeamNameList = TeamName?.ToList().ConvertAll(s => s.ToLower()); var baseResourceList = new List <TeamResource>(); if (TeamNameList == null) { baseResourceList = _connection.Repository.Teams.FindAll(); } else { //Multiple values but one of them is wildcarded, which is not an accepted scenario (I.e -MachineName WebServer*, Database1) if (TeamNameList.Any(item => WildcardPattern.ContainsWildcardCharacters(item) && TeamNameList.Count > 1)) { throw OctoposhExceptions.ParameterCollectionHasRegularAndWildcardItem("TeamName"); } //Only 1 wildcarded value (ie -MachineName WebServer*) else if (TeamNameList.Any(item => WildcardPattern.ContainsWildcardCharacters(item) && TeamNameList.Count == 1)) { var pattern = new WildcardPattern(TeamNameList.First()); baseResourceList = _connection.Repository.Teams.FindMany(t => pattern.IsMatch(t.Name.ToLower())); } //multiple non-wildcared values (i.e. -MachineName WebServer1,Database1) else if (!TeamNameList.Any(WildcardPattern.ContainsWildcardCharacters)) { baseResourceList = _connection.Repository.Teams.FindMany(t => TeamNameList.Contains(t.Name.ToLower())); } } if (ResourceOnly) { if (baseResourceList.Count == 1) { WriteObject(baseResourceList.FirstOrDefault(), true); } else { WriteObject(baseResourceList, true); } } else { var converter = new OutputConverter(); var outputList = converter.GetOctopusTeam(baseResourceList); if (outputList.Count == 1) { WriteObject(outputList.FirstOrDefault(), true); } else { WriteObject(outputList, true); } } }
public int GetFourCost(BoardPosition[,] currentBoard, TeamName myTeam) { int fourCost = MovesRequiredToFillPath.Count; List <BoardPosition> unFilledPathPositions = Path.Where(x => x.IsOccupied == false).ToList(); fourCost += unFilledPathPositions.Count; return(fourCost); }
private void TeamSelected(TeamName teamName) { HideMenu(); int teamNumber = GetTeamNumber(teamName); //vp_master.photonView.RPC("ReceiveInitialSpawnInfo", PhotonTargets.All, PhotonNetwork.player.ID, PhotonNetwork.player, placement.Position, placement.Rotation, playerTypeName, teamNumber); //netWorkManagerExtension.SpawnPlayer(teamName); }
public void TeamNameWorksWithHashSet() { var nameOne = new TeamName("Ifk Göteborg"); var nameTwo = new TeamName("Ifk Göteborg"); var nameHashSet = new HashSet <TeamName> { nameOne, nameTwo }; Assert.IsTrue(nameHashSet.Count == 1); }
private GameObject BuildTeamPieceContainer(TeamName teamName) { GameObject teamPieceContainer = GameObject.Find(teamName.ToString()); if (teamPieceContainer == null) { teamPieceContainer = new GameObject(teamName.ToString()); } return(teamPieceContainer); }
public override int GetHashCode() { unchecked { var hashCode = Guid.GetHashCode(); hashCode = (hashCode * 397) ^ (DriverName?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (TeamName?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Skins.Aggregate(0, (current, skin) => current ^ skin.GetHashCode()).GetHashCode(); return(hashCode); } }
private void OnGameForfeit(object sender, TeamName e) { GameResult result = new GameResult(); //This is misleading in this case it is actually the team that forfeited the game result.Winner = e; result.WinType = WinType.Forfeit; _stats.DisplayForfeitMessage(result); ScoreKeeper.UpdateStats(result); HandleEndOfRound(); }
private Target BestTargetFromList(List <Target> targets, TeamName teamName) { Target selectedTarget = null; targets = targets.OrderBy(x => x.GetFourCost(_currentBoard, teamName)).ToList(); if (targets.Count > 0) { selectedTarget = targets[0]; } return(selectedTarget); }
public override int GetHashCode() { unchecked { int result = (ReleaseNumber != null ? ReleaseNumber.GetHashCode() : 0); result = (result * 397) ^ (ReleaseFiInstructions != null ? ReleaseFiInstructions.GetHashCode() : 0); result = (result * 397) ^ (TeamName != null ? TeamName.GetHashCode() : 0); result = (result * 397) ^ (PrePatEmail != null ? PrePatEmail.GetHashCode() : 0); result = (result * 397) ^ (ServiceNowTicketLink != null ? ServiceNowTicketLink.GetHashCode() : 0); return(result); } }
public ActionResult CreateTeamName(TeamName newTeamName) { var teamNameCollection = Dbh.GetCollection<TeamName>("TeamNames"); var playerCollection = Dbh.GetCollection<Player>("Players"); var player1 = playerCollection.FindOne(Query.EQ("_id", BsonObjectId.Create(newTeamName.Team.Players[0].Id))); var player2 = playerCollection.FindOne(Query.EQ("_id", BsonObjectId.Create(newTeamName.Team.Players[1].Id))); var teamName = new TeamName() { Name = newTeamName.Name, Team = new Team() { Players = new List<Player>() { player1, player2 } } }; teamNameCollection.Save(teamName); return Json(new { success = true, newTeam = teamName }); }
public Fixture SaveFixture(int legacyFixtureId, DateTime fixtureDate, TeamName homeTeam, TeamName opposition) { using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { try { var fixture = session.CreateCriteria(typeof (Fixture)) .List<Fixture>() .FirstOrDefault(x => x.LegacyId.Equals(legacyFixtureId)) ?? new Fixture { FixtureKey = CustomStringHelper.BuildKey(new[] {homeTeam.Name, fixtureDate.ToShortDateString()}), LegacyId = legacyFixtureId, DatePlayed = fixtureDate, HomeTeam = homeTeam, Opposition = opposition }; if (fixture.Id != 0) { transaction.Rollback(); return fixture; } SetAudit(fixture); session.SaveOrUpdate(fixture); transaction.Commit(); return fixture; } catch (Exception ex) { Logger.Log(LogLevel.Error, ex, string.Empty, null); transaction.Rollback(); return null; } } } }
public void ComparisonIdenticalTeamNameTest(string left, string right) { var teamNameOne = new TeamName { RU = left }; var teamNameTwo = new TeamName { RU = right }; Assert.IsTrue(teamNameOne == teamNameTwo, "Error, сomparing identical commands are not passed"); }
public bool Equals(TeamName other) { return string.Equals(this.RU, other.RU) && string.Equals(this.EN, other.EN); }
public void ComparisonNotIdenticalTeamNameTest(string left, string right) { var teamNameOne = new TeamName { RU = left }; var teamNameTwo = new TeamName { RU = right }; Assert.IsFalse(teamNameOne == teamNameTwo, "Error, сomparing differences commands are passed"); }
public ConfigItem SaveTeamName(ConfigItem newItem, out TeamName team) { using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { try { var item = session.CreateCriteria(typeof(TeamName)) .List<TeamName>() .FirstOrDefault(x => x.Name.ToLowerInvariant() == newItem.Name.ToLowerInvariant()) ?? new TeamName { Name = newItem.Name }; if (item.Id != 0) { transaction.Rollback(); team = item; return null; } item.Type = newItem.Type == "Opposition" ? (int)TeamType.Opposition : (int)TeamType.Home; SetAudit(item); session.SaveOrUpdate(item); transaction.Commit(); team = item; newItem.Id = item.Id; } catch (Exception ex) { team = null; Logger.Log(LogLevel.Error, ex, string.Empty, null); transaction.Rollback(); } return newItem; } } }