Compare commits
7 Commits
1.1.0
...
28f9c01f14
| Author | SHA1 | Date | |
|---|---|---|---|
| 28f9c01f14 | |||
| 24d6addc24 | |||
| c0ebfa42b7 | |||
| 44696a0ac3 | |||
| 1686e53b28 | |||
| 132cfab990 | |||
| c2db8b386e |
@ -4,4 +4,6 @@ from .anim import AnimationHandler
|
|||||||
from .anim import AnimatedObject
|
from .anim import AnimatedObject
|
||||||
from .events import AnimStart
|
from .events import AnimStart
|
||||||
from .events import AnimFinish
|
from .events import AnimFinish
|
||||||
from .events import Timeout
|
from .events import Timeout
|
||||||
|
from .turns import BaseTurnHandler
|
||||||
|
from .turns import RoundTable
|
||||||
|
|||||||
@ -74,4 +74,8 @@ class Game:
|
|||||||
ID on the stack, False otherwise.
|
ID on the stack, False otherwise.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return any([timeout.timeoutID == id for timeout in self._timeouts])
|
return any([timeout.timeoutID == id for timeout in self._timeouts])
|
||||||
|
|
||||||
|
# TODO: Add popup method
|
||||||
|
|
||||||
|
# TODO: add punish(player, intensity)
|
||||||
|
|||||||
69
src/gameUtils/turns.py
Normal file
69
src/gameUtils/turns.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# TODO: Add a variable for the game developers to see if pain is "avaialbe",
|
||||||
|
# I.E. has the shocker been passed to the next player.
|
||||||
|
# Also add a pop-up, probably using pygame-gui, to tell the player
|
||||||
|
# to pass the shocker to the next person.
|
||||||
|
# NOTE: Each expansion is assigned multiple players, if an expansion has a tag
|
||||||
|
# such as "ONE_PERSON_ONLY", it means that when the game developer wants
|
||||||
|
# to go to the next player, it must self.notify() the players to pass the
|
||||||
|
# physical object around.
|
||||||
|
# NOTE: That tag IS NOT a part of NoPE-Lib or PDO-Lib. It simply acts as an
|
||||||
|
# identifier for games to use.
|
||||||
|
# TODO: Add player config editor.
|
||||||
|
|
||||||
|
class BaseTurnHandler:
|
||||||
|
def __init__(self, playersManager):
|
||||||
|
"""
|
||||||
|
The base turn handler metaclass, used to create round
|
||||||
|
handlers such as round table.
|
||||||
|
"""
|
||||||
|
self._pm = playersManager
|
||||||
|
# The current turn number (0 based)
|
||||||
|
self.turn = 0
|
||||||
|
# The maximum number of turns
|
||||||
|
self.turns = len(self._pm)
|
||||||
|
# The current round number (0 based)
|
||||||
|
self.round = 0
|
||||||
|
# Which players are playing in this turn
|
||||||
|
self.playing = []
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
class RoundTable(BaseTurnHandler):
|
||||||
|
"""
|
||||||
|
A simple "round table" round system.
|
||||||
|
"""
|
||||||
|
# TODO: Add some kind of implementation with NoPE
|
||||||
|
# to determain if we actually need to re-assign PDOs.
|
||||||
|
def __init__(self, teamSize: int, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
if teamSize > len(self._pm):
|
||||||
|
raise Exception('Too little players for specified team size.') # TODO: Custom exception
|
||||||
|
|
||||||
|
self.teamSize = teamSize
|
||||||
|
self.turns //= self.teamSize
|
||||||
|
|
||||||
|
self.turn -= 1
|
||||||
|
self.next()
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
"""
|
||||||
|
Oh god I hate it.
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.turn += 1
|
||||||
|
if self.turn >= self.turns:
|
||||||
|
self.turn -= self.turns
|
||||||
|
self.round += 1
|
||||||
|
|
||||||
|
self.playing = []
|
||||||
|
playerNames = list(self._pm.keys())
|
||||||
|
|
||||||
|
for i in range(self.teamSize):
|
||||||
|
self.playing.append(self._pm[playerNames[(i+self.turn)%len(playerNames)]])
|
||||||
|
|
||||||
|
return self.playing
|
||||||
Reference in New Issue
Block a user