working
This commit is contained in:
9
src/Display.py
Normal file
9
src/Display.py
Normal 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
0
src/GameState.py
Normal file
5
src/PlayerDisplay.py
Normal file
5
src/PlayerDisplay.py
Normal 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
15
src/PlayerState.py
Normal 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
25
src/SpecialDisplay.py
Normal 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()
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import requests_unixsocket as req
|
import requests_unixsocket as req
|
||||||
import socket
|
import socket
|
||||||
|
from src.utils.Singleton import Singleton
|
||||||
|
|
||||||
class Networking:
|
|
||||||
|
class Networking(metaclass=Singleton):
|
||||||
def __init__(self, output_server_address, input_socket_address):
|
def __init__(self, output_server_address, input_socket_address):
|
||||||
self.server_address = ""
|
self.server_address = ""
|
||||||
self.input_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
self.input_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from src.targets.Target import Target
|
||||||
|
|
||||||
class Bank(Target):
|
class Bank(Target):
|
||||||
def __init__(self, targets):
|
def __init__(self, targets):
|
||||||
self.targets = targets
|
self.targets = targets
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class BankTarget(Target):
|
class BankTarget(Target):
|
||||||
def __init__(self, points):
|
def __init__(self, points):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class FirstFixedTarget(Target):
|
class FirstFixedTarget(Target):
|
||||||
|
|||||||
@@ -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
|
# A standup target. When lit, it scores the Orange Special (operator
|
||||||
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 300,000
|
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 300,000
|
||||||
|
|||||||
@@ -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
|
# A standup target. When lit, it scores the Red Special (operator
|
||||||
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 1,000,000
|
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 1,000,000
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftDropTarget(Target):
|
class LeftDropTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftLaneButton2Target(Target):
|
class LeftLaneButton2Target(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftLaneButton3Target(Target):
|
class LeftLaneButton3Target(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftLaneButton4Target(Target):
|
class LeftLaneButton4Target(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftLaneButton5Target(Target):
|
class LeftLaneButton5Target(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftPopBumperTarget(Target):
|
class LeftPopBumperTarget(Target):
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from src.targets.Target import Target
|
||||||
|
|
||||||
class OutholeTarget(Target):
|
class OutholeTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(100, 'Outhole Target')
|
super(100, 'Outhole Target')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class RightDropTarget(Target):
|
class RightDropTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class RightInlaneTarget(Target):
|
class RightInlaneTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class RightOutlaneKickerTarget(Target):
|
class RightOutlaneKickerTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class RightOutlaneTarget(Target):
|
class RightOutlaneTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class RightSlingshotTarget(Target):
|
class RightSlingshotTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class SecondFixedTarget(Target):
|
class SecondFixedTarget(Target):
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
from observable import Observable
|
||||||
|
|
||||||
|
|
||||||
class Target(Observable):
|
class Target(Observable):
|
||||||
def __init__(self, points, name):
|
def __init__(self, points, name):
|
||||||
self.points = points
|
self.points = points
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class UPRightDropTarget(Target):
|
class UPRightDropTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.targets.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class UpperPlayfieldRollUnderTarget(Target):
|
class UpperPlayfieldRollUnderTarget(Target):
|
||||||
|
|||||||
6
src/utils/Singleton.py
Normal file
6
src/utils/Singleton.py
Normal 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]
|
||||||
Reference in New Issue
Block a user