Package parserTXT

Examples of parserTXT.Script


   */
  public static Parser geraExemplo(){
    Parser parser = new Parser();

    //512,biscoitoGengibre,biscoitoGengibre,0,50,25,1,,,,,,2,,,0,,{ itemheal 25,0; },{}
    Script uso = new Script();
    Script eqp = new Script();
    Comando cmd = new Comando();
    cmd.addToken( new Token(TipoToken.CMD, "itemheal") );
    cmd.addToken( new Token(TipoToken.NUM, "25") );
    cmd.addToken( new Token(TipoToken.NUM, "0") );
    uso.addComando(cmd);
    Object[] item1 = {"512", "biscoitoGengibre", "biscoitoGengibre" , "0", "50", "25" , "1", "", "", "", "", "", "2", "", "", "0", "", uso, eqp};

    //3046,verdadeiroTrevo,Verdadeiro Trevo,5,50000,25000,10,,,,5,0,2,8,,0,0,{},{ bonus bLuk, 10; bonus bMdef, 25; }
    uso = new Script();
    eqp = new Script();
    cmd = new Comando();
    cmd.addToken( new Token(TipoToken.CMD, "bonus") );
    cmd.addToken( new Token(TipoToken.VAR, "bLuk") );
    cmd.addToken( new Token(TipoToken.NUM, "10") );
    eqp.addComando(cmd);
    cmd = new Comando();
    cmd.addToken( new Token(TipoToken.CMD, "bonus") );
    cmd.addToken( new Token(TipoToken.VAR, "bMdef") );
    cmd.addToken( new Token(TipoToken.NUM, "25") );
    eqp.addComando(cmd);
    Object[] item2 = {"3046", "verdadeiroTrevo", "Verdadeiro Trevo", "5", "50000", "25000", "10", "", "", "", "5", "0", "2", "8", "", "0", "0", uso, eqp};

    parser.addItem(new Item(item1));
    parser.addItem(new Item(item2));

View Full Code Here


  }

  public static void tabelaItens(){
    Item item = null;
    String str = null;
    Script script = null;
    Comando cmd = null;

    //Parser itens = geraExemplo();
    Parser itens = new Parser();
    try {
      //itens.carregarItens("item_db.txt");
      itens.carregarItens("../../db/item_db.txt");
    } catch (Exception e) {
      e.printStackTrace();
    }
    int[] cols = { Item.ID, Item.NOME, Item.DESC, Item.TIPO, Item.COMP, Item.VEND, Item.USO, Item.EQP };

    out.println("| ID | NOME | DESCRICAO | TIPO | COMPRA | VENDA | USO | EQUIP |");
    itens.initIterator();
    while( itens.seProx() ) {
      item = itens.getProx();
      out.print("|");
      for(int i=0; i<cols.length; i++){

        // Quando for do tipo String:
        str = item.getColString( cols[i] );
        if( str!=null ){
          out.print(" "+str+" |");
        }

        // Quando for do tipo Script:
        script = item.getColScript( cols[i] );
        if( script!=null ){
          script.initIterator();
          while( script.seProx() ){
            cmd = script.getProx();
            if( cmd.getComando().equals("itemheal") ){
              if( !cmd.getString(1).equals("0") )
                out.print(" HP: +" +cmd.getString(1));
              if( !cmd.getString(2).equals("0") )
                out.print(" MP: +" +cmd.getString(2));
View Full Code Here

TOP

Related Classes of parserTXT.Script

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.