-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfield.py
More file actions
80 lines (70 loc) · 2.12 KB
/
field.py
File metadata and controls
80 lines (70 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from image import Image
from sound import Sound
from text import Text
from scoreboard import Scoreboard
##This class mostly exists for A E S T E T I C reasons
##Like cute animations, or maybe full-fledged gameplay playback.
class Field:
def __init__(self):
self.ground_image_url = 'field.png'
self.ground_image = Image(self.ground_image_url, 0, 0)
self.scoreboard = Scoreboard()
self.font = 'scoreboardfont.ttf'
self.yardline = Text("0", 360, 360, self.font, 56, (255,255,255))
self.drawables = [self.ground_image, self.yardline, self.scoreboard]
self.game_history = []
self.save_number = 0
def draw(self, DS):
for d in self.drawables:
d.draw(DS)
self.scoreboard.draw(DS)
def update(self, action):
if not action == None:
#save the game
self.game_history.append(self.scoreboard)
self.save_number+=1
if isinstance(action, int):
self.scoreboard.move_ball(action)
elif isinstance(action, str):
self.get_action(action)
self.scoreboard.update()
if self.scoreboard.yardline > 50:
self.yardline.set_text(str(100-self.scoreboard.yardline))
else:
self.yardline.set_text(str(self.scoreboard.yardline))
def undo(self):
if save_number > 0:
self.save_number -= 1
self.scoreboard = self.game_history.pop()
def get_action(self, a):
#a is for action, which poems are hard
if a == 'touchdown':
self.scoreboard.touchdown()
elif a == 'interception':
self.scoreboard.interception()
elif a == 'fumble':
self.scoreboard.fumble()
elif a == 'yellow':
self.scoreboard.yellow()
elif a == 'penalty5':
self.scoreboard.penalty(5)
elif a == 'penalty5LDL':
self.scoreboard.low_dart_penalty(5)
elif a == 'penalty10LDL':
self.scoreboard.low_dart_penalty(10)
elif a == 'breakaway2':
self.scoreboard.breakaway(2)
elif a == 'breakaway3':
self.scoreboard.breakaway(3)
elif a == 'punt':
self.scoreboard.punt()
elif a == 'kick':
self.scoreboard.kick()
elif a == 'offboard':
self.scoreboard.offboard()
elif a == 'yesgood':
self.scoreboard.yes_good()
elif a == 'nonotgood':
self.scoreboard.no_notgood()
elif a == 'undo':
self.undo()