Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Jan 10, 2014
2 parents 59163b4 + 819644f commit e8610d5
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 574 deletions.
29 changes: 28 additions & 1 deletion db/card.kr.txt

Large diffs are not rendered by default.

34 changes: 28 additions & 6 deletions db/card.tw.txt

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion db/item.kr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@
80,기적의 응원수술,많이 모으면∙∙∙
81,성탄 양말,많이 모으면∙∙∙
82,배틀 포인트,많이 모으면∙∙∙
83,두둑한 세뱃돈,많이 모으면∙∙∙
84,할배가 주는 세뱃돈,많이 모으면∙∙∙
8001,명예의 깃발,많이 모으면∙∙∙
8002,명예의 깃발,많이 모으면∙∙∙
8003,명예의 깃발,많이 모으면∙∙∙
8004,명예의 깃발,많이 모으면∙∙∙
8005,명예의 깃발,많이 모으면∙∙∙
8006,명예의 깃발,많이 모으면∙∙∙
8007,명예의 깃발,많이 모으면∙∙∙
8008,명예의 깃발,많이 모으면∙∙∙
8008,명예의 깃발,많이 모으면∙∙∙
8009,명예의 깃발,많이 모으면∙∙∙
3 changes: 2 additions & 1 deletion db/item.tw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@
86,指南針,從古代流傳下來指引方向的物品
87,砲管碎片,砲管的碎片
88,甲板碎片,甲板的碎片
89,船錨殘骸,船錨的殘骸
89,船錨殘骸,船錨的殘骸
8001,公會點數,公會點數
4 changes: 2 additions & 2 deletions db/revision.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cn,218,218
tw,200,168
kr,225,167
tw,202,171
kr,227,168
jp,0,0
126 changes: 64 additions & 62 deletions maclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
#SERV_CN, SERV_CN2, SERV_TW = 'cn', 'cn2', 'tw'
# eval dicts
eval_fairy_select = [('LIMIT', 'time_limit'), ('NOT_BATTLED', 'not_battled'), ('.lv', '.fairy.lv'), ('IS_MINE', 'user.id == self.player.id'), ('IS_WAKE_RARE', 'wake_rare'), ('IS_WAKE', 'wake'), ('IS_GUILD', "fairy.race_type=='12'"), ('STILL_ALIVE', "self.player.fairy['alive']")]
eval_fairy_select_carddeck = [('IS_MINE', 'discoverer_id == self.player.id'), ('IS_WAKE_RARE', 'wake_rare'), ('IS_WAKE', 'wake'), ('STILL_ALIVE', "self.player.fairy['alive']"), ('LIMIT', 'time_limit')]
eval_fairy_select_carddeck = [('IS_MINE', 'discoverer_id == self.player.id'), ('IS_WAKE_RARE', 'wake_rare'), ('IS_WAKE', 'wake'), ('STILL_ALIVE', "self.player.fairy['alive']"), ('LIMIT', 'time_limit'), ('IS_GUILD', "race_type=='12'")]
eval_explore_area = [('IS_EVENT', "area_type=='1'"), ('IS_GUILD', "race_type=='12'"), ('IS_DAILY_EVENT', "id.startswith('5')"), ('NOT_FINNISHED', "prog_area!='100'")]
eval_explore_floor = [('NOT_FINNISHED', 'progress!="100"')]
eval_select_card = [('atk', 'power'), ('mid', 'master_card_id'), ('price', 'sale_price'), ('sid', 'serial_id'), ('holo', 'holography==1')]

eval_task = []
duowan = {'cn':'http://db.duowan.com/ma/cn/card/detail/%s.html', 'tw':'http://db.duowan.com/ma/card/detail/%s.html'}
#duowan = {'cn':'http://db.duowan.com/ma/cn/card/detail/%s.html', 'tw':'http://db.duowan.com/ma/card/detail/%s.html'}
logging = maclient_logging.Logging('logging') # =sys.modules['logging']

def setT(strt):
Expand Down Expand Up @@ -985,10 +985,10 @@ def gacha(self, gacha_type = GACHA_FRIENNSHIP_POINT):
for card in excards:
mid = self.player.card.sid(card.serial_id).master_card_id
if gacha_type > GACHA_FRIENNSHIP_POINT:
rare = ['R', 'R+', 'SR', 'SR+']
rare = ['R', 'R+', 'SR', 'SR+','MR']
rare_str = ' ' + rare[self.carddb[int(mid)][1] - 3]
else:
rare = ['', '', '', 'R+', 'SR', 'SR+']
rare = ['', '', '', 'R+', 'SR', 'SR+','MR']
rare_str = ' %s' % (rare[self.carddb[int(mid)][1] - 1])
excname.append('[%s]%s%s' % (
self.carddb[int(mid)][0],
Expand Down Expand Up @@ -1285,10 +1285,11 @@ def fairy_floor(f = fairy):
# if fairy.race_type == '12':#找不到
# disc_name = '公会妖精'
hms = lambda x:x >= 3600 and time.strftime('%H:%M:%S', time.localtime(x + 16 * 3600)) or time.strftime('%M:%S', time.localtime(x))
logging.info('妖精:%sLv%d hp:%d 发现者:%s 小伙伴:%d 剩余%s %s' % (
logging.info('妖精:%sLv%d hp:%d 发现者:%s 小伙伴:%d 剩余%s %s%s' % (
fairy.name, fairy.lv, fairy.hp, disc_name,
len(f_attackers), hms(fairy.time_limit),
fairy.wake and 'WAKE!' or''))
fairy.race_type == '12' and '公会' or '',
fairy.wake and ' WAKE!' or ''))
if carddeck:
cardd = carddeck
logging.debug('fairy_battle:carddeck override:%s' % (cardd))
Expand Down Expand Up @@ -1856,62 +1857,63 @@ def factor_battle(self, minbc = 0, sel_lake = ''):
deck_rank = int(u.deck_rank)
rank = int(u.rank)
lv = int(u.town_level)
try:
star = int(self.carddb[cid][1])
except KeyError:
logging.warning('id为 %d 的卡片木有找到. 你可能想要查看这个网页:\n%s' % (
cid,
duowan[self.loc[:2]] % (base64.encodestring('{"no":"%d"}' % cid).strip('\n').replace('=', '_3_'))))
else:
logging.debug('factor_battle: star:%s, cid:%d, deckrank:%d, cost:%d, result:%s' % (
star,
cid,
deck_rank,
cost,
eval(self.evalstr_factor))
)
if eval(self.evalstr_factor):
logging.debug('factor_battle:->%s @ %s' % (u.name, u.leader_card.master_card_id))
ap = self.player.ap['current']
bc = self.player.bc['current']
logging.info('%s%s%s' % ('艹了一下一个叫 ', u.name, ' 的家伙'))
if l.event_id != '0': # event
fparam = 'battle_type=0&event_id=%s&user_id=%s' % (l.event_id, u.id)
else:
fparam = 'lake_id=%s&parts_id=%d&user_id=%s' % (l.lake_id, partid, u.id)
resp, ct = self._dopost('battle/battle', postdata = fparam)
if resp['error']:
time.sleep(2)
continue
elif resp['errno'] == 1050:
logging.warning('BC不够了TOT')
if not self.red_tea(False):
logging.error('那就不打了哟(* ̄︶ ̄)y ')
return
else:
try:
result = ct.body.battle_result.winner
except KeyError:
logging.warning('no BC ?')
return
if int(resp['content-length']) > 10000:
logging.info('收集碎片合成了新的骑士卡片!')
# print bc,self.player.bc.current
logging.info((result == '0' and '擦输了QAQ' or '赢了XDDD') +
' AP:%+d/%s/%s' % (
self.player.ap['current'] - ap,
self.player.ap['current'],
self.player.ap['max']) +
' BC:%+d/%s/%s' % (
self.player.bc['current'] - bc,
self.player.bc['current'],
self.player.bc['max']))
time.sleep(8.62616513)
resp, cmp_parts_ct = self._dopost('battle/area')
if result == '1': # 赢过一次就置为真
battle_win += 1
cmp_parts = cmp_parts_ct.body.competition_parts
break
star = int(self.carddb[cid][1])
# try:
# star = int(self.carddb[cid][1])
# except KeyError:
# logging.warning('id为 %d 的卡片木有找到. 你可能想要查看这个网页:\n%s' % (
# cid,
# duowan[self.loc[:2]] % (base64.encodestring('{"no":"%d"}' % cid).strip('\n').replace('=', '_3_'))))
# else:
logging.debug('factor_battle: star:%s, cid:%d, deckrank:%d, cost:%d, result:%s' % (
star,
cid,
deck_rank,
cost,
eval(self.evalstr_factor))
)
if eval(self.evalstr_factor):
logging.debug('factor_battle:->%s @ %s' % (u.name, u.leader_card.master_card_id))
ap = self.player.ap['current']
bc = self.player.bc['current']
logging.info('%s%s%s' % ('艹了一下一个叫 ', u.name, ' 的家伙'))
if l.event_id != '0': # event
fparam = 'battle_type=0&event_id=%s&user_id=%s' % (l.event_id, u.id)
else:
fparam = 'lake_id=%s&parts_id=%d&user_id=%s' % (l.lake_id, partid, u.id)
resp, ct = self._dopost('battle/battle', postdata = fparam)
if resp['error']:
time.sleep(2)
continue
elif resp['errno'] == 1050:
logging.warning('BC不够了TOT')
if not self.red_tea(False):
logging.error('那就不打了哟(* ̄︶ ̄)y ')
return
else:
try:
result = ct.body.battle_result.winner
except KeyError:
logging.warning('no BC ?')
return
if int(resp['content-length']) > 10000:
logging.info('收集碎片合成了新的骑士卡片!')
# print bc,self.player.bc.current
logging.info((result == '0' and '擦输了QAQ' or '赢了XDDD') +
' AP:%+d/%s/%s' % (
self.player.ap['current'] - ap,
self.player.ap['current'],
self.player.ap['max']) +
' BC:%+d/%s/%s' % (
self.player.bc['current'] - bc,
self.player.bc['current'],
self.player.bc['max']))
time.sleep(8.62616513)
resp, cmp_parts_ct = self._dopost('battle/area')
if result == '1': # 赢过一次就置为真
battle_win += 1
cmp_parts = cmp_parts_ct.body.competition_parts
break
time.sleep(int(self._read_config('system', 'factor_sleep')))
logging.sleep('换一个碎片……:-/')
time.sleep(int(self._read_config('system', 'factor_sleep')))
Expand Down
6 changes: 3 additions & 3 deletions maclient_smart.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import time
import math
import itertools
__version__ = '1.1-build20140103'
__version__ = '1.1-build20140109'
# server specified configutaions
max_card_count_cn = max_card_count_kr = max_card_count_tw = max_card_count_jp = 250
max_fp_cn = max_fp_kr = 50000
Expand All @@ -32,8 +32,8 @@
app_ver_kr = 105
app_ver_jp = 236
# wake
name_wake_rare = ['神秘']
name_wake = name_wake_rare + ['觉醒', '覺醒', '聖劍']
name_wake_rare = ['-PLACE-HOLDER-']
name_wake = name_wake_rare + ['觉醒', '覺醒', '黑劍']
# snda gplus, not working
class snda_gplus():
# thanks to luw2007(https://github.com/luw2007/libMA/blob/master/push.py)
Expand Down
9 changes: 6 additions & 3 deletions plugins/carddeck_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from _prototype import plugin_prototype
import sys
import os
from subprocess import Popen, PIPE
import re
from cross_platform import *
from xml2dict import XML2Dict
Expand Down Expand Up @@ -78,12 +79,14 @@ def write_config(sec, key, val):
os.system('adb logcat -c')
#suppress all but D/CJH
#btw CJH is...what?
logcat=os.popen('adb logcat CJH:D *:S')
logcat=Popen('adb logcat CJH:D *:S', stdout = PIPE)
print(du8('=======Good!'))
print(du8('请设置一次卡组,并保存\n你可以按Ctrl+C退出'))
while(1):
try:
line=logcat.readline()
line = logcat.stdout.readline()
if not line:
break
C=re.findall('([\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+,'
'[\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+,[\d|empty]+)',line)
if C!=[]:
Expand All @@ -104,7 +107,7 @@ def write_config(sec, key, val):
except KeyboardInterrupt:
break
print(du8('请设置一次卡组,并保存\n你可以按Ctrl+C退出'))

os.system('adb kill-server')
return do

def check_debug(plugin_vals):
Expand Down
44 changes: 44 additions & 0 deletions plugins/infinite_guild_fairy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# coding:utf-8
from _prototype import plugin_prototype
from cross_platform import *
import time
# start meta
__plugin_name__ = '狼娘无限舔公会妖'
__author = 'fffonion'
__version__ = 0.2
__tip__ = '插件已开启,如需关闭请移除plugins下的infinite_guild_fairy'
hooks = {'EXIT__fairy_battle':10}
# extra cmd hook
extra_cmd = {}
# end meta
class plugin(plugin_prototype):
def __init__(self):
self.__name__ = __plugin_name__
self.mac_instance = None

def fairy_floor(self,fairy):
paramfl = 'check=1&race_type=%s&serial_id=%s&user_id=%s' % (
fairy.race_type, fairy.serial_id, fairy.discoverer_id)
resp, ct = self.mac_instance._dopost('exploration/fairy_floor', postdata = paramfl)
if resp['error']:
return None
else:
return ct.body.fairy_floor.explore.fairy

def EXIT__fairy_battle(self, *args, **kwargs):
self.logger = args[0].logger
fairy=args[1]
if fairy.race_type == '12' and fairy.time_limit != '0':
print(du8("工会妖精!"))
self.mac_instance = args[0]
self.mac_instance.lastfairytime=0
if self.mac_instance.player.bc['current']>=2:
time.sleep(5)
fairy=self.fairy_floor(fairy)
if fairy.hp == '0':
return
self.mac_instance._fairy_battle(fairy, kwargs)
else:
print(du8("BC<2,两分钟后再战ww"))
time.sleep(120)

Loading

0 comments on commit e8610d5

Please sign in to comment.