Skip to content

Commit

Permalink
Merge branch 'release/1.5.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Henjuro committed Nov 16, 2018
2 parents 1c588f3 + 0818992 commit 80578b0
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#Changelog
* 1.5.5:
* Improvements:
* Added rules for sorting titans/supers into dps
* Added ability to parse Fighters (which are officially not included in EFT format as documented by ccp)
* 1.5.4:
* Fixes:
* Corrected error in databases scheme to represent dogma attributes, which blocked imports
Expand Down
23 changes: 16 additions & 7 deletions waitlist/blueprints/xup/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
sniper_weapons, dps_weapons, weapongroups, dps_ships, t3c_ships
from waitlist.utility.history_utils import create_history_object
from waitlist.utility.fitting_utils import get_fit_format, parse_dna_fitting,\
parse_eft
parse_eft, is_logi_hull, is_allowed_hull, is_dps_by_group,\
is_sniper_by_group
from waitlist import db
from . import bp
from flask_babel import gettext, ngettext
from typing import Dict, List, Tuple
from waitlist.utility.constants import location_flags
from waitlist.utility.constants import location_flags, groups

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -258,14 +259,12 @@ def submit():
# check that ship is an allowed ship

# it is a logi put on logi wl
if fit.ship_type in logi_ships:
if is_logi_hull(fit.ship_type):
fit.wl_type = WaitlistNames.logi
fits_ready.append(fit)
continue

is_allowed = False
if fit.ship_type in sniper_ships or fit.ship_type in dps_ships or fit.ship_type in t3c_ships:
is_allowed = True
is_allowed = is_allowed_hull(fit.ship_type)

if not is_allowed: # not an allowed ship, push it on other list :P
fit.wl_type = WaitlistNames.other
Expand All @@ -279,7 +278,11 @@ def submit():
high_slot_mod_map = mod_list[location_flags.HIGH_SLOT]
for mod in high_slot_mod_map:
inv_type: InvType = db.session.query(InvType).get(mod)
if high_slot_mod_map[mod][1] >= 4:
if high_slot_mod_map[mod][1] >= 4 or (
inv_type.groupID in [groups.remote_armor_repairer,
groups.remote_shield_booster]
and 'Capital' in inv_type.typeName
):
logger.info('Adding %s as possible weapon', inv_type.typeName)
possible_weapons.append(mod)
else:
Expand Down Expand Up @@ -331,6 +334,12 @@ def submit():
break

# ships with no valid weapons put on other wl
if weapon_type == "None":
if is_dps_by_group(fit.ship_type):
weapon_type = WaitlistNames.dps
elif is_sniper_by_group(fit.ship_type):
weapon_type = WaitlistNames.sniper

if weapon_type == "None":
fit.wl_type = WaitlistNames.other
fits_ready.append(fit)
Expand Down
2 changes: 1 addition & 1 deletion waitlist/data/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.5.4-$Format:%h$"
version = "1.5.5-$Format:%h$"
10 changes: 10 additions & 0 deletions waitlist/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,16 @@ def IsDrone(self):

return self.group.categoryID == categories.drone

@property
def IsFighter(self):
""" Is a Fighter
"""
if self.group is None:
return False
if self.group.categoryID is None:
return False
return self.group.categoryID == categories.fighter

def __repr__(self):
return f'<InvType typeID={self.typeID} typeName={self.typeName} groupID={self.groupID}' \
f' marketGroupID={self.marketGroupID} description={self.description}>'
Expand Down
11 changes: 11 additions & 0 deletions waitlist/storage/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,19 @@
24694: "Maelstrom", 32311: "Typhoon Fleet Issue", 17732: "Tempest Fleet Issue",
47271: "Leshark"
}

dps_groups = {659: 'Supercarrier', 30: 'Titan'}
logi_groups = {1538: 'Force Auxiliary'}
sniper_groups = {}

t3c_ships = {29990: "Loki", 29984: "Tengu"}

