This commit is contained in:
Jonas Zeunert
2020-01-28 11:58:52 +01:00
parent 32f3965daa
commit 19ba128a92
28 changed files with 88 additions and 20 deletions

9
src/Display.py Normal file
View File

@@ -0,0 +1,9 @@
from src.networking.Networking import Networking
class Display:
def __init__(self, name):
self.name = name
def write_score(self, score):
Networking.write(self.name, score)

0
src/GameState.py Normal file
View File

5
src/PlayerDisplay.py Normal file
View File

@@ -0,0 +1,5 @@
from src.Display import Display
class PlayerDisplay(Display):
def __init__(self, name):
super(name)

15
src/PlayerState.py Normal file
View File

@@ -0,0 +1,15 @@
from src.networking.Networking import Networking
class PlayerState:
def __init__(self, id, ballsToPlay, upperPlayfieldTime = 5, bonusTime = 0):
self.networking = networking
self.__id = id
self.__points = 0
self.ballsLeft = ballsToPlay
self.upperPlayfieldTime = upperPlayfieldTime
self.bonusTime = bonusTime
def addPoints(self, points):
self.__points += points
Networking.writeDisplayScore(self.__id, self.__points)

25
src/SpecialDisplay.py Normal file
View File

@@ -0,0 +1,25 @@
from src.Display import Display
class SpecialDisplay(Display):
def __init__(self, name):
super(name)
self.credits = 0
self.gameTimeBonus = 0
self.ballsToPlay = 0
def write_score(self):
super.write_score(int(str(self.credits).zfill(2)
+ str(self.gameTimeBonus).zfill(2)
+ str(self.ballsToPlay).zfill(2)))
def write_ballsToPlay(self, ballsToPlay):
self.ballsToPlay = ballsToPlay
self.write_score()
def write_gameTimeBonus(self, gameTimeBonus):
self.gameTimeBonus = gameTimeBonus
self.write_score()
def write_credits(self, credits):
self.credits = credits
self.write_score()

View File

@@ -1,7 +1,9 @@
import requests_unixsocket as req
import socket
from src.utils.Singleton import Singleton
class Networking:
class Networking(metaclass=Singleton):
def __init__(self, output_server_address, input_socket_address):
self.server_address = ""
self.input_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

View File

@@ -1,3 +1,5 @@
from src.targets.Target import Target
class Bank(Target):
def __init__(self, targets):
self.targets = targets

View File

@@ -1,5 +1,4 @@
from Target import Target
from src.targets.Target import Target
class BankTarget(Target):
def __init__(self, points):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class FirstFixedTarget(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
# A standup target. When lit, it scores the Orange Special (operator
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 300,000

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
# A standup target. When lit, it scores the Red Special (operator
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 1,000,000

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class LeftDropTarget(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class LeftLaneButton2Target(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class LeftLaneButton3Target(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class LeftLaneButton4Target(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class LeftLaneButton5Target(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class LeftPopBumperTarget(Target):

View File

@@ -1,3 +1,5 @@
from src.targets.Target import Target
class OutholeTarget(Target):
def __init__(self):
super(100, 'Outhole Target')

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class RightDropTarget(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class RightInlaneTarget(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class RightOutlaneKickerTarget(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class RightOutlaneTarget(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class RightSlingshotTarget(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class SecondFixedTarget(Target):

View File

@@ -1,3 +1,6 @@
from observable import Observable
class Target(Observable):
def __init__(self, points, name):
self.points = points

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class UPRightDropTarget(Target):

View File

@@ -1,4 +1,4 @@
from Target import Target
from src.targets.Target import Target
class UpperPlayfieldRollUnderTarget(Target):

6
src/utils/Singleton.py Normal file
View File

@@ -0,0 +1,6 @@
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]