Firefly《暗黑世界》碎片合成部分代码

这里讲的是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通过对于的指令号进入到对应的处理方法中处理。

原文地址:https://www.cnblogs.com/9miaoshetuan/p/3845185.html