# -*- coding: cp936 -*-
import urllib
import urllib2
import time
__metaclass__=type
class CheckItem:
def __init__(self):
self.dic={}
filename = raw_input('输入物品名称表:') + '.txt'
with open(filename,'r') as f:
lines = f.readlines()
for line in lines:
temp = line.strip('\n').split('\t')
temp_key = '['+temp[0]+','+temp[1]+','+temp[2]+']'
temp_val = temp[3]
self.dic[temp_key]=temp_val
def checkDic(self):
filename = raw_input('输入奖励物品:') + '.txt'
with open(filename,'r') as f:
lines = f.readlines()
for line in lines:
line_list = eval(line)
temp = '['+str(line_list[0])+','+str(line_list[1])+','+str(line_list[2])+']'
num = line_list[3]
#print temp
try:
print self.dic[temp]+'x'+ str(num)
except (KeyError),e:
print 'ID:%s not find' % e
class GmTool:
def __init__(self):
self.url='http://xxx.xxx.xxx'
self.value = {
'AreaID':'1',
'Uid':None,
'Name':'',
'Type':None,
'SubType':None,
'ID':None,
'Count':None,
'Lock':'0'
}
self.UUID = raw_input('输入角色ID:')
def __postMsg(self,UUID,params):
self.value['Uid']=UUID
self.value['Type']=params[0]
self.value['SubType']=params[1]
self.value['ID']=params[2]
try:
self.value['Count']=params[3]
except IndexError:
self.value['Count']=10
#print self.value
data = urllib.urlencode(self.value)
req = urllib2.Request(self.url,data)
urllib2.urlopen(req)
def sendByInput(self):
while True:
print '----------------------------'
putin = raw_input('输入道具ID、数量:')
if not putin:break
if '\t' in putin: putin = putin.replace('\t','.')
temp = putin.split('.')
#temp = tuple(temp)
self.__postMsg(self.UUID,temp)
def sendByTxt(self):
print '----------------------------'
filename = raw_input('输入文件名:') + '.txt'
#print filename
if not filename: return
num = raw_input('输入道具数量:')
print '道具发送中...'
with open(filename,'r') as f:
lines = f.readlines()
for line in lines:
if line=='\n': return
temp = line.strip('\n').split('\t')
temp.append(str(num))
#print temp
self.__postMsg(self.UUID,temp)
def sendByCopy(self):
print '----------------------------'
lines=eval(raw_input('输入合成需要道具:'))
if not lines: return
for line in lines:
if line[0]==0: return
temp = line[:4]
#print temp
self.__postMsg(self.UUID,temp)
定义类,GM工具脚本
最新推荐文章于 2025-06-19 23:16:23 发布