rarityValue property Null safety

int rarityValue

rarity value of worker. its an int between 0-6

Implementation

int get rarityValue {
  return {
        "common": [1, 1],
        "uncommon": [2, 2],
        "rare": [3, 3],
        "epic": [4, 4],
        "legendary": [5, 5],
        "mythic": [6, 0],
      }[rarity]?[isLeader ? 1 : 0] ??
      0;
}