Firefly《暗黑世界》片段合成部分代碼

來源:互聯網
上載者:User

標籤:des   代碼   re   div   c   line   

這裡講的是Firefly《暗黑世界》片段合成的流程部分的代碼,這個主要是訊息解析的部分,好吧上代碼,代碼路徑app/game/gatenodeapp/compound.py。

  1. #coding:utf8

  2. ‘‘‘

  3. Created on 2013-3-21

  4. 物品合成

  5. @author: lan (www.9miao.com)

  6. ‘‘‘

  7. from app.game.gatenodeservice import remoteserviceHandle

  8. import json

  9. #匯入功能邏輯處理模組

  10. from app.game.appinterface import compound

  11.  

  12. @remoteserviceHandle#將處理方法,添加到service中,供gateserver進程調用。

  13. def GetCompoundPackage_2109(dynamicId,request_proto):

  14.     ‘‘‘擷取合成包裹的資訊

  15.     ‘‘‘

  16.         #解析json字串

  17.     argument = json.loads(request_proto)

  18.         #擷取角色的ID

  19.     characterId = argument.get(‘characterId‘)

  20.         #擷取合成包裹的資訊

  21.     response = compound.GetCompoundPackage_2109(dynamicId, characterId)

  22.         #將資訊序列化,產生json字串,返回給用戶端

  23.     return json.dumps(response)

  24.  

  25. @remoteserviceHandle#將處理方法,添加到service中,供gateserver進程調用。

  26. def GetOneItemInfo_211(dynamicId,request_proto):

  27.     ‘‘‘擷取單個物品的資訊

  28.     ‘‘‘

  29.         #解析json字串

  30.     argument = json.loads(request_proto)

  31.         #擷取角色的ID

  32.     characterId = argument.get(‘characterId‘)
  33.         #擷取物品的執行個體id
  34.     itemid = argument.get(‘itemid‘)
  35.         #擷取物品的資訊
  36.     response = compound.GetOneItemInfo(dynamicId, characterId,itemid)
  37.         #將資訊序列化,產生json字串,返回給用戶端
  38.     return json.dumps(response)
  39.     
  40. @remoteserviceHandle#將處理方法,添加到service中,供gateserver進程調用。
  41. def GetCompoundItem_205(dynamicId,request_proto):
  42.     """擷取當前片段能合成的物品的資訊
  43.     """
  44.         #解析json字串
  45.     argument = json.loads(request_proto)
  46.         #擷取角色的ID
  47.     characterId = argument.get(‘characterId‘)
  48.         #擷取將要合成的物品的模型id
  49.     tempid = argument.get(‘tempid‘)
  50.         #擷取當前片段能合成的物品的資訊
  51.     response = compound.GetCompoundItem(dynamicId, characterId, tempid)
  52.         #將資訊序列化,產生json字串,返回給用戶端
  53.     return json.dumps(response)
  54.  
  55. @remoteserviceHandle#將處理方法,添加到service中,供gateserver進程調用。
  56. def CompoundItem_2116(dynamicId,request_proto):
  57.     ‘‘‘合成物品
  58.     ‘‘‘
  59.         #解析json字串
  60.     argument = json.loads(request_proto)
  61.         #擷取角色的ID
  62.     characterId = argument.get(‘characterId‘)
  63.         #擷取將要合成的物品的模型id
  64.     tempid = argument.get(‘tempid‘)
  65.         #進行物品合成並返回合成後的結果
  66.     response = compound.CompoundItem(dynamicId, charac這terId, tempid)
  67.         #將資訊序列化,產生json字串,返回給用戶端
  68.     return json.dumps(response)
  69.     
  70.  
複製代碼裡並沒有做實際的邏輯處理,只是做瞭解析用戶端發過來的參數,當要替換通訊訊息格式時,不會影響邏輯處理部分的代碼。訊息會通過netserver傳遞到gateserver,由gateserver分發給指定的gameserver,gameserver通過對於的指令號進入到對應的處理方法中處理。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.