-
Notifications
You must be signed in to change notification settings - Fork 4
/
switchtracker.py
69 lines (58 loc) · 3.16 KB
/
switchtracker.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
#################################################################################
## _________ ____ ________ _______ __ _____ __ __ __________ __
## / ____/ | / __ \/_ __/ / / / ___// / / / | / //_// ____/ __ \/ /
## / __/ / /| | / /_/ / / / / /_/ /\__ \/ /_/ / /| | / ,< / __/ / /_/ / /
## / /___/ ___ |/ _, _/ / / / __ /___/ / __ / ___ |/ /| |/ /___/ _, _/_/
## /_____/_/ |_/_/ |_| /_/ /_/ /_//____/_/ /_/_/ |_/_/ |_/_____/_/ |_(_)
## ___ ______________________ _____ __ ______ ________ __
## / | / ____/_ __/ ____/ __ \/ ___// / / / __ \/ ____/ //_/
## / /| | / /_ / / / __/ / /_/ /\__ \/ /_/ / / / / / / ,<
## / ___ |/ __/ / / / /___/ _, _/___/ / __ / /_/ / /___/ /| |
## /_/ |_/_/ /_/ /_____/_/ |_|/____/_/ /_/\____/\____/_/ |_|
##
## A P-ROC Project by Scott Danesi, Copyright 2013-2014
## Built on the PyProcGame Framework from Adam Preble and Gerry Stellenberg
#################################################################################
#################################################################################
## ______ ____________________ __ __________ ___ ________ __ __________
## / ___/ | / / _/_ __/ ____/ / / / /_ __/ __ \/ | / ____/ //_// ____/ __ \
## \__ \| | /| / // / / / / / / /_/ / / / / /_/ / /| |/ / / ,< / __/ / /_/ /
## ___/ /| |/ |/ // / / / / /___/ __ / / / / _, _/ ___ / /___/ /| |/ /___/ _, _/
## /____/ |__/|__/___/ /_/ \____/_/ /_/ /_/ /_/ |_/_/ |_\____/_/ |_/_____/_/ |_|
##
## This mode will be used to track all switch hits during the game. Will get
## loaded and unloaded for each ball.
#################################################################################
import procgame.game
from procgame import *
import pinproc
import locale
import logging
class SwitchTrackerMode(game.Mode):
def __init__(self, game, priority):
super(SwitchTrackerMode, self).__init__(game, priority)
##############################
#### Set Global Variables ####
##############################
self.greatharm_switchnames = []
self.ballSearchDelayTime = 15
for switch in self.game.switches.items_tagged('greatharm'):
self.greatharm_switchnames.append(switch.name)
for switch in self.greatharm_switchnames:
self.add_switch_handler(name=switch, event_type='active', delay=None, handler=self.greatharm_switch_handler)
def greatharm_switch_handler(self,sw):
self.cancel_delayed('ballSearchTimer')
self.game.utilities.set_player_stats('greatharm_switch_hits',self.game.utilities.get_player_stats('greatharm_switch_hits') + 1)
self.delay(name='ballSearchTimer',delay=self.ballSearchDelayTime,handler=self.ballSearch)
def ballSearch(self):
if self.game.utilities.get_player_stats('ball_in_play') == True:
if (self.game.trough.num_balls() == 3):
#### Something is wrong... Kick Out Ball ####
self.game.trough.launch_balls(num=1)
else:
self.game.utilities.executeBallSearch()
self.delay(name='ballSearchTimer',delay=self.ballSearchDelayTime,handler=self.ballSearch)
def mode_started(self):
pass
def mode_stopped(self):
pass