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)
|
slotID = match.getUserSlotID(userID)
|
||||||
if slotID is not None:
|
if slotID is not None:
|
||||||
match.toggleSlotReady(slotID)
|
match.toggleSlotReady(slotID)
|
||||||
|
|
||||||
|
# If this is a tournament match, we should send the current status of ready
|
||||||
|
# players.
|
||||||
|
if match.isTourney:
|
||||||
|
match.sendReadyStatus(match)
|
||||||
|
|
|
@ -815,3 +815,36 @@ class match:
|
||||||
for _slot in self.slots:
|
for _slot in self.slots:
|
||||||
if _slot.status == slotStatuses.READY:
|
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))
|
chat.joinChannel(token=self, channel="#multi_{}".format(self.matchID))
|
||||||
self.enqueue(serverPackets.matchJoinSuccess(matchID))
|
self.enqueue(serverPackets.matchJoinSuccess(matchID))
|
||||||
|
|
||||||
# Alert the user if we have just joined a tourney match
|
|
||||||
if match.isTourney:
|
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."))
|
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):
|
def leaveMatch(self):
|
||||||
"""
|
"""
|
||||||
|
@ -354,6 +357,11 @@ class token:
|
||||||
# Set slot to free
|
# Set slot to free
|
||||||
match.userLeft(self)
|
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"):
|
def kick(self, message="You have been kicked from the server. Please login again.", reason="kick"):
|
||||||
"""
|
"""
|
||||||
Kick this user from the server
|
Kick this user from the server
|
||||||
|
|
Loading…
Reference in New Issue
Block a user