Exemplo n.º 1
0
  public boolean runScript() throws Exception {
    int fuel = 0;
    int org = 0;
    int equip = 0;
    int holds = Swath.ship.holds();

    // Set product amounts
    switch (m_type.getCurrentChoice()) {
      case Swath.FUEL_ORE:
        fuel = holds;
        break;
      case Swath.ORGANICS:
        org = holds;
        break;
      case Swath.EQUIPMENT:
        equip = holds;
        break;
    }

    // Loop
    while (true) {
      Land.exec(m_planet.getInteger());
      TakeLeaveProducts.exec(fuel, org, equip);
      LiftOff.exec();
      Trade.exec(-fuel, -org, -equip);
    }
  }
Exemplo n.º 2
0
  public boolean runScript() throws Exception {
    // declare the params we need
    Sector sector;
    int loop, start, totsectors, maxcycles, cycle;
    boolean activateVoids, oneWarp, twoWarp, threeWarp, fourWarp, fiveWarp, sixWarp;
    // load the start sector we picked
    start = startSector.getInteger();
    activateVoids = toggleVoid.getBoolean();
    oneWarp = oneWarps.getBoolean();
    twoWarp = twoWarps.getBoolean();
    threeWarp = threeWarps.getBoolean();
    fourWarp = fourWarps.getBoolean();
    fiveWarp = fiveWarps.getBoolean();
    sixWarp = sixWarps.getBoolean();

    // Since you can't launch an eprobe in your current sector let's adjust
    // sector # to a higher value..
    if (start == Swath.main.currSector()) start++;
    // load max cycles
    maxcycles = cycles.getInteger();
    // if user set 0 as maxcycles then set maxcycles so we
    // will run until we reaches last sector of universe.
    if (maxcycles == 0) maxcycles = Swath.main.sectors();
    // Let's set 1 for our first cycle
    cycle = 1;
    // set max size of universe.
    totsectors = Swath.main.sectors();
    // set param loop
    loop = 0;
    // start our main loop
    while (loop < 1) {
      // we got any etherprobes ???
      if (Swath.ship.etherProbes() == 0) {
        // if we are here we didn't have any. Let's check
        // if we are at SD so we can buy some..
        if (Swath.main.currSector() == Swath.main.stardock()) {
          // apparently we are at SD so let's check
          // our cash status if we can buy at least 1 eprobe
          if (Swath.you.credits() >= 3000) {
            // dock at SD got to Hardware and buy eprobes.
            SendString.exec("ps");
            WaitForText.exec("<StarDock> Where to? (?=Help)");
            SendString.exec("he");
            // here we will have future check for how many
            // probes the ship will take
            String x;
            x = WaitForText.exec("How many Probes do you want (Max");
            // we got enough credit for max load ?
            if ((Swath.you.credits() / 3000) < 20) {
              // nope we can't aford max load
              int num;
              // let's buy what we can afford.
              num = Swath.you.credits() / 3000;
              SendString.exec(+num + "\rqqi");
              WaitForText.exec("Command [TL=00:00:00]:[");
            }
            // can we buy more then max load
            if ((Swath.you.credits() / 3000) > 20) {
              // yes get max load
              SendString.exec("20\rqqi");
              WaitForText.exec("Command [TL=00:00:00]:[");
            }
          }
          // if above check failed let's quit if we
          // don't have enough cash to buy more probes.
          else {
            PrintText.exec("\nOut of cash quitting!\n");
            if (activateVoids == true) {
              // remove all our voids we set probing.
              SendString.exec("cv0\ryyq");
            }
            // quit cleanly
            return true;
          }
        }
        // ok if we where not at SD let's quit
        else {
          // since we where out of probes and not at SD time to quit
          PrintText.exec("\n No more eprobes and not at SD so I can not buy more probes\n");
          if (activateVoids == true) {
            // remove all our voids we set probing.
            SendString.exec("cv0\ryyq");
          }
          // quit cleanly
          return true;
        }
      }

      sector = Swath.getSector(start);
      if (sector.isUnexplored()) {
        // only probe sectors that got 1 warps (dead ends)
        switch (sector.warps()) {
          case 6:
            if (sixWarp == true) {
              LaunchEtherProbe.exec(start);
              // set that sector void.
              if (activateVoids == true) {
                SendString.exec("cv" + start + "\rq");
                // take a break let us get to command prompt again
                WaitForText.exec("Command [TL=");
              }
            }
            break;
          case 5:
            if (fiveWarp == true) {
              LaunchEtherProbe.exec(start);
              // set that sector void.
              if (activateVoids == true) {
                SendString.exec("cv" + start + "\rq");
                // take a break let us get to command prompt again
                WaitForText.exec("Command [TL=");
              }
            }
            break;
          case 4:
            if (fourWarp == true) {
              LaunchEtherProbe.exec(start);
              // set that sector void.
              if (activateVoids == true) {
                SendString.exec("cv" + start + "\rq");
                // take a break let us get to command prompt again
                WaitForText.exec("Command [TL=");
              }
            }
            break;
          case 3:
            if (threeWarp == true) {
              LaunchEtherProbe.exec(start);
              // set that sector void.
              if (activateVoids == true) {
                SendString.exec("cv" + start + "\rq");
                // take a break let us get to command prompt again
                WaitForText.exec("Command [TL=");
              }
            }
            break;
          case 2:
            if (twoWarp == true) {
              LaunchEtherProbe.exec(start);
              // set that sector void.
              if (activateVoids == true) {
                SendString.exec("cv" + start + "\rq");
                // take a break let us get to command prompt again
                WaitForText.exec("Command [TL=");
              }
            }
            break;
          case 1:
            if (oneWarp == true) {
              LaunchEtherProbe.exec(start);
              // set that sector void.
              if (activateVoids == true) {
                SendString.exec("cv" + start + "\rq");
                // take a break let us get to command prompt again
                WaitForText.exec("Command [TL=");
              }
            }
            break;
          default:
            break;
        }
        /*
        if (sector.warps()<= 2) {
        	// launch our therprobe
        	LaunchEtherProbe.exec(start);
        	// set that sector void.
        	if (activateVoids==true) {
        		SendString.exec("cv"+start+"\rq");
        		// take a break let us get to command prompt again
        		WaitForText.exec("Command [TL=");
        	}
        }
        // ok if we have a sector with 5 or 6 warps unexplored
        // probe it and void it.
        if (activateVoids==true) {
        	if (sector.warps()>=5) {
        		LaunchEtherProbe.exec(start);
        		SendString.exec("cv"+start+"\rq");
        		WaitForText.exec("Command [TL=");
        	}
        }
        */
      }
      // for explored sectors
      else {
        // if the sector is a 6 warp void it.. so our probes will
        // get better paths.
        if (activateVoids == true) {
          if (sector.warps() > 5) {
            SendString.exec("cv" + start + "\rq");
            WaitForText.exec("Command [TL=");
          }
        }
      }

      // add the sector counter for next sector to probe
      start++;
      // check if next sector is same as current in that case
      // we increase the value.
      if (start == Swath.main.currSector()) start++;
      // have we reached the highest sector number of the
      // universe yet ??
      if (start > totsectors) {
        // yes so let's clean the voids we have set.
        SendString.exec("cv0\ryyq");
        PrintText.exec("\nMax sectors reached quitting!\n");
        // quit cleanly
        return true;
      }
      // have we reached the max specified cycles yet ??
      if (maxcycles <= cycle) {
        // yes so let's clean the voids we have set.
        SendString.exec("cv0\ryyq");
        PrintText.exec("\nMax cycles reached quitting!\n");
        // quit cleanly
        return true;
      }
      // increase the cycle counter..
      cycle++;
      // end of while loop
    }

    // we shouldn't reach this part but just incase
    // let's put in a quit signal
    return true;
  }