Skip to content

Commit

Permalink
Reducing data kept in memory during stats generation
Browse files Browse the repository at this point in the history
  • Loading branch information
2kai2kai2 committed Aug 6, 2020
1 parent 6651880 commit 749c8d5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions EU4Bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,6 @@ async def generateImage(self) -> Image:
"""
Returns a stats Image based off the self.game data.
"""
imgFinal: Image = Image.open("src/finalTemplate.png")
mapFinal: Image = self.politicalImage.copy()
# Make the army display text

Expand All @@ -818,6 +817,7 @@ def armyDisplay(army: int):

def invertColor(color: Tuple[int, int, int]) -> Tuple[int, int, int]:
return (255 - color[0], 255 - color[1], 255 - color[2])

playerColors = {} # Formatting: (map color) = (player contrast color)
for natTag in self.game.allNations:
try:
Expand Down Expand Up @@ -856,13 +856,16 @@ def invertColor(color: Tuple[int, int, int]) -> Tuple[int, int, int]:
drawColors[playerColor].append((x, y))
except KeyError:
drawColors[playerColor] = [(x, y)]
break
finally:
break
del(pixlist)
for drawColor in drawColors:
mapDraw.point(drawColors[drawColor], drawColor)
del(drawColors)
del(playerColors)
# Start Final Img Creation
# Copy map into bottom of final image
imgFinal: Image = Image.open("src/finalTemplate.png")
imgFinal.paste(mapFinal, (0, imgFinal.size[1]-mapFinal.size[1]))
del(mapFinal)
# The top has 5632x1119
Expand Down

0 comments on commit 749c8d5

Please sign in to comment.