/** (C) Game Page Network, Inc., Confidential, All Rights Reserved */
// TalkCommand.java
// --paul@gamepage.net, 22jul97

import java.util.*;

public class TalkCommand extends Command {
  TalkCommand() {
    super("talk", -1, null,
          "Send to TABLE members a MESSAGE*.\n"+
          "Example: talk Lobby who is the fastest player?\n"+
          "See also: whisper, shout, mute.");
  }
  public void process(StringTokenizer args, Client c) {
    Member talker = c.getMember();  

    if (args.countTokens()<2) {
      c.send("? talk");
      return;
    }
    String name = args.nextToken();
    Table table = Table.findIt(name);
    if (table==null) {  
      /// should also require current member to already be observing table
      c.send("! talk "+name+": No such table.");
      return;
    }
      
    StringBuffer buf = new StringBuffer("talk "+talker+" ");
    buf.append(args.nextToken("\0").trim()); // grab the rest of the string
    table.tell(talker,buf.toString(),Table.P2);    
  }
}

