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

import java.io.*;
import java.util.*;

public class ResignCommand extends Command {
  ResignCommand() {
    super("resign", 1, "TABLE",
          "Resign the game at TABLE.");
  }
  public void process(StringTokenizer args, Client c) {
    Member current = c.getMember();  
    String name = args.nextToken();
    Table table = Table.findIt(name);
    String error = "! resign "+name;
    if (table==null) {
      c.send(error+"No such open table");
      return;
    }
    Game game = table.getGame();
    if (game==null) {
      c.send(error+"No game.");
    } else if (!game.isActive()) {
      c.send(error+"Game not active.");
    } if (!current.isPlayer(table)) {
      c.send(error+"You are not playing.");
    } else {
      table.resign(current);
    }
  }
}

