Package net.sf.arianne.marboard.client

Source Code of net.sf.arianne.marboard.client.Start

package net.sf.arianne.marboard.client;

import marauroa.client.ClientFramework;
import marauroa.common.game.AccountResult;
import marauroa.common.game.CharacterResult;
import marauroa.common.game.RPObject;
import marauroa.common.game.Result;
import net.sf.arianne.marboard.client.core.CurrentBoard;
import net.sf.arianne.marboard.client.core.MarboardClientFramework;
import net.sf.arianne.marboard.client.gui.MainWindow;

import org.apache.log4j.Logger;

/**
* starts the marboard client
*
* @author hendrik
*/
public class Start {
  private static Logger logger = Logger.getLogger(Start.class);

  /**
   * @param args command line arguments
   * @throws Exception in case of an unexpected error
   */
  public static void main(String[] args) throws Exception {
    String server = "stendhalgame.org";
    if (args.length > 0) {
      server = args[0];
    }
    String username = "testuser" + (int) (Math.random() * Integer.MAX_VALUE);
    String password = username;
   

    CurrentBoard board = new CurrentBoard();
   
    ClientFramework client = new MarboardClientFramework(board);
        client.connect(server, 4851);
       
    AccountResult account = client.createAccount(username, password, "email@mailinator.com");
    if (account.getResult() == Result.OK_CREATED) {
      client.login(username, password);
      CharacterResult character = client.createCharacter(username, new RPObject());
      logger.info("Creating character: " + character.getResult());
    } else {
      if (account.getResult() == Result.FAILED_PLAYER_EXISTS) {
        client.login(username, password);
      } else {
        logger.error(account);
      }
    }

    MainWindow mainWindow = new MainWindow(client, board);
    mainWindow.createWindow();
    logger.info("Starting client loop");

    mainWindow.loop();
    System.exit(0);
  }

}
TOP

Related Classes of net.sf.arianne.marboard.client.Start

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.