Skip to content

Commit

Permalink
Merge branch 'feature/upwell-reinforce' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eve-n0rman committed Apr 25, 2019
2 parents ca194de + 3c0b6c3 commit fa78785
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
18 changes: 11 additions & 7 deletions structurebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
parser.add_argument('--suppress-unscheduled-detonations', dest='unscheduled_detonations', action='store_false')
parser.add_argument('--suppress-ansiblex-ozone', dest='ansiblex_ozone', action='store_false')
parser.add_argument('--suppress-fuel-warning', dest='fuel_warning', action='store_false')
parser.add_argument('--suppress-service-status', dest='service_status', action='store_false')
parser.add_argument('--suppress-service-state', dest='service_state', action='store_false')
parser.add_argument('--suppress-structure-state', dest='structure_state', action='store_false')

args = parser.parse_args()

Expand All @@ -37,21 +38,24 @@
msg = 'Found an inaccesible citadel ({}) in {}'.format(structure.structure_id, structure.system_id)
messages.append(msg)
continue
if structure.needs_detonation and args.unscheduled_detonations:
if args.unscheduled_detonations and structure.needs_detonation:
message.append('Needs to have an extraction scheduled')
if structure.detonates_soon and args.upcoming_detonations:
if args.upcoming_detonations and structure.detonates_soon:
message.append('Ready to detonate {}'.format(structure.detonation))
if structure.needs_ozone and args.ansiblex_ozone:
if args.ansiblex_ozone and structure.needs_ozone:
message.append('Low on Liquid Ozone: {}'.format(structure.jump_fuel))
if structure.needs_fuel and args.fuel_warning:
if args.fuel_warning and structure.needs_fuel:
message.append('Runs out of fuel on {}'.format(structure.fuel_expires))
if args.service_status:
if args.service_state:
if structure.online_services:
message.append('Online Services: {}'.format(', '.join(structure.online_services)))
if structure.offline_services:
message.append('Offline Services: {}'.format(', '.join(structure.offline_services)))
elif structure.offline_services and args.service_status:
if args.service_state and structure.offline_services:
message.append('Offline services: {}'.format(', '.join(structure.offline_services)))
if args.structure_state and (structure.vulnerable or structure.reinforced):
state = structure.state.replace('_', ' ').title()
message.append('{} until {}'.format(state, structure.state_timer_end))
if message:
messages.append(u'\n'.join([u'{}'.format(structure.name)] + message))
messages += check_pos(corp_name, assets)
Expand Down
31 changes: 22 additions & 9 deletions structurebot/citadels.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
class Structure(object):
def __init__(self, structure_id, type_id=None, type_name=None,
system_id=None, services=None, fuel_expires=None,
accessible=None, name=None, detonation=None,
fuel=[], fitting=Fitting()):
accessible=None, name=None, state=None, state_timer_end=None,
detonation=None, fuel=[], fitting=Fitting()):
super(Structure, self).__init__()
self.structure_id = structure_id
self.type_id = type_id
self.type_name = type_name
self.system_id = system_id
self.fuel = fuel
self.fuel_expires = fuel_expires
self.fuel_expires = getattr(fuel_expires, 'v', None)
self.accessible = accessible
self.name = name
self.detonation = detonation
self.state = state
self.state_timer_end = getattr(state_timer_end, 'v', None)
self.detonation = getattr(detonation, 'v', None)
self.fitting = fitting
self._fuel_rate = 0
# Grab structure name
Expand Down Expand Up @@ -155,7 +157,7 @@ def needs_detonation(self):
@property
def detonates_soon(self):
now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
if self.detonation and (self.detonation.v - now < CONFIG['DETONATION_WARNING']):
if self.detonation and (self.detonation - now < CONFIG['DETONATION_WARNING']):
return True
return False

Expand All @@ -168,14 +170,26 @@ def needs_ozone(self):
@property
def needs_fuel(self):
now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
if self.fuel_expires and (self.fuel_expires.v - now < CONFIG['TOO_SOON']):
if self.fuel_expires and (self.fuel_expires - now < CONFIG['TOO_SOON']):
return True
return False

@property
def jump_fuel(self):
return sum([lo.quantity for lo in self.fuel if lo.name == 'Liquid Ozone'])

@property
def reinforced(self):
if self.state in ['armor_reinforce', 'hull_reinforce']:
return True
return False

@property
def vulnerable(self):
if self.state in ['deploy_vulnerable', 'armor_vulnerable', 'hull_vulnerable']:
return True
return False

@classmethod
def from_corporation(cls, corporation_name, assets=None):
structure_list = []
Expand All @@ -191,12 +205,11 @@ def from_corporation(cls, corporation_name, assets=None):
detonations = detonations_response.data
detonations = {d['structure_id']: d['chunk_arrival_time']
for d in detonations}
structure_keys = ['structure_id', 'system_id',
'services', 'fuel_expires']
structure_keys = ['structure_id', 'system_id', 'type_id'
'services', 'fuel_expires', 'state', 'state_timer_end']
for s in structures:
sid = s['structure_id']
kwargs = {k: v for k, v in s.items() if k in structure_keys}
kwargs['type_id'] = s['type_id']
kwargs['type_name'] = ids_to_names([s['type_id']])[s['type_id']]
kwargs['detonation'] = detonations.get(sid)
structure_contents = [a for a in assets if a.location_id == sid]
Expand Down

0 comments on commit fa78785

Please sign in to comment.