In tourney rooms, send a message in the chat when the ready status changes.
This commit is contained in:
parent
48534bb551
commit
3ed837dc96
|
@ -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(match)
|
||||
|
|
|
@ -814,4 +814,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 match.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(match)
|
||||
|
||||
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(match)
|
||||
|
||||
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