craft static method

Slot craft(
  1. int row, [
  2. int? col,
  3. int start = 1
])

used to mark a 3x3 space inside a conventional container. takes in two numbers, like Slot.inv or one number from 1-9. The start options marks the upper left.

Implementation

static Slot craft(int row, [int? col, int start = 1]) {
  var res = 0;
  if (col != null) {
    if (col > 0) res = col - 1;
    if (row > 0) res += (row - 1) * 3;
  } else {
    res = row - 1;
  }

  if (res > 5) {
    res = start + 18 + (res - 6);
  } else if (res > 2) {
    res = start + 9 + (res - 3);
  } else {
    res += start;
  }

  return Slot(slot: 'container.$res', id: res);
}