Class Action

All Implemented Interfaces:
Described, Encoded, Logical, Unique, Comparable<Action>

public final class Action extends SignedAsset implements Comparable<Action>, Encoded
An action is a signed asset that causes a change in a story world's state. The agents in a session negotiate when actions happen via turns.
Author:
Stephen G. Ware
  • Constructor Details

    • Action

      public Action(int id, Signature signature, Entity[] consenting, String description, String code)
      Constructs a new action.
      Parameters:
      id - the action's unique ID number
      signature - the action's unique signature
      consenting - an array of entities representing characters in the the story world who need to agree to take the action
      description - the action's description
      code - the action's code
  • Method Details

    • compareTo

      public int compareTo(Action other)
      Specified by:
      compareTo in interface Comparable<Action>
    • setID

      protected Action setID(int id)
      Description copied from class: Asset
      Returns a new asset that is the same as this asset, except that its ID number is the given value.
      Specified by:
      setID in class Asset
      Parameters:
      id - the ID number the new asset should have
      Returns:
      an asset identical to this asset, except with the given ID number
    • setSignature

      protected Action setSignature(Signature signature)
      Description copied from class: SignedAsset
      Returns a new signed asset that is the same as this asset, except that its signature and name are the given value.
      Specified by:
      setSignature in class SignedAsset
      Parameters:
      signature - the signature and name the new asset should have
      Returns:
      a signed asset identical to this asset, except with the given signature and name
    • getConsenting

      public Set<Entity> getConsenting()
      Returns an unmodifiable set of entities in the story world representing the characters who need to agree to take the action. An action with no consenting characters represents an accident or happening that can occur and time it is convenient for the story. An action with one consenting character means it is taken by a single character. An action with two or more consenting characters means it is a joint action taken by many characters who all need to have a reason to do it. Note that a character can be involved in an action without being a consenting character if the action represents something that happens to the character against their will.
      Returns:
      the action's set of consenting characters
    • setConsenting

      protected Action setConsenting(Set<Entity> consenting)
      Returns a new action that is the same as this action, except that its consenting characters is the given set.
      Parameters:
      consenting - the consenting characters the new action should have
      Returns:
      an action identical to this action, except with the given consenting characters
    • setDescription

      public Action setDescription(String description)
      Description copied from class: Asset
      Returns a new asset that is the same as this asset, except that its description is the given value.
      Specified by:
      setDescription in class Asset
      Parameters:
      description - the description the new asset should have
      Returns:
      an asset identical to this asset, except with the given description
    • getCode

      public String getCode()
      Description copied from interface: Encoded
      Returns a string of 1's and 0's that uniquely represents this object among other objects of the same type in the same story world. Every encoded object of the same type should return a string of the same length, even if it must be padded with 0's.
      Specified by:
      getCode in interface Encoded
      Returns:
      a string of 1's and 0's
    • setCode

      protected Action setCode(String code)
      Returns a new action that is the same as this action, except this its code is the given value.
      Parameters:
      code - the code the new action should have
      Returns:
      an action identical to this action, except with the given code
    • consents

      public boolean consents(Role role)
      Returns true if the given story role controls one or more of the consenting characters for this action. An action with no consenting character requires on the consent of the game master. An action whose only consenting character is the player character requires only the consent of the player. All other actions require the consent of both roles.
      Parameters:
      role - the role in question
      Returns:
      true if the given role needs to consent to take this action
    • substitute

      public Action substitute(Function<Object,Object> substitution)
      Description copied from interface: Logical
      Returns a logical object identical to this one, except that its logical elements have been replaced according to the given substitution. A substitution defines how some logical formula (the input to the function) should be replaced with a different formula (the output of the function).
      Specified by:
      substitute in interface Logical
      Specified by:
      substitute in class SignedAsset
      Parameters:
      substitution - a function which maps logical formula that should be replaced to the formula they should be replaced with
      Returns:
      an identical object, except that its logical formula have been replaced according to the substitution