Class Entity
java.lang.Object
edu.uky.cs.nil.tt.world.Asset
edu.uky.cs.nil.tt.world.Entity
- All Implemented Interfaces:
Named, Described, Encoded, Expression, Logical, Unique, Value, Comparable<Entity>
An entity is an
asset that represents a character, object,
place, or idea in a story world.- Author:
- Stephen G. Ware
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of this logical expression in the given state.getCode()Returns a string of1's and0's that uniquely represents this object among other objects of the same type in the same story world.booleanisPlayer()Returns true if this entity represents the player character in its story world.protected EntityReturns a new entity that is the same as this entity, except this itscodeis the given value.setDescription(String description) Returns a new asset that is the same as this asset, except that itsdescriptionis the given value.protected EntitysetID(int id) Returns a new asset that is the same as this asset, except that its ID number is the given value.substitute(Function<Object, Object> substitution) Returns a logical object identical to this one, except that its logical elements have been replaced according to the given substitution.toEntity()If this value represents anEntity, this method returns that entity; all other values are converted to {code null}.
-
Constructor Details
-
Entity
-
-
Method Details
-
compareTo
- Specified by:
compareToin interfaceComparable<Entity>
-
setID
Description copied from class:AssetReturns a new asset that is the same as this asset, except that its ID number is the given value. -
setDescription
Description copied from class:AssetReturns a new asset that is the same as this asset, except that itsdescriptionis the given value.- Specified by:
setDescriptionin classAsset- Parameters:
description- the description the new asset should have- Returns:
- an asset identical to this asset, except with the given description
-
getCode
Description copied from interface:EncodedReturns a string of1's and0'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 with0's. -
setCode
-
substitute
Description copied from interface:LogicalReturns 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:
substitutein interfaceExpression- Specified by:
substitutein interfaceLogical- Specified by:
substitutein interfaceValue- Specified by:
substitutein classAsset- 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
-
evaluate
Description copied from interface:ValueReturns the value of this logical expression in the given state.A logical value evaluates to itself.
- Specified by:
evaluatein interfaceExpression- Specified by:
evaluatein interfaceValue- Parameters:
state- a mapping of values to all of a story world's variables- Returns:
- the value of the expression in the given state
-
toEntity
-
isPlayer
public boolean isPlayer()Returns true if this entity represents the player character in its story world.By default, the entity with ID number 0 is assumed to be the player character.
- Returns:
- true if this entity represents the player character, false otherwise
-