public void ReturnsCorrectDiff() { Shots shots = new Shots(); shots.Add(new Shot()); shots.Clean(); shots.Add(new Shot()); shots.Add(new Shot()); Assert.AreEqual(2, shots.GetDiff().Count); }
/** * Adds a shot in the shots list using positions in parameters to create it * start : the position where the shot was performed * target : the position of the target on the map * userPosition : the current position of the user (the position where the ball was shot) * return the created Shot object */ public Shot addPositionForCurrentHole(MyPosition start, MyPosition target, MyPosition userPosition) { Shot s = new Shot(CurrentClub, start, target, userPosition, DateTime.Now); Shots.Add(s); return(s); }
public void CanDirtyState() { Shots shots = new Shots(); shots.Add(new Shot()); Assert.IsTrue(shots.IsDirty); }
public void CanCleanState() { Shots shots = new Shots(); shots.Add(new Shot()); shots.Clean(); Assert.IsFalse(shots.IsDirty); }
public List <Shot> Play() { bool isHunting = true; Shot result; while (ShipsDestroyed != Ship.NUM_OF_SHIPS) { Display.Grid(Board); //DISPLAY PURPOSE if (isHunting) { result = Hunt(); if (result.ShotTypeId == (int)ShotType.Hit) { TargetCoords.Add(new Coordinates { X = result.X, Y = result.Y, Val = result.InitialVal.GetValueOrDefault() }); isHunting = false; } } else { result = Target(); if (result.ShotTypeId != (int)ShotType.Missed) { if (result.ShotTypeId == (int)ShotType.Hit) { TargetCoords.Add(new Coordinates { X = result.X, Y = result.Y, Val = result.InitialVal.GetValueOrDefault() }); } else if (result.ShotTypeId == (int)ShotType.Destroyed) { isHunting = true; ShipsDestroyed++; TargetDirection = DirectionTaken.Random; TargetOrientation = Orientation.Random; PossibleTargets.Clear(); TargetCoords.Clear(); } } } if (result.ShotTypeId != (int)ShotType.Duplicate) { Shots.Add(result); ShotNumber++; } } Console.WriteLine("----------------"); //Display Purpose return(Shots); }
public List <Shot> Play() { while (ShipsDestroyed != Ship.NUM_OF_SHIPS) { Display.Grid(Board); //DISPLAY PURPOSE ShotNumber++; Shots.Add(Shoot()); } Console.WriteLine("----------------"); //Display Purpose return(Shots); }
public void Fire(Coordinate coordinates) { if (ShotMap().TryGetValue(coordinates, out _)) { throw new ShipBattlesException($"Shot already taken: {coordinates}"); } if (coordinates.X >= Height || coordinates.Y >= Height) { throw new ShipBattlesException($"Shot outside board: {coordinates}"); } var hit = ShipMap().TryGetValue(coordinates, out _); Shots.Add(new Shot(coordinates, hit)); }
public void Shot(Guid shotPlayerId, Guid reboundPlayerId = new Guid()) { DbAttackShot playerShot = Shots.FirstOrDefault(p => p.PlayerId.Equals(shotPlayerId)); if (playerShot == null) { Shots.Add(new DbAttackShot { Id = Guid.NewGuid(), AttackId = DbAttack.Id, PlayerId = shotPlayerId, Count = 1 }); } else { playerShot.Count++; } if (reboundPlayerId == Guid.Empty) { return; } IDbAttackRebound playerRebound = Rebounds.FirstOrDefault(p => p.PlayerId.Equals(reboundPlayerId)); if (playerRebound == null) { Rebounds.Add(new DbAttackRebound { Id = Guid.NewGuid(), AttackId = DbAttack.Id, PlayerId = reboundPlayerId, Count = 1 }); } else { playerRebound.Count++; } }
private void PhaseShoot() { Shots.Add(FirstTeam, FirstTeam.MakeTeamShots()); Shots.Add(SecondTeam, SecondTeam.MakeTeamShots()); }
private void Add(Shot shot) { Shots.Add(shot); Shots.Add(shot); }