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 NA servers #111

Merged
merged 4 commits into from
Aug 7, 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
11 changes: 9 additions & 2 deletions FGO-py/fgoDetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
for i in range(3):setattr(IMG,f'CHARGE{i}_SMALL',[cv2.resize(i,(0,0),fx=.77,fy=.77,interpolation=cv2.INTER_CUBIC)for i in getattr(IMG,f'CHARGE{i}')])
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')})
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 @@ -188,6 +189,11 @@ class XDetectCN(XDetectBase,metaclass=logMeta(logger)):
class XDetectJP(XDetectBase,metaclass=logMeta(logger)):
tmpl=IMG_JP
ocr=OCR.JA
class XDetectNA(XDetectBase,metaclass=logMeta(logger)):
tmpl=IMG_NA
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 DetectBase(XDetectBase,metaclass=logMeta(logger)):
def __init__(self,anteLatency=.1,postLatency=0):
schedule.sleep(anteLatency)
Expand All @@ -207,15 +213,16 @@ def _asyncImageChange(self,*args,**kwargs):
p=yield t
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 XDetect:
provider={'CN':XDetectCN,'JP':XDetectJP}
provider={'CN':XDetectCN,'JP':XDetectJP,'NA':XDetectNA}
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}
class Detect(XDetect):provider={'CN':DetectCN,'JP':DetectJP,'NA':DetectNA}
def setup(device):
XDetectBase.screenshot=device.screenshot
if not hasattr(device,'package'):return
Expand Down
Binary file added FGO-py/fgoImage/na/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/na/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/na/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/na/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/na/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/na/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/na/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/na/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/na/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/na/synthesis.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.