示例#1
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();
  }
示例#2
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();
 }