Beispiel #1
0
  /*Moves equipment from State s and Order o to the next State */
  private void moveEquip(int s, int o) {

    Equipment movedEquip = new Equipment();
    switch (s) {
      case 1:
        movedEquip = availEquipment.get(o);
        movedEquip.state = 2;
        rentEquipment.add(movedEquip);
        availEquipment.remove(o); /*removes the actual equipment from the Arraylist */
        break;
      case 2:
        movedEquip = rentEquipment.get(o);
        movedEquip.state = 3;
        shopEquipment.add(movedEquip);
        rentEquipment.remove(movedEquip);
        break;
      case 3:
        movedEquip = shopEquipment.get(o);
        movedEquip.state = 1;
        availEquipment.add(movedEquip);
        shopEquipment.remove(movedEquip);
        break;
    }
    eraseOldShapes();
    assignShapes();
    placeEquipments();
  }
Beispiel #2
0
  /*Fills the Available state */
  private void fillAvailable(int t1, int t2, int t3) {

    /*Fill the type1 in the available state */
    for (int i = 1; i <= t1; i++) {
      Equipment e = new Equipment();
      e.state = 1;
      e.type = 1;
      e.ident = i;
      e.c = equipColor(e.type);
      availEquipment.add(e);
    }

    /*Fill the type2 in the available state */
    for (int i = 1; i <= t2; i++) {
      Equipment e = new Equipment();
      e.state = 1;
      e.type = 2;
      e.ident = i;
      e.c = equipColor(e.type);
      availEquipment.add(e);
    }

    /*Fill the type3 in the available state */
    for (int i = 1; i <= t3; i++) {
      Equipment e = new Equipment();
      e.state = 1;
      e.type = 3;
      e.ident = i;
      e.c = equipColor(e.type);
      availEquipment.add(e);
    }

    computeInitialTimes();
    assignShapes();
  }
Beispiel #3
0
 /*Creates the equipment in all states to initiate the game */
 private void fillStates(int sAvail, int sRent, int sShop) {
   int[] statesSizes = {sAvail, sRent, sShop};
   int s = 1;
   for (int stateSize : statesSizes) {
     for (int t = 1; t <= TYPES; t++) {
       for (int i = 1; i <= stateSize; i++) {
         Equipment e = new Equipment();
         e.state = s;
         e.type = t;
         int sMax =
             Math.max(
                 s - 2, 0); /*formula to make sure identifiers resume counting and stay unique */
         int sMin =
             Math.min(
                 s - 1, 1); /*formula to make sure identifiers resume counting and stay unique */
         e.ident = i + (sMin) * sAvail + (sMax) * sRent;
         e.c = equipColor(e.type);
         switch (s) {
           case 1:
             availEquipment.add(e);
             break;
           case 2:
             rentEquipment.add(e);
             break;
           case 3:
             shopEquipment.add(e);
             break;
         }
       }
     }
     s++;
   }
   computeInitialTimes();
   assignShapes();
 }