none_logi_ships = {}
none_logi_ships.update(sniper_ships)
none_logi_ships.update(dps_ships)
none_logi_ships.update(resist_ships)
none_logi_ships.update(t3c_ships)

weapongroups = {'dps': {"Pulse Lasers": None, "Blasters": None, "Missile Launchers": None, "Autocannons": None, 'Entropic Disintegrators': None},
'sniper': {"Beam Lasers": None, "Railguns": None, "Artillery Cannons": None}
}
1 change: 1 addition & 0 deletions waitlist/utility/constants/categories.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
charge = 8
subystem = 32
drone = 18
fighter = 87
2 changes: 2 additions & 0 deletions waitlist/utility/constants/groups.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
booster = 303
remote_armor_repairer = 325
remote_shield_booster = 41
1 change: 1 addition & 0 deletions waitlist/utility/constants/location_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
SUBYSTEM_SLOT = 4
DRONEBAY_SLOT = 5
CARGO_SLOT = 6
FIGHTERS_SLOT = 7
# this is for old fits where we did not care about locations yet
UNKNOWN_SLOT = 1000
81 changes: 64 additions & 17 deletions waitlist/utility/fitting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
import logging
import re
from waitlist.utility.eve_id_utils import get_item_id
from waitlist.storage.modules import logi_ships, logi_groups, none_logi_ships,\
dps_groups, sniper_groups

logger = logging.getLogger(__name__)


def parse_eft(lines: List[str]) -> Shipfit:
slot_list: List[Dict[int, List[int]]] = [dict(), dict(), dict(),
dict(), dict(), dict(),
dict()]
dict(), dict()]
if len(lines) < 2:
return None

Expand Down Expand Up @@ -42,7 +44,7 @@ def parse_eft(lines: List[str]) -> Shipfit:
sections = [location_flags.LOW_SLOT, location_flags.MID_SLOT,
location_flags.HIGH_SLOT, location_flags.RIG_SLOT,
location_flags.SUBYSTEM_SLOT, location_flags.DRONEBAY_SLOT,
location_flags.CARGO_SLOT]
location_flags.CARGO_SLOT, location_flags.FIGHTERS_SLOT]

section_idx = 0 # 'low'
# used to store a list of items
Expand Down Expand Up @@ -74,15 +76,16 @@ def parse_eft(lines: List[str]) -> Shipfit:
i += 1
continue

# check if it contains a xNUMBER and is by that drone or cargo
# check if it contains a xNUMBER and is by that drone/fighter or cargo
is_cargo = re.match(".*x\d+$", line) is not None
logger.debug("%s is_cargo = %s", line, is_cargo)

if sections[section_idx] == location_flags.CARGO_SLOT:
mod_info = line.rsplit(" x", 2)
mod_name = mod_info[0]
mod_amount = int(mod_info[1])
elif sections[section_idx] == location_flags.DRONEBAY_SLOT:
elif sections[section_idx] in [location_flags.DRONEBAY_SLOT,
location_flags.FIGHTERS_SLOT]:
# because of how pyfa and ingame format are different
# we might endup here while really being in cargo...
mod_info = line.rsplit(" x", 2)
Expand Down Expand Up @@ -112,7 +115,7 @@ def parse_eft(lines: List[str]) -> Shipfit:
slot_list[sections[section_idx]] = dict()
slot_list[location_flags.CARGO_SLOT] = mod_map
# and change our index
section_idx = 6
section_idx = location_flags.CARGO_SLOT

mod_map = slot_list[sections[section_idx]]

Expand Down Expand Up @@ -142,7 +145,7 @@ def parse_eft(lines: List[str]) -> Shipfit:
db_module = FitModule(moduleID=mod[0], locationFlag=idx,
amount=mod[1])
fit.moduleslist.append(db_module)

logger.debug('SlotList: %r', slot_list)
fit.modules = create_dna_string(slot_list)

