wyvern.kernel.player
Class PlayerGroups

java.lang.Object
  extended bywyvern.kernel.player.PlayerGroups
All Implemented Interfaces:
BuiltInCommand, Command

public class PlayerGroups
extends java.lang.Object
implements BuiltInCommand

Manages players grouping together.

Version:
1.0, Jun 5, 2001
Author:
Steve Yegge

Nested Class Summary
static class PlayerGroups.Group
          Tracks a single group.
 
Field Summary
static int FOOD_DELAY
           
 
Method Summary
 void addCommands(java.util.Map commands, CommandList list)
          Adds commands.
static boolean checkProximity(GameObject o1, GameObject o2)
          Checks if 2 players are close enough to do group commands.
 CommandEvent createEvent(CommandEvent event)
          Creates the event.
static PlayerGroups.Group createGroup(java.lang.String leader)
          Creates a group under a certain person.
 boolean disband(CommandEvent event, Commandable agent)
          Executes the "disband" command.
 boolean execute(CommandEvent event)
          Executes the event.
 boolean follow(CommandEvent event, Commandable agent)
          Executes the "follow" command.
static PlayerGroups.Group getGroup(java.lang.String name)
          Returns the group led by the passed character, if any.
static java.util.HashMap getGroups()
          Returns all the groups in the game.
static PlayerGroups getImpl()
           
 boolean group(CommandEvent event, Commandable agent)
          Executes the "group" command.
static boolean grouped(Player p1, Player p2)
          Returns true if two players are in the same group.
 boolean groupname(CommandEvent event, Commandable agent)
          Executes the "groupname" command.
 boolean groups(CommandEvent event)
          Shows what groups are currently online.
 boolean grouptell(CommandEvent event, Commandable agent)
          Executes the "grouptell" command.
 boolean knowsCommand(java.lang.String command)
          Returns true if we want to handle the command.
 boolean members(CommandEvent event, Commandable agent)
          Executes the "members" command.
 void printGroup(Commandable agent)
          Tells the agent about his/her group membership.
 boolean publish(Commandable agent, boolean publish)
          Publishes a group so other people can see it.
static void removeGroup(java.lang.String leader)
          Removes and disbands the specified group.
 boolean unfollow(CommandEvent event, Commandable agent)
          Executes the "follow" command.
 boolean ungroup(CommandEvent event, Commandable agent)
          Executes the "ungroup" command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOOD_DELAY

public static int FOOD_DELAY
Method Detail

getImpl

public static PlayerGroups getImpl()

addCommands

public void addCommands(java.util.Map commands,
                        CommandList list)
Adds commands.

Specified by:
addCommands in interface BuiltInCommand
Parameters:
commands - the map to add to
list - the command list we're registering in, from which we can derive the command agent (i.e. player or monster) and other information.

knowsCommand

public boolean knowsCommand(java.lang.String command)
Returns true if we want to handle the command.

Specified by:
knowsCommand in interface Command
Parameters:
command - the entire command string, including arguments
Returns:
true if we want to handle the command

createEvent

public CommandEvent createEvent(CommandEvent event)
Creates the event.

Specified by:
createEvent in interface Command
Parameters:
event - a "blank" CommandEvent containing only the command text and the agent who's performing the command. This initial event is created by the originator of the event (e.g. the AI or player's command preprocessor).
Returns:
a CommandEvent subclass encapsulating this command's execution parameters and state. It should copy in the fields from the passed-in event.

execute

public boolean execute(CommandEvent event)
Executes the event.

Specified by:
execute in interface Command
Parameters:
event - the CommandEvent to execute
Returns:
true if the event completed successfully, else false.

follow

public boolean follow(CommandEvent event,
                      Commandable agent)
Executes the "follow" command.


checkProximity

public static boolean checkProximity(GameObject o1,
                                     GameObject o2)
Checks if 2 players are close enough to do group commands.


unfollow

public boolean unfollow(CommandEvent event,
                        Commandable agent)
Executes the "follow" command.


group

public boolean group(CommandEvent event,
                     Commandable agent)
Executes the "group" command.


ungroup

public boolean ungroup(CommandEvent event,
                       Commandable agent)
Executes the "ungroup" command.


disband

public boolean disband(CommandEvent event,
                       Commandable agent)
Executes the "disband" command.


groupname

public boolean groupname(CommandEvent event,
                         Commandable agent)
Executes the "groupname" command.


members

public boolean members(CommandEvent event,
                       Commandable agent)
Executes the "members" command. Shows the team's current members.


grouptell

public boolean grouptell(CommandEvent event,
                         Commandable agent)
Executes the "grouptell" command.


getGroup

public static PlayerGroups.Group getGroup(java.lang.String name)
Returns the group led by the passed character, if any.

Returns:
the Group, or null if there isn't one

getGroups

public static java.util.HashMap getGroups()
Returns all the groups in the game.

Returns:
a map whose keys are group leaders, and whose values are the Group objects containing the members' names.

createGroup

public static PlayerGroups.Group createGroup(java.lang.String leader)
Creates a group under a certain person.

Parameters:
leader - the name of the person leading the group.

removeGroup

public static void removeGroup(java.lang.String leader)
Removes and disbands the specified group. Doesn't update the group property on any of the members.


printGroup

public void printGroup(Commandable agent)
Tells the agent about his/her group membership.


publish

public boolean publish(Commandable agent,
                       boolean publish)
Publishes a group so other people can see it.

Parameters:
agent - the player executing the publish command
publish - true to publish the group so others can see it

groups

public boolean groups(CommandEvent event)
Shows what groups are currently online.


grouped

public static boolean grouped(Player p1,
                              Player p2)
Returns true if two players are in the same group.