Merge branch 'tourney-mp-room-changes' of ripple/pep.py into master
This commit is contained in:
commit
3dfb1228ee
|
@ -14,3 +14,8 @@ def handle(userToken, _):
|
|||
slotID = match.getUserSlotID(userID)
|
||||
if slotID is not None:
|
||||
match.toggleSlotReady(slotID)
|
||||
|
||||
# If this is a tournament match, we should send the current status of ready
|
||||
# players.
|
||||
if match.isTourney:
|
||||
match.sendReadyStatus()
|
||||
|
|
|
@ -427,6 +427,12 @@ class match:
|
|||
# Console output
|
||||
log.info("MPROOM{}: Match completed".format(self.matchID))
|
||||
|
||||
# If this is a tournament match, then we send a notification in the chat
|
||||
# saying that the match has completed.
|
||||
chanName = "#multi_{}".format(self.matchID)
|
||||
if self.isTourney and (chanName in glob.channels.channels):
|
||||
chat.sendMessage("FokaBot", chanName, "Match has just finished.")
|
||||
|
||||
def resetSlots(self):
|
||||
for i in range(0,16):
|
||||
if self.slots[i].user is not None and self.slots[i].status == slotStatuses.PLAYING:
|
||||
|
@ -814,4 +820,37 @@ class match:
|
|||
def resetReady(self):
|
||||
for _slot in self.slots:
|
||||
if _slot.status == slotStatuses.READY:
|
||||
_slot.status = slotStatuses.NOT_READY
|
||||
_slot.status = slotStatuses.NOT_READY
|
||||
|
||||
def sendReadyStatus(self):
|
||||
chanName = "#multi_{}".format(self.matchID)
|
||||
|
||||
# Make sure match exists before attempting to do anything else
|
||||
if chanName not in glob.channels.channels:
|
||||
return
|
||||
|
||||
totalUsers = 0
|
||||
readyUsers = 0
|
||||
|
||||
for slot in self.slots:
|
||||
# Make sure there is a user in this slot
|
||||
if slot.user is None:
|
||||
continue
|
||||
|
||||
# In this slot there is a user, so we increase the amount of total users
|
||||
# in this multi room.
|
||||
totalUsers += 1
|
||||
|
||||
if slot.status == slotStatuses.READY:
|
||||
readyUsers += 1
|
||||
|
||||
message = "{} users ready out of {}.".format(readyUsers, totalUsers)
|
||||
|
||||
if totalUsers == readyUsers:
|
||||
message += " All users ready!"
|
||||
|
||||
# Check whether there is anyone left in this match.
|
||||
if totalUsers == 0:
|
||||
message = "The match is now empty."
|
||||
|
||||
chat.sendMessage("FokaBot", chanName, message)
|
||||
|
|
|
@ -321,9 +321,12 @@ class token:
|
|||
chat.joinChannel(token=self, channel="#multi_{}".format(self.matchID))
|
||||
self.enqueue(serverPackets.matchJoinSuccess(matchID))
|
||||
|
||||
# Alert the user if we have just joined a tourney match
|
||||
if match.isTourney:
|
||||
# Alert the user if we have just joined a tourney match
|
||||
self.enqueue(serverPackets.notification("You are now in a tournament match."))
|
||||
# If an user joins, then the ready status of the match changes and
|
||||
# maybe not all users are ready.
|
||||
match.sendReadyStatus()
|
||||
|
||||
def leaveMatch(self):
|
||||
"""
|
||||
|
@ -354,10 +357,15 @@ class token:
|
|||
# Set slot to free
|
||||
match.userLeft(self)
|
||||
|
||||
if match.isTourney:
|
||||
# If an user leaves, then the ready status of the match changes and
|
||||
# maybe all users are ready. Or maybe nobody is in the match anymore
|
||||
match.sendReadyStatus()
|
||||
|
||||
def kick(self, message="You have been kicked from the server. Please login again.", reason="kick"):
|
||||
"""
|
||||
Kick this user from the server
|
||||
|
||||
|
||||
:param message: Notification message to send to this user.
|
||||
Default: "You have been kicked from the server. Please login again."
|
||||
:param reason: Kick reason, used in logs. Default: "kick"
|
||||
|
|
Loading…
Reference in New Issue
Block a user