HoN client semver
HoN uses 3 and 4 digit semantic versioning:
- major.minor.patch (e.g. 1.0.21)
- major.minor.patch.hotfix (e.g. 1.0.21.1)
Hotfix versions don't always exist for a specific patch version.
We need to define some basic functionality for fetching next version for a given one. I just hacked together a very messy way that I believe works for the next() function on SemverUtil. It takes as a parameter an exists boolean, because the next version depends on if the current version exists. For example: 1.0.1 next() is 1.0.1.0 if it exists, 1.1.0 if it doesn't. 1.0.1.0 next() is 1.0.1.1 if it exists, or 1.0.2 if it doesn't. Feel free to clean up the messy function:
def next(self, exists=True):
_items = self.items[:]
if exists:
if len(_items) == 4:
# for 4 digit semvers that exist, the next hotfix version
_items[-1] = str(int(_items[-1]) + 1)
if len(_items) == 3:
# for 3 digit semvers that exist, the first hotfix version
_items.append('0')
return self._create_semver(_items)
else:
if len(_items) == 3:
if _items[1] == '0' and _items[2] == '0':
# we ran out of versions
raise SemverException('There is no next version')
elif _items[2] == '0':
# for zero 3rd digit semvers, we probably ran out of minor
# versionsincrement major
_items[0] = str(int(_items[0]) + 1)
_items[1] = '0'
_items[2] = '0'
else:
# for non-zero 3rd digit semvers, increment 2nd digit,
# set 3rd to 0
_items[1] = str(int(_items[1]) + 1)
_items[2] = '0'
if len(_items) == 4:
# for 4 digit semvers that don't exist, remove 4th digit
# increment 3rd by 1
_items = _items[:3]
_items[-1] = str(int(_items[-1]) + 1)
return self._create_semver(_items)
HoN client semver
HoN uses 3 and 4 digit semantic versioning:
Hotfix versions don't always exist for a specific patch version.
We need to define some basic functionality for fetching next version for a given one. I just hacked together a very messy way that I believe works for the
next()function on SemverUtil. It takes as a parameter anexistsboolean, because the next version depends on if the current version exists. For example:1.0.1next() is1.0.1.0if it exists,1.1.0if it doesn't.1.0.1.0next() is1.0.1.1if it exists, or1.0.2if it doesn't. Feel free to clean up the messy function: