Add: [TW] Commission support (#360)

This commit is contained in:
LmeSzinc 2021-11-14 13:00:50 +08:00
parent 93cc5e7bd7
commit e25577f71f
2 changed files with 82 additions and 1 deletions

View File

@ -186,7 +186,51 @@ class Commission:
color -= [50, 30, 20]
self.status = dic[int(np.argmax(color))]
@Config.when(SERVER='cn')
@Config.when(SERVER='tw')
def commission_parse(self):
# Name
area = area_offset((176, 23, 420, 53), self.area[0:2])
button = Button(area=area, color=(), button=area, name='COMMISSION')
ocr = Ocr(button, lang='tw', threshold=256)
self.button = button
self.name = ocr.ocr(self.image)
self.genre = self.commission_name_parse(self.name)
# Suffix
ocr = SuffixOcr(button, lang='azur_lane', letter=(255, 255, 255), threshold=128, alphabet='IV')
self.suffix = self.beautify_name(ocr.ocr(self.image))
# Duration time
area = area_offset((290, 68, 390, 95), self.area[0:2])
button = Button(area=area, color=(), button=area, name='DURATION')
ocr = Duration(button)
self.duration = ocr.ocr(self.image)
# Expire time
area = area_offset((-49, 68, -45, 84), self.area[0:2])
button = Button(area=area, color=(189, 65, 66),
button=area, name='IS_URGENT')
if button.appear_on(self.image):
area = area_offset((-49, 67, 45, 94), self.area[0:2])
button = Button(area=area, color=(), button=area, name='EXPIRE')
ocr = Duration(button)
self.expire = ocr.ocr(self.image)
else:
self.expire = timedelta(seconds=0)
# Status
area = area_offset((179, 71, 187, 93), self.area[0:2])
dic = {
0: 'finished',
1: 'running',
2: 'pending'
}
color = get_color(self.image, area)
if self.genre == 'event_daily':
color -= [50, 30, 20]
self.status = dic[int(np.argmax(color))]
@Config.when(SERVER=None)
def commission_parse(self):
# Name
area = area_offset((176, 23, 420, 53), self.area[0:2])
@ -346,6 +390,26 @@ class Commission:
self.valid = False
return ''
@Config.when(SERVER='tw')
def commission_name_parse(self, string):
"""
Args:
string (str): Commission name, such as 'NYB要员护卫'.
Returns:
str: Commission genre, such as 'urgent_gem'.
"""
if self.is_event_commission():
return 'daily_event'
for key, value in dictionary_tw.items():
for keyword in value:
if keyword in string:
return key
logger.warning(f'Name with unknown genre: {string}')
self.valid = False
return ''
@Config.when(SERVER=None)
def commission_name_parse(self, string):
"""

View File

@ -55,3 +55,20 @@ dictionary_jp = {
'urgent_gem': ['要人護衛', '休暇護衛'],
'urgent_ship': ['小型観艦式', '連合艦隊観艦式', '多国連合観艦式'],
}
dictionary_tw = {
'major_comm': ['自主訓練', '對抗演習', '科研任務', '工具整備', '戰術課程', '貨物運輸'],
'daily_resource': ['日常資源開發'],
'daily_chip': ['高階戰術研發'],
'extra_drill': ['航行訓練', '防衛巡邏', '海域浮標檢查作業'],
'extra_part': ['委託'],
'extra_cube': ['演習'],
'extra_oil': ['油田'],
'extra_book': ['商船護衛'],
'urgent_drill': ['運輸部隊', '偵查部隊', '主力部隊', '精銳部隊'],
'urgent_part': ['維拉', '', '多倫瓦', '恐班納', '馬內', ''],
'urgent_book': ['土豪爾', '姆波羅', '馬拉基', '卡波羅', '瑪麗', '特林'],
'urgent_box': ['裝備', '物資'],
'urgent_cube': ['解救', '敵襲'],
'urgent_gem': ['要員', '度假', '巡視'],
'urgent_ship': ['觀艦'],
}