mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-22 00:35:34 +00:00
Fix: Get obtain with Trailblaze_EXP drops
This commit is contained in:
parent
4a5508859e
commit
ca18869f2f
BIN
assets/share/combat/obtain/OBTAIN_4.png
Normal file
BIN
assets/share/combat/obtain/OBTAIN_4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.SEARCH.png
Normal file
BIN
assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.SEARCH.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.png
Normal file
BIN
assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
@ -71,8 +71,8 @@ class GenerateItemBase(GenerateKeyword):
|
||||
|
||||
class GenerateItemCurrency(GenerateItemBase):
|
||||
output_file = './tasks/planner/keywords/item_currency.py'
|
||||
# Leave 'Credit' only
|
||||
whitelist = [2]
|
||||
# Leave 'Credit' and `Trailblaze_EXP`
|
||||
whitelist = [2, 22]
|
||||
|
||||
def iter_keywords(self) -> t.Iterable[dict]:
|
||||
for data in self.iter_items():
|
||||
|
@ -80,3 +80,23 @@ OBTAIN_3 = ButtonWrapper(
|
||||
button=(965, 414, 1029, 478),
|
||||
),
|
||||
)
|
||||
OBTAIN_4 = ButtonWrapper(
|
||||
name='OBTAIN_4',
|
||||
share=Button(
|
||||
file='./assets/share/combat/obtain/OBTAIN_4.png',
|
||||
area=(1041, 414, 1105, 478),
|
||||
search=(1021, 394, 1125, 498),
|
||||
color=(76, 101, 109),
|
||||
button=(1041, 414, 1105, 478),
|
||||
),
|
||||
)
|
||||
OBTAIN_TRAILBLAZE_EXP = ButtonWrapper(
|
||||
name='OBTAIN_TRAILBLAZE_EXP',
|
||||
share=Button(
|
||||
file='./assets/share/combat/obtain/OBTAIN_TRAILBLAZE_EXP.png',
|
||||
area=(827, 425, 860, 451),
|
||||
search=(813, 349, 877, 589),
|
||||
color=(167, 173, 194),
|
||||
button=(827, 425, 860, 451),
|
||||
),
|
||||
)
|
||||
|
@ -7,7 +7,7 @@ from module.ocr.ocr import Digit
|
||||
from tasks.combat.assets.assets_combat_obtain import *
|
||||
from tasks.combat.assets.assets_combat_prepare import COMBAT_PREPARE
|
||||
from tasks.dungeon.keywords import DungeonList
|
||||
from tasks.planner.keywords import ITEM_CLASSES
|
||||
from tasks.planner.keywords import ITEM_CLASSES, KEYWORDS_ITEM_CURRENCY
|
||||
from tasks.planner.model import ObtainedAmmount, PlannerMixin
|
||||
from tasks.planner.scan import OcrItemName
|
||||
|
||||
@ -93,7 +93,7 @@ class CombatObtain(PlannerMixin):
|
||||
continue
|
||||
|
||||
@staticmethod
|
||||
def _obtain_get_entry(dungeon: DungeonList, index: int = 1, prev: ObtainedAmmount = None):
|
||||
def _obtain_get_entry(dungeon: DungeonList, index: int = 1, prev: ObtainedAmmount = None, start: int = 0):
|
||||
"""
|
||||
Args:
|
||||
dungeon: Current dungeon
|
||||
@ -101,7 +101,7 @@ class CombatObtain(PlannerMixin):
|
||||
prev: Previous item checked
|
||||
|
||||
Returns:
|
||||
ButtonWrapper: Item entry, or None if no more check needed
|
||||
int: Item entry index, or None if no more check needed
|
||||
"""
|
||||
if (index > 1 and prev is None) or (index <= 1 and prev is not None):
|
||||
raise ScriptError(f'_obtain_get_entry: index and prev must be set together, index={index}, prev={prev}')
|
||||
@ -111,20 +111,29 @@ class CombatObtain(PlannerMixin):
|
||||
|
||||
def may_obtain_one():
|
||||
if prev is None:
|
||||
return OBTAIN_1
|
||||
if start:
|
||||
return 1 + start
|
||||
else:
|
||||
return 1
|
||||
else:
|
||||
return None
|
||||
|
||||
def may_obtain_multi():
|
||||
if prev is None:
|
||||
return OBTAIN_1
|
||||
if start:
|
||||
return 1 + start
|
||||
else:
|
||||
return 1
|
||||
# End at the item with the lowest rarity
|
||||
if prev.item.is_rarity_green:
|
||||
return None
|
||||
if index == 2:
|
||||
return OBTAIN_2
|
||||
if index == 3:
|
||||
return OBTAIN_3
|
||||
# End at credict
|
||||
if prev.item == KEYWORDS_ITEM_CURRENCY.Credit:
|
||||
return None
|
||||
if start:
|
||||
return index + start
|
||||
else:
|
||||
return index
|
||||
|
||||
if dungeon is None:
|
||||
return may_obtain_multi()
|
||||
@ -185,18 +194,38 @@ class CombatObtain(PlannerMixin):
|
||||
index = 1
|
||||
prev = None
|
||||
items = []
|
||||
dic_entry = {
|
||||
1: OBTAIN_1,
|
||||
2: OBTAIN_2,
|
||||
3: OBTAIN_3,
|
||||
4: OBTAIN_4,
|
||||
}
|
||||
|
||||
self._find_may_obtain()
|
||||
|
||||
trailblaze_exp = False
|
||||
for _ in range(5):
|
||||
entry = self._obtain_get_entry(dungeon, index=index, prev=prev)
|
||||
if entry is None:
|
||||
if not trailblaze_exp and self.appear(OBTAIN_TRAILBLAZE_EXP):
|
||||
trailblaze_exp = True
|
||||
logger.attr('trailblaze_exp', trailblaze_exp)
|
||||
|
||||
entry_index = self._obtain_get_entry(dungeon, index=index, prev=prev, start=int(trailblaze_exp))
|
||||
if entry_index is None:
|
||||
logger.info('Obtain get end')
|
||||
break
|
||||
try:
|
||||
entry = dic_entry[entry_index]
|
||||
except KeyError:
|
||||
logger.error(f'No obtain entry for {entry_index}')
|
||||
break
|
||||
|
||||
self._obtain_enter(entry)
|
||||
item = self._obtain_parse()
|
||||
if item is not None:
|
||||
if item.item == KEYWORDS_ITEM_CURRENCY.Trailblaze_EXP:
|
||||
logger.warning('Trailblaze_EXP is in obtain list, OBTAIN_TRAILBLAZE_EXP may need to verify')
|
||||
index += 1
|
||||
prev = item
|
||||
elif item is not None:
|
||||
items.append(item)
|
||||
index += 1
|
||||
prev = item
|
||||
@ -258,6 +287,7 @@ class CombatObtain(PlannerMixin):
|
||||
OBTAIN_1.load_offset(MAY_OBTAIN)
|
||||
OBTAIN_2.load_offset(MAY_OBTAIN)
|
||||
OBTAIN_3.load_offset(MAY_OBTAIN)
|
||||
OBTAIN_4.load_offset(MAY_OBTAIN)
|
||||
return True
|
||||
|
||||
|
||||
|
@ -16,3 +16,16 @@ Credit = ItemCurrency(
|
||||
item_group=0,
|
||||
dungeon_id=-1,
|
||||
)
|
||||
Trailblaze_EXP = ItemCurrency(
|
||||
id=2,
|
||||
name='Trailblaze_EXP',
|
||||
cn='里程',
|
||||
cht='里程',
|
||||
en='Trailblaze EXP',
|
||||
jp='マイレージ',
|
||||
es='EXP trazacaminos',
|
||||
rarity='Rare',
|
||||
item_id=22,
|
||||
item_group=0,
|
||||
dungeon_id=-1,
|
||||
)
|
||||
|
@ -22,7 +22,7 @@ class OcrItemName(Ocr):
|
||||
result = result.replace('念火之心', '忿火之心')
|
||||
result = re.sub('工造机$', '工造机杼', result)
|
||||
result = re.sub('工造轮', '工造迴轮', result)
|
||||
result = re.sub('月狂牙', '月狂獠牙', result)
|
||||
result = re.sub('月狂[療撩]?牙', '月狂獠牙', result)
|
||||
return result
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user