return fit
Expand All @@ -154,12 +157,15 @@ def create_dna_string(slot_list: List[Dict[int, List[int]]]):
# charges are contained under cargo together with other items
dna_order = [location_flags.SUBYSTEM_SLOT, location_flags.HIGH_SLOT,
location_flags.MID_SLOT, location_flags.LOW_SLOT,
location_flags.RIG_SLOT, location_flags.DRONEBAY_SLOT]
location_flags.RIG_SLOT, location_flags.DRONEBAY_SLOT,
location_flags.FIGHTERS_SLOT]
for slot_id in dna_order:
logger.debug('SLOTID: %d', slot_id)
mod_map = slot_list[slot_id]
sub_dna = ''
for mod_id in mod_map:
mod = mod_map[mod_id]
logger.debug('ModId: %d ModAmount: %d', mod[0], mod[1])
sub_dna += str(mod[0]) + ';' + str(mod[1]) + ':'

dna += sub_dna
Expand Down Expand Up @@ -197,7 +203,7 @@ def parse_dna_fitting(dna_string: str) -> List[Dict[int, List[int]]]:
"""
slot_list: List[Dict[int, List[int]]] = [dict(), dict(), dict(),
dict(), dict(),
dict(), dict()]
dict(), dict(), dict()]
mods = dna_string.split(':')
for mod in mods:
if not mod:
Expand All @@ -215,15 +221,19 @@ def parse_dna_fitting(dna_string: str) -> List[Dict[int, List[int]]]:
else:
raise ValueError("Mod did not contain an amount")

inv_type = db.session.query(InvType).get(mod_id)
if inv_type is None:
raise ValueError("InvType with id=" + mod_id + " not found")

location_flag = get_location_flag(inv_type)
if location_flag is None:
logger.error("No locationflag found for InvType with typeID=%d",
inv_type.typeID)
continue
if is_cargo_module:
location_flag = location_flags.CARGO_SLOT
else:
inv_type = db.session.query(InvType).get(mod_id)
if inv_type is None:
raise ValueError("InvType with id=" + mod_id + " not found")

location_flag = get_location_flag(inv_type)
if location_flag is None:
logger.error("No locationflag found for"
+ " InvType with typeID=%d",
inv_type.typeID)
continue

mod_map = slot_list[location_flag]
if mod_id in mod_map:
Expand All @@ -242,6 +252,9 @@ def get_location_flag(inv_type: InvType) -> Optional[int]:
return location_flags.CARGO_SLOT
if inv_type.IsDrone:
return location_flags.DRONEBAY_SLOT
if inv_type.IsFighter:
return location_flags.FIGHTERS_SLOT

for dogma_effect in inv_type.dogma_effects:
if dogma_effect.effectID == effects.POWER_SLOT_HIGH:
return location_flags.HIGH_SLOT
Expand All @@ -262,3 +275,37 @@ def get_fit_format(line):
return "eft"
else: # just consider everyhting else dna
return "dna"


def is_logi_hull(type_id: int):
if type_id in logi_ships:
return True
inv_type: InvType = db.session.query(InvType).get(type_id)
if inv_type.groupID in logi_groups and type_id not in none_logi_ships:
return True
return False


def is_allowed_hull(type_id: int):
if type_id in none_logi_ships or type_id in logi_ships:
return True
inv_type: InvType = db.session.query(InvType).get(type_id)
if inv_type.groupID in logi_groups or (
inv_type.groupID in dps_groups) or (
inv_type.groupID in sniper_groups):
return True
return False


def is_dps_by_group(type_id: int):
inv_type: InvType = db.session.query(InvType).get(type_id)
if inv_type.groupID in dps_groups:
return True
return False


def is_sniper_by_group(type_id: int):
inv_type: InvType = db.session.query(InvType).get(type_id)
if inv_type.groupID in sniper_groups:
return True
return False

0 comments on commit 80578b0

Please sign in to comment.