⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fritz-franz-setup.py

📁 大型多人在线游戏开发,该书光盘上附带的源码
💻 PY
字号:
# Import Twisted codefrom twisted.spread.pb import AuthRoot, BrokerFactory, portnofrom twisted.internet.app import Applicationfrom twisted.cred.authorizer import DefaultAuthorizer# Import our own libraryimport cellphoneimport metamorph# Create root-level object and authorizerapp = Application("Metamorphosis")auth = DefaultAuthorizer(app)# Create our services (inside the App directory)phoneCompany = cellphone.PhoneCompany("cellphone", app, auth)buggyWorld = metamorph.BuggyWorld("metamorph", app, auth)# Create Identities for Joe and Bob.def makeAccount(userName, phoneNumber, bugName, pw):    # Create a cell phone for the player, so they can chat.    phone = phoneCompany.createPerspective(phoneNumber)    # Create a bug for the player, so they can play the game.    bug = buggyWorld.createPerspective(bugName)    # Create an identity for the player, so they can log in.    i = auth.createIdentity(userName)    i.setPassword(pw)    # add perspectives to identity we created    i.addKeyForPerspective(phone)    i.addKeyForPerspective(bug)    # Finally, commit the identity back to its authorizer.    i.save()# Create both Bob's and Joe's accounts.makeAccount("joe", "222-303-8484", "fritz", "joepass")makeAccount("bob", "222-303-8485", "franz", "bobpass")app.listenTCP(portno, BrokerFactory(AuthRoot(auth)))app.run()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -