Compare commits
217 Commits
57fc86b563
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e8e27e868 | ||
|
|
e53b8cf5e8 | ||
|
|
4b41444256 | ||
|
|
4194ef5261 | ||
|
|
d9ed478d84 | ||
|
|
ef7acb7246 | ||
|
|
a5d41ba7cb | ||
|
|
bfdae47e8b | ||
|
|
fba6bd2e99 | ||
|
|
4d4529011c | ||
|
|
d6afc37e3a | ||
|
|
67294f8160 | ||
|
|
b338964e06 | ||
|
|
1653a911bf | ||
|
|
7c0937d329 | ||
|
|
db8075016c | ||
|
|
93b5cf3465 | ||
|
|
e418fc3b9b | ||
|
|
2583f952b7 | ||
|
|
40345083f1 | ||
|
|
10c45939db | ||
|
|
2516a46072 | ||
|
|
ffb7ee58b1 | ||
|
|
db72d1c744 | ||
|
|
90428b39c7 | ||
|
|
d4026f1201 | ||
|
|
0b89d9127b | ||
|
|
f5f292e560 | ||
|
|
60add0abaa | ||
|
|
d19263de9a | ||
|
|
9582405bb0 | ||
|
|
eb9722a4c3 | ||
|
|
81d84ec507 | ||
|
|
833b62507d | ||
|
|
934cb56360 | ||
|
|
3d044940c3 | ||
|
|
050a3161e4 | ||
|
|
6cd20e34f4 | ||
|
|
ce8d374e57 | ||
|
|
69598752ed | ||
|
|
4d4d313e18 | ||
|
|
72689233e5 | ||
|
|
1c31a3b4ab | ||
|
|
724557160e | ||
|
|
149a804e29 | ||
|
|
3049be8958 | ||
|
|
b77107d60d | ||
|
|
b54f9e4261 | ||
|
|
326272289d | ||
|
|
00122949c2 | ||
|
|
9725c69118 | ||
|
|
175265be84 | ||
|
|
0dea250e44 | ||
|
|
e9e1b90c33 | ||
|
|
fb2b7c3718 | ||
|
|
ffdd522c7b | ||
|
|
bb12a2da17 | ||
|
|
6f1941f873 | ||
|
|
e12c4f60ba | ||
|
|
8869c490a5 | ||
|
|
71fb36742a | ||
|
|
1fac6b38ce | ||
|
|
be4994343c | ||
|
|
88be7391b6 | ||
|
|
0e786ac17f | ||
|
|
7dea027c6c | ||
|
|
9dfd8c5209 | ||
|
|
a0d2083b01 | ||
|
|
5fb8bb54f0 | ||
|
|
52bfa8c6fe | ||
|
|
8b15d26e10 | ||
|
|
e2c77b9b3f | ||
|
|
83e60af546 | ||
|
|
970ee916c3 | ||
|
|
1a8f482c66 | ||
|
|
a75d57f594 | ||
|
|
0ef881bb91 | ||
|
|
ca75dba340 | ||
|
|
db54f0f95c | ||
|
|
029af11f22 | ||
|
|
4da7a3110d | ||
|
|
401b3a332b | ||
|
|
73c7837e97 | ||
|
|
4af5ecb0f3 | ||
|
|
e2fc1894b5 | ||
|
|
1b13b24d89 | ||
|
|
b093454ccd | ||
|
|
b36d26ec29 | ||
|
|
66089d0d4d | ||
|
|
dfb99aaedc | ||
|
|
762cb03912 | ||
|
|
d980934216 | ||
|
|
ac4e70c0c4 | ||
|
|
13c9d54ec5 | ||
|
|
85871bdb6c | ||
|
|
26dcf03452 | ||
|
|
d07ff00cde | ||
|
|
484b0d4e25 | ||
|
|
3c28d8f41c | ||
|
|
891b8b567a | ||
|
|
0ca8367982 | ||
|
|
d8091b64de | ||
|
|
07f61b3eb7 | ||
|
|
446e83395d | ||
|
|
845ccd2eb7 | ||
|
|
a89f435313 | ||
|
|
f6c1fcc1f7 | ||
|
|
808c9bbd28 | ||
|
|
a093ec34ca | ||
|
|
4b1e911bc8 | ||
|
|
1e25576dce | ||
|
|
4c3aa016ba | ||
|
|
269e072010 | ||
|
|
3fa64a2c8a | ||
|
|
c58426b96c | ||
|
|
ee492017be | ||
|
|
e553591101 | ||
|
|
f8cd4bdeb4 | ||
|
|
7ba27978d7 | ||
|
|
3a8ee6b70c | ||
|
|
ecaafa47a3 | ||
|
|
166fb85652 | ||
|
|
bbba1bf025 | ||
|
|
17027e9411 | ||
|
|
e422a62445 | ||
|
|
f3ed0db12a | ||
|
|
d75474a3b2 | ||
|
|
ee758d770c | ||
|
|
622c067a7a | ||
|
|
e0ccc25680 | ||
|
|
5d90922c37 | ||
|
|
4bae555e0e | ||
|
|
c67cce5dcc | ||
|
|
ee95711027 | ||
|
|
4523c515f3 | ||
|
|
40e90972e4 | ||
|
|
b696f30463 | ||
|
|
99e2307f09 | ||
|
|
5571c2b52a | ||
|
|
fe826568b8 | ||
|
|
50e6832811 | ||
|
|
54430116be | ||
|
|
d2e30aed7b | ||
|
|
4416c052ef | ||
|
|
05a8020689 | ||
|
|
33a0fd931a | ||
|
|
782f3ebd56 | ||
|
|
06f3f76257 | ||
|
|
8f28dc2143 | ||
|
|
5db0d3f03d | ||
|
|
414b5bbb38 | ||
|
|
a82e923b64 | ||
|
|
e9faf5b4a3 | ||
|
|
f376038c83 | ||
|
|
91347e49a2 | ||
|
|
3185efd0c6 | ||
|
|
b362442bb8 | ||
|
|
4c2b4f310e | ||
|
|
394f764961 | ||
|
|
9b1c994b44 | ||
|
|
cfdcbcb5bd | ||
|
|
3d2008dc4d | ||
|
|
65873496f6 | ||
|
|
23021a1298 | ||
|
|
f64bf4a50f | ||
|
|
7eda32415b | ||
|
|
63db921e2d | ||
|
|
b79ff6e2b9 | ||
|
|
a6ffaaa48a | ||
|
|
b726998d5f | ||
|
|
7852ba2cda | ||
|
|
c1aedcf424 | ||
|
|
40ca25188c | ||
|
|
3e21c98862 | ||
|
|
c29c46f755 | ||
|
|
e03d0e7aa5 | ||
|
|
83cb1c26b4 | ||
|
|
267736a7d9 | ||
|
|
37a6438c95 | ||
|
|
beaa4aab99 | ||
|
|
76ee172fbc | ||
|
|
d4cd779ba5 | ||
|
|
195752c936 | ||
|
|
22731d2673 | ||
|
|
990afc1e19 | ||
|
|
a1520884ee | ||
|
|
ea01669563 | ||
|
|
bc7550473c | ||
|
|
0956732d62 | ||
|
|
20b472b82c | ||
|
|
3a11b92503 | ||
|
|
d383ce8ec3 | ||
|
|
934d732c4c | ||
|
|
ca6c9368c3 | ||
|
|
fb870cdec9 | ||
|
|
ea4cee05c4 | ||
|
|
0dccf2288b | ||
|
|
68dc6ecf3e | ||
|
|
ca4430e1b7 | ||
|
|
18b8e4afda | ||
|
|
63d7777d8e | ||
|
|
302b1e35ba | ||
|
|
14b42b8f5a | ||
|
|
17f46eb36e | ||
|
|
fc271b74d4 | ||
|
|
009caaa414 | ||
|
|
3e2c59741a | ||
|
|
807438af7d | ||
|
|
e356105bc2 | ||
|
|
d860e22ad8 | ||
|
|
5f19119aef | ||
|
|
ff5d9d4dfa | ||
|
|
ae93fd81f2 | ||
|
|
53e985379a | ||
|
|
5b42a2ba63 | ||
|
|
05c26080ab | ||
|
|
011ff20365 |
4
Bank.py
4
Bank.py
@@ -11,11 +11,11 @@ class Bank(Target):
|
||||
self.__all_targets_hit__()
|
||||
|
||||
def __all_targets_hit__(self):
|
||||
self.__reset_all_targets__()
|
||||
self.reset()
|
||||
super().hit()
|
||||
pass
|
||||
|
||||
def __reset_all_targets__(self):
|
||||
def reset(self):
|
||||
for target in self.targets:
|
||||
target.reset()
|
||||
|
||||
|
||||
@@ -6,9 +6,11 @@ class BankTarget(Target):
|
||||
self.is_hit = False
|
||||
|
||||
def hit(self):
|
||||
if self.is_hit:
|
||||
return
|
||||
|
||||
self.is_hit = True
|
||||
super().hit()
|
||||
#notify Bank
|
||||
|
||||
def reset(self):
|
||||
self.is_hit = False
|
||||
9
Game.py
9
Game.py
@@ -1,6 +1,8 @@
|
||||
import asyncio
|
||||
import signal
|
||||
import logging
|
||||
import sys
|
||||
|
||||
|
||||
class Game:
|
||||
def __init__(self, input_handler, events, game_state):
|
||||
@@ -9,17 +11,16 @@ class Game:
|
||||
self.game_state = game_state
|
||||
signal.signal(signal.SIGINT, self.interrupt)
|
||||
self.is_running = asyncio.Condition()
|
||||
pass
|
||||
|
||||
def interrupt(self):
|
||||
def interrupt(self, _, __):
|
||||
logging.info('Received SIGINT. Stopping Game :-)')
|
||||
self.is_running.release()
|
||||
sys.exit(0)
|
||||
|
||||
async def run(self):
|
||||
logging.info('Starting game')
|
||||
|
||||
await self.is_running.acquire()
|
||||
|
||||
await self.input_handler.handleInputs()
|
||||
|
||||
await self.is_running.wait()
|
||||
pass
|
||||
|
||||
168
GameState.py
168
GameState.py
@@ -1,21 +1,165 @@
|
||||
import logging
|
||||
|
||||
import config
|
||||
from lamps.Lamp import CREDIT
|
||||
from itertools import cycle
|
||||
from lamps.LampGroup import *
|
||||
import asyncio
|
||||
import threading
|
||||
from Sound import Sound
|
||||
from sounds.YoureChamp import YoureChamp
|
||||
from sounds.YoureGood import YoureGood
|
||||
|
||||
class GameState:
|
||||
def __init__(self, players, highscore, currentPlayerID = 0):
|
||||
self.players = players
|
||||
self.currentPlayerID = currentPlayerID
|
||||
playerCount = 0
|
||||
players = None
|
||||
playerList = []
|
||||
credits = config.BALLS_PER_GAME
|
||||
isPlaying = False
|
||||
isStarted = False
|
||||
isIdle = True
|
||||
idleThread = None
|
||||
|
||||
def __init__(self, playerStateFactory, highscore, specialDisplay, currentPlayerID = 0):
|
||||
CREDIT.activate()
|
||||
self.highscore = highscore
|
||||
self.playerStateFactory = playerStateFactory
|
||||
self.dummyPlayer = playerStateFactory.createDummyPlayerState()
|
||||
self._currentPlayer = self.dummyPlayer
|
||||
self.gameStateID = currentPlayerID
|
||||
self.highscore = highscore
|
||||
self.specialDisplay = specialDisplay
|
||||
self.specialDisplay.printCredits(self.credits)
|
||||
self.startIdleLoop()
|
||||
|
||||
def nextPlayer(self):
|
||||
if not self.isStarted:
|
||||
return
|
||||
|
||||
self.checkHighscore()
|
||||
self.currentPlayer = next(self.players)
|
||||
Lamp("Highest Score").deactivate()
|
||||
if self.currentPlayer.hasHighscore:
|
||||
Lamp("Highest Score").activate()
|
||||
|
||||
def checkHighscore(self):
|
||||
highestScorePlayer = None
|
||||
|
||||
for player in self.playerList:
|
||||
if player.points > self.highscore:
|
||||
if not highestScorePlayer:
|
||||
highestScorePlayer = player
|
||||
else:
|
||||
if highestScorePlayer.points < player.points:
|
||||
highestScorePlayer = player
|
||||
|
||||
if highestScorePlayer:
|
||||
self.highscore = highestScorePlayer.points
|
||||
for player in self.playerList:
|
||||
player.hasHighscore = False
|
||||
highestScorePlayer.hasHighscore = True
|
||||
logging.info("New Highscore from Player" + str(highestScorePlayer.id))
|
||||
|
||||
def startGame(self, playerCount):
|
||||
self.isStarted = True
|
||||
self.createPlayers(playerCount)
|
||||
self.nextPlayer()
|
||||
#self.isPlaying = True
|
||||
logging.info("Game Started")
|
||||
|
||||
def endGame(self):
|
||||
for player in self.playerList:
|
||||
if player.hasHighscore:
|
||||
YoureChamp().play()
|
||||
|
||||
self.checkHighscore()
|
||||
self.writeHighscore()
|
||||
self.players = None
|
||||
self.playerList = []
|
||||
self.playerCount = 0
|
||||
self._currentPlayer = self.dummyPlayer
|
||||
self.isPlaying = False
|
||||
self.isStarted = False
|
||||
|
||||
logging.info("Game ended")
|
||||
self.startIdleLoop()
|
||||
|
||||
def startIdleLoop(self):
|
||||
logging.info("Starting Idle Loop")
|
||||
|
||||
for display in self.playerStateFactory.displays:
|
||||
display.printScore(self.highscore)
|
||||
|
||||
self.playerStateFactory.specialDisplay.printContent("00000000")
|
||||
|
||||
PLAYER_LAMPS.deactivate()
|
||||
self.isIdle = True
|
||||
self.idleThread = threading.Thread(target=self.idleLoop)
|
||||
self.idleThread.start()
|
||||
|
||||
def stopIdleLoop(self):
|
||||
logging.info("Stopping Idle Loop")
|
||||
self.isIdle = False
|
||||
self.idleThread.join()
|
||||
self.idleThread = None
|
||||
self.deactivate_all()
|
||||
|
||||
def deactivate_all(self):
|
||||
all_cabinet_lamps = [BONUS_LAMPS, BONUS_MULTIPLIER_LAMPS, CHAMP_LAMPS,
|
||||
UPPER_PLAYFIELD_TIME_LAMPS, TUNNEL_NUMBER_LAMPS,
|
||||
TUNNEL_LAMPS, TUNNEL_SCORE_LAMPS]
|
||||
for lamp_group in all_cabinet_lamps:
|
||||
lamp_group.deactivate()
|
||||
|
||||
def idleLoop(self):
|
||||
all_cabinet_lamps = [BONUS_LAMPS, BONUS_MULTIPLIER_LAMPS, CHAMP_LAMPS,
|
||||
UPPER_PLAYFIELD_TIME_LAMPS, TUNNEL_NUMBER_LAMPS,
|
||||
TUNNEL_LAMPS, TUNNEL_SCORE_LAMPS, ORANGE_SPECIAL_LAMPS]
|
||||
|
||||
YoureGood().play()
|
||||
|
||||
while True:
|
||||
for _ in range(20):
|
||||
random_group = random.choice(all_cabinet_lamps)
|
||||
random_group.toggleRandom(0.2)
|
||||
if not self.isIdle:
|
||||
return
|
||||
|
||||
for lamps in all_cabinet_lamps:
|
||||
for lamp in lamps.lamps:
|
||||
lamp.activate()
|
||||
if not self.isIdle:
|
||||
return
|
||||
time.sleep(0.1)
|
||||
self.deactivate_all()
|
||||
|
||||
def createPlayers(self, playerCount):
|
||||
self.playerCount = playerCount
|
||||
players = []
|
||||
for i in range(playerCount):
|
||||
player = self.playerStateFactory.createPlayerState(i)
|
||||
players.append(player)
|
||||
self.playerList = players
|
||||
self.players = cycle(players)
|
||||
|
||||
@property
|
||||
def currentPlayer(self):
|
||||
return self.players[self.currentPlayerID]
|
||||
return self._currentPlayer
|
||||
|
||||
def setCurrentPlayer(self, playerId):
|
||||
if(playerId > len(self.players)):
|
||||
pass # todo throw error
|
||||
@currentPlayer.setter
|
||||
def currentPlayer(self, player):
|
||||
logging.info("Set active player to player " + str(player.id))
|
||||
|
||||
logging.info("Set active player to player " + str(playerId))
|
||||
self._currentPlayer = self.dummyPlayer
|
||||
|
||||
savedPlayer = self.players[0]
|
||||
self.players[0] = next(filter(lambda x: playerId == x.id, self.players))
|
||||
self.players.remove(savedPlayer)
|
||||
self.players.append(savedPlayer)
|
||||
player.activate()
|
||||
|
||||
self._currentPlayer = player
|
||||
|
||||
def writeHighscore(self):
|
||||
for player in self.playerList:
|
||||
if player.hasHighscore:
|
||||
with open(config.HIGHSCORE_FILE, "w+") as file:
|
||||
file.write(str(player.points))
|
||||
file.close()
|
||||
self.highscore = player.points
|
||||
@@ -8,9 +8,13 @@ class InputHandler:
|
||||
|
||||
async def handleInputs(self):
|
||||
self.isRunning = True
|
||||
|
||||
while self.isRunning:
|
||||
event = await networking.getInputEvent()
|
||||
self.targets[event["name"]].hit() #Todo
|
||||
try:
|
||||
self.targets[event["name"]].hit() #Todo
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def stop(self):
|
||||
self.isRunning = False
|
||||
|
||||
674
LICENSE
Normal file
674
LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
259
PlayerState.py
259
PlayerState.py
@@ -2,30 +2,63 @@ from threading import Timer
|
||||
from utils.RepeatTimer import RepeatTimer
|
||||
import time
|
||||
import random
|
||||
|
||||
import logging
|
||||
import config
|
||||
|
||||
from lamps.Lamp import Lamp
|
||||
from lamps.Lamp import SHOOT_AGAIN
|
||||
from lamps.LampGroup import CHAMP_LAMPS
|
||||
from lamps.LampGroup import UPPER_PLAYFIELD_TIME_LAMPS
|
||||
from lamps.LampGroup import TUNNEL_NUMBER_LAMPS
|
||||
from lamps.LampGroup import TUNNEL_LAMPS
|
||||
from lamps.LampGroup import TUNNEL_SCORE_LAMPS
|
||||
from lamps.LampGroup import BONUS_MULTIPLIER_LAMPS
|
||||
from lamps.LampGroup import BONUS_LAMPS
|
||||
from lamps.LampGroup import PLAYER_LAMPS
|
||||
from lamps.LampGroup import ORANGE_SPECIAL_LAMPS
|
||||
|
||||
from Sound import Sound
|
||||
|
||||
from events.LeaveUpperPlayfieldEvent import LeaveUpperPlayfieldEvent
|
||||
from solenoids.BottomLeftBankSolenoid import BottomLeftBankSolenoid
|
||||
from solenoids.BottomRightBankSolenoid import BottomRightBankSolenoid
|
||||
from solenoids.TopCentralBankSolenoid import TopCentralBankSolenoid
|
||||
|
||||
from solenoids.MainFlipper import MainFlipper
|
||||
|
||||
TUNNEL_SCORES = [20000, 30000, 50000]
|
||||
BONUS_MULTIPLIER = [1, 10, 20, 50]
|
||||
UPPER_PLAYFIELD_TIME = [5, 10, 20, 30]
|
||||
|
||||
class PlayerState:
|
||||
display = None
|
||||
specialDisplay = None
|
||||
id = 0
|
||||
points = 0
|
||||
_points = 0
|
||||
@property
|
||||
def points(self):
|
||||
return self._points
|
||||
|
||||
@points.setter
|
||||
def points(self, points):
|
||||
self._points = points
|
||||
self.display.printScore(self.points)
|
||||
|
||||
bonus = 0
|
||||
bonusMultiplierIter = iter(BONUS_MULTIPLIER)
|
||||
bonusMultiplier = 1
|
||||
tunnelScoreIter = iter(TUNNEL_SCORES)
|
||||
tunnelScore = 0
|
||||
tunnelLit = 0
|
||||
ballsLeft = 0
|
||||
replayBall = False
|
||||
hasBallScored = False
|
||||
isActive = False
|
||||
hasHighscore = False
|
||||
|
||||
redSpecial = 0
|
||||
redSpecialLit = False
|
||||
|
||||
orangeSpecial = 0
|
||||
orangeSpecialLeft = False
|
||||
orangeSpecialRight = False
|
||||
orangeSpecialLit = False
|
||||
@@ -36,9 +69,15 @@ class PlayerState:
|
||||
timeAdvanceRightTimer = None
|
||||
|
||||
upperPlayfieldTimer = None
|
||||
upperPlayfieldTimeIter = iter(UPPER_PLAYFIELD_TIME)
|
||||
upperPlayfieldTime = 0
|
||||
|
||||
def __init__(self, display, specialDisplay, id, ballsToPlay):
|
||||
replayBall = False
|
||||
bonusTime = config.BEGINNING_BONUS_TIME
|
||||
replayBallTimer = None
|
||||
|
||||
def __init__(self, display, specialDisplay, id, ballsToPlay, banks):
|
||||
self.banks = banks
|
||||
self.display = display
|
||||
self.specialDisplay = specialDisplay
|
||||
self.id = id
|
||||
@@ -47,9 +86,18 @@ class PlayerState:
|
||||
|
||||
self.enableTiming()
|
||||
|
||||
self.bonusTime = config.BEGINNING_BONUS_TIME
|
||||
self.printSpecial()
|
||||
|
||||
self.reset()
|
||||
def activate(self):
|
||||
self.isActive = False
|
||||
self.resetBall()
|
||||
PLAYER_LAMPS.deactivate()
|
||||
PLAYER_LAMPS.activate_one(self.id)
|
||||
time.sleep(config.WAIT_TIME_TO_RESET_SECONDS)
|
||||
self.isActive = True
|
||||
|
||||
def deactivate(self):
|
||||
self.isActive = False
|
||||
|
||||
def enableTiming(self):
|
||||
if config.BONUS_TIME_ALGORITHM == config.BONUS_TIME_ALGORITHM_OPTIONS.RANDOM:
|
||||
@@ -102,21 +150,36 @@ class PlayerState:
|
||||
Lamp("Right Advance Time").deactivate()
|
||||
|
||||
def reset(self):
|
||||
self.resetBall()
|
||||
self.points = 0
|
||||
|
||||
def resetBall(self):
|
||||
self.resetBanks()
|
||||
self.resetTargets()
|
||||
self.printSpecial()
|
||||
self.upperPlayfieldTimeIter = iter(UPPER_PLAYFIELD_TIME)
|
||||
self.upperPlayfieldTime = next(self.upperPlayfieldTimeIter)
|
||||
self.upperPlayfieldTimer = None
|
||||
UPPER_PLAYFIELD_TIME_LAMPS.activateNext()
|
||||
|
||||
self.replayBall = False
|
||||
self.upperPlayfieldTime = config.BEGINNING_UPPER_PLAYFIELD_TIME
|
||||
self.hasBallScored = False
|
||||
SHOOT_AGAIN.activate()
|
||||
|
||||
self.resetBonus()
|
||||
self.resetTargets()
|
||||
|
||||
def resetBonus(self):
|
||||
self.bonus = 0
|
||||
self.bonusMultiplier = 1
|
||||
self.bonusMultiplierIter = iter(BONUS_MULTIPLIER)
|
||||
self.bonusMultiplier = next(self.bonusMultiplierIter)
|
||||
BONUS_LAMPS.deactivate()
|
||||
BONUS_MULTIPLIER_LAMPS.deactivate()
|
||||
|
||||
def resetTargets(self):
|
||||
self.resetBanks()
|
||||
self.resetRedSpecial()
|
||||
ORANGE_SPECIAL_LAMPS.deactivate()
|
||||
ORANGE_SPECIAL_LAMPS.activateNext()
|
||||
self.resetOrangeSpecial()
|
||||
self.resetTunnel()
|
||||
|
||||
@@ -133,13 +196,34 @@ class PlayerState:
|
||||
Lamp("Special Orange").deactivate()
|
||||
|
||||
def resetTunnel(self):
|
||||
self.tunnelScoreIter = iter(TUNNEL_SCORES)
|
||||
self.tunnelScore = next(self.tunnelScoreIter)
|
||||
self.tunnelLit = 0
|
||||
TUNNEL_SCORE_LAMPS.deactivate()
|
||||
TUNNEL_SCORE_LAMPS.activateNext()
|
||||
TUNNEL_LAMPS.deactivate()
|
||||
|
||||
def resetBanks(self):
|
||||
for bank in self.banks:
|
||||
bank.reset()
|
||||
|
||||
BottomRightBankSolenoid().trigger()
|
||||
BottomLeftBankSolenoid().trigger()
|
||||
TopCentralBankSolenoid().trigger()
|
||||
|
||||
def printSpecial(self):
|
||||
self.specialDisplay.printBallsToPlay(self.ballsLeft)
|
||||
self.specialDisplay.printGameTimeBonus(self.bonusTime)
|
||||
|
||||
def advanceRightOrangeSpecial(self):
|
||||
if not self.isActive:
|
||||
return
|
||||
self.orangeSpecialRight = True
|
||||
self.setOrangeSpecialLit()
|
||||
|
||||
def advanceLeftOrangeSpecial(self):
|
||||
if not self.isActive:
|
||||
return
|
||||
self.orangeSpecialLeft = True
|
||||
self.setOrangeSpecialLit()
|
||||
|
||||
@@ -150,22 +234,66 @@ class PlayerState:
|
||||
self.orangeSpecialLit = self.orangeSpecialRight and self.orangeSpecialLeft
|
||||
|
||||
if self.orangeSpecialLit:
|
||||
self.orangeSpecial += 1
|
||||
ORANGE_SPECIAL_LAMPS.activateNext()
|
||||
|
||||
if self.orangeSpecial > 2:
|
||||
self.orangeSpecial = 0
|
||||
ORANGE_SPECIAL_LAMPS.deactivate()
|
||||
ORANGE_SPECIAL_LAMPS.activateNext()
|
||||
|
||||
Sound(21).play()
|
||||
time.sleep(0.9)
|
||||
Sound(20).play()
|
||||
Lamp("Special Orange").activate()
|
||||
|
||||
|
||||
def advanceRedSpecial(self):
|
||||
if not self.isActive:
|
||||
return
|
||||
|
||||
self.redSpecial += 1
|
||||
CHAMP_LAMPS.activateNext()
|
||||
|
||||
if(self.redSpecial == config.RED_SPECIAL_TIMES):
|
||||
if self.redSpecial == config.RED_SPECIAL_TIMES:
|
||||
Sound(21).play()
|
||||
time.sleep(0.9)
|
||||
Sound(23).play()
|
||||
self.redSpecialLit = True
|
||||
Lamp("Special Red").activate()
|
||||
|
||||
def advanceTunnelScore(self):
|
||||
if not self.isActive:
|
||||
return
|
||||
|
||||
try:
|
||||
self.tunnelScore = next(self.tunnelScoreIter)
|
||||
TUNNEL_SCORE_LAMPS.deactivateCurrent()
|
||||
TUNNEL_SCORE_LAMPS.currentLampPtr += 1 # dirty
|
||||
TUNNEL_SCORE_LAMPS.activateNext()
|
||||
except StopIteration:
|
||||
self.advanceBonusMultiplier()
|
||||
self.tunnelScore = iter(TUNNEL_SCORES)
|
||||
self.tunnelScore = next(self.tunnelScoreIter)
|
||||
TUNNEL_SCORE_LAMPS.deactivate()
|
||||
TUNNEL_SCORE_LAMPS.activateNext()
|
||||
|
||||
def advanceTunnel(self):
|
||||
if self.tunnelLit <= 5:
|
||||
self.tunnelLit += 1
|
||||
if not self.isActive:
|
||||
return
|
||||
|
||||
if self.tunnelLit == 5:
|
||||
self.advanceTunnelScore()
|
||||
TUNNEL_LAMPS.deactivate()
|
||||
TUNNEL_NUMBER_LAMPS.deactivate()
|
||||
return
|
||||
|
||||
self.tunnelLit += 1
|
||||
TUNNEL_LAMPS.activateNext()
|
||||
TUNNEL_NUMBER_LAMPS.activateNext()
|
||||
|
||||
def advanceBonus(self):
|
||||
if not self.isActive:
|
||||
return
|
||||
if self.bonus >= 20:
|
||||
return
|
||||
|
||||
@@ -173,26 +301,66 @@ class PlayerState:
|
||||
BONUS_LAMPS.activateNext()
|
||||
|
||||
def advanceBonusMultiplier(self):
|
||||
if self.bonusMultiplier >= 15:
|
||||
if not self.isActive:
|
||||
return
|
||||
|
||||
if self.bonusMultiplier == 1:
|
||||
self.bonusMultiplier = 10
|
||||
elif self.bonusMultiplier == 10:
|
||||
self.bonusMultiplier = 20
|
||||
elif self.bonusMultiplier == 20:
|
||||
self.bonusMultiplier == 50
|
||||
|
||||
BONUS_MULTIPLIER_LAMPS.activateNext()
|
||||
try:
|
||||
self.bonusMultiplier = next(self.bonusMultiplierIter)
|
||||
BONUS_MULTIPLIER_LAMPS.activateNext()
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
def setReplayBall(self):
|
||||
self.replayBall = True
|
||||
if not self.isActive:
|
||||
return
|
||||
|
||||
if self.ballsLeft == 0 and self.bonusTime != 0:
|
||||
self.replayBall = True
|
||||
SHOOT_AGAIN.activate()
|
||||
if self.replayBallTimer != None:
|
||||
self.replayBallTimer.cancel()
|
||||
self.replayBallTimer = Timer(interval=1, function=self.updateReplayBall)
|
||||
self.replayBallTimer.start()
|
||||
|
||||
def updateReplayBall(self):
|
||||
self.bonusTime -= 1
|
||||
self.printSpecial()
|
||||
|
||||
if self.bonusTime == 5:
|
||||
Sound(28).play()
|
||||
|
||||
if self.bonusTime == 0:
|
||||
self.stopReplayBall()
|
||||
return
|
||||
|
||||
self.replayBallTimer = Timer(interval=1, function=self.updateReplayBall)
|
||||
self.replayBallTimer.start()
|
||||
|
||||
def stopReplayBall(self):
|
||||
if not self.isActive:
|
||||
return
|
||||
|
||||
self.replayBall = False
|
||||
self.replayBallTimer = None
|
||||
SHOOT_AGAIN.deactivate()
|
||||
MainFlipper().deactivate()
|
||||
|
||||
def addPoints(self, points):
|
||||
if points == 0:
|
||||
return
|
||||
|
||||
if not self.isActive:
|
||||
return
|
||||
|
||||
if not self.hasBallScored:
|
||||
SHOOT_AGAIN.deactivate()
|
||||
self.hasBallScored = True
|
||||
|
||||
self.points += points
|
||||
self.display.printScore(self.points)
|
||||
|
||||
def addBall(self):
|
||||
if not self.isActive:
|
||||
return
|
||||
self.ballsLeft += 1
|
||||
self.specialDisplay.printBallsToPlay(self.ballsLeft)
|
||||
|
||||
@@ -204,32 +372,39 @@ class PlayerState:
|
||||
self.specialDisplay.printBallsToPlay(self.ballsLeft)
|
||||
|
||||
def advanceUpperPlayfieldTime(self):
|
||||
if self.upperPlayfieldTime == 0:
|
||||
self.upperPlayfieldTime = 5
|
||||
elif self.upperPlayfieldTime == 5:
|
||||
self.upperPlayfieldTime = 10
|
||||
elif self.upperPlayfieldTime == 10:
|
||||
self.upperPlayfieldTime = 20
|
||||
elif self.upperPlayfieldTime == 20:
|
||||
self.upperPlayfieldTime = 30
|
||||
|
||||
UPPER_PLAYFIELD_TIME_LAMPS.activateNext()
|
||||
if not self.isActive:
|
||||
return
|
||||
try:
|
||||
self.upperPlayfieldTime = next(self.upperPlayfieldTimeIter)
|
||||
UPPER_PLAYFIELD_TIME_LAMPS.activateNext()
|
||||
except StopIteration:
|
||||
pass
|
||||
|
||||
def startUpperPlayfieldTimer(self):
|
||||
self.upperPlayfieldTimer = Timer(1, self.updatePlayfieldTime)
|
||||
logging.info("Started Upper Playfield Timer")
|
||||
self.upperPlayfieldTimer = Timer(interval=5, function=self.updatePlayfieldTime)
|
||||
self.upperPlayfieldTimer.start()
|
||||
|
||||
def updatePlayfieldTime(self):
|
||||
if self.upperPlayfieldTime == 0:
|
||||
self.upperPlayfieldTimer = None
|
||||
LeaveUpperPlayfieldEvent(self, )
|
||||
return
|
||||
|
||||
if self.upperPlayfieldTime == 5:
|
||||
Sound(28).play()
|
||||
if self.upperPlayfieldTime in [0, 5, 10, 20]:
|
||||
UPPER_PLAYFIELD_TIME_LAMPS.deactivateCurrent()
|
||||
|
||||
self.upperPlayfieldTime -= 1
|
||||
self.upperPlayfieldTimer = Timer(1, self.updatePlayfieldTime)
|
||||
if self.upperPlayfieldTime == 0:
|
||||
self.upperPlayfieldTimer = None
|
||||
LeaveUpperPlayfieldEvent(self).trigger(None)
|
||||
logging.info("Stopped Upper Playfield Timer")
|
||||
return
|
||||
|
||||
self.upperPlayfieldTime -= 5
|
||||
logging.info("Playfield time left: " + str(self.upperPlayfieldTime))
|
||||
self.upperPlayfieldTimer = Timer(interval=5, function=self.updatePlayfieldTime)
|
||||
self.upperPlayfieldTimer.start()
|
||||
|
||||
def addBonusTimeSecond(self):
|
||||
if not self.isActive:
|
||||
return
|
||||
self.bonusTime += 1
|
||||
self.printSpecial()
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# FlippR-Game
|
||||
|
||||
The python game for our FlippR
|
||||
Game for a Zaccharia Pinbal Champ '82 to work in combination with the driver found at [[flippr-code|https://gitlab.rhetenor.de/rhetenor/flippr-code]].
|
||||
@@ -1,4 +1,3 @@
|
||||
from networking.Networking import Networking
|
||||
from utils.util import normalizeName
|
||||
from __main__ import networking
|
||||
|
||||
|
||||
9
Sound.py
Normal file
9
Sound.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from __main__ import networking
|
||||
|
||||
class Sound:
|
||||
def __init__(self, id):
|
||||
self.name = "Sound " + str(id)
|
||||
pass
|
||||
|
||||
def play(self):
|
||||
networking.playSound(self.name)
|
||||
@@ -2,6 +2,7 @@ from observable import Observable
|
||||
from collections import defaultdict
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
class Target(Observable):
|
||||
def __init__(self, points, name):
|
||||
|
||||
@@ -11,7 +11,7 @@ import logging
|
||||
|
||||
def main():
|
||||
args = parseCommandLine()
|
||||
logging.basicConfig(filename='log.txt', level=logging.INFO)
|
||||
logging.basicConfig(filename=config.LOG_FILE, level=config.LOG_LEVEL)
|
||||
game = createGame(args)
|
||||
asyncio.run(game.run())
|
||||
|
||||
|
||||
20
config.py
20
config.py
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import os
|
||||
from events.SpecialEvent import SpecialEvent
|
||||
from enum import Enum
|
||||
@@ -6,21 +7,32 @@ ORANGE_SPECIAL_BANK_OPTIONS = Enum("ORANGE_SPECIAL_BANK_OPTIONS", ["BOTH", "ONE"
|
||||
BONUS_TIME_ALGORITHM_OPTIONS = Enum("BONUS_TIME_ALGORITHM_OPTIONS", ["ALWAYS", "RANDOM"])
|
||||
|
||||
# Game Config
|
||||
MAX_PLAYERS = 4
|
||||
## Network Config
|
||||
SOCKET_PATH = os.environ["XDG_RUNTIME_DIR"] if os.environ["XDG_RUNTIME_DIR"] else '/tmp'
|
||||
SOCKET_PATH = '/tmp' #os.environ["XDG_RUNTIME_DIR"] if os.environ["XDG_RUNTIME_DIR"] else '/tmp'
|
||||
INPUT_SOCKET_NAME = "/S.flippR_driver.in"
|
||||
OUTPUT_SOCKET_NAME = "/S.flippR_driver.out"
|
||||
## Player State config
|
||||
BALLS_PER_GAME = 3
|
||||
BEGINNING_UPPER_PLAYFIELD_TIME = 5
|
||||
BEGINNING_BONUS_TIME = 0
|
||||
BEGINNING_BONUS_TIME = 15
|
||||
## Bonus Time Algorithm
|
||||
BONUS_TIME_ALGORITHM = BONUS_TIME_ALGORITHM_OPTIONS["RANDOM"]
|
||||
BONUS_TIME_MIN_RANDOM_TIME = 5
|
||||
BONUS_TIME_MAX_RANDOM_TIME = 15
|
||||
BONUS_TIME_ACTIVATION_PROBABILITY = 0.1
|
||||
## Special config
|
||||
RED_SPECIAL = SpecialEvent.replay
|
||||
RED_SPECIAL = SpecialEvent.extra_ball
|
||||
RED_SPECIAL_TIMES = 1
|
||||
ORANGE_SPECIAL = SpecialEvent.points
|
||||
ORANGE_SPECIAL = SpecialEvent.bonus_time
|
||||
ORANGE_SPECIAL_BANK = ORANGE_SPECIAL_BANK_OPTIONS["BOTH"]
|
||||
## Tech config
|
||||
LOG_FILE="flippr-game.log"
|
||||
LOG_LEVEL=logging.INFO
|
||||
WAIT_TIME_TO_RESET_SECONDS = 1
|
||||
MAX_NETWORK_RETRIES = 10
|
||||
NETWORK_SLEEP_TIME_SECONDS = 0.1
|
||||
BANK_SLEEP_TIME = 0.1
|
||||
BONUS_SLEEP_TIME = 0.1
|
||||
PLAYER_CHOOSE_INTERVAL = 2
|
||||
HIGHSCORE_FILE = "./high.score"
|
||||
|
||||
@@ -5,4 +5,7 @@ class Display:
|
||||
self.name = name
|
||||
|
||||
def printScore(self, score):
|
||||
networking.writeDisplayScore(self.name, score)
|
||||
networking.writeDisplayScore(self.name, score)
|
||||
|
||||
def printContent(self, content):
|
||||
networking.writeDisplayContent(self.name, content)
|
||||
21
displays/DummyDisplay.py
Normal file
21
displays/DummyDisplay.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from displays.Display import Display
|
||||
|
||||
|
||||
class DummyDisplay(Display):
|
||||
def __init__(self):
|
||||
super(DummyDisplay, self).__init__("DummyDisplay")
|
||||
|
||||
def printContent(self, content):
|
||||
pass
|
||||
|
||||
def printScore(self, score):
|
||||
pass
|
||||
|
||||
def printBallsToPlay(self, ballsToPlay):
|
||||
pass
|
||||
|
||||
def printGameTimeBonus(self, gameTimeBonus):
|
||||
pass
|
||||
|
||||
def printCredits(self, credits):
|
||||
pass
|
||||
@@ -8,9 +8,9 @@ class SpecialDisplay(Display):
|
||||
self.ballsToPlay = 0
|
||||
|
||||
def printScore(self):
|
||||
super().printScore(int(str(self.credits).zfill(2)
|
||||
+ str(self.gameTimeBonus).zfill(2)
|
||||
+ str(self.ballsToPlay).zfill(2)))
|
||||
super().printContent(str(self.credits).zfill(2)
|
||||
+ str(self.gameTimeBonus).zfill(3)
|
||||
+ str(self.ballsToPlay).zfill(3))
|
||||
|
||||
def printBallsToPlay(self, ballsToPlay):
|
||||
self.ballsToPlay = ballsToPlay
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
from Event import Event
|
||||
|
||||
from time import sleep
|
||||
from config import BANK_SLEEP_TIME
|
||||
|
||||
class BankEvent(Event):
|
||||
def __init__(self, bankSolenoid, name, playerState):
|
||||
def __init__(self, bankSolenoid, name, gameState):
|
||||
self.bankSolenoid = bankSolenoid
|
||||
super().__init__(name)
|
||||
self.playerState = playerState
|
||||
self.gameState = gameState
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
self.bankSolenoid.trigger()
|
||||
self.advanceBonus()
|
||||
|
||||
def advanceBonus(self):
|
||||
self.playerState().advanceBonus()
|
||||
sleep(BANK_SLEEP_TIME) # Wait for bank to reset before resetting targets
|
||||
|
||||
11
events/BonusEvent.py
Normal file
11
events/BonusEvent.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from Event import Event
|
||||
|
||||
|
||||
class BonusEvent(Event):
|
||||
def __init__(self, playerState):
|
||||
self.gameState = playerState
|
||||
super().__init__("Bonus Event")
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
self.gameState.currentPlayer.advanceBonus()
|
||||
@@ -2,10 +2,10 @@ from Event import Event
|
||||
|
||||
|
||||
class BonusTimeEvent(Event):
|
||||
def __init__(self, playerState):
|
||||
self.playerState = playerState
|
||||
def __init__(self, gameState):
|
||||
self.gameState = gameState
|
||||
super().__init__("Bonus Time Event")
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
self.playerState().addBonusTimeSecond()
|
||||
self.gameState.currentPlayer.addBonusTimeSecond()
|
||||
|
||||
@@ -3,11 +3,12 @@ from solenoids.BottomLeftBankSolenoid import BottomLeftBankSolenoid
|
||||
|
||||
|
||||
class BottomLeftBankEvent(BankEvent):
|
||||
def __init__(self, playerState):
|
||||
super().__init__(BottomLeftBankSolenoid(), "Bottom Left Bank Event", playerState)
|
||||
def __init__(self, gameState):
|
||||
super().__init__(BottomLeftBankSolenoid(), "Bottom Left Bank Event", gameState)
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
playerState = self.playerState()
|
||||
playerState = self.gameState.currentPlayer
|
||||
playerState.advanceLeftOrangeSpecial()
|
||||
playerState.advanceUpperPlayfieldTime()
|
||||
if playerState.upperPlayfieldTime < 30 and playerState.advanceTimeLeft:
|
||||
playerState.advanceUpperPlayfieldTime()
|
||||
|
||||
@@ -3,12 +3,12 @@ from solenoids.BottomRightBankSolenoid import BottomRightBankSolenoid
|
||||
|
||||
|
||||
class BottomRightBankEvent(BankEvent):
|
||||
def __init__(self, playerState):
|
||||
super().__init__(BottomRightBankSolenoid(), "Bottom Right Bank Event", playerState)
|
||||
def __init__(self, gameState):
|
||||
super().__init__(BottomRightBankSolenoid(), "Bottom Right Bank Event", gameState)
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
playerState = self.playerState()
|
||||
playerState = self.gameState.currentPlayer
|
||||
playerState.advanceRightOrangeSpecial()
|
||||
if playerState.upperPlayfieldTime < 30:
|
||||
if playerState.upperPlayfieldTime < 30 and playerState.advanceTimeRight:
|
||||
playerState.advanceUpperPlayfieldTime()
|
||||
|
||||
@@ -1,28 +1,65 @@
|
||||
import config
|
||||
from Event import Event
|
||||
|
||||
from events.EndGameEvent import EndGameEvent
|
||||
from events.StartBallEvent import StartBallEvent
|
||||
|
||||
from solenoids.MainFlipper import MainFlipper
|
||||
from solenoids.TopFlipper import TopFlipper
|
||||
|
||||
from solenoids.OutHoleSolenoid import OutHoleSolenoid
|
||||
|
||||
from time import sleep
|
||||
from config import BONUS_SLEEP_TIME
|
||||
|
||||
from lamps.LampGroup import BONUS_LAMPS
|
||||
|
||||
class EndBallEvent(Event):
|
||||
def __init__(self, playerState):
|
||||
self.playerState = playerState
|
||||
def __init__(self, gameState):
|
||||
self.gameState = gameState
|
||||
super().__init__("End Of Ball Event")
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
if self.playerState.replayBall:
|
||||
StartBallEvent().trigger(None)
|
||||
if not self.gameState.isPlaying:
|
||||
return
|
||||
|
||||
self.playerState().removeBall()
|
||||
if not self.gameState.isStarted:
|
||||
return
|
||||
|
||||
super().trigger(target)
|
||||
|
||||
TopFlipper().deactivate()
|
||||
|
||||
if not self.gameState.currentPlayer.hasBallScored:
|
||||
OutHoleSolenoid().trigger()
|
||||
return
|
||||
|
||||
|
||||
if self.gameState.currentPlayer.ballsLeft > 0:
|
||||
self.gameState.currentPlayer.removeBall()
|
||||
|
||||
self.gameState.currentPlayer.setReplayBall()
|
||||
|
||||
if self.gameState.currentPlayer.replayBall:
|
||||
OutHoleSolenoid().trigger()
|
||||
return
|
||||
|
||||
MainFlipper().deactivate()
|
||||
|
||||
self.gameState.isPlaying = False
|
||||
|
||||
self.scorePoints()
|
||||
self.playerState().reset()
|
||||
self.gameState.currentPlayer.deactivate()
|
||||
|
||||
if self.playerState().ballsLeft == 0:
|
||||
EndGameEvent().trigger(None)
|
||||
if self.gameState.currentPlayer.ballsLeft == 0 and self.gameState.currentPlayer.id == (self.gameState.playerCount - 1):
|
||||
self.gameState.endGame()
|
||||
return
|
||||
|
||||
self.gameState.nextPlayer()
|
||||
|
||||
def scorePoints(self):
|
||||
bonus = self.playerState().bonus * self.playerState().bonusMultiplier * 1000
|
||||
self.playerState().addPoints(bonus)
|
||||
currentPlayer = self.gameState.currentPlayer
|
||||
for i in range(currentPlayer.bonus):
|
||||
bonus = self.gameState.currentPlayer.bonusMultiplier * 1000
|
||||
self.gameState.currentPlayer.addPoints(bonus)
|
||||
BONUS_LAMPS.deactivateCurrent()
|
||||
sleep(BONUS_SLEEP_TIME)
|
||||
@@ -3,12 +3,12 @@ from solenoids.TopFlipper import TopFlipper
|
||||
|
||||
|
||||
class EnterUpperPlayfieldEvent(Event):
|
||||
def __init__(self, playerState):
|
||||
self.playerState = playerState
|
||||
def __init__(self, gameState):
|
||||
self.gameState = gameState
|
||||
self.flipper = TopFlipper()
|
||||
super().__init__("Enter Upper Playfield Event")
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
self.flipper.activate()
|
||||
self.playerState().startUpperPlayfieldTimer()
|
||||
self.gameState.currentPlayer.startUpperPlayfieldTimer()
|
||||
|
||||
@@ -2,10 +2,10 @@ from Event import Event
|
||||
|
||||
|
||||
class FixedTargetEvent(Event):
|
||||
def __init__(self, playerState):
|
||||
def __init__(self, gameState):
|
||||
super().__init__("Fixed Target Event")
|
||||
self.playerState = playerState
|
||||
self.gameState = gameState
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
self.playerState().advanceTunnel()
|
||||
self.gameState.currentPlayer.advanceTunnel()
|
||||
|
||||
@@ -3,8 +3,8 @@ from solenoids.TopFlipper import TopFlipper
|
||||
|
||||
|
||||
class LeaveUpperPlayfieldEvent(Event):
|
||||
def __init__(self, playerState):
|
||||
self.playerState = playerState
|
||||
def __init__(self, gameState):
|
||||
self.gameState = gameState
|
||||
self.flipper = TopFlipper()
|
||||
super().__init__("Leave Upper Playfield Event")
|
||||
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
from events.SpecialEvent import SpecialEvent
|
||||
|
||||
import config
|
||||
|
||||
from lamps.LampGroup import ORANGE_SPECIAL_LAMPS
|
||||
|
||||
class OrangeSpecialEvent(SpecialEvent):
|
||||
def __init__(self, playerState):
|
||||
super().__init__("Orange Special Event", playerState)
|
||||
self.points = 200000
|
||||
def __init__(self, gameState):
|
||||
super().__init__("Orange Special Event", gameState)
|
||||
self.points = 100000
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
if self.playerState().orangeSpecialLit:
|
||||
config.ORANGE_SPECIAL(self)
|
||||
self.playerState().resetOrangeSpecial()
|
||||
if self.gameState.currentPlayer.orangeSpecial == 0:
|
||||
self.points = 100000
|
||||
elif self.gameState.currentPlayer.orangeSpecial == 1:
|
||||
self.points = 200000
|
||||
elif self.gameState.currentPlayer.orangeSpecial == 2:
|
||||
self.points = 300000
|
||||
|
||||
super().trigger(target)
|
||||
|
||||
if self.gameState.currentPlayer.orangeSpecialLit:
|
||||
#config.ORANGE_SPECIAL(self)
|
||||
self.gameState.currentPlayer.addBonusTimeSecond()
|
||||
self.gameState.currentPlayer.resetOrangeSpecial()
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ from Event import Event
|
||||
|
||||
|
||||
class PointEvent(Event):
|
||||
def __init__(self, playerState):
|
||||
self.playerState = playerState
|
||||
def __init__(self, gameState):
|
||||
self.gameState = gameState
|
||||
super().__init__("Point Event")
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
self.playerState().addPoints(target.points)
|
||||
self.gameState.currentPlayer.addPoints(target.points)
|
||||
@@ -8,8 +8,8 @@ class RedSpecialEvent(SpecialEvent):
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
if self.playerState().redSpecialLit:
|
||||
if self.gameState.currentPlayer.redSpecialLit:
|
||||
config.RED_SPECIAL(self)
|
||||
self.playerState().resetRedSpecial()
|
||||
self.gameState.currentPlayer.resetRedSpecial()
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
from Event import Event
|
||||
from solenoids.RightKickerSolenoid import RightKickerSolenoid
|
||||
|
||||
from time import sleep
|
||||
from random import randrange
|
||||
|
||||
class RightKickerEvent(Event):
|
||||
def __init__(self):
|
||||
self.rightKickerSolenoid = RightKickerSolenoid()
|
||||
self.is_running = False
|
||||
super().__init__("Right Kicker Event")
|
||||
|
||||
def trigger(self, target):
|
||||
if self.is_running:
|
||||
return
|
||||
|
||||
self.is_running = True
|
||||
|
||||
sleeptime = randrange(300, 1200) / 1000
|
||||
sleep(sleeptime)
|
||||
|
||||
super().trigger(target)
|
||||
self.rightKickerSolenoid.trigger()
|
||||
self.rightKickerSolenoid.trigger()
|
||||
|
||||
self.is_running = False
|
||||
@@ -2,18 +2,21 @@ from Event import Event
|
||||
|
||||
|
||||
class SpecialEvent(Event):
|
||||
def __init__(self, name, playerState):
|
||||
def __init__(self, name, gameState):
|
||||
super().__init__(name)
|
||||
self.playerState = playerState
|
||||
self.gameState = gameState
|
||||
|
||||
def replay(self):
|
||||
self.playerState.setReplayBall()
|
||||
self.gameState.currentPlayer.setReplayBall()
|
||||
|
||||
def extra_ball(self):
|
||||
self.playerState.addBall()
|
||||
self.gameState.currentPlayer.addBall()
|
||||
|
||||
def points(self):
|
||||
self.playerState.addPoints(self.points)
|
||||
self.gameState.currentPlayer.addPoints(self.points)
|
||||
|
||||
def bonus_time(self):
|
||||
self.gameState.currentPlayer.addBonusTimeSecond()
|
||||
|
||||
def super_bonus(self):
|
||||
pass
|
||||
|
||||
@@ -3,9 +3,9 @@ from time import time
|
||||
|
||||
|
||||
class SpinnerEvent(Event):
|
||||
def __init__(self, playerState):
|
||||
def __init__(self, gameState):
|
||||
super().__init__("Spinner Event")
|
||||
self.playerState = playerState
|
||||
self.gameState = gameState
|
||||
self.activationTime = time()
|
||||
|
||||
def trigger(self, target):
|
||||
@@ -17,13 +17,13 @@ class SpinnerEvent(Event):
|
||||
self.scorePoints()
|
||||
|
||||
def scorePoints(self):
|
||||
playerState = self.playerState()
|
||||
playerState = self.gameState.currentPlayer
|
||||
timePassed = time() - self.activationTime
|
||||
if 1 <= timePassed < 1.5:
|
||||
if 0.5 <= timePassed < 1:
|
||||
playerState.addPoints(100000)
|
||||
elif 1.5 <= timePassed < 2:
|
||||
elif 1 <= timePassed < 1.5:
|
||||
playerState.addPoints(150000)
|
||||
elif 2 <= timePassed < 5:
|
||||
elif 1.5 <= timePassed < 3:
|
||||
playerState.addPoints(200000)
|
||||
elif timePassed >= 5:
|
||||
elif timePassed >= 3:
|
||||
playerState.addPoints(500000)
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
from Event import Event
|
||||
from solenoids.OutHoleSolenoid import OutHoleSolenoid
|
||||
from solenoids.MainFlipper import MainFlipper
|
||||
|
||||
from sounds.LowScore import LowScore
|
||||
|
||||
class StartBallEvent(Event):
|
||||
def __init__(self):
|
||||
def __init__(self, gameState = None):
|
||||
self.gameState = gameState
|
||||
self.flipper = MainFlipper()
|
||||
self.outHoleSolenoid = OutHoleSolenoid()
|
||||
super().__init__("Start Ball Event")
|
||||
|
||||
def trigger(self, target):
|
||||
if self.gameState is not None:
|
||||
if self.gameState.isPlaying or not self.gameState.isStarted:
|
||||
return
|
||||
|
||||
self.gameState.isPlaying = True
|
||||
if self.gameState.currentPlayer.ballsLeft == 1:
|
||||
LowScore().play()
|
||||
|
||||
|
||||
super().trigger(target)
|
||||
self.flipper.activate()
|
||||
self.outHoleSolenoid.trigger()
|
||||
OutHoleSolenoid().trigger()
|
||||
|
||||
@@ -1,15 +1,59 @@
|
||||
from Event import Event
|
||||
from events.StartBallEvent import StartBallEvent
|
||||
from solenoids.OutHoleSolenoid import OutHoleSolenoid
|
||||
from solenoids.MainFlipper import MainFlipper
|
||||
|
||||
from threading import Timer
|
||||
import config
|
||||
|
||||
from lamps.LampGroup import PLAYER_LAMPS
|
||||
|
||||
|
||||
class StartGameEvent(Event):
|
||||
def __init__(self):
|
||||
playerCount = 1
|
||||
timer = None
|
||||
|
||||
def __init__(self, gameState):
|
||||
self.gameState = gameState
|
||||
self.flipper = MainFlipper()
|
||||
self.outHoleSolenoid = OutHoleSolenoid()
|
||||
super().__init__("Start Game Event")
|
||||
|
||||
def restart_timer(self):
|
||||
if self.timer is not None:
|
||||
self.timer.cancel()
|
||||
|
||||
self.timer = Timer(interval=config.PLAYER_CHOOSE_INTERVAL, function=self.player_choose_ended)
|
||||
self.timer.start()
|
||||
|
||||
def trigger(self, target):
|
||||
if self.gameState.isStarted:
|
||||
return
|
||||
|
||||
super().trigger(target)
|
||||
self.flipper.activate()
|
||||
self.outHoleSolenoid.trigger()
|
||||
|
||||
if self.gameState.isIdle:
|
||||
self.gameState.stopIdleLoop()
|
||||
|
||||
if self.timer is None:
|
||||
PLAYER_LAMPS.deactivate()
|
||||
PLAYER_LAMPS.activateNext()
|
||||
self.restart_timer()
|
||||
return
|
||||
|
||||
self.restart_timer()
|
||||
|
||||
if self.playerCount == config.MAX_PLAYERS:
|
||||
PLAYER_LAMPS.deactivate()
|
||||
PLAYER_LAMPS.activateNext()
|
||||
self.playerCount = 1
|
||||
return
|
||||
|
||||
PLAYER_LAMPS.activate_one(self.playerCount)
|
||||
self.playerCount += 1
|
||||
|
||||
def player_choose_ended(self):
|
||||
self.timer = None
|
||||
PLAYER_LAMPS.deactivate()
|
||||
self.gameState.startGame(self.playerCount)
|
||||
#StartBallEvent().trigger(None)
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
from Event import Event
|
||||
from solenoids.MainFlipper import MainFlipper
|
||||
from solenoids.TopFlipper import TopFlipper
|
||||
from solenoids.MainFlipper import MainFlipper
|
||||
|
||||
#todo temporary
|
||||
import sys
|
||||
|
||||
class EndGameEvent(Event):
|
||||
class TiltEvent(Event):
|
||||
def __init__(self):
|
||||
super().__init__("End Game Event")
|
||||
super().__init__("Tilt Event")
|
||||
|
||||
def trigger(self, target):
|
||||
TopFlipper().deactivate()
|
||||
MainFlipper().deactivate()
|
||||
super().trigger(target)
|
||||
self.flipper.deactivate()
|
||||
sys.exit(0)
|
||||
@@ -8,6 +8,7 @@ class TopCentralBankEvent(BankEvent):
|
||||
|
||||
|
||||
def trigger(self, target):
|
||||
self.playerState().advanceRedSpecial()
|
||||
super().trigger(target)
|
||||
self.gameState.currentPlayer.advanceRedSpecial()
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
from Event import Event
|
||||
|
||||
class TunnelEvent(Event):
|
||||
def __init__(self, playerState):
|
||||
def __init__(self, gameState):
|
||||
super().__init__("Tunnel Event")
|
||||
self.playerState = playerState
|
||||
self.gameState = gameState
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
self.advanceBonusMultiplier()
|
||||
self.scoreBonusTunnelPoints()
|
||||
|
||||
def advanceBonusMultiplier(self):
|
||||
self.playerState().advanceBonusMultiplier()
|
||||
|
||||
def scoreBonusTunnelPoints(self):
|
||||
playerState = self.playerState()
|
||||
playerState = self.gameState.currentPlayer
|
||||
if playerState.tunnelLit == 2:
|
||||
playerState.addPoints(10000)
|
||||
elif playerState.tunnelLit == 3:
|
||||
|
||||
@@ -3,9 +3,9 @@ from Event import Event
|
||||
|
||||
class UpperPlayfieldTimeEvent(Event):
|
||||
def __init__(self, playerState):
|
||||
self.playerState = playerState
|
||||
self.gameState = playerState
|
||||
super().__init__("Upper Playfield Time Event")
|
||||
|
||||
def trigger(self, target):
|
||||
super().trigger(target)
|
||||
self.playerState().addUpperPlayfieldTime(1)
|
||||
self.gameState.currentPlayer.addUpperPlayfieldTime(1)
|
||||
@@ -1,10 +1,21 @@
|
||||
from displays.PlayerDisplay import PlayerDisplay
|
||||
from displays.SpecialDisplay import SpecialDisplay
|
||||
|
||||
import config
|
||||
import logging
|
||||
class DisplayFactory:
|
||||
def __init__(self, displayNames):
|
||||
self.displayNames = displayNames
|
||||
|
||||
def createDisplays(self):
|
||||
displays = [None] * config.MAX_PLAYERS
|
||||
|
||||
for display in self.displayNames:
|
||||
if "Player" in display['name']:
|
||||
id = int(display['name'].replace("Player_", "")) - 1
|
||||
displays[id] = PlayerDisplay(display['name'])
|
||||
|
||||
return displays
|
||||
|
||||
def createSpecialDisplay(self):
|
||||
name = next(displayName['name'] for displayName in self.displayNames if "Special" in displayName['name'])
|
||||
return SpecialDisplay(name)
|
||||
|
||||
@@ -7,7 +7,7 @@ from events.LeftFlapEvent import LeftFlapEvent
|
||||
from events.RightKickerEvent import RightKickerEvent
|
||||
from events.EnterUpperPlayfieldEvent import EnterUpperPlayfieldEvent
|
||||
from events.StartGameEvent import StartGameEvent
|
||||
from events.EndGameEvent import EndGameEvent
|
||||
from events.StartBallEvent import StartBallEvent
|
||||
from events.BottomRightBankEvent import BottomRightBankEvent
|
||||
from events.BottomLeftBankEvent import BottomLeftBankEvent
|
||||
from events.TopCentralBankEvent import TopCentralBankEvent
|
||||
@@ -18,11 +18,35 @@ from events.RedSpecialEvent import RedSpecialEvent
|
||||
from events.OrangeSpecialEvent import OrangeSpecialEvent
|
||||
from events.SpinnerEvent import SpinnerEvent
|
||||
from events.FixedTargetEvent import FixedTargetEvent
|
||||
from events.BonusEvent import BonusEvent
|
||||
from events.TiltEvent import TiltEvent
|
||||
|
||||
BONUS_EVENT_TARGETS = [
|
||||
"Left Inlane",
|
||||
"Right Inlane",
|
||||
"Right Outlane Kicker",
|
||||
"Canal Button Bottom",
|
||||
"Canal Button Middle Bottom",
|
||||
"Canal Button Middle Top",
|
||||
"Canal Button Top",
|
||||
"Fixed Target 1",
|
||||
"Fixed Target 2",
|
||||
"Fixed Target 3",
|
||||
"Fixed Target 4",
|
||||
"Fixed Target 5",
|
||||
"Left Bank Left",
|
||||
"Left Bank Middle Left",
|
||||
"Left Bank Middle Right",
|
||||
"Left Bank Right",
|
||||
"Right Bank Left",
|
||||
"Right Bank Middle",
|
||||
"Right Bank Right",
|
||||
]
|
||||
|
||||
class EventFactory:
|
||||
def __init__(self, targets, currentPlayer):
|
||||
def __init__(self, targets, gameState):
|
||||
self.targets = targets
|
||||
self.currentPlayer = currentPlayer
|
||||
self.gameState = gameState
|
||||
|
||||
def allEvents(self):
|
||||
methods = inspect.getmembers(self, predicate=inspect.ismethod)
|
||||
@@ -34,13 +58,13 @@ class EventFactory:
|
||||
return result
|
||||
|
||||
def createPointEvent(self):
|
||||
event = PointEvent(self.currentPlayer)
|
||||
event = PointEvent(self.gameState)
|
||||
for target in self.targets.values():
|
||||
self.__registerEventToTarget(event, target)
|
||||
return event
|
||||
|
||||
def createEndOfBallEvent(self):
|
||||
event = EndBallEvent(self.currentPlayer)
|
||||
event = EndBallEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets['Outhole'])
|
||||
return event
|
||||
|
||||
@@ -60,27 +84,32 @@ class EventFactory:
|
||||
return event
|
||||
|
||||
def createEnterUpperPlayfieldEvent(self):
|
||||
event = EnterUpperPlayfieldEvent(self.currentPlayer)
|
||||
self.__registerEventToTarget(event, self.targets['Rising Ball'])
|
||||
event = EnterUpperPlayfieldEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets['Rising ball'])
|
||||
return event
|
||||
|
||||
def createStartGameEvent(self):
|
||||
event = StartGameEvent()
|
||||
event = StartGameEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets['Credit'])
|
||||
return event
|
||||
|
||||
def createStartBallEvent(self):
|
||||
event = StartBallEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets['Credit'])
|
||||
return event
|
||||
|
||||
def createBottomLeftBankEvent(self):
|
||||
event = BottomLeftBankEvent(self.currentPlayer)
|
||||
event = BottomLeftBankEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets["Left Bank"])
|
||||
return event
|
||||
|
||||
def createBottomRightBankEvent(self):
|
||||
event = BottomRightBankEvent(self.currentPlayer)
|
||||
event = BottomRightBankEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets["Right Bank"])
|
||||
return event
|
||||
|
||||
def createTopCentralBankEvent(self):
|
||||
event = TopCentralBankEvent(self.currentPlayer)
|
||||
event = TopCentralBankEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets["Top Bank"])
|
||||
return event
|
||||
|
||||
@@ -95,27 +124,27 @@ class EventFactory:
|
||||
return event
|
||||
|
||||
def createTunnelEvent(self):
|
||||
event = TunnelEvent(self.currentPlayer)
|
||||
event = TunnelEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets["Canal Button Bottom"])
|
||||
return event
|
||||
|
||||
def createRedSpecialEvent(self):
|
||||
event = RedSpecialEvent(self.currentPlayer)
|
||||
event = RedSpecialEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets["Special Red"])
|
||||
return event
|
||||
|
||||
def createOrangeSpecialEvent(self):
|
||||
event = OrangeSpecialEvent(self.currentPlayer)
|
||||
event = OrangeSpecialEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets["Special Orange"])
|
||||
return event
|
||||
|
||||
def createSpinnerEvent(self):
|
||||
event = SpinnerEvent(self.currentPlayer)
|
||||
event = SpinnerEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets["Spinner"])
|
||||
return event
|
||||
|
||||
def createFixedTargetEvent(self):
|
||||
event = FixedTargetEvent(self.currentPlayer)
|
||||
event = FixedTargetEvent(self.gameState)
|
||||
self.__registerEventToTarget(event, self.targets["Fixed Target 1"])
|
||||
self.__registerEventToTarget(event, self.targets["Fixed Target 2"])
|
||||
self.__registerEventToTarget(event, self.targets["Fixed Target 3"])
|
||||
@@ -123,5 +152,17 @@ class EventFactory:
|
||||
self.__registerEventToTarget(event, self.targets["Fixed Target 5"])
|
||||
return event
|
||||
|
||||
def createBonusEvent(self):
|
||||
event = BonusEvent(self.gameState)
|
||||
self.__registerEventToTargets(event, BONUS_EVENT_TARGETS)
|
||||
|
||||
def createTiltEvent(self):
|
||||
event = TiltEvent()
|
||||
self.__registerEventToTarget(event, self.targets['Tilt'])
|
||||
|
||||
def __registerEventToTargets(self, event, targetNames):
|
||||
for targetName in targetNames:
|
||||
self.__registerEventToTarget(event, self.targets[targetName])
|
||||
|
||||
def __registerEventToTarget(self, event, target):
|
||||
target.on(target.hit_key, event.trigger)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import config
|
||||
from __main__ import networking
|
||||
|
||||
from factories.PlayerStateFactory import PlayerStateFactory
|
||||
@@ -11,38 +12,42 @@ from GameState import GameState
|
||||
|
||||
from Game import Game
|
||||
|
||||
from lamps.LampGroup import PLAYER_LAMPS
|
||||
|
||||
class GameFactory:
|
||||
def __init__(self):
|
||||
displayNames = networking.getDisplays()['displays']
|
||||
self.displayFactory = DisplayFactory(displayNames)
|
||||
specialDisplay = self.displayFactory.createSpecialDisplay()
|
||||
self.displays = self.displayFactory.createDisplays()
|
||||
self.specialDisplay = self.displayFactory.createSpecialDisplay()
|
||||
|
||||
self.playerCount = len(displayNames) - 1
|
||||
self.playerCount = len(displayNames)
|
||||
|
||||
self.playerStateFactory = PlayerStateFactory(specialDisplay)
|
||||
self.targets = TargetFactory.createAllTargets()
|
||||
banks = [self.targets['Left Bank'], self.targets['Right Bank'], self.targets['Top Bank']]
|
||||
|
||||
self.playerStateFactory = PlayerStateFactory(self.specialDisplay, banks, self.displays)
|
||||
|
||||
PLAYER_LAMPS.activateNext()
|
||||
|
||||
def getHighScore(self):
|
||||
try:
|
||||
with open(config.HIGHSCORE_FILE, "r") as file:
|
||||
score_str = file.readline()
|
||||
file.close()
|
||||
except IOError:
|
||||
return 0
|
||||
|
||||
if score_str == "":
|
||||
return 0
|
||||
|
||||
return int(score_str)
|
||||
|
||||
def createGame(self):
|
||||
targets = TargetFactory.createAllTargets()
|
||||
inputHandler = InputHandler(targets)
|
||||
inputHandler = InputHandler(self.targets)
|
||||
gameState = GameState(self.playerStateFactory, self.getHighScore(), self.specialDisplay)
|
||||
|
||||
players = self.createPlayers()
|
||||
|
||||
gameState = GameState(players, self.getHighScore(), players[0].id)
|
||||
|
||||
eventFactory = EventFactory(targets, gameState.currentPlayer)
|
||||
eventFactory = EventFactory(self.targets, gameState)
|
||||
events = eventFactory.allEvents()
|
||||
|
||||
return Game(inputHandler, gameState, events)
|
||||
|
||||
def createPlayers(self):
|
||||
players = []
|
||||
for id in range(1, self.playerCount):
|
||||
display = self.displayFactory.createPlayerDisplay(id)
|
||||
player = self.playerStateFactory.createPlayerState(display, id)
|
||||
players.append(player)
|
||||
return players
|
||||
|
||||
def getHighScore(self): # todo
|
||||
return 0
|
||||
|
||||
return Game(inputHandler, gameState, events)
|
||||
@@ -1,10 +1,16 @@
|
||||
from config import *
|
||||
from PlayerState import PlayerState
|
||||
|
||||
from displays.DummyDisplay import DummyDisplay
|
||||
|
||||
class PlayerStateFactory:
|
||||
def __init__(self, specialDisplay):
|
||||
def __init__(self, specialDisplay, banks, displays):
|
||||
self.specialDisplay = specialDisplay
|
||||
self.banks = banks
|
||||
self.displays = displays
|
||||
|
||||
def createPlayerState(self, display, id):
|
||||
return PlayerState(display, self.specialDisplay, id, BALLS_PER_GAME)
|
||||
def createPlayerState(self, id):
|
||||
return PlayerState(self.displays[id], self.specialDisplay, id, BALLS_PER_GAME, self.banks)
|
||||
|
||||
def createDummyPlayerState(self):
|
||||
display = DummyDisplay()
|
||||
return PlayerState(display, display, -1, -1, None)
|
||||
@@ -13,3 +13,16 @@ class Lamp:
|
||||
def isActivated(self):
|
||||
networking.getLamps(self)
|
||||
|
||||
CREDIT = Lamp('Credit')
|
||||
SHOOT_AGAIN = Lamp('Ball')
|
||||
|
||||
HIGHSCORE = Lamp('Highest Score')
|
||||
GAMEOVER = Lamp('Game Over')
|
||||
TILT = Lamp('Tilt')
|
||||
MATCH = Lamp ('Match')
|
||||
BALL_TO_PLAY = Lamp('Ball To Play')
|
||||
UP = Lamp('UP')
|
||||
DOWN = Lamp('Down')
|
||||
BALL = Lamp('Ball')
|
||||
MAN = Lamp('Man Speech Lamp')
|
||||
WOMAN = Lamp('Woman Speech Lamp')
|
||||
@@ -1,10 +1,14 @@
|
||||
from lamps.Lamp import Lamp
|
||||
|
||||
from itertools import cycle
|
||||
import random
|
||||
import time
|
||||
|
||||
class LampGroup:
|
||||
def __init__(self, lamps):
|
||||
self.lamps = lamps
|
||||
self.currentLamp = 0
|
||||
self.currentLampPtr = 0
|
||||
self.lamp_cycle = cycle(lamps)
|
||||
self.currentLamp = None
|
||||
self.deactivate()
|
||||
|
||||
def activate(self):
|
||||
@@ -12,24 +16,57 @@ class LampGroup:
|
||||
lamp.activate()
|
||||
|
||||
def deactivate(self):
|
||||
self.currentLampPtr = 0
|
||||
|
||||
for lamp in self.lamps:
|
||||
lamp.deactivate()
|
||||
|
||||
def activateNext(self):
|
||||
self.lamps[self.currentLamp].activate()
|
||||
def activate_one(self, id):
|
||||
self.lamps[id].activate()
|
||||
|
||||
if self.currentLamp == len(self.lamps):
|
||||
def activateNext(self):
|
||||
self.lamps[self.currentLampPtr].activate()
|
||||
|
||||
if self.currentLampPtr == len(self.lamps) - 1:
|
||||
return
|
||||
|
||||
self.currentLamp += 1
|
||||
self.currentLampPtr += 1
|
||||
|
||||
def deactivateCurrent(self):
|
||||
self.lamps[self.currentLamp].deactivate()
|
||||
self.lamps[self.currentLampPtr].deactivate()
|
||||
|
||||
if self.currentLamp == 0:
|
||||
if self.currentLampPtr == 0:
|
||||
return
|
||||
|
||||
self.currentLamp -= 1
|
||||
self.currentLampPtr -= 1
|
||||
|
||||
def toggleRandom(self, sleepTime):
|
||||
count = random.randint(1,3)
|
||||
random_lamps = random.choices(self.lamps, k=count)
|
||||
|
||||
for lamp in random_lamps:
|
||||
lamp.activate()
|
||||
|
||||
time.sleep(sleepTime)
|
||||
|
||||
for lamp in random_lamps:
|
||||
lamp.deactivate()
|
||||
|
||||
def cycle(self):
|
||||
if self.currentLamp:
|
||||
self.currentLamp.deactivate()
|
||||
self.currentLamp = next(self.lamp_cycle)
|
||||
self.currentLamp.activate()
|
||||
|
||||
|
||||
|
||||
|
||||
PLAYER_LAMPS = LampGroup([
|
||||
Lamp("Can Play 1"),
|
||||
Lamp("Can Play 2"),
|
||||
Lamp("Can Play 3"),
|
||||
Lamp("Can Play 4")
|
||||
])
|
||||
|
||||
CHAMP_LAMPS = LampGroup([
|
||||
Lamp("C Of Champ"),
|
||||
@@ -46,6 +83,27 @@ UPPER_PLAYFIELD_TIME_LAMPS = LampGroup([
|
||||
Lamp("Lamp 30 Sec")
|
||||
])
|
||||
|
||||
TUNNEL_NUMBER_LAMPS = LampGroup([
|
||||
Lamp("Lamp 1"),
|
||||
Lamp("Lamp 2"),
|
||||
Lamp("Lamp 3"),
|
||||
Lamp("Lamp 4"),
|
||||
Lamp("Lamp 5"),
|
||||
])
|
||||
TUNNEL_LAMPS = LampGroup([
|
||||
Lamp("1st Button"),
|
||||
Lamp("2nd Button"),
|
||||
Lamp("3rd Button"),
|
||||
Lamp("4th Button"),
|
||||
Lamp("5th Button")
|
||||
])
|
||||
|
||||
TUNNEL_SCORE_LAMPS = LampGroup([
|
||||
Lamp("Tunnel Lamp 20000 Points"),
|
||||
Lamp("Tunnel Lamp 30000 Points"),
|
||||
Lamp("Tunnel Lamp 50000 Points")
|
||||
])
|
||||
|
||||
BONUS_MULTIPLIER_LAMPS = LampGroup([
|
||||
Lamp("Bonus Multiplier x10"),
|
||||
Lamp("Bonus Multiplier x20"),
|
||||
@@ -74,3 +132,9 @@ BONUS_LAMPS = LampGroup([
|
||||
Lamp("Bonus 19000"),
|
||||
Lamp("Bonus 20000")
|
||||
])
|
||||
|
||||
ORANGE_SPECIAL_LAMPS = LampGroup([
|
||||
Lamp("Special 100000 Points"),
|
||||
Lamp("Special 200000 Points"),
|
||||
Lamp("Special 300000 Points")
|
||||
])
|
||||
@@ -1,19 +1,42 @@
|
||||
import requests_unixsocket as req
|
||||
import config
|
||||
from time import sleep
|
||||
import socket
|
||||
import json
|
||||
|
||||
import logging
|
||||
|
||||
class Networking:
|
||||
def __init__(self, output_server_address, input_socket_address):
|
||||
self.retries = 0
|
||||
self.server_address = ""
|
||||
self.output_server_address = output_server_address
|
||||
self.input_socket_address = input_socket_address
|
||||
self.__connect__()
|
||||
|
||||
|
||||
def __connect__(self):
|
||||
self.input_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
self.output_session = req.Session()
|
||||
self.server_address = "http+unix://" + output_server_address.replace("/", "%2F")
|
||||
self.input_socket.connect(input_socket_address)
|
||||
print("Connected to " + input_socket_address + " and started server " + self.server_address)
|
||||
adapter = req.adapters.UnixAdapter(pool_connections=1)
|
||||
self.output_session.mount('http+unix://', adapter)
|
||||
self.server_address = "http+unix://" + self.output_server_address.replace("/", "%2F")
|
||||
self.input_socket.connect(self.input_socket_address)
|
||||
print("Connected to " + self.input_socket_address + " and started server " + self.server_address)
|
||||
|
||||
def get(self, path):
|
||||
response = self.output_session.get(self.server_address + path)
|
||||
if self.retries > config.MAX_NETWORK_RETRIES:
|
||||
return
|
||||
|
||||
try:
|
||||
response = self.output_session.get(self.server_address + path)
|
||||
except Exception as e:
|
||||
logging.error("Network exception. Could not get " + path + ".... Reconnecting!")
|
||||
logging.error(e)
|
||||
self.retries += 1
|
||||
sleep(config.NETWORK_SLEEP_TIME_SECONDS)
|
||||
self.__connect__()
|
||||
return self.get(path)
|
||||
|
||||
assert response.status_code == 200
|
||||
return response.content
|
||||
|
||||
@@ -45,7 +68,7 @@ class Networking:
|
||||
self.get("/flippers/" + name + "/activate")
|
||||
|
||||
def deactivateFlipper(self, name):
|
||||
self.get("/flippers/" + name + "deactivate")
|
||||
self.get("/flippers/" + name + "/deactivate")
|
||||
|
||||
def lampStatus(self, lamp):
|
||||
return json.loads(self.get("/lamps/" + lamp + "/status"))
|
||||
@@ -53,6 +76,9 @@ class Networking:
|
||||
def writeDisplayScore(self, display, score):
|
||||
self.get("/displays/" + display + "/write_score/" + str(score))
|
||||
|
||||
def writeDisplayContent(self, display, content):
|
||||
self.get("/displays/" + display + "/write_content/" + content)
|
||||
|
||||
async def getInputEvent(self):
|
||||
header = list()
|
||||
while b'\x02' not in header:
|
||||
|
||||
5
sounds/AnotherCoin.py
Normal file
5
sounds/AnotherCoin.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class AnotherCoin(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 15: "Another coin please."'''
|
||||
5
sounds/BeCareful.py
Normal file
5
sounds/BeCareful.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class BeCareful(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 11: "Be careful."'''
|
||||
5
sounds/ChallengeChamp.py
Normal file
5
sounds/ChallengeChamp.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class ChallengeChamp(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 5: "Challenge the champ!"'''
|
||||
5
sounds/Countdown.py
Normal file
5
sounds/Countdown.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class Countdown(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 4: "Five, Four, Three, Two, One."'''
|
||||
5
sounds/GameTimeBonus.py
Normal file
5
sounds/GameTimeBonus.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class GameTimeBonus(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 13: "Be ready for the Game Time Bonus."'''
|
||||
5
sounds/GoSpecial.py
Normal file
5
sounds/GoSpecial.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class GoSpecial(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 27: "Go for the Special."'''
|
||||
5
sounds/HighLevel.py
Normal file
5
sounds/HighLevel.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class HighLevel(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 20: "Go for the high level board."'''
|
||||
5
sounds/IAmChamp.py
Normal file
5
sounds/IAmChamp.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class IAmChamp(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 17: "I am the champ! Challenge me!"'''
|
||||
5
sounds/LowScore.py
Normal file
5
sounds/LowScore.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class LowScore(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 9: "What a low score!"'''
|
||||
5
sounds/MaxScore.py
Normal file
5
sounds/MaxScore.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class Seconds(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 8: "This is a maximum score."'''
|
||||
5
sounds/Naughty.py
Normal file
5
sounds/Naughty.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class Naughty(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 14: "That's naughty!"'''
|
||||
5
sounds/PlayGently.py
Normal file
5
sounds/PlayGently.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class PlayGently(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 21: "Play gently to beat me."'''
|
||||
5
sounds/Quick.py
Normal file
5
sounds/Quick.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class Quick(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 22: "Quick! Hit the Special"'''
|
||||
5
sounds/Red.py
Normal file
5
sounds/Red.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class Red(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 25: "Red"'''
|
||||
5
sounds/Seconds.py
Normal file
5
sounds/Seconds.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class Seconds(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 3: "Seconds"'''
|
||||
5
sounds/ShootSpecial.py
Normal file
5
sounds/ShootSpecial.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class ShootSpecial(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 23: "Shoot the special."'''
|
||||
5
sounds/SpecialAgain.py
Normal file
5
sounds/SpecialAgain.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class SpecialAgain(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 19: "Once again for the special."'''
|
||||
5
sounds/TheLastBall.py
Normal file
5
sounds/TheLastBall.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class TheLastBall(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 12: "The last ball."'''
|
||||
5
sounds/Thirty.py
Normal file
5
sounds/Thirty.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class Thirty(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 24: "Thirty"'''
|
||||
5
sounds/TimeOver.py
Normal file
5
sounds/TimeOver.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class TimeOver(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 16: "Sorry. The time is over."'''
|
||||
5
sounds/TimeShort.py
Normal file
5
sounds/TimeShort.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class TimeShort(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 18: "Time is short."'''
|
||||
5
sounds/TryHarder.py
Normal file
5
sounds/TryHarder.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class TryHarder(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 10: "Try harder!"'''
|
||||
5
sounds/Twenty.py
Normal file
5
sounds/Twenty.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class Twenty(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 2: "Twenty"'''
|
||||
5
sounds/WoW.py
Normal file
5
sounds/WoW.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class WoW(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 7: "WoW."'''
|
||||
5
sounds/Yellow.py
Normal file
5
sounds/Yellow.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class Yellow(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 26: "Yellow"'''
|
||||
5
sounds/YoureChamp.py
Normal file
5
sounds/YoureChamp.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class YoureChamp(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 6: "Good. You're a champ!"'''
|
||||
5
sounds/YoureGood.py
Normal file
5
sounds/YoureGood.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Sound import Sound
|
||||
|
||||
class YoureGood(Sound):
|
||||
def __init__(self):
|
||||
self.name = '''Speech 1: "You're good! But I'm still the Champ!"'''
|
||||
16
sounds/__init__.py
Normal file
16
sounds/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
__all__ = []
|
||||
|
||||
import pkgutil
|
||||
import inspect
|
||||
|
||||
__path__ = pkgutil.extend_path(__path__, __name__)
|
||||
|
||||
for loader, name, is_pkg in pkgutil.walk_packages(__path__):
|
||||
module = loader.find_module(name).load_module(name)
|
||||
|
||||
for name, value in inspect.getmembers(module):
|
||||
if name.startswith('__'):
|
||||
continue
|
||||
|
||||
globals()[name] = value
|
||||
__all__.append(name)
|
||||
@@ -1,5 +1,5 @@
|
||||
from Target import Target
|
||||
|
||||
from Sound import Sound
|
||||
class LeftInlaneTarget(Target):
|
||||
def __init__(self):
|
||||
super().__init__(3000, 'Left Inlane')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from Target import Target
|
||||
from Sound import Sound
|
||||
|
||||
|
||||
class CanalButtonTopTarget(Target):
|
||||
@@ -6,4 +7,5 @@ class CanalButtonTopTarget(Target):
|
||||
super().__init__(20000, "Canal Button Bottom")
|
||||
|
||||
def hit(self):
|
||||
Sound(2).play()
|
||||
super().hit()
|
||||
@@ -1,4 +1,5 @@
|
||||
from Target import Target
|
||||
from Sound import Sound
|
||||
|
||||
|
||||
class LeftLaneButton4Target(Target):
|
||||
@@ -6,4 +7,5 @@ class LeftLaneButton4Target(Target):
|
||||
super().__init__(20000, "Canal Button Middle Bottom")
|
||||
|
||||
def hit(self):
|
||||
Sound(1).play()
|
||||
super().hit()
|
||||
@@ -1,4 +1,5 @@
|
||||
from Target import Target
|
||||
from Sound import Sound
|
||||
|
||||
|
||||
class LeftLaneButton3Target(Target):
|
||||
@@ -6,4 +7,5 @@ class LeftLaneButton3Target(Target):
|
||||
super().__init__(20000, "Canal Button Middle")
|
||||
|
||||
def hit(self):
|
||||
Sound(2).play()
|
||||
super().hit()
|
||||
@@ -1,4 +1,5 @@
|
||||
from Target import Target
|
||||
from Sound import Sound
|
||||
|
||||
|
||||
class LeftLaneButton2Target(Target):
|
||||
@@ -6,4 +7,5 @@ class LeftLaneButton2Target(Target):
|
||||
super().__init__(20000, "Canal Button Middle Top")
|
||||
|
||||
def hit(self):
|
||||
Sound(1).play()
|
||||
super().hit()
|
||||
@@ -1,8 +1,10 @@
|
||||
from Target import Target
|
||||
from Sound import Sound
|
||||
|
||||
class LeftLaneButton1Target(Target):
|
||||
def __init__(self):
|
||||
super().__init__(100, 'Canal Button Top')
|
||||
|
||||
def hit(self):
|
||||
Sound(2).play()
|
||||
super().hit()
|
||||
@@ -1,9 +1,10 @@
|
||||
from Target import Target
|
||||
|
||||
from Sound import Sound
|
||||
|
||||
class FixedTarget1(Target):
|
||||
def __init__(self):
|
||||
super().__init__(30000, "Fixed Target 1")
|
||||
|
||||
def hit(self):
|
||||
Sound(6).play()
|
||||
super().hit()
|
||||
@@ -1,4 +1,5 @@
|
||||
from Target import Target
|
||||
from Sound import Sound
|
||||
|
||||
|
||||
class FixedTarget2(Target):
|
||||
@@ -6,4 +7,5 @@ class FixedTarget2(Target):
|
||||
super().__init__(30000, "Fixed Target 2")
|
||||
|
||||
def hit(self):
|
||||
Sound(6).play()
|
||||
super().hit()
|
||||
@@ -1,8 +1,10 @@
|
||||
from Target import Target
|
||||
from Sound import Sound
|
||||
|
||||
class FixedTarget3(Target):
|
||||
def __init__(self):
|
||||
super().__init__(30000, 'Fixed Target 3')
|
||||
|
||||
def hit(self):
|
||||
Sound(6).play()
|
||||
super().hit()
|
||||
@@ -1,4 +1,5 @@
|
||||
from Target import Target
|
||||
from Sound import Sound
|
||||
|
||||
|
||||
class FixedTarget4(Target):
|
||||
@@ -6,4 +7,5 @@ class FixedTarget4(Target):
|
||||
super().__init__(30000, 'Fixed Target 4')
|
||||
|
||||
def hit(self):
|
||||
Sound(6).play()
|
||||
super().hit()
|
||||
@@ -1,4 +1,5 @@
|
||||
from Target import Target
|
||||
from Sound import Sound
|
||||
|
||||
|
||||
class FixedTarget5(Target):
|
||||
@@ -6,4 +7,5 @@ class FixedTarget5(Target):
|
||||
super().__init__(30000, 'Fixed Target 5')
|
||||
|
||||
def hit(self):
|
||||
Sound(6).play()
|
||||
super().hit()
|
||||
@@ -1,7 +1,7 @@
|
||||
from Target import Target
|
||||
from BankTarget import BankTarget
|
||||
|
||||
|
||||
class LeftBankRightTarget(Target):
|
||||
class LeftBankRightTarget(BankTarget):
|
||||
def __init__(self):
|
||||
super().__init__(30000, 'Left Bank Right')
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from Target import Target
|
||||
|
||||
from Sound import Sound
|
||||
|
||||
class LeftPopTarget(Target):
|
||||
def __init__(self):
|
||||
super().__init__(5000, "Left Pop")
|
||||
|
||||
def hit(self):
|
||||
Sound(3).play()
|
||||
super().hit()
|
||||
@@ -1,9 +1,10 @@
|
||||
from Target import Target
|
||||
|
||||
from Sound import Sound
|
||||
|
||||
class RightPopTarget(Target):
|
||||
def __init__(self):
|
||||
super().__init__(5000, 'Right Pop')
|
||||
|
||||
def hit(self):
|
||||
Sound(3).play()
|
||||
super().hit()
|
||||
@@ -1,8 +1,9 @@
|
||||
from Target import Target
|
||||
|
||||
from Sound import Sound
|
||||
class LeftSlingshotTarget(Target):
|
||||
def __init__(self):
|
||||
super().__init__(100, 'Left Slingshot')
|
||||
|
||||
def hit(self):
|
||||
Sound(6).play()
|
||||
super().hit()
|
||||
@@ -1,4 +1,5 @@
|
||||
from Target import Target
|
||||
from Sound import Sound
|
||||
|
||||
|
||||
class RightSlingshotTarget(Target):
|
||||
@@ -6,4 +7,5 @@ class RightSlingshotTarget(Target):
|
||||
super().__init__(10, "Right Slingshot")
|
||||
|
||||
def hit(self):
|
||||
Sound(6).play()
|
||||
super().hit()
|
||||
@@ -1,5 +1,5 @@
|
||||
from Target import Target
|
||||
|
||||
from Sound import Sound
|
||||
|
||||
# A standup target. When lit, it scores the Orange Special (operator
|
||||
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 300,000
|
||||
@@ -9,4 +9,5 @@ class FixedSpecialOrangeTarget(Target):
|
||||
super().__init__(100000, "Special Orange")
|
||||
|
||||
def hit(self):
|
||||
Sound(5).play()
|
||||
super().hit()
|
||||
@@ -1,5 +1,5 @@
|
||||
from Target import Target
|
||||
|
||||
from Sound import Sound
|
||||
# A standup target. When lit, it scores the Red Special (operator
|
||||
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 1,000,000
|
||||
# points. Scores 10,000 points when not lit.
|
||||
@@ -8,4 +8,5 @@ class FixedSpecialRedTarget(Target):
|
||||
super().__init__(10000, "Special Red")
|
||||
|
||||
def hit(self):
|
||||
Sound(4).play()
|
||||
super().hit()
|
||||
@@ -3,7 +3,7 @@ from Target import Target
|
||||
|
||||
class RisingBallTarget(Target):
|
||||
def __init__(self):
|
||||
super().__init__(0, "Rising Ball")
|
||||
super().__init__(0, "Rising ball")
|
||||
|
||||
def hit(self):
|
||||
super().hit()
|
||||
8
targets/technical/TiltTarget.py
Normal file
8
targets/technical/TiltTarget.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from Target import Target
|
||||
|
||||
class TiltTarget(Target):
|
||||
def __init__(self):
|
||||
super().__init__(0, 'Tilt')
|
||||
|
||||
def hit(self):
|
||||
super().hit()
|
||||
Reference in New Issue
Block a user