def from_url(qparams): params = SeedGenParams() params.seed = qparams.get("seed") if not params.seed: log.error("No seed in %r! returning None" % qparams) return None params.variations = enums_from_strlist(Variation, qparams.getall("var")) params.logic_paths = enums_from_strlist(LogicPath, qparams.getall("path")) if not params.logic_paths: log.error("No logic paths in %r! returning None" % qparams) return None params.key_mode = KeyMode(qparams.get("key_mode", "Clues")) params.path_diff = PathDifficulty(qparams.get("path_diff", "Normal")) params.exp_pool = int(qparams.get("exp_pool", 10000)) params.balanced = qparams.get("gen_mode") != "Classic" params.players = int(qparams.get("players", 1)) params.tracking = qparams.get("tracking") != "Disabled" params.warmth = WarmthFragmentOptions.from_url(qparams) params.sync = MultiplayerOptions.from_url(qparams) raw_fass = qparams.get("fass") if raw_fass: params.placements = [] for fass in raw_fass.split("|"): loc, _, item = fass.partition(":") stuff = [Stuff(code=item[:2], id=item[2:], player="")] params.placements.append(Placement(location=loc, zone="", stuff=stuff)) return params.put()
def from_json(json): params = SeedGenParams() params.seed = str(json.get("seed")) if not params.seed: log.error("No seed in %r! returning None" % json) return None params.variations = enums_from_strlist(Variation, json.get("variations", [])) params.logic_paths = enums_from_strlist(LogicPath, json.get("paths", [])) if not params.logic_paths: log.error("No logic paths in %r! returning None" % json) return None params.key_mode = KeyMode(json.get("keyMode", "Clues")) params.path_diff = PathDifficulty(json.get("pathDiff", "Normal")) params.exp_pool = json.get("expPool", 10000) params.balanced = json.get("fillAlg") != "Classic" params.players = json.get("players", 1) params.tracking = json.get("tracking") params.frag_count = json.get("fragCount", 30) params.frag_req = json.get("fragReq", 20) params.relic_count = json.get("relicCount", 8) params.cell_freq = json.get("cellFreq", 256) params.sync = MultiplayerOptions.from_json(json) params.sense = json.get("senseData") params.item_pool = json.get("itemPool", {}) params.bingo_lines = json.get("bingoLines", 3) params.pool_preset = json.get("selectedPool", "Standard") params.placements = [ Placement( location=fass["loc"], zone="", stuff=[Stuff(code=fass["code"], id=fass["id"], player="")]) for fass in json.get("fass", []) ] return params.put()
def from_url(qparams): params = SeedGenParams() params.seed = qparams.get("seed") if not params.seed: log.error("No seed in %r! returning None" % qparams) return None params.variations = enums_from_strlist(Variation, qparams.getall("var")) params.logic_paths = enums_from_strlist(LogicPath, qparams.getall("path")) if not params.logic_paths: log.error("No logic paths in %r! returning None" % qparams) return None params.key_mode = KeyMode(qparams.get("key_mode", "Clues")) params.path_diff = PathDifficulty(qparams.get("path_diff", "Normal")) params.exp_pool = int(qparams.get("exp_pool", 10000)) params.balanced = qparams.get("gen_mode") != "Classic" params.players = int(qparams.get("players", 1)) params.tracking = qparams.get("tracking") != "Disabled" params.frag_count = int(qparams.get("frags", 30)) params.frag_req = int(qparams.get("frags_req", 20)) params.relic_count = int(qparams.get("relics", 8)) params.cell_freq = int(qparams.get("cell_freq", 256)) params.sync = MultiplayerOptions.from_url(qparams) params.sense = qparams.get("sense") params.pool_preset = qparams.get("pool_preset", "Standard").title() params.item_pool = {} raw_pool = qparams.get("item_pool") if raw_pool: for itemcnt in raw_pool.split("|"): item, _, count = itemcnt.partition(":") params.item_pool[item] = int(count) else: if Variation.EXTRA_BONUS_PICKUPS in params.variations or params.pool_preset == "Extra Bonus": params.pool_preset = "Extra Bonus" params.item_pool = { "TP|Grove": [1], "TP|Swamp": [1], "TP|Grotto": [1], "TP|Valley": [1], "TP|Sorrow": [1], "TP|Ginso": [1], "TP|Horu": [1], "TP|Forlorn": [1], "HC|1": [12], "EC|1": [14], "AC|1": [33], "RP|RB/0": [3], "RP|RB/1": [3], "RB|6": [5], "RB|9": [1], "RB|10": [1], "RB|11": [1], "RB|12": [3], "RB|37": [3], "RB|13": [3], "RB|15": [3], "RB|31": [1], "RB|32": [1], "RB|33": [3], "BS|*": [4], "WP|*": [4, 8], } elif params.pool_preset == "Bonus Lite": params.item_pool = { "TP|Grove": [1], "TP|Swamp": [1], "TP|Grotto": [1], "TP|Valley": [1], "TP|Sorrow": [1], "TP|Ginso": [1], "TP|Horu": [1], "TP|Forlorn": [1], "HC|1": [12], "EC|1": [14], "AC|1": [33], "RB|0": [3], "RB|1": [3], "RB|6": [5], "RB|9": [1], "RB|10": [1], "RB|11": [1], "RB|12": [3], "RB|37": [3], "RB|13": [3], "RB|15": [3], "RB|31": [1], "RB|32": [1], "RB|33": [3], "RB|36": [1], "WP|*": [4, 8], } elif params.pool_preset == "Competitive": params.item_pool = { "TP|Grove": [1], "TP|Swamp": [1], "TP|Grotto": [1], "TP|Valley": [1], "TP|Sorrow": [1], "TP|Forlorn": [1], "HC|1": [12], "EC|1": [14], "AC|1": [33], "RB|0": [3], "RB|1": [3], "RB|6": [3], "RB|9": [1], "RB|10": [1], "RB|11": [1], "RB|12": [1], "RB|13": [3], "RB|15": [3], } elif params.pool_preset == "Hard": params.item_pool = { "TP|Grove": [1], "TP|Swamp": [1], "TP|Grotto": [1], "TP|Valley": [1], "TP|Sorrow": [1], "EC|1": [3] } else: params.pool_preset = "Standard" params.item_pool = { "TP|Grove": [1], "TP|Swamp": [1], "TP|Grotto": [1], "TP|Valley": [1], "TP|Sorrow": [1], "TP|Ginso": [1], "TP|Horu": [1], "TP|Forlorn": [1], "HC|1": [12], "EC|1": [14], "AC|1": [33], "RB|0": [3], "RB|1": [3], "RB|6": [3], "RB|9": [1], "RB|10": [1], "RB|11": [1], "RB|12": [1], "RB|13": [3], "RB|15": [3], } raw_fass = qparams.get("fass") if raw_fass: params.placements = [] for fass in raw_fass.split("|"): loc, _, item = fass.partition(":") stuff = [Stuff(code=item[:2], id=item[2:], player="")] params.placements.append( Placement(location=loc, zone="", stuff=stuff)) return params.put()
def get_pathdiff(self): return PathDifficulty(self.str_pathdiff)
def get_pathdiff(self): return PathDifficulty.from_ndb(self.ndb_pathdiff) def set_pathdiff(self, pathdiff): self.ndb_pathdiff = pathdiff.to_ndb()