realm.py 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. """结界皮肤只覆盖共用素材的搜索区域;在鲤鱼旗配置之前应用。"""
  2. from copy import deepcopy
  3. from tasks.Component.Costume.config import RealmType
  4. from tasks.KekkaiUtilize.assets import KekkaiUtilizeAssets
  5. _REALM_NAMES = ('I_REALM_SHIN', 'I_CARD_EXP', 'I_BOX_AP', 'I_BOX_EXP')
  6. # Capture pristine shared rules before a task applies any realm/carp-banner skin.
  7. _DEFAULT_RULES = {name: deepcopy(getattr(KekkaiUtilizeAssets, name)) for name in _REALM_NAMES}
  8. # Only the search region varies. Template, method, threshold and template size
  9. # remain the shared defaults; matching updates the actual click position.
  10. _REALM_REGIONS = {
  11. RealmType.COSTUME_REALM_DEFAULT: {},
  12. RealmType.COSTUME_REALM_YUEHAI_YOUXING: {
  13. 'I_REALM_SHIN': (175, 390, 115, 110),
  14. 'I_CARD_EXP': (865, 205, 135, 105),
  15. 'I_BOX_AP': (975, 415, 90, 105),
  16. 'I_BOX_EXP': (1035, 420, 85, 110),
  17. },
  18. }
  19. def apply_realm(realm_type: RealmType) -> None:
  20. regions = _REALM_REGIONS[realm_type] # Validate before mutating shared rules.
  21. for name, source in _DEFAULT_RULES.items():
  22. # Preserve references and reset stale images, features and match state.
  23. target = getattr(KekkaiUtilizeAssets, name)
  24. target.__dict__.clear()
  25. target.__dict__.update(deepcopy(source.__dict__))
  26. if name in regions:
  27. target.roi_back = regions[name]