Example #1
0
  public void add(AttackUnit j) {
    // THIS IS ONLY FOR DB USAGE...
    // getAu().add(j);
    UberStatement stmt;
    try {

      stmt = con.createStatement();

      // First things first. We update the player table.
      boolean transacted = false;
      while (!transacted) {

        try {
          stmt.execute(
              "start transaction;"); // it's logged in, starts transaction so data problems won't
                                     // happen.

          // let's add this raid and therefore get the rid out of it.
          if (j.getSlot() < 6) {
            stmt.executeUpdate(
                "update raid set au"
                    + (j.getSlot() + 1)
                    + " = "
                    + j.getSize()
                    + " where rid = "
                    + raidID
                    + ";");
          } else {

            stmt.executeUpdate(
                "insert into raidSupportAU (rid,tid,tidslot,size) values ("
                    + raidID
                    + ","
                    + getTown1().townID
                    + ","
                    + j.getSlot()
                    + ","
                    + j.getSize()
                    + ");"); // don't need original slot, need
            // current town slot for remembering!

          }

          stmt.execute("commit;");
          stmt.close();
          transacted = true;
        } catch (MySQLTransactionRollbackException exc) {
          System.out.println(raidID + " is having trouble adding units.");
        }
      }
    } catch (SQLException exc) {
      exc.printStackTrace();
    }
  }
Example #2
0
  public void makeSupportRun() {
    setSupport(1);
    if (getTown2().getPlayer().ID != getTown1().getPlayer().ID && !isRaidOver()) {
      // this means all of these units need to be labeled as support units since they are foreign.
      int i = 0;
      AttackUnit a;
      while (i < getAu().size()) {
        a = getAu().get(i);
        a.makeSupportUnit(a.getSlot(), getTown1().getPlayer(), getTown1().townID);

        i++;
      }
    }
  }
Example #3
0
  public ArrayList<AttackUnit> getAu() {
    if (au == null) {
      int y = 0;

      ArrayList<AttackUnit> raidAU = new ArrayList<AttackUnit>();
      AttackUnit auHold;
      ArrayList<AttackUnit> tau = getTown1().getAu();
      while (y < 6) {
        auHold = tau.get(y).returnCopy();
        if (getSupport() == 1 && getTown1().getPlayer().ID != getTown2().getPlayer().ID) {
          auHold.makeSupportUnit(auHold.getSlot(), getTown1().getPlayer(), getTown1().townID);
        } else if (getSupport() == 2 && getTown1().getPlayer().ID != getTown2().getPlayer().ID)
          auHold.makeOffSupportUnit(auHold.getSlot(), getTown1().getPlayer(), getTown1().townID);

        auHold.setSize(getInt("au" + (y + 1)));
        raidAU.add(auHold);

        y++;
      }

      try {

        UberStatement rustown2 = con.createStatement();
        ResultSet rrs2 =
            rustown2.executeQuery(
                "select * from raidSupportAU where rid = "
                    + raidID
                    + " and tid = "
                    + getTown1().townID
                    + " order by tidslot asc");
        AttackUnit sAU;
        while (rrs2.next()) {
          int size = rrs2.getInt(4);
          // right we have what we need, we know
          // we already have a reference to town1...
          int j = 6;
          boolean found = false;
          while (j < tau.size()) {
            if (tau.get(j).getSlot() == rrs2.getInt(3)) {
              sAU = tau.get(j).returnCopy();
              // attackunits are already on town 1, so they were ported
              // here, just need sizes!
              sAU.setSize(size);
              raidAU.add(sAU);
            }
            j++;
          }
        }

        rrs2.close();
        rustown2.close();

        au = raidAU;
      } catch (SQLException exc) {
        exc.printStackTrace();
      }
    }
    return au;
  }
Example #4
0
  public void setMemSize(int index, int size) {
    if (index < 6) setInt("au" + (index + 1), size);
    else {
      try {
        UberStatement stmt = con.createStatement();
        AttackUnit a = getAu().get(index);
        stmt.executeUpdate(
            "update raidSupportAU set size = "
                + size
                + " where tidslot = "
                + a.getSlot()
                + " and rid = "
                + raidID
                + " and tid = "
                + getTown1().townID);

        stmt.close();
      } catch (SQLException exc) {
        exc.printStackTrace();
        System.out.println("Your shit is a-okay.");
      }
    }
  }