Package Stutsman.C4.net

Examples of Stutsman.C4.net.GameHandler


    //information from the server
    chatArea=boarded;
    name = n;
    //Creates a fake board until it gets the information from the server
    //This won't show up normally
    display = new ChatBoard(1,1,Color.black,Color.black,boarded);
   
    //The thread that constantly waits for input from the server
    Thread x = new Thread(new runner());
    x.start();
  }
View Full Code Here


            chatOpen=false; //Finish exploding
            return; //Have a nice day :)
          case C4Protocol.SETTINGS:
            //This actually gets the settings
            Object[] haha = C4Protocol.parseSettings(act);
            display=new ChatBoard(
              (Integer) haha[0],(Integer) haha[1],(Color) haha[2],
              (Color) haha[3],chatArea);
            fakeBoard = false;
            break;
          case C4Protocol.FAIL:
View Full Code Here

      {
        alert("Error","Server connection error");
        return;
      }
     
      chat.addClickListener(new ChatListener(service,chat));
      for(int i=0;i<theBoard.getRows();i++)
      {
        for(int j=0;j<theBoard.getCols();j++)
        {
          JButton temp =theBoard.getCellButton(i,j);
View Full Code Here

  private static JFrame frame;
  private static ChatInput chat = new ChatInput(4,30,30);
 
  public static void main(String[] args)
  {
    Client service;
    ConnectBoard theBoard;
    String a,b,d;
    int c;
    a=input("127.0.0.1","Enter the IP of the server you will connect to");
    b=input("8080","Enter the port number that you will connect to");
    c=Integer.parseInt(b);
    d=input("Player","Enter the name you want to go by on the server");
   
    while(true)
    {
      try
      {
        service = new Client(d,a,c,chat);
      } catch(UnknownHostException ex) {
        alert("Bad host","Trying to connect to unknown host.");
        return;
      } catch(IOException ex) {
        alert("Error","There has been an error");
        return;
      } catch(Exception ex) {
        alert("Error","Unknown error");
        return;
      }
     
      theBoard = service.getBoard();
      if(theBoard==null)
      {
        alert("Error","Server connection error");
        return;
      }
     
      chat.addClickListener(new ChatListener(service,chat));
      for(int i=0;i<theBoard.getRows();i++)
      {
        for(int j=0;j<theBoard.getCols();j++)
        {
          JButton temp =theBoard.getCellButton(i,j);
          temp.addActionListener(new GridFunction(i,j,service));
        }
      }
     
      setUp(theBoard,theBoard.getRows(),theBoard.getCols());
     
      service.notifyEnd();
     
      if(ask("Again?","Play again?")==1) break;
    }
  }
View Full Code Here

 
  public static void main(String[] args)
  {
    try
    {
      Server theserve;
      boolean v=false;
      int port;
      port = Integer.parseInt(input("8080","Enter port number"));
      if(ask("Logging","Enable logging?")==0)
      {
        File logfile = new File("ServerLog.txt");
        FileOutputStream fiout = new FileOutputStream(logfile,true);
        PrintStream sout = new PrintStream(fiout,true);
        System.setOut(sout);
      }
      if(ask("Default","Use default settings?")==0)
      {
        theserve = new Server(port);
      } else {
        int r,c;
        r = Integer.parseInt(input("6","Enter the number of rows"));
        c = Integer.parseInt(input("8","Enter the number of columns"));
        if(ask("Colors","Enter color settings?")==0)
        {
          Color[] cs = new Color[4];
          String type,temp;
          String[] rgb;
         
          for(int i=0;i<4;i++)
          {
            switch(i)
            {
              case 0: type = " the background "; break;
              case 1: type = " the borders "; break;
              case 2: type = " player 1 "; break;
              case 3: type = " player 2 "; break;
              default: type = " ? "; break;
            }
            temp = input("0 0 0",
                "Enter the RGB value (separated by spaces) for"+
                type);
            rgb = temp.split(" ");
            cs[i] = new Color(Integer.parseInt(rgb[0]),
                        Integer.parseInt(rgb[1]),
                        Integer.parseInt(rgb[2]));
           
          }
         
          theserve = new Server(port,r,c,cs[0],cs[1],cs[2],cs[3]);
        } else {
          theserve = new Server(port,r,c,Color.white,Color.black);
        }
      }
      theserve.run();
    } catch(IllegalArgumentException ex) {
      ex.printStackTrace();
      alert("Error","You have entered illegal settings, probably colors");
    } catch(Exception ex) {
      ex.printStackTrace();
View Full Code Here

TOP

Related Classes of Stutsman.C4.net.GameHandler

Copyright © 2018 www.massapicom. 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.