Conversión de un programa

Hola amigos. Sé que por aquí hay mucho programador bueno, y le querría pedir un favor...

Tengo el código fuente de un programa, (cálculo de experiencia de un juego de rol), y me interesaría poder tenerlo en el móvil. Vamos, que lo que quiero es si alguien lo puede convertir a J2ME...

El código es este:

/*  d20functions.js - Automated tools for Dungeons & Dragons and other d20
*  System games.
*  Copyright (C) 2007 Brian S. Stephan
*  version 1.1
*  Dungeons & Dragons is (C) Wizards of the Coast
*  The d20 System is the trademark of Wizards of the Coast
* ------------------------------------------------------------------------
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License along
*  with this program; if not, write to the Free Software Foundation, Inc.,
*  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
* ------------------------------------------------------------------------
* Brian S. Stephan <bssteph at incorporeal dot org>
* [url]http://www.php.net/manual/en/[/url]
*/

/* draw a new PC Level [  ] x [  ] line */
function addExpCalcPCField() {
   var par = document.getElementById('pcblock');
   
   // create a new div with the inputs, and append it to the div containing all lines
   var line = document.createElement('div');
   line.innerHTML = '<b>Nivel personaje</b> <input type="text" size="3" class="pcLevel" /> x <input type="text" size="3" class="pcMul" />';
   par.appendChild(line);
}

/* draw a new CR [  ] x [  ] line */
function addExpCalcCRField() {
   var par = document.getElementById('crblock');
   
   // create a new div with the inputs, and append it to the div containing all lines
   var line = document.createElement('div');
   line.innerHTML = '<b>Nivel desafio</b> <input type="text" size="3" class="crLevel" /> x <input type="text" size="3" class="crMul" />';
   par.appendChild(line);
}

/* hide the warning if the browser is not javascript-enabled,
* and initialize the display */
function initialize() {
   var nojs = document.getElementById('no-js');
//   nojs.setAttribute('class', 'hidden-block');
   nojs.style.display = 'none';
   if (navigator.appName != 'Microsoft Internet Explorer') {
      var rant = document.getElementById('ie-sucks-rant');
      rant.style.display = 'none';
   }
}

/* hide all displays except for the default (which is akin to a splash page) */
function showDefault() {
   // hide all divs except the default
   var children = document.getElementById('body').childNodes;
   for (var i = 0; i < children.length; i++) {
//      if (children[i].nodeType == Node.ELEMENT_NODE) {
         if (children[i].id != 'default-block') {
//            children[i].setAttribute('class', 'hidden-block');
            children[i].style.display = 'none';
         }
//      }
   }
   
   // show the default
   var def = document.getElementById('default-block');
//   def.removeAttribute('class');
   def.style.display = 'block';
}

/* hide all displays except the experience calculator */
function showExpCalc() {
   // hide all divs except the experience point calculator
   var children = document.getElementById('body').childNodes;
   for (var i = 0; i < children.length; i++) {
//      if (children[i].nodeType == Node.ELEMENT_NODE) {
         if (children[i].id != 'exp-calc-block') {
//            children[i].setAttribute('class', 'hidden-block');
            children[i].style.display = 'none';
         }
//      }
   }
   
   // show the experience point calculator
   var def = document.getElementById('exp-calc-block');
//   def.removeAttribute('class');
   def.style.display = 'block';
}

/* add both fields, to save the user on clicking */
function addExpCalcFields() {
   addExpCalcPCField();
   addExpCalcCRField();
}

/* do all of our maths. */
function doExpCalc() {
   // set up some initial arrays
   var lowLvlArray = new Array( 300, 600, 900, 1350, 1800, 2700, 3600, 5400, 7200, 10800 );
   var mulArray = new Array( 1.0, 1.5, 2.25, 3.0, 4.0, 6.0, 8.0, 12.0, 18.0, 24.0, 36.0,
                             48.0, 72.0, 96.0, 144.0 );
   
   // get the PCs
   var pcArray = new Array();
   var pcs = document.getElementById('pcblock').childNodes;
   for (var i = 0; i < pcs.length; i++) {
//      if (pcs[i].nodeType == Node.ELEMENT_NODE) {
         // each time in here is a <div> with two input fields
         var inputs = pcs[i].getElementsByTagName('input');
         
//         if (inputs[0] > 0) {
            for (var j = 0; j < inputs[1].value; j++) {
               pcArray.push(parseInt(inputs[0].value));
            }
//         }
//      }
   }
   
   // do the same for CRs
   var crArray = new Array();
   var crs = document.getElementById('crblock').childNodes;
   for (var i = 0; i < crs.length; i++) {
//      if (crs[i].nodeType == Node.ELEMENT_NODE) {
         // each time in here is a <div> with two input fields
         var inputs = crs[i].getElementsByTagName('input');
         
//         if (inputs[0] > 0) {
            for (var j = 0; j < inputs[1].value; j++) {
               crArray.push(parseInt(inputs[0].value));
            }
//         }
//      }
   }
   
   // make the start of the table for display
   var html = '<table width="100%"><caption><em>Los resultados por Nivel y desafio son</em></caption>';
   
   // make the headers
   html += '<tr><th></th>';
   for (var i = 0; i < crArray.length; i++) {
      html += '<th>CR' + crArray[i] + '</th>';
   }
   html += '<th>TOTAL</th>';
   html += '<th>EXP GRUPO</th></tr>';
   
   // show the experience for each PC
   for (var j = 0; j < pcArray.length; j++) {
      html += '<tr><th>L' + pcArray[j] + '</th>';
      
      // calculate the experience
      var totalExperience = 0;
      for (var i = 0; i < crArray.length; i++) {
         // experience for one CR
         var experience;
         
         html += '<td>';
         
         if (pcArray[j] < 4) {
            // certain low level characters have a fixed value
            experience = lowLvlArray[crArray[i] - 1];
         } else if (Math.abs(pcArray[j] - crArray[i]) < 8) {
            var base = 200 + (25*((crArray[i] - 1) - ((crArray[i] + 7) - pcArray[j])));
            experience = base;
            var multiplier = mulArray[(crArray[i] + 8 - pcArray[j]) - 1];
            experience *= multiplier;
         } else {
            experience = 0;
         }
         
         html += experience;
         html += '</td>';
         
         totalExperience += experience;
      }
      
      html += '<td>' + totalExperience + '</td>';
      html += '<td><b>' + totalExperience / pcArray.length + ' Exp</b></td></tr>';
   }
   
   // finish the table
   html += '</table>';
   
   var result = document.getElementById('expCalcResult');
   result.innerHTML = html;
}

// kate: tab-width 4; show-tabs false;


¿Puede alguien echarme una mano?
0 respuestas