costume_base.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # This Python file uses the following encoding: utf-8
  2. # @author runhey
  3. # github https://github.com/runhey
  4. from module.atom.image import RuleImage
  5. from tasks.Component.Costume.config import MainType, CostumeConfig
  6. from tasks.Component.Costume.assets import CostumeAssets
  7. main_costume_model = {
  8. MainType.COSTUME_MAIN_1: {'I_CHECK_MAIN': 'I_CHECK_MAIN_1',
  9. 'I_MAIN_GOTO_EXPLORATION': 'I_MAIN_GOTO_EXPLORATION_1',
  10. 'I_MAIN_GOTO_SUMMON': 'I_MAIN_GOTO_SUMMON_1',
  11. 'I_MAIN_GOTO_TOWN': 'I_MAIN_GOTO_TOWN_1',
  12. 'I_PET_HOUSE': 'I_PET_HOUSE_1', },
  13. MainType.COSTUME_MAIN_2: {'I_CHECK_MAIN': 'I_CHECK_MAIN_2',
  14. 'I_MAIN_GOTO_EXPLORATION': 'I_MAIN_GOTO_EXPLORATION_2',
  15. 'I_MAIN_GOTO_SUMMON': 'I_MAIN_GOTO_SUMMON_2',
  16. 'I_MAIN_GOTO_TOWN': 'I_MAIN_GOTO_TOWN_2',
  17. 'I_PET_HOUSE': 'I_PET_HOUSE_2', },
  18. MainType.COSTUME_MAIN_3: {'I_CHECK_MAIN': 'I_CHECK_MAIN_3',
  19. 'I_MAIN_GOTO_EXPLORATION': 'I_MAIN_GOTO_EXPLORATION_3',
  20. 'I_MAIN_GOTO_SUMMON': 'I_MAIN_GOTO_SUMMON_3',
  21. 'I_MAIN_GOTO_TOWN': 'I_MAIN_GOTO_TOWN_3',
  22. 'I_PET_HOUSE': 'I_PET_HOUSE_3', },
  23. MainType.COSTUME_MAIN_4: {'I_CHECK_MAIN': 'I_CHECK_MAIN_4',
  24. 'I_MAIN_GOTO_EXPLORATION': 'I_MAIN_GOTO_EXPLORATION_4',
  25. 'I_MAIN_GOTO_SUMMON': 'I_MAIN_GOTO_SUMMON_4',
  26. 'I_MAIN_GOTO_TOWN': 'I_MAIN_GOTO_TOWN_4',
  27. 'I_PET_HOUSE': 'I_PET_HOUSE_4', },
  28. MainType.COSTUME_MAIN_5: {'I_CHECK_MAIN': 'I_CHECK_MAIN_5',
  29. 'I_MAIN_GOTO_EXPLORATION': 'I_MAIN_GOTO_EXPLORATION_5',
  30. 'I_MAIN_GOTO_SUMMON': 'I_MAIN_GOTO_SUMMON_5',
  31. 'I_MAIN_GOTO_TOWN': 'I_MAIN_GOTO_TOWN_5',
  32. 'I_PET_HOUSE': 'I_PET_HOUSE_5', },
  33. }
  34. class CostumeBase:
  35. def check_costume(self, config: CostumeConfig):
  36. self.check_costume_main(config.costume_main_type)
  37. def check_costume_main(self, main_type: MainType):
  38. if main_type == MainType.COSTUME_MAIN:
  39. return
  40. costume_assets = CostumeAssets()
  41. for key, value in main_costume_model[main_type].items():
  42. assert_value: RuleImage = getattr(costume_assets, value)
  43. self.replace_img(key, assert_value)
  44. def replace_img(self, asset_before: str, asset_after: RuleImage):
  45. if not hasattr(self, asset_before):
  46. return
  47. # setattr(self, asset_before, asset_after)
  48. asset_before_object: RuleImage = getattr(self, asset_before)
  49. asset_before_object.roi_front = asset_after.roi_front
  50. asset_before_object.roi_back = asset_after.roi_back
  51. asset_before_object.threshold = asset_after.threshold
  52. asset_before_object.file = asset_after.file
  53. if __name__ == '__main__':
  54. c = CostumeBase()
  55. c.check_costume_main(MainType.COSTUME_MAIN_1)