def _getLifepath(step, tableName): lifepath = [] repeat = None while tableName and not repeat: result = getFilteredQuery( _collection, {"step": step, "table_name": tableName, "random_count": 1}, {"step": 0}, ) if result: result = result[0] repeat = result.get("repeat", False) tableName = result.get("redirect", False) choose = result.get("choose", True) if tableName: tableName = tableName if not choose else choice(tableName) del result["redirect"] if repeat and tableName: del result["repeat"] result["data"] = [ _getLifepath(step, tableName) for sibling in range(0, repeat) ] elif not choose and tableName: del result["choose"] result["data"] = [_getLifepath(step, tn) for tn in tableName] lifepath.append(result) else: break return lifepath
def rollRandomCybernetics(cyNum): """Returns a list of random cybernetics. Cybernetic options that have prerequisites will automatically be given those prerequisites as a part of that roll (ex: Thermograph without a cybereye will be given a cybereye as a part of that roll.) Params: cyNum int The number of cybernetic "rolls" to make. """ cyberList = getFilteredQuery(_cyberCollection, {"random_count": cyNum}) # Roll humanity loss for cyber in cyberList: rollHumanityLoss(cyber) # Handle missing pre-requisite systems for cyber in [c for c in cyberList if c["requirements"]]: cyberIds = getCyberIdList(cyberList) requirements = cyber["requirements"] intersection = set(requirements) & set(cyberIds) if not intersection: req = choice(requirements) requiredCyber = getFilteredQuery(_cyberCollection, {"id_code": req}) if isinstance(requiredCyber, list) and requiredCyber: requiredCyber = requiredCyber[0] rollHumanityLoss(requiredCyber) requiredCyber["subsystems"] = [cyber] cyberList.remove(cyber) cyberList.append(requiredCyber) else: parentId = choice(list(intersection)) parentCyber = next( (c for c in cyberList if c["id_code"] == parentId), None, ) rollHumanityLoss(parentCyber) if not parentCyber: raise Exception( parentId + " not found in " + " | ".join([i["id_code"] for i in cyberList]) ) if not parentCyber.get("subsystems", False): parentCyber["subsystems"] = [] parentCyber["subsystems"].append(cyber) cyberList.remove(cyber) return cyberList
def post(self): parser = reqparse.RequestParser() parser.add_argument("availability", type=str, default=None) parser.add_argument("category", type=str, default=None) parser.add_argument("concealability", type=str, default=None) parser.add_argument("reliability", type=str, default=None) parser.add_argument("type", type=str, default=None) parser.add_argument("ammo_type", type=str, default=None) parser.add_argument("random_count", type=int, default=None) args = parser.parse_args() return jsonify(getFilteredQuery(_weaponsCollection, args))
def getRandomArmors(numArmors): """Returns a random list of armor of numArmors size. Armors will not overlap protected locations. """ armor = [] filter_base = {"random_count": 1} for aIdx in range(0, numArmors): filter = getArmorFilter(armor) filter.update(filter_base) result = getFilteredQuery(_armorCollection, filter) armor += result return armor
def post(self): parser = reqparse.RequestParser() parser.add_argument("head", type=bool, default=None) parser.add_argument("torso", type=bool, default=None) parser.add_argument("arms", type=bool, default=None) parser.add_argument("legs", type=bool, default=None) parser.add_argument("soft", type=bool, default=None) parser.add_argument("half_vs_edged", type=bool, default=None) parser.add_argument("encumbrance_value", type=int, default=None) parser.add_argument("random_count", type=int, default=None) args = parser.parse_args() return jsonify(getFilteredQuery(_armorCollection, args))
def get(self, requirement): return jsonify( getFilteredQuery(_cyberCollection, {"requirements": requirement}) )
def get(self, classification): return jsonify( getFilteredQuery( _cyberCollection, {"classification": classification} ) )
def get(self, concealability): return jsonify( getFilteredQuery(_weaponsCollection, {"concealability": concealability}))
def get(self, category): return jsonify( getFilteredQuery(_weaponsCollection, {"category": unquote(category)}))
def get(self, availability): return jsonify( getFilteredQuery(_weaponsCollection, {"availability": availability}))
def get(self): return jsonify(getFilteredQuery(_weaponsCollection, {}))
def getRandomWeapons(numWeapons): """Returns a random list of weapons of numWeapons size. """ return getFilteredQuery(_weaponsCollection, {"random_count": numWeapons},)
def getSkills(): return getFilteredQuery(_skillsCollection, {})
def getCareerSkillsForRole(roleName): return getFilteredQuery( _careerSkillsCollection, {"role_name": roleName}, {"role_name": 0}, )
def get(self): return jsonify(getFilteredQuery(_armorCollection, {"legs": True}))