-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamescreen.py
75 lines (64 loc) · 3.19 KB
/
gamescreen.py
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
import pygame
from quit import *
from game import *
from multiplayerscreen import *
from settingsscreen import *
from gui.dialog import *
from gui.image import *
from players import *
class GameScreen(Dialog):
def __init__(self, surface, images, locations):
self.images = images
self.locations = locations
Dialog.__init__ (self, surface)
def createWidgets(self):
# Set the background
self.surface.blit(self.images['gamescreen']['background'],(0,0))
self.wm.register(Button(self.images['gamescreen']['humanvscpu'], self.images['gamescreen']['humanvscpu'],
(int(self.locations['gamescreen']['humanvscpu_x']),
int(self.locations['gamescreen']['humanvscpu_y'])),
callbacks={widget.MOUSEBUTTONUP : self.humanvscpu }
))
self.wm.register(Button(self.images['gamescreen']['multiplayer'], self.images['gamescreen']['multiplayer'],
(int(self.locations['gamescreen']['multiplayer_x']),
int(self.locations['gamescreen']['multiplayer_y'])),
callbacks={widget.MOUSEBUTTONUP : self.multiplayergame }
))
self.wm.register(Button(self.images['gamescreen']['back'], self.images['gamescreen']['back'],
(int(self.locations['gamescreen']['back_x']),
int(self.locations['gamescreen']['back_y'])),
callbacks={widget.MOUSEBUTTONUP : self.back }
))
def humanvscpu(self, trigger, event):
player1 = StrategicMinMax(self.surface, self.images, self.locations, 2)
player2 = Human(self.surface, self.images, self.locations, 2)
game = Game(self.surface, self.images, self.locations, player1, player2)
game.run()
self.surface.blit(self.images['startscreen']['background'],(0,0))
self.wm.paint(1,0)
def multiplayergame(self, trigger, event):
multiplayerscreen = MultiplayerScreen(self.surface, self.images, self.locations)
multiplayerscreen.run()
self.surface.blit(self.images['startscreen']['background'],(0,0))
self.wm.paint(1,0)
def back(self, trigger, event):
self.state = 1
return widget.DONE
def loadPlayer(self, name):
difficulty = 4 #int(self.settings.getGlobal()['game'][name+'_level'])
if self.settings.getGlobal()['game'][name+'_type'] == 'human':
player = Human(self.screen, self.images, self.settings, difficulty)
elif self.settings.getGlobal()['game'][name+'_type'] == 'strategic':
player = StrategicMinMax(self.screen, self.images, self.settings, difficulty)
elif self.settings.getGlobal()['game'][name+'_type'] == 'random':
player = RandomAI(self.screen, self.images, self.settings, difficulty)
elif self.settings.getGlobal()['game'][name+'_type'] == 'minmax':
player = MinMax(self.screen, self.images, self.settings, difficulty)
elif self.settings.getGlobal()['game'][name+'_type'] == 'weighted':
player = WeightedMinMax(self.screen, self.images, self.settings, difficulty)
else:
print "INI FILE CURRUPT: set a player type to a legal one"
print "Legal players include:"
print "human, strategic, random, minmax"
quit()
return player