定义类,GM工具脚本

来源:互联网 发布:网络拓扑分层的好处 编辑:程序博客网 时间:2024/04/20 03:31
# -*- coding: cp936 -*-import urllibimport urllib2import time__metaclass__=typeclass 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' % eclass 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)

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 彩虹圈线缠住了怎么办 彩虹圈被打搅了怎么办 吃中药吃大蒜了怎么办 呕吐蛋黄哥干了怎么办 鹦鹉的脚受伤了怎么办 内痔疮疼得厉害怎么办 孕妇用了痔疮膏怎么办 痔疮犯了特别疼怎么办 有痔疮肛门很痛怎么办 这几天痔疮犯了怎么办 孕初期肛裂出血怎么办 胃疼怎么办怎么缓解胃 脚踝崴了肿了怎么办 脚扭了脚背肿了怎么办 儿童脚扭伤肿了怎么办 脚关节扭伤肿了怎么办 小孩脚扭伤肿了怎么办 抱小孩腰扭伤了怎么办 跳舞把腰拉伤了怎么办 脚不小心扭伤了怎么办 娱乐之太帅了怎么办txt 走路走多了脚痛怎么办 胃疼怎么办简单按摩法 经常胃疼的厉害怎么办 半夜胃疼的厉害怎么办 吃消炎药伤胃了怎么办 吃药伤胃了胃疼怎么办 宝宝吃药伤胃了怎么办 胃胀胃痛怎么办快速解决方法 半夜2点3点胃疼怎么办 晚上吃多了胃疼怎么办 骨折打石膏后痒怎么办 脚脖子崴了肿了怎么办 喝酒喝的吐血了怎么办 感冒后咳嗽有痰怎么办 嗓子里老是有痰怎么办 物业把水停了怎么办 机洗衬衫缩水了怎么办 羊绒大衣洗缩水了怎么办 棉质衣服缩水了怎么办 衣服洗了变小了怎么办