標籤:des 代碼 re div c line
這裡講的是Firefly《暗黑世界》片段合成的流程部分的代碼,這個主要是訊息解析的部分,好吧上代碼,代碼路徑app/game/gatenodeapp/compound.py。
#coding:utf8
‘‘‘
Created on 2013-3-21
物品合成
@author: lan (www.9miao.com)
‘‘‘
from app.game.gatenodeservice import remoteserviceHandle
import json
#匯入功能邏輯處理模組
from app.game.appinterface import compound
@remoteserviceHandle#將處理方法,添加到service中,供gateserver進程調用。
def GetCompoundPackage_2109(dynamicId,request_proto):
‘‘‘擷取合成包裹的資訊
‘‘‘
#解析json字串
argument = json.loads(request_proto)
#擷取角色的ID
characterId = argument.get(‘characterId‘)
#擷取合成包裹的資訊
response = compound.GetCompoundPackage_2109(dynamicId, characterId)
#將資訊序列化,產生json字串,返回給用戶端
return json.dumps(response)
@remoteserviceHandle#將處理方法,添加到service中,供gateserver進程調用。
def GetOneItemInfo_211(dynamicId,request_proto):
‘‘‘擷取單個物品的資訊
‘‘‘
#解析json字串
argument = json.loads(request_proto)
#擷取角色的ID
- characterId = argument.get(‘characterId‘)
- #擷取物品的執行個體id
- itemid = argument.get(‘itemid‘)
- #擷取物品的資訊
- response = compound.GetOneItemInfo(dynamicId, characterId,itemid)
- #將資訊序列化,產生json字串,返回給用戶端
- return json.dumps(response)
-
- @remoteserviceHandle#將處理方法,添加到service中,供gateserver進程調用。
- def GetCompoundItem_205(dynamicId,request_proto):
- """擷取當前片段能合成的物品的資訊
- """
- #解析json字串
- argument = json.loads(request_proto)
- #擷取角色的ID
- characterId = argument.get(‘characterId‘)
- #擷取將要合成的物品的模型id
- tempid = argument.get(‘tempid‘)
- #擷取當前片段能合成的物品的資訊
- response = compound.GetCompoundItem(dynamicId, characterId, tempid)
- #將資訊序列化,產生json字串,返回給用戶端
- return json.dumps(response)
-
- @remoteserviceHandle#將處理方法,添加到service中,供gateserver進程調用。
- def CompoundItem_2116(dynamicId,request_proto):
- ‘‘‘合成物品
- ‘‘‘
- #解析json字串
- argument = json.loads(request_proto)
- #擷取角色的ID
- characterId = argument.get(‘characterId‘)
- #擷取將要合成的物品的模型id
- tempid = argument.get(‘tempid‘)
- #進行物品合成並返回合成後的結果
- response = compound.CompoundItem(dynamicId, charac這terId, tempid)
- #將資訊序列化,產生json字串,返回給用戶端
- return json.dumps(response)
-
-
複製代碼裡並沒有做實際的邏輯處理,只是做瞭解析用戶端發過來的參數,當要替換通訊訊息格式時,不會影響邏輯處理部分的代碼。訊息會通過netserver傳遞到gateserver,由gateserver分發給指定的gameserver,gameserver通過對於的指令號進入到對應的處理方法中處理。