Entity.java 908 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package eu.oschl.textadventure.entities;
  2. import eu.oschl.textadventure.Game;
  3. /**
  4. * Represents a generic entity in the game.
  5. * This class serves as a base for all entities, such as enemies.
  6. *
  7. * @author Ondřej Schlaichert
  8. */
  9. public abstract class Entity {
  10. protected Game game;
  11. protected final String name;
  12. protected final String description;
  13. public Entity(String name, String description) {
  14. this.name = name;
  15. this.description = description;
  16. }
  17. public String getName() {
  18. return name;
  19. }
  20. public String getDescription() {
  21. return description;
  22. }
  23. /**
  24. * Sets the game instance. This is typically called during the game's setup phase.
  25. *
  26. * @param game the game instance to associate
  27. */
  28. public void setGame(Game game) {
  29. if (game == null) {
  30. return;
  31. }
  32. this.game = game;
  33. }
  34. }