# Class Context

java.lang.Object
it.polimi.ingsw.is25am31.model.cards.Context

public class Context extends Object
This class is used to make call to setCardContext and applyEffect uniform between all the specific card types. It contains all the parameters to pass in order to apply the specific effects for the specific cards. Only the useful parameters get assigned depending on the specific card's `EffectType`. An instance of Context is then passed to the setCardContext or applyEffect method that can extract specific information that it needs from it using `getParameters()`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Context(Map<String,Object> parameters)`
  Constructs a new `Context` object with the given parameters.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T> T`
  `getParameters(String key, Class<T> type)`
  Retrieves a parameter from the context's internal parameter map, casting it to the specified type.

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

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

- ## Constructor Details

  - ### Context

    public Context(Map<String,Object> parameters)
    Constructs a new `Context` object with the given parameters.
    Parameters:
      `parameters` - A map containing key-value pairs representing the parameters required for the specific card's effects or other contextual data.

- ## Method Details

  - ### getParameters

    public <T> T getParameters(String key, Class<T> type)
    Retrieves a parameter from the context's internal parameter map, casting it to the specified type.
    Type Parameters:
      `T` - The type to which the parameter will be cast.
    Parameters:
      `key` - The key associated with the parameter to retrieve.
      `type` - The `Class` representing the expected type of the parameter.
    Returns:
      The parameter corresponding to the given key, cast to the specified type, or `null` if the key is not present in the map.
    Throws:
      `ClassCastException` - If the object associated with the key cannot be cast to the specified type.