Represents one Conversation that a Player would hold with an NPC.

Each Conversation has options that a Player can use the Say Command to say. Since this class implements InvokableItem, each conversation can perform one action at time of each conversation starting.

A general conversation flow goes something like this:

-> player talks to npc

-> npc conversation starts
    -> conversation onInvoke called
    -> conversation message and options displayed

-> player says an option

-> get conversation child from option
    -> conversation onInvoke called
    -> conversation message and options displayed

-> repeat until no more options or player leaves conversation



package: constructs;




Creates a new Conversation object with a blank starting message.

Conversation(String message)

Creates a new Conversation object with the starting message.


String getMessage()

Returns the starting message for this Conversation.

NPC getOwner()

Returns the NPC that owns this conversation. Used as a back reference.

int getNumOptions()

Returns the number of options for this Conversation.

ArrayList getOptions()

Returns a list of Conversation options that stem from this Conversation.

void setMessage(String message)

Sets the starting message to message

void addOption(Conversation opt)

Adds an already instantiated Conversation object opt as an option.

void addOption(String message)

Adds an option to this conversation by making a new Conversation with the message message.

void removeOption(int optionIndex)

Removes the option specified by the index optionIndex.

Throws a IndexOutOfBoundsException if the index given is greater than or equal to the number of options.

void setOwner(NPC owner)

Recursively sets the NPC owner of this Conversation and this Conversation’s Options to owner.

void startConversation()

Start this conversation by printing the message and a list of options.

void onInvoke(Player p, Map m)

Called every time a Conversation message is displayed. Usefull for when you want an NPC to perform some action after a Player has successfully engaged that NPC.

Implemented from InvokableItem

void onObtain(Player p, Map m)

Not used. Referenced only because it’s required by InvokableItem.

Implemented from InvokableItem