com.tootsville.npc
Class ShortOrderCook

java.lang.Object
  extended by org.starhope.appius.user.GeneralUser
      extended by org.starhope.appius.user.AbstractNonPlayerCharacter
          extended by com.tootsville.npc.ShortOrderCook
All Implemented Interfaces:
Serializable, Comparable<Object>, RoomListener, Collidable, HasVariables, AbstractUser, DataRecordBacked<UserRecord>, AcceptsMetronomeTicks, HasName

public class ShortOrderCook
extends AbstractNonPlayerCharacter

Short-order cook for TootsBurger as a cheap Diner Dash clone.

The TootsBurger Game

The player triggers this game by putting on their apron.

The way this game works, is that the player walks up to a ChatterBot, who will find their way to a seat (cleverly tagged, one hopes, by a “$seat” space in the room) and demand attention. The player will (one hopes) heed their calls and walk over. When they approach one of the impatient pachyderms, they'll get a demand for some food item or other. The helpful player will then walk over to the ShortOrderCook and repeat the order. If, instead, they walk over to the DinerDishWasher, he will helpfully fill them in on the rules (at a whisper, no less!).

Once the intrepid server has repeated the order, s/he can idle for a bit while the cook prepares the food. After a moment, the cook will call back the order, and the player has a window of opportunity to pick up the food from the cook.

Picking up the food on time costs the player a few peanuts (depending on the order). The cook will inform them of that cost, but gives them the food. They now have a limited time to run the food out to the patient patrons, who will cheerfully announce their pleasure and promptly pay their food, with a gratuity based upon the speed of delivery. Note that patrons count time from the time that they ordered, not when the food was ready, so a 15%-35% tip can result depending on the player's alacrity.

Failure to pick up the order in time will cost the player — they'll raise the ire of the cook, who will charge them for the spoiled food, as well as the customers, who will ask for a different server, or leave the diner altogether.

How The Cook Works

Author:
BRPocock@Star-Hope.org
See Also:
Serialized Form

Field Summary
private  int apronItem
          The apron which has to be worn to be an employee.
private static String[] cooks
           The names of some of my (BRP) personal favourite short-order diner cooks.
 String[] foods
          List of foods.
private static AtomicInteger nextID
           Provide an unique ID counter for multiple instances of the same cook character in different Zones at the same time.
private static long serialVersionUID
          WRITEME: Document this brpocock@star-hope.org
 
Fields inherited from class org.starhope.appius.user.AbstractNonPlayerCharacter
buddyList, casualSpeechQueue, casualSpeechRate, instanceID, kalendor, lastActive, lastSpoken
 
Fields inherited from class org.starhope.appius.user.GeneralUser
baseStats, collisionBounds, currentRoom, facing, lastUserMovement, pathFinder, userRecord
 
Constructor Summary
ShortOrderCook(Room diner)
           Create a short-order cook.
 
Method Summary
 void acceptObjectJoinRoom(Room room, RoomListener object)
          Notification that someone has entered the room.
 void acceptObjectPartRoom(Room room, RoomListener thing)
          Notification that someone has left a room
 void acceptOutOfBandMessage(AbstractUser sender, Room room, org.json.JSONObject body)
          Accept an out-of-band communications packet that was broadcast to a room in which this Listener is listening.
 void acceptPublicMessage(AbstractUser sender, Room room, String message)
          Accept a public chat message or /emote.
 void acceptPublicMessage(AbstractUser from, String message)
          Accept a public chat message.
 void acceptUserVariableUpdate(AbstractUser user, String varName, String varValue)
          Receive notification of the change of an user variable
 void ban(AbstractUser u, String banReason)
           
protected  int getInstanceID()
           
private  Set<AbstractUser> getWaiters()
           
 void sendEarnings(Room room, String string)
           
 void sendMigrate(AbstractZone refugeeZone)
          WRITEME: document this method (brpocock@star-hope.org, Jan 11, 2010)
 void sendWardrobe()
          WRITEME
 void tick(long currentTime, long deltaTime)
          This method is called periodically from the metronome thread.
 
Methods inherited from class org.starhope.appius.user.AbstractNonPlayerCharacter
acceptErrorReply, acceptGameAction, acceptGameStateChange, acceptMessage, acceptPrivateMessage, acceptSuccessReply, acceptUserList, addBuddy, addGiftSubscription, addItem, canTalk, destroy, doTransport, equals, getAccessibleRooms, getAvatarClass, getAvatarLabel, getBaseColor, getBuddyListNames, getDebugName, getGreeting, getIPAddress, getKickedMessage, getLag, getLanguage, getLocation, getMail, getName, getNameApprovedAt, getNameRequestedAt, getNameStripped, getPublicInfo_new, getServerThread, hashCode, inviteBuddy, isBuddy, isNPC, isOnline, isPaidMember, kick, liftBan, needsParent, reportedToModeratorBy, reportedToModeratorBy, sendOops, sendResponse, setLastActive, setMail, setParent, speak, speakCasually, toJSON, toSFSXML, toString, whenAtTarget
 
Methods inherited from class org.starhope.appius.user.GeneralUser
acceptUserAction, assertLocationUnlocked, assertStaffLevel, attend, canApproveSelf, canBetaTest, canEnterChatZone, canEnterMenuZone, changeBaseDefenses, compareTo, deleteVariable, doffClothes, getAge, getAgeGroup, getApprovedDateString, getBaseDefenses, getBaseStat, getCenterOfMass, getCollisionBounds, getCurrentAction, getD, getDialect, getDisplayName, getEffectiveDefenses, getEndMovementTime, getExtraColor, getFacing, getGameEquipItems_JSON, getGameEquipItems, getHeight, getHouse, getInventory, getItemsByType, getItemsByType, getItemsByTypeAsArray, getKickedByUserID, getKickedReasonCode, getKickedUntil, getLocationForUpdate, getMass, getMoney, getPathFinder, getPublicInfo, getRegisteredAt, getRegisteredDate, getRegisteredDateString, getRequestedName, getResponsibleMail, getRoom, getRoomNumber, getSizeScalar, getStaffLevel, getStartMovementTime, getStartT, getStat, getTarget, getTravelRate, getTravelStart, getUserID, getUserListIterator, getUserName, getUserVariables, getVariable, getVariables, getVariablesJSON, getVelocity, getWallet, getZone, handleWalkFail, hasStaffLevel, hasVariable, ignore, isActive, isApproved, isBanned, isCanceled, isKicked, local_publicInfo, purchase, removeBuddy, resetVariables, sendBuddyList, sendEarnings, sendEarnings, setAgeGroupToSystem, setBackingRecord, setBaseColor, setCanTalk, setCenterOfMass, setCurrentAction, setExtraColor, setFacing, setLocation, setRoom, setStartT, setTarget, setTravelRate, setTravelStart, setVariable, setVariable, setVariables, setVelocity, takeAttack, unlockLocation, updateWallet
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
WRITEME: Document this brpocock@star-hope.org

See Also:
Constant Field Values

foods

public final String[] foods
List of foods. Accessed by DinerDiner also. Names match emotes.


apronItem

private final int apronItem
The apron which has to be worn to be an employee.


nextID

private static AtomicInteger nextID

Provide an unique ID counter for multiple instances of the same cook character in different Zones at the same time.


cooks

private static String[] cooks

The names of some of my (BRP) personal favourite short-order diner cooks.

Constructor Detail

ShortOrderCook

public ShortOrderCook(Room diner)
               throws NotFoundException,
                      GameLogicException

Create a short-order cook. The cook's name is pseudo-randomly taken from a pool of available names, on the principle that there should definitely be more than one chef at a fine 24-hour diner like TootsBurger. The names of the characters are homages to some of my personal favourite 24-hour diner short-order cooks. (BRP)

Parameters:
diner - the TootsBurger room
Throws:
NotFoundException - WRITEME
GameLogicException - WRITEME
Method Detail

acceptObjectJoinRoom

public void acceptObjectJoinRoom(Room room,
                                 RoomListener object)
Description copied from interface: RoomListener
Notification that someone has entered the room.

Specified by:
acceptObjectJoinRoom in interface RoomListener
Overrides:
acceptObjectJoinRoom in class GeneralUser
Parameters:
room - The room
object - The thing (probably user) entering
See Also:
RoomListener.acceptObjectJoinRoom(org.starhope.appius.game.Room, org.starhope.appius.game.RoomListener)

acceptObjectPartRoom

public void acceptObjectPartRoom(Room room,
                                 RoomListener thing)
Description copied from interface: RoomListener
Notification that someone has left a room

Specified by:
acceptObjectPartRoom in interface RoomListener
Overrides:
acceptObjectPartRoom in class GeneralUser
Parameters:
room - The room
thing - The thing (probably user) departing
See Also:
RoomListener.acceptObjectPartRoom(org.starhope.appius.game.Room, org.starhope.appius.game.RoomListener)

acceptOutOfBandMessage

public void acceptOutOfBandMessage(AbstractUser sender,
                                   Room room,
                                   org.json.JSONObject body)
Description copied from interface: RoomListener
Accept an out-of-band communications packet that was broadcast to a room in which this Listener is listening.

Specified by:
acceptOutOfBandMessage in interface RoomListener
Overrides:
acceptOutOfBandMessage in class GeneralUser
Parameters:
sender - The sender of the OOB message
room - The room in which the OOB message is being broadcast
body - A JSON object containing the OOB message. The contents of this message are not constrained.
See Also:
RoomListener.acceptOutOfBandMessage(org.starhope.appius.user.AbstractUser, org.starhope.appius.game.Room, org.json.JSONObject)

acceptPublicMessage

public void acceptPublicMessage(AbstractUser sender,
                                Room room,
                                String message)
Description copied from interface: RoomListener
Accept a public chat message or /emote.

Specified by:
acceptPublicMessage in interface RoomListener
Overrides:
acceptPublicMessage in class AbstractNonPlayerCharacter
Parameters:
sender - The speaker
room - The room in which the words were spoken
message - The spoken text or /emote
See Also:
RoomListener.acceptPublicMessage(org.starhope.appius.user.AbstractUser, org.starhope.appius.game.Room, java.lang.String)

acceptPublicMessage

public void acceptPublicMessage(AbstractUser from,
                                String message)
Description copied from interface: RoomListener
Accept a public chat message. This prototype does not specify the room, on the (potentially invalid) assumption that the room listener doesn't care from which room the speech was made.

Specified by:
acceptPublicMessage in interface RoomListener
Overrides:
acceptPublicMessage in class AbstractNonPlayerCharacter
Parameters:
from - The speaker
message - The spoken text or /emote
See Also:
RoomListener.acceptPublicMessage(org.starhope.appius.user.AbstractUser, java.lang.String)

acceptUserVariableUpdate

public void acceptUserVariableUpdate(AbstractUser user,
                                     String varName,
                                     String varValue)
Description copied from interface: RoomListener
Receive notification of the change of an user variable

Specified by:
acceptUserVariableUpdate in interface RoomListener
Overrides:
acceptUserVariableUpdate in class GeneralUser
Parameters:
user - The user updating their variable
varName - The name of the variable (key)
varValue - The new value (null if unset)
See Also:
RoomListener.acceptUserVariableUpdate(org.starhope.appius.user.AbstractUser, java.lang.String, java.lang.String)

ban

public void ban(AbstractUser u,
                String banReason)
         throws PrivilegeRequiredException
Parameters:
u - WRITEME
banReason - WRITEME
Throws:
PrivilegeRequiredException - WRITEME
See Also:
AbstractUser.ban(org.starhope.appius.user.AbstractUser, java.lang.String)

getInstanceID

protected int getInstanceID()
Specified by:
getInstanceID in class AbstractNonPlayerCharacter
Returns:
An unique ID for this instance of
See Also:
AbstractNonPlayerCharacter.getInstanceID()

getWaiters

private Set<AbstractUser> getWaiters()
Returns:
The number of waiters in the room

sendEarnings

public void sendEarnings(Room room,
                         String string)
Specified by:
sendEarnings in interface AbstractUser
Overrides:
sendEarnings in class GeneralUser
Parameters:
room - WRITEME
string - WRITEME
See Also:
AbstractUser.sendEarnings(org.starhope.appius.game.Room, java.lang.String)

sendMigrate

public void sendMigrate(AbstractZone refugeeZone)
                 throws UserDeadException
Description copied from interface: AbstractUser
WRITEME: document this method (brpocock@star-hope.org, Jan 11, 2010)

Specified by:
sendMigrate in interface AbstractUser
Overrides:
sendMigrate in class AbstractNonPlayerCharacter
Parameters:
refugeeZone - WRITEME
Throws:
UserDeadException - WRITEME
See Also:
AbstractUser.sendMigrate(org.starhope.appius.types.AbstractZone)

sendWardrobe

public void sendWardrobe()
Description copied from interface: AbstractUser
WRITEME

Specified by:
sendWardrobe in interface AbstractUser
Overrides:
sendWardrobe in class GeneralUser
See Also:
AbstractUser.sendWardrobe()

tick

public void tick(long currentTime,
                 long deltaTime)
          throws UserDeadException
Description copied from interface: AcceptsMetronomeTicks
This method is called periodically from the metronome thread. To save computation, it receives both the current time since epoch in milliseconds at the start of the global tick propagation, and the delta time since the previous metronome tick.

Specified by:
tick in interface AcceptsMetronomeTicks
Overrides:
tick in class AbstractNonPlayerCharacter
Parameters:
currentTime - Time since epoch at the start of the global metronome propagation, as per System.currentTimeMillis()
deltaTime - Delta-time in milliseconds since the prior global metronome tick
Throws:
UserDeadException - if a user has died during this tick
See Also:
AcceptsMetronomeTicks.tick(long, long)