All Known Implementing Classes:
LetterCell, SymbolCell

public interface Cell
Represents the fundamental interactive unit within the game. A Cell serves as the smallest element that a player can interact with during gameplay.

This interface outlines the expected behaviour of a Cell within the context of the program, allowing it to:

  • Contain a letter, symbol, or other character.
  • Be associated with a group, cluster, or exist in isolation.

Implementing classes should ensure that these behaviours are appropriately defined and adhere to the game's logic and interactive design principles.

Since:
2024-08-12
Version:
3.0
Author:
Kheagen Haskins
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    The IllegalCharAddition class is a specific type of IllegalArgumentException that is thrown when an invalid character is added to a cell.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addClickListener(javafx.beans.value.ChangeListener<? super Boolean> listener)
    Adds a listener that will be notified whenever the value of the `clickCount` property changes.
    void
    addContentListener(javafx.beans.value.ChangeListener<? super Character> listener)
    Registers a listener that will be notified when the content of the cell changes, such as when it is filled or modified.
    void
    addStateListener(javafx.beans.value.ChangeListener<? super Boolean> listener)
    Adds a listener to the `isActiveProperty` to monitor changes in its value.
    boolean
    Adds this Cell to the specified CellCluster.
    void
    Handles the internal behaviour triggered by a click on this cell.
    char
    Retrieves the content (a character) contained within this Cell.
    Retrieves the primary cluster that this Cell is associated with.
    boolean
    Checks if the cell is part of an active cluster.
    boolean
    Checks if the cell is part of a cluster.
    boolean
    Checks if the cell is currently active.
    boolean
    matches(Cell cell)
    Determines whether the content of this Cell matches the content of the specified Cell.
    boolean
    Removes this Cell from the specified CellCluster.
    void
    setActive(boolean newState)
    Changes the state of the cell.
    void
    setContent(char content)
    Sets the content (a character) of this Cell.
    boolean
    Determines whether this Cell shares the same cluster with another specified Cell.
  • Method Details

    • getContent

      char getContent()
      Retrieves the content (a character) contained within this Cell.
      Returns:
      the character content of this Cell.
    • setContent

      void setContent(char content)
      Sets the content (a character) of this Cell.
      Parameters:
      content - the character to be set as the content of this Cell.
    • setActive

      void setActive(boolean newState)
      Changes the state of the cell. This changes the visual properties of the Cell.
      Parameters:
      newState - the new state of the cell, true for active, false for inactive.
    • addToCluster

      boolean addToCluster(CellCluster cluster)
      Adds this Cell to the specified CellCluster.
      Parameters:
      cluster - the CellCluster to which this Cell will be added.
      Returns:
      true if the cell was successfully added to the cluster.
    • removeCluster

      boolean removeCluster(CellCluster cluster)
      Removes this Cell from the specified CellCluster.
      Parameters:
      cluster - the CellCluster to which this Cell will be removed.
      Returns:
      true if the cluster was successfully removed.
    • sharesClusterWith

      boolean sharesClusterWith(Cell cell)
      Determines whether this Cell shares the same cluster with another specified Cell.

      This method checks if both Cell instances are part of the same cluster. A cluster is a group of cells that are logically connected in the context of the game. This connection could be based on proximity, content similarity, or game-specific rules.

      Parameters:
      cell - the Cell to compare with this instance for cluster membership.
      Returns:
      true if this Cell and the specified Cell are part of the same cluster; false otherwise.
    • getMainCluster

      CellCluster getMainCluster()
      Retrieves the primary cluster that this Cell is associated with. The determination of the main cluster is contingent upon the type and internal content of the Cell.

      For LetterCell instances, which can only be part of a single cluster, this method will always return that cluster.

      In contrast, SymbolCell instances may belong to multiple clusters. This method will return the main cluster only if the SymbolCell is the first element in that cluster. If the SymbolCell is part of one or more clusters but not as the first element, this method will return null.

      Returns:
      The primary cluster associated with this Cell, or null if no such cluster exists.
    • isActive

      boolean isActive()
      Checks if the cell is currently active. In the context of the game, an active cell is one that the mouse is currently hovered over, highlighting it for potential interaction.
      Returns:
      true if the cell is active, false otherwise.
    • addStateListener

      void addStateListener(javafx.beans.value.ChangeListener<? super Boolean> listener)
      Adds a listener to the `isActiveProperty` to monitor changes in its value. The listener will be notified whenever the value of the `isActiveProperty` changes.
      Parameters:
      listener - the listener to add; it must be an implementation of ChangeListener that can handle the value of type Boolean.
    • addContentListener

      void addContentListener(javafx.beans.value.ChangeListener<? super Character> listener)
      Registers a listener that will be notified when the content of the cell changes, such as when it is filled or modified. The listener will receive a notification whenever the character content within the cell is altered.
      Parameters:
      listener - the ChangeListener to be added; it will be triggered with a Character when the cell's content changes
    • addClickListener

      void addClickListener(javafx.beans.value.ChangeListener<? super Boolean> listener)
      Adds a listener that will be notified whenever the value of the `clickCount` property changes.
      Parameters:
      listener - the listener to be added, which should implement the ChangeListener<? super Boolean> interface. This listener will be notified with the new value whenever the `clickCount` changes.
    • inActiveCluster

      boolean inActiveCluster()
      Checks if the cell is part of an active cluster. Active clusters might have special behaviour or visual indications in the game.
      Returns:
      true if the cell is part of an active cluster, false otherwise.
    • inCluster

      boolean inCluster()
      Checks if the cell is part of a cluster.
      Returns:
      true if the cell is part of a cluster, false otherwise.
    • matches

      boolean matches(Cell cell)
      Determines whether the content of this Cell matches the content of the specified Cell.

      This method compares the content of the two Cell instances. If the Cells belong to different subclasses, this method will automatically return false, ensuring that only cells of the same type are considered comparable.

      For most subclasses, including LetterCell, this method checks if the content of both cells is identical. However, for more specialised subclasses like SymbolCell, the implementation may involve more nuanced rules, such as determining whether certain types of symbols are considered equivalent, even if their content differs.

      Parameters:
      cell - The Cell whose content is to be compared with this Cell.
      Returns:
      true if the content of the two Cells matches and they belong to the same subclass; false otherwise.
    • click

      void click()
      Handles the internal behaviour triggered by a click on this cell. This typically involves delegating the click to any main cluster. The exact behavior may vary depending on the implementation specifics.