Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for TW server 增加對台服的支持 #114

Merged
merged 10 commits into from Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions FGO-py/fgoConst.py
Expand Up @@ -43,6 +43,6 @@
'com.bilibili.fatego':'CN',
'com.aniplex.fategrandorder':'JP',
'com.aniplex.fategrandorder.en':'NA',
'com.aniplex.fategrandorder.tw':'TW',
'com.xiaomeng.fategrandorder':'TW',
'com.aniplex.fategrandorder.kr':'KR',
}
}
10 changes: 8 additions & 2 deletions FGO-py/fgoDetect.py
Expand Up @@ -13,6 +13,7 @@
IMG_CN=type('IMG_CN',(IMG,),{i[:-4].upper():(lambda x:(x[...,:3],x[...,3]))(cv2.imread(f'fgoImage/cn/{i}',cv2.IMREAD_UNCHANGED))for i in os.listdir('fgoImage/cn')if i.endswith('.png')})
IMG_JP=type('IMG_JP',(IMG,),{i[:-4].upper():(lambda x:(x[...,:3],x[...,3]))(cv2.imread(f'fgoImage/jp/{i}',cv2.IMREAD_UNCHANGED))for i in os.listdir('fgoImage/jp')if i.endswith('.png')})
IMG_NA=type('IMG_NA',(IMG,),{i[:-4].upper():(lambda x:(x[...,:3],x[...,3]))(cv2.imread(f'fgoImage/na/{i}',cv2.IMREAD_UNCHANGED))for i in os.listdir('fgoImage/na')if i.endswith('.png')})
IMG_TW=type('IMG_TW',(IMG,),{i[:-4].upper():(lambda x:(x[...,:3],x[...,3]))(cv2.imread(f'fgoImage/tw/{i}',cv2.IMREAD_UNCHANGED))for i in os.listdir('fgoImage/tw')if i.endswith('.png')})
CLASS={100:[(lambda x:(x[...,:3],x[...,3]))(cv2.imread(f'fgoImage/class/{i}{j}.png',cv2.IMREAD_UNCHANGED))for i in['shielder','saber','archer','lancer','rider','caster','assassin','berserker','ruler','avenger','alterego','mooncancer','foreigner','pretender','beast']for j in range(3)]}
for scale in [75,93,125]:CLASS[scale]=[[cv2.resize(j,(0,0),fx=scale/100,fy=scale/100,interpolation=cv2.INTER_CUBIC)for j in i]for i in CLASS[100]]
MATERIAL=[(i[:-4],cv2.imread(f'fgoImage/material/{i}'))for i in os.listdir('fgoImage/material')if i.endswith('.png')]
Expand Down Expand Up @@ -194,6 +195,10 @@ class XDetectNA(XDetectBase,metaclass=logMeta(logger)):
ocr=OCR.EN
def isHouguReady(self,that=None):return(lambda that:[not any(that._compare(j,(313+231*i,194,515+231*i,270),.52)for j in(self.tmpl.HOUGUSEALED,self.tmpl.CHARASEALED,self.tmpl.CARDSEALED))and(numpy.mean(self._crop((144+319*i,679,156+319*i,684)))>55 or numpy.mean(that._crop((144+319*i,679,156+319*i,684)))>55)for i in range(3)])((time.sleep(.15),type(self)())[1]if that is None else that)
def isSkillReady(self,i,j):return not self._compare(self.tmpl.STILL,(41+318*i+88*j,607,74+318*i+88*j,614),.6)
class XDetectTW(XDetectBase,metaclass=logMeta(logger)):
tmpl=IMG_TW
ocr=OCR.ZH
def isHouguReady(self,that=None):return(lambda that:[not any(that._compare(j,(313+231*i,194,515+231*i,270),.52)for j in(self.tmpl.HOUGUSEALED,self.tmpl.CHARASEALED,self.tmpl.CARDSEALED))and(numpy.mean(self._crop((144+319*i,679,156+319*i,684)))>55 or numpy.mean(that._crop((144+319*i,679,156+319*i,684)))>55)for i in range(3)])((time.sleep(.15),type(self)())[1]if that is None else that)
class DetectBase(XDetectBase,metaclass=logMeta(logger)):
def __init__(self,anteLatency=.1,postLatency=0):
schedule.sleep(anteLatency)
Expand All @@ -214,15 +219,16 @@ def _asyncImageChange(self,*args,**kwargs):
class DetectCN(DetectBase,XDetectCN,metaclass=logMeta(logger)):pass # mro: DetectCN->DetectBase->XDetectCN->XDetectBase->object
class DetectJP(DetectBase,XDetectJP,metaclass=logMeta(logger)):pass
class DetectNA(DetectBase,XDetectNA,metaclass=logMeta(logger)):pass
class DetectTW(DetectBase,XDetectTW,metaclass=logMeta(logger)):pass
class XDetect:
provider={'CN':XDetectCN,'JP':XDetectJP,'NA':XDetectNA}
provider={'CN':XDetectCN,'JP':XDetectJP,'NA':XDetectNA,'TW':XDetectTW}
region=''
cache=None
def __new__(cls,*args,**kwargs):
if cls.region:cls.cache=cls.provider[cls.region](*args,**kwargs)
else:cls.cache=XDetectBase(*args,**kwargs)
return cls.cache
class Detect(XDetect):provider={'CN':DetectCN,'JP':DetectJP,'NA':DetectNA}
class Detect(XDetect):provider={'CN':DetectCN,'JP':DetectJP,'NA':DetectNA,'TW':DetectTW}
def setup(device):
XDetectBase.screenshot=device.screenshot
if not hasattr(device,'package'):return
Expand Down
Binary file added FGO-py/fgoImage/tw/arts.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FGO-py/fgoImage/tw/buster.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FGO-py/fgoImage/tw/cardsealed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FGO-py/fgoImage/tw/charasealed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FGO-py/fgoImage/tw/defeated.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FGO-py/fgoImage/tw/dropitem.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FGO-py/fgoImage/tw/hougusealed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FGO-py/fgoImage/tw/quick.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FGO-py/fgoImage/tw/still.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FGO-py/fgoImage/tw/synthesis.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.