Anyone care to lend a small hand.
Absolutely hate working out bitmasks.
Need bitmask to detect if user == bot
* MYSTATUS status
Sent by client to server telling him his status changed. Each bit has its meaning:
b0 = in game (0 - normal, 1 - in game)
b1 = away status (0 - normal, 1 - away)
b2-b4 = rank (see Account class implementation for description of rank) - client is not
allowed to change rank bits himself (only server may set them).
b5 = access status (tells us whether this client is a server moderator or not) - client is not
allowed to change this bit himself (only server may set them).
b6 = bot mode (0 - normal user, 1 - automated bot). This bit is copied from user's account
and can not be changed by the client himself. Bots differ from human players in that
they are fully automated and that some anti-flood limitations do not apply to them.
To figure out if battle is "in-game", client must check in-game status of the host.
Extract of sample of bitmask code in UnityLobby atm for an idea.
Just need a sample of code or bitmask number to use would save me alot of working out. If u understand it better than i do :)
Code: Select all
isAway() =========================================================================================
# ==================================================================================================
# Returns true if the user is "away",
# and false if they are not.
# ==================================================================================================
def isAway(self):
status = self.status
bitmask = 2
status = bitmask & status
#Bitwise AND
#===================
#2 = 000010
#status = 010110
#returns= 000010
if status != 0:
return True
else:
return False
# /end isAway() ====================================================================================
# inGame() =========================================================================================
# ==================================================================================================
# Returns true if the user is in a game,
# and false if they are not.
# ==================================================================================================
def inGame(self):
status = self.status
bitmask = 1
status = bitmask & status
if status != 0:
return True
else:
return False
# /end inGame() ====================================================================================
# getRank() ========================================================================================
# ==================================================================================================
# Returns the users rank and updates the self.rank_image variable.
# ==================================================================================================
def getRank(self):
status = self.status
bitmask = 0x1C
status = bitmask & status
status = status >> 2
if self.admin() == False:
self.rank_image = status + 5
else:
self.rank_image = 10
return str(status)
# /end getRank() ===================================================================================
# admin() ==========================================================================================
# ==================================================================================================
# Returns true if the user is admin
# ==================================================================================================
def admin(self):
status = self.status
bitmask = 32
status = bitmask & status
if status != 0:
return True
else:
return False
# /end admin() =====================================================================================