Skip to content

Commit

Permalink
add mypy check
Browse files Browse the repository at this point in the history
  • Loading branch information
oflatt committed Mar 12, 2019
1 parent 5d7cdd6 commit 3bd13db
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ random*
save0*
savebackup*

# mypy
*/.mypy_cache/*
.mypy_cache/*


# virtual env
env/*

Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ install:

script:
- python3 src/test_suite.py
- mypy src/bearly\ dancing.py

4 changes: 4 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# globals
[mypy]
ignore_missing_imports = True
2 changes: 1 addition & 1 deletion src/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dependencies = ["pygame", "numpy", "cx-Freeze"]
dependencies = ["pygame", "numpy", "cx-Freeze", "typing"]
dependencies.append("dill")

from sys import platform
Expand Down
8 changes: 5 additions & 3 deletions src/growgame/PlantNode.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from typing import List, Tuple

from DestructiveFrozenClass import DestructiveFrozenClass


class PlantNode(DestructiveFrozenClass):

def __init__(self, plantshapelist, repeatnumcircle, anglespace, children = [], anchor = (0, 0)):

# a list of PlantShape to make one petal/leaf
self.plantshapelist = plantshapelist
self.plantshapelist : List[Tuple[float, float]] = plantshapelist

# where in the plantshapelist the base of the shape is
self.anchor = anchor
self.anchor : Tuple[float, float] = anchor

# child PlantNodes
self.children = children
Expand Down
8 changes: 8 additions & 0 deletions src/growgame/crossplants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .PlantShape import PlantShape

combinenodeschance = 0.5
scalenumberchance = 0.2


def combinechildren(nodes):
Expand Down Expand Up @@ -68,6 +69,13 @@ def randnode():
newattr = combinechildren(nodes)
elif attrkey == "plantshapelist":
newattr = combineshapes(nodes)
elif type(attr) == float or type(attr) == int:
if random.random() < 0.2:
newattr = attr*random.uniform(0.5, 1.5)*random.choice((-1, 1))
if type(attr) == int:
newattr = int(attr)
else:
newattr = attr
else:
newattr = attr

Expand Down
13 changes: 8 additions & 5 deletions src/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import platform
import dill as pickle
from pygame import Rect
from typing import List


from Settings import Settings
Expand Down Expand Up @@ -104,7 +105,8 @@ def soundinit():

modes = pygame.display.list_modes()
mode = modes[0]
ratio = mode[0]/mode[1]
if not mode is None:
ratio = mode[0]/mode[1]

if sys.platform == 'win32':
import ctypes
Expand All @@ -121,8 +123,9 @@ def soundinit():

#(ctypes.windll.user32.GetSystemMetrics(0),ctypes.windll.user32.GetSystemMetrics(1))
# Set the width and height of the screen [width,height]
height = mode[1]
width = mode[0]
if not mode is None:
height = mode[1]
width = mode[0]

if testsmallp:
height = int(height/2)
Expand All @@ -145,9 +148,9 @@ def setscreen(windowmode):
# this is used so that time does not continue durng the frame that it generates the beatmap
generatingbeatmapp = False

olddirtyrects = []
olddirtyrects : List[Rect] = []
# keep track of areas of the screen to update. Blitting is done regardless of dirty rects, but when a dirtyrect is appended to this list it is updated twice- this frame and next
dirtyrects = []
dirtyrects : List[Rect] = []
#screen = pygame.Surface([height, width])

unrounded_displayscale = height*0.0025
Expand Down

0 comments on commit 3bd13db

Please sign in to comment.