/// <summary> /// Passes the <paramref name="register"/> to the base constructor and generates a <see cref="Event.Message"/>. /// </summary> /// <param name="register">The <see cref="ControllerRegister"/> winning a <see cref="Round"/>.</param> public ControllerWonEvent(ControllerID register) : base(register) { Message = register + " has won the round."; }
public void MakeReceiver(ControllerID receiver) { shotsByReceiver[(int)receiver] = new List <Shot>(); }
/// <summary> /// Passes the <paramref name="register"/> to the base constructor, stores the parameters, and /// generates a <see cref="Event.Message"/>. /// </summary> /// <param name="register">The <see cref="ControllerRegister"/> creating the <see cref="Shot"/></param> /// <param name="opposer">The receiving <see cref="ControllerRegister"/> of the <see cref="Shot"/>.</param> /// <param name="shot">The <see cref="Shot"/> created.</param> public ControllerHitShipEvent(ControllerID sender, Shot shot) : base(sender) { HitShot = shot; }
public ControllerLostEvent(ControllerID register) : base(register) { }
public Register(MatchInfo match, ControllerID id) : base(match, id) { }
/// <summary> /// Called when an opposing <see cref="Controller"/> has had all of their <see cref="Ship"/>s destroyed, /// lost the round, and has been removed from the active <see cref="Controller"/>s in the round. /// </summary> /// <param name="destroyedID">The <see cref="ControllerID"/> of the <see cref="Controller"/> that /// is no longer an opponent.</param> public virtual void OpponentDestroyed(ControllerID destroyedID) { }
/// <summary> /// Sets the previous and next <see cref="ControllerID"/>s in the switch. /// </summary> /// <param name="last">The previous <see cref="ControllerID"/> that had the turn.</param> /// <param name="next">The next <see cref="ControllerID"/> to take the turn.</param> public RoundTurnChangeEvent(ControllerID last, ControllerID next) { NextTurn = next; PreviousTurn = last; }
/// <summary> /// For a given <see cref="Register"/>, fires the <see cref="ControllerLostEvent"/>, /// calls the <see cref="ControllerUser.RoundLost()"/> method in the <see cref="ControllerUser"/>, /// and removes the <see cref="ControllerUser"/> from the remaining <see cref="Register"/>s. /// </summary> /// <param name="rID">The <see cref="ControllerUser"/> that lost the round.</param> protected void MakeLoser(ControllerID rID) { MakeEvent(new ControllerLostEvent(rID)); try { Controllers[rID].RoundLost(); } catch (ControllerTimeoutException ex) { MakeEvent(new ControllerTimeoutEvent(ex)); } }
/// <summary> /// Passes the <paramref name="register"/> to the base constructor, stores the <paramref name="shot"/>, /// and generates a <see cref="Event.Message"/>. /// </summary> /// <param name="register">A <see cref="ControllerRegister"/> making the <paramref name="shot"/></param> /// <param name="shot">The <see cref="Shot"/> made by the <paramref name="register"/>.</param> public ControllerShotEvent(ControllerID register, Shot shot) : base(register) { Shot = shot; }
/// <summary> /// Indicates whether or not a <see cref="Shot"/> made by a <see cref="ControllerUser"/> violates the /// standard rules for making a <see cref="Shot"/>. /// </summary> /// <param name="rID">The <see cref="ControllerUser"/> making a <see cref="Shot"/>.</param> /// <param name="shot">The <see cref="Shot"/> made by the given <see cref="ControllerUser"/>.</param> /// <returns>A value indicating if the <see cref="Shot"/> made was invalid.</returns> protected bool ControllerShotInvalid(ControllerID rID, Shot shot) { return shot == null || (shot.Coordinates > MatchInfo.FieldSize) || (shot.Coordinates < new Coordinates(0, 0)) || rID == shot.Receiver || Registers[rID].Shots.Contains(shot) || !Remaining.Contains(shot.Receiver); }
/// <summary> /// Indicates whether or not the current state of a given <see cref="Register"/> has <see cref="Ship"/>s /// that are valid, checking the following: /// <list type="bullet"> /// <item>The <see cref="ShipList"/> is not null</item> /// <item>The <see cref="ShipList"/> has the same <see cref="Ship.Length"/>s as the in the <see cref="MatchInfo.StartingShips"/></item> /// <item>All <see cref="Ship"/>s in the <see cref="ShipList"/> have been placed</item> /// <item>None of the <see cref="Ship"/>s in the <see cref="ShipList"/> are conflicting</item> /// </list> /// </summary> /// <param name="rID">The <see cref="Register"/> to check the ships for.</param> /// <returns>A value indicating if all aforementioned conditions are true.</returns> protected bool ControllerShipsValid(ControllerID rID) { return Registers[rID].Ships != null && Registers[rID].Ships.EqualLengthsAs(MatchInfo.StartingShips) && Registers[rID].Ships.ShipsPlaced && Registers[rID].Ships.GetConflictingShips().Count == 0; }
/// <summary> /// Passes the <paramref name="register"/> to the base constructor, stores the other parameters, /// and generates a <see cref="Event.Message"/>. /// </summary> /// <param name="register">The <see cref="ControllerRegister"/> that destroyed the <see cref="Ship"/>.</param> /// <param name="shipOwner">The <see cref="ControllerRegister"/> that owns the destroyed <see cref="Ship"/></param> /// <param name="destroyedShip">The destroyed <see cref="Ship"/>.</param> public ControllerShipDestroyedEvent(ControllerID register, Ship destroyedShip) : base(register) { DestroyedShip = destroyedShip; }
/// <summary> /// Copies the <see cref="ControllerRegister"/> object reference. /// </summary> /// <param name="register"></param> public ControllerEvent(ControllerID registerID) { RegisterID = registerID; }
/// <summary> /// Passes the <paramref name="register"/> to the base constructor, stores the rest of the parameters, /// and generates a message based on the state of the given <see cref="ShipList"/>. /// </summary> /// <param name="register">A <see cref="ControllerRegister"/>.</param> /// <param name="newShips">The <see cref="ShipList"/> associated with the <see cref="ControllerRegister"/></param> public ControllerShipsPlacedEvent(ControllerID register, ShipList oldShips, ShipList newShips) : base(register) { Ships = newShips; PrevShips = oldShips; }