def clearAttacksPlayerDead(victim): """ Remove all attacks against dead player. """ for player in AllPlayers.values(): if player.attacking == victim: endCombat( player )
def doDurationEffectSpells(): """ Apply duration effects of spells. """ for player in AllPlayers.values(): # If player isn't playing. No need to heal if player.status is not PLAYING: continue for spell in player.spells.values(): spell.durationEffect()
def doCombatRound(combatqueue): """ Calls doAttack for each player in the combat queue. """ for attacker in combatqueue.getCombatQueue(): if attacker not in AllPlayers.keys(): combatqueue.removeAttack(attacker) else: player = AllPlayers[attacker] if not player.attacking: continue if player.attacking.name not in AllPlayers.keys(): endCombat(player) else: victim = player.attacking if player.room == victim.room: doAttack(player, victim) else: endCombat(player)
def naturalHealing(): """ Natural healing loop. """ healRate = 5 for player in AllPlayers.values(): # If player isn't playing. No need to heal if player.status is not PLAYING: continue healPlayer(player, HP, healRate) player.statLine()
def restHealing(): """ If player resting, rest heal him. """ healRate = 15 for player in AllPlayers.values(): # If player isn't playing. No need to heal if player.status is not PLAYING: continue if player.stats[RESTING]: healPlayer(player, HP, healRate) player.statLine()
def saveAllPlayers(): """ Save all users. """ i = 0 for player in AllPlayers.values(): if player.status is PLAYING or player.status is PURGATORY: i += 1 player.save() logger.gamelogger.logger.log.debug("Saving {0} of {1} players.".format(i, len(AllPlayers)))
def getUsername(player, line): """ getUsername() Check for username or new and work. """ # not blank, 15 characters or less and all characters are alpha or numberic if line == "" or len(line) > 15 or not line.isalnum(): player.sendLine("Invalid name, please try again.") askUsername(player) return if player.status is LOGIN: # If "new", create new player. TODO: Setup the new character creation functionality if line.lower() == "new": player.status = CREATEPLAYER createPlayer(player) return from character.players import AllPlayers # Check to see if the player's name is already connected. for name in AllPlayers.keys(): if line.lower() in name.lower(): player.sendLine("User is already connected, please try again.") askUsername(player) return # See if player exists in database. if player.status is LOGIN: if utils.gameutils.userCheck(line): player.name = line player.loadPlayer() player.status = GETPASSWORD player.transport.write("Enter your password: "******"Username entered does not exist, please try again.") askUsername(player) return elif player.status is GETNEWUSERNAME: # name can't be "new" if line.lower() == "new": player.sendLine("Invalid name, please try again.") player.status = LOGIN askUsername(player) return if not utils.gameutils.userCheck(line): player.name = line[:1].upper() + line[1:] player.status = GETNEWPASSWORD # Disable local echo to not show passwords being typed. #player.transport._dont(ECHO) askPlayerPassword(player) return else: character.communicate.sendToPlayer(player, "Username already exist, please try again.") player.status = LOGIN askUsername(player) return logger.gamelogger.logger.log.info( "{0} just logged in.".format(player) ) player.status = GETCLASS askClass(player)