wyvern.kernel.monsters
Class Talker.Response

java.lang.Object
  extended bywyvern.kernel.monsters.Talker.Response
Enclosing class:
Talker

public class Talker.Response
extends java.lang.Object

Keeps track of the response(s) to a given subject.


Field Summary
protected  int chance_
          Chance that a response will come back at all - only used for combat messages.
protected  boolean combat_
          "combat" means this is a combat message
protected  boolean cycle_
           
protected  int cycleIndex_
           
protected  boolean default_
          "default" means this is the default response if the topic they typed in doesn't have a match in our subject list.
protected  boolean nosubject_
          "nosubject" means they just typed "talk" or "talk to " - i.e. the first response you get if you just type "talk"
protected  boolean random_
           
protected  java.util.ArrayList replies_
           
protected  java.util.ArrayList subjects_
           
 
Constructor Summary
Talker.Response()
           
 
Method Summary
 void addCyclicResponse(java.lang.String response, boolean nosay)
          Adds a response to cycle through - responses are cycled though in the order they're added.
 void addRandomResponse(java.lang.String response, boolean nosay)
          Adds a random response to be chosen from a list.
 void addSubject(java.lang.String name)
          Adds a subject for this response.
 boolean containsReply(java.lang.String reply)
          Returns true if we have this reply in our list already.
 int getChance()
           
 java.util.List getReplies()
          Returns the list of replies for this topic; only non-null if it's random or cyclic.
 java.lang.String getResponse()
          Returns the response.
 Talker.Reply getSingleReply()
          For topics/subjects where there is only one reply, writeData() needs to get to the Reply object.
 java.util.List getSubjects()
          Returns the list of subjects for this topic.
 boolean isCombat()
           
 boolean isCyclic()
           
 boolean isDefault()
           
 boolean isNoSay(java.lang.String reply)
          Returns true if "no-say" is active for this reply.
 boolean isNoSubject()
           
 boolean isRandom()
           
 boolean removeReply(java.lang.String reply)
          Removes a reply from this Response object.
 void setChance(int chance)
          Sets the percentage chance that there will be a response.
 void setCombat()
           
 void setDefault()
           
 void setNoSay(java.lang.String reply, boolean nosay)
          Sets no-say for the given reply.
 void setNoSubject()
           
 void setResponse(java.lang.String response, boolean nosay)
          Sets the (only) response for this topic.
 java.lang.String toString()
          For debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cycleIndex_

protected int cycleIndex_

random_

protected boolean random_

cycle_

protected boolean cycle_

subjects_

protected java.util.ArrayList subjects_

replies_

protected java.util.ArrayList replies_

nosubject_

protected boolean nosubject_
"nosubject" means they just typed "talk" or "talk to " - i.e. the first response you get if you just type "talk"


default_

protected boolean default_
"default" means this is the default response if the topic they typed in doesn't have a match in our subject list.


combat_

protected boolean combat_
"combat" means this is a combat message


chance_

protected int chance_
Chance that a response will come back at all - only used for combat messages.

Constructor Detail

Talker.Response

public Talker.Response()
Method Detail

getResponse

public java.lang.String getResponse()
Returns the response. If random, chooses a random response. If cycling, cycles to next response.

Returns:
a response

setResponse

public void setResponse(java.lang.String response,
                        boolean nosay)
Sets the (only) response for this topic.

Parameters:
response - the response to add

addSubject

public void addSubject(java.lang.String name)
Adds a subject for this response. Mostly useful for reconstructing the XML from the Talker object.


getSubjects

public java.util.List getSubjects()
Returns the list of subjects for this topic.


getReplies

public java.util.List getReplies()
Returns the list of replies for this topic; only non-null if it's random or cyclic.


removeReply

public boolean removeReply(java.lang.String reply)
Removes a reply from this Response object. Could result in the response being empty.

Parameters:
reply - the reply to remove
Returns:
true if we found and removed the passed reply

containsReply

public boolean containsReply(java.lang.String reply)
Returns true if we have this reply in our list already.


isNoSay

public boolean isNoSay(java.lang.String reply)
Returns true if "no-say" is active for this reply.


setNoSay

public void setNoSay(java.lang.String reply,
                     boolean nosay)
Sets no-say for the given reply.


addRandomResponse

public void addRandomResponse(java.lang.String response,
                              boolean nosay)
Adds a random response to be chosen from a list.

Parameters:
response - the response to add

addCyclicResponse

public void addCyclicResponse(java.lang.String response,
                              boolean nosay)
Adds a response to cycle through - responses are cycled though in the order they're added.

Parameters:
response - the response to add

setChance

public void setChance(int chance)
Sets the percentage chance that there will be a response.


getChance

public int getChance()

isRandom

public boolean isRandom()

isCyclic

public boolean isCyclic()

setNoSubject

public void setNoSubject()

setDefault

public void setDefault()

setCombat

public void setCombat()

isDefault

public boolean isDefault()

isNoSubject

public boolean isNoSubject()

isCombat

public boolean isCombat()

getSingleReply

public Talker.Reply getSingleReply()
For topics/subjects where there is only one reply, writeData() needs to get to the Reply object.


toString

public java.lang.String toString()
For debugging.