Skip to content

Commit

Permalink
Add: gear code for gemsfarming
Browse files Browse the repository at this point in the history
  • Loading branch information
guoh064 committed Apr 27, 2024
1 parent ed5923a commit 8a45743
Showing 1 changed file with 39 additions and 21 deletions.
60 changes: 39 additions & 21 deletions module/campaign/gems_farming.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from module.campaign.run import CampaignRun
from module.combat.assets import BATTLE_PREPARATION
from module.equipment.assets import *
from module.equipment.equipment_code import EquipmentCodeHandler
from module.equipment.fleet_equipment import FleetEquipment
from module.exception import CampaignEnd, ScriptError
from module.handler.assets import AUTO_SEARCH_MAP_OPTION_OFF
Expand Down Expand Up @@ -67,7 +68,34 @@ def handle_combat_low_emotion(self):
raise CampaignEnd('Emotion withdraw')


class GemsFarming(CampaignRun, FleetEquipment, Dock):
class GemsEquipmentHandler(EquipmentCodeHandler):
def __init__(self, config, device=None, task=None):
super().__init__(config=config,
device=device,
task=task,
key="GemsFarming.GemsFarming.EquipmentCode",
ships=['DD', 'bogue', 'hermes', 'langley', 'ranger'])

def current_ship(self):
"""
Reuse templates in module.retire.assets,
which needs different rescaling to match each current flagship.
Pages:
in: gear_code
"""
if TEMPLATE_BOGUE.match(self.device.image, scaling=1.46): # image has rotation
return 'bogue'
if TEMPLATE_HERMES.match(self.device.image, scaling=124/89):
return 'hermes'
if TEMPLATE_RANGER.match(self.device.image, scaling=4/3):
return 'ranger'
if TEMPLATE_LANGLEY.match(self.device.image, scaling=25/21):
return 'langley'
return 'DD'


class GemsFarming(CampaignRun, Dock, FleetEquipment, GemsEquipmentHandler):

def load_campaign(self, name, folder='campaign_main'):
super().load_campaign(name, folder)
Expand Down Expand Up @@ -104,65 +132,55 @@ def fleet_to_attack(self):

def flagship_change(self):
"""
Change flagship and flagship's equipment
If config.GemsFarming_CommonCV == 'any', only change auxiliary equipment
Change flagship and flagship's equipment using gear code
Returns:
bool: True if flagship changed.
"""

if self.config.GemsFarming_CommonCV == 'any':
index_list = range(3, 5)
else:
index_list = range(0, 5)
logger.hr('Change flagship', level=1)
logger.attr('ChangeFlagship', self.config.GemsFarming_ChangeFlagship)
self.fleet_enter(self.fleet_to_attack)
if self.change_flagship_equip:
logger.hr('Record flagship equipment', level=2)
logger.hr('Unmount flagship equipments', level=2)
self.fleet_enter_ship(FLEET_DETAIL_ENTER_FLAGSHIP)
self.ship_equipment_record_image(index_list=index_list)
self.ship_equipment_take_off()
self.clear_all_equip()
self.fleet_back()

logger.hr('Change flagship', level=2)
success = self.flagship_change_execute()

if self.change_flagship_equip:
logger.hr('Equip flagship equipment', level=2)
logger.hr('Mount flagship equipments', level=2)
self.fleet_enter_ship(FLEET_DETAIL_ENTER_FLAGSHIP)
self.ship_equipment_take_off()
self.ship_equipment_take_on_image(index_list=index_list)
self.apply_equip_code()
self.fleet_back()

return success

def vanguard_change(self):
"""
Change vanguard and vanguard's equipment
Change vanguard and vanguard's equipment using gear code
Returns:
bool: True if vanguard changed
"""

logger.hr('Change vanguard', level=1)
logger.attr('ChangeVanguard', self.config.GemsFarming_ChangeVanguard)
self.fleet_enter(self.fleet_to_attack)
if self.change_vanguard_equip:
logger.hr('Record vanguard equipment', level=2)
logger.hr('Unmount vanguard equipments', level=2)
self.fleet_enter_ship(FLEET_DETAIL_ENTER)
self.ship_equipment_record_image()
self.ship_equipment_take_off()
self.clear_all_equip()
self.fleet_back()

logger.hr('Change vanguard', level=2)
success = self.vanguard_change_execute()

if self.change_vanguard_equip:
logger.hr('Equip vanguard equipment', level=2)
logger.hr('Mount vanguard equipments', level=2)
self.fleet_enter_ship(FLEET_DETAIL_ENTER)
self.ship_equipment_take_off()
self.ship_equipment_take_on_image()
self.apply_equip_code()
self.fleet_back()

return success
Expand Down

0 comments on commit 8a45743

Please sign in to comment.