Skip to content

Commit b6da3ff

Browse files
authored
Merge pull request #223 from mathsman5133/fix/3.2.1
Fix/3.2.1
2 parents 5e51714 + d56c613 commit b6da3ff

File tree

7 files changed

+36
-8
lines changed

7 files changed

+36
-8
lines changed

coc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = "3.2.0"
25+
__version__ = "3.2.1"
2626

2727
from .abc import BasePlayer, BaseClan
2828
from .clans import RankedClan, Clan

coc/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2413,7 +2413,7 @@ def get_spell(self, name: str, level: int = None, townhall: int = None) -> Optio
24132413
if not self._spell_holder.loaded:
24142414
raise RuntimeError("Spell metadata must be loaded to use this feature.")
24152415

2416-
spell = self._spell_holder.get(name)
2416+
spell = self._spell_holder.get((name, True))
24172417
if spell is None:
24182418
return None
24192419
elif level is not None:

coc/spell.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,14 @@ def _load_json(self, english_aliases, lab_to_townhall):
158158
self.item_lookup[(new_spell.name, new_spell._is_home_village)] = new_spell
159159

160160
self.loaded = True
161+
162+
def load(self, data, townhall: int, default: "Spell" = Spell, load_game_data: bool = None) -> Spell:
163+
if load_game_data is True:
164+
try:
165+
spell = self.item_lookup[(data["name"], True)]
166+
except KeyError:
167+
spell = default
168+
else:
169+
spell = default
170+
171+
return spell(data=data, townhall=townhall)

coc/utils.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,14 @@ def get_clan_games_start(time: Optional[datetime] = None) -> datetime:
390390
if time is None:
391391
time = datetime.utcnow()
392392
month = time.month
393+
year = time.year
393394
this_months_cg_end = datetime(year=time.year, month=time.month, day=28, hour=8, minute=0, second=0)
394-
if time > this_months_cg_end:
395+
if time > this_months_cg_end and month < 12:
395396
month += 1
396-
return datetime(year=time.year, month=month, day=22, hour=8, minute=0, second=0)
397+
elif time > this_months_cg_end: # we're at the end of December
398+
month = 1
399+
year += 1
400+
return datetime(year=year, month=month, day=22, hour=8, minute=0, second=0)
397401

398402

399403
def get_clan_games_end(time: Optional[datetime] = None) -> datetime:
@@ -419,10 +423,14 @@ def get_clan_games_end(time: Optional[datetime] = None) -> datetime:
419423
if time is None:
420424
time = datetime.utcnow()
421425
month = time.month
426+
year = time.year
422427
this_months_cg_end = datetime(year=time.year, month=time.month, day=28, hour=8, minute=0, second=0)
423-
if time > this_months_cg_end:
428+
if time > this_months_cg_end and month < 12:
424429
month += 1
425-
return datetime(year=time.year, month=month, day=28, hour=8, minute=0, second=0)
430+
elif time > this_months_cg_end: # we're in December
431+
month = 1
432+
year += 1
433+
return datetime(year=year, month=month, day=28, hour=8, minute=0, second=0)
426434

427435

428436
def get_raid_weekend_start(time: Optional[datetime] = None) -> datetime:

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
project = 'coc'
1616
copyright = '2022, mathsman5133'
1717
author = 'mathsman5133'
18-
release = '3.2.0'
18+
release = '3.2.1'
1919

2020
# -- General configuration ---------------------------------------------------
2121
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

docs/miscellaneous/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ Changelog
77
This page keeps a fairly detailed, human readable version
88
of what has changed, and whats new for each version of the lib.
99

10+
v3.2.1
11+
------
12+
13+
Bugs Fixed:
14+
~~~~~~~~~~~
15+
- Fixed an issue that would cause spells to not be properly looked up, breaking :func:`coc.Client.get_spell` and
16+
:attr:`Player.spells`
17+
- Fixed a month overflow issue with clan game start/end events that would occur from Dec 28th to Dec 31st
18+
1019
v3.2.0
1120
------
1221

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "coc.py"
77
authors = [{ name = "mathsman5133" }]
88
maintainers = [{ name = "majordoobie" }, { name = "MagicTheDev" }, { name = "Kuchenmampfer" },
99
{ name = "lukasthaler"}, { name = "doluk"}]
10-
version = "3.2.0"
10+
version = "3.2.1"
1111
description = "A python wrapper for the Clash of Clans API"
1212
requires-python = ">=3.7.3"
1313
readme = "README.rst"

0 commit comments

Comments
 (0)