//Ship asssembly constructor. Requires ship class, ship component list, and location col/row as input. //TODO: Figure out default ship positions, continue making static methods for determining has<Flags>, and eventually figure out ToString AssembledShip(string shipNameInp, IShipClassInterface shipClass, int locationRowInp, int locationColInp, List <IShipComponentInterface> shipComponentList) { shipName = shipNameInp; shipHealth = shipClass.hullHealth; currentShipClass = shipClass; currentShipComponents = shipComponentList; locationRow = locationRowInp; locationCol = locationColInp; isDestroyed = false; isDisabled = false; hasPropulsion = ClassComponentSelect.hasPropulsion(shipComponentList); hasWeapon = ClassComponentSelect.hasWeapons(shipComponentList); hasLifeSupport = ClassComponentSelect.hasLifeSupport(shipComponentList); hasControl = ClassComponentSelect.hasControl(shipComponentList); hasComms = ClassComponentSelect.hasComms(shipComponentList); }
//Default ship constructor: Will construct a simple frigate. //TODO: Go through each member and create defaults public AssembledShip(IShipClassInterface selectedShipClass, int locationRowInput, int locationColInput) { //ERROR-CATCH: // If the input class is null, or otherwise erroneous, this method will fail. if (selectedShipClass == null) { throw new ArgumentException("CreateDefaultShip: selectedShipClass cannot be null!"); } currentShipClass = selectedShipClass; shipName = $"Default {currentShipClass}"; shipHealth = currentShipClass.hullHealth; currentShipComponents = new List <IShipComponentInterface>(currentShipClass.numComponents); //Populting Default Ship: //Interrupting object creation flow in order to populate the default ship with components dynamically. int numComponents = currentShipComponents.Capacity; for (int i = 0; i < numComponents - 1; i++) { currentShipComponents.Add(new Components.IonEngines()); } currentShipComponents.Add(new Components.Cockpit()); locationRow = locationRowInput; locationCol = locationColInput; isDestroyed = false; isDisabled = false; hasPropulsion = ClassComponentSelect.hasPropulsion(currentShipComponents); hasWeapon = ClassComponentSelect.hasWeapons(currentShipComponents); hasLifeSupport = ClassComponentSelect.hasLifeSupport(currentShipComponents); hasControl = ClassComponentSelect.hasControl(currentShipComponents); hasComms = ClassComponentSelect.hasComms(currentShipComponents); }