# Class Cannon

java.lang.Object
it.polimi.ingsw.is25am31.model.components.Component
it.polimi.ingsw.is25am31.model.components.Cannon

All Implemented Interfaces:
  `Serializable`

public class Cannon extends Component
Represents a Cannon component with configurable power and orientation. The Cannon can calculate firepower based on its type and position. The class supports single-power and multi-power cannons. The class extends the Component base class.

See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class it.polimi.ingsw.is25am31.model.components.Component

  `connector, id, name, orientation, x, y`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Cannon(int id, String name, Map<Side,Connector> connector, Side orientation, int power)`
  Constructs a cannon with specified power and orientation

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `activate()`
  Activates this multi-power cannon for the next fire calculation
  `double`
  `calculateFirePower()`
  Calculates the fire power this turn based on cannon type and orientation Single-power cannons produce 1.0 if facing FRONT connector, else 0.5
  `String[]`
  `getAsciiArt()`
  Returns an ASCII art representation of the cannon, showing orientation arrows and power label
  `int`
  `getPower()`
  `boolean`
  `isActive()`
  Checks if this multi-power cannon is currently active

  ### Methods inherited from class it.polimi.ingsw.is25am31.model.components.Component

  `addContains, calculateThrust, getAlienColor, getCapacity, getConnector, getConnectors, getContains, getCrewMembers, getCurrentAlien, getId, getMaxGoodValue, getName, getOrientation, getOrientationShield, getX, getY, isAlienLifeSupport, isAlienStructural, modifyCapacity, modifyCrewMembers, modifyOrientation, protectedSides, removeContains, setOrientationShield, setX, setY`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Cannon

    public Cannon(int id, String name, Map<Side,Connector> connector, Side orientation, int power)
    Constructs a cannon with specified power and orientation
    Parameters:
      `id` - unique component identifier
      `name` - descriptive name of the cannon
      `connector` - map of side-to-connector mappings
      `orientation` - initial orientation of the component
      `power` - fire power rating

- ## Method Details

  - ### isActive

    public boolean isActive()
    Checks if this multi-power cannon is currently active
    Overrides:
      `isActive` in class `Component`
    Returns:
      true if active or single-power, false otherwise

  - ### activate

    public void activate()
    Activates this multi-power cannon for the next fire calculation
    Overrides:
      `activate` in class `Component`

  - ### calculateFirePower

    public double calculateFirePower()
    Calculates the fire power this turn based on cannon type and orientation Single-power cannons produce 1.0 if facing FRONT connector, else 0.5
    Overrides:
      `calculateFirePower` in class `Component`
    Returns:
      fire power value

  - ### getPower

    public int getPower()
    Overrides:
      `getPower` in class `Component`

  - ### getAsciiArt

    public String[] getAsciiArt()
    Returns an ASCII art representation of the cannon, showing orientation arrows and power label
    Overrides:
      `getAsciiArt` in class `Component`
    Returns:
      array of ASCII art lines