コード例 #1
0
ファイル: region.py プロジェクト: croxis/CityMania
 def unfoundCity(self, peer, ident):
     '''Checks permissions and, if all good, unfounds city.'''
     # Can't unfound the region or a city that doesn't exist
     logging.debug("Requesting to unfound city %s by %s" %(ident, peer))
     container = proto.Container()
     if not ident or ident not in self.cities:
         container.response = "Can not unfound imaginary city."
         messenger.send("sendData", [peer, container])
         return
     
     user = users.getNameFromPeer(peer)
     access = users.getType(user)
     
     if access > 1 or self.cities[ident].mayor == user:
         for tile in self.tiles:
             if tile.cityid is ident:
                 tile.cityid = 0
                 self.updateTile(container, tile)
         del self.cities[ident]
         container.unfoundCity = ident
         messenger.send("broadcastData", [container])
     else:
         container.response = "Lack permissions for unfounding this city."
         messenger.send("sendData", [peer, container])
     logging.info("City %s unfounded. New city db: %s" %(ident, self.cities))
コード例 #2
0
ファイル: server.py プロジェクト: croxis/CityMania
 def login(self, peer, login):
     """
     Logs in player to the server
     """
     self.lock.acquire()
     container = proto.Container()
     container.loginResponse.type = 1
     if login.regionPassword != self.password:
         container.loginResponse.type = 0
         container.loginResponse.message = "Region password incorrect"
     if login.name not in users.userdb:
         users.addUser(login.name, login.password)
     loginType = users.login(login.name, login.password, peer)
     if not loginType:
         container.loginResponse.type = 0
         container.loginResponse.message = "Player password incorrect"
     if container.loginResponse.type:
         container.loginResponse.usertype = users.getType(login.name)
         container.loginResponse.username = login.name
         messenger.send("loggedIn", [peer, login.name])
         logger.info("Logged in: %s %s" %(login.name, peer) )
     messenger.send("sendData", [peer, container])
     self.lock.release()