diff --git a/db/carves.json b/db/carves.json new file mode 100644 index 0000000..4d671c3 --- /dev/null +++ b/db/carves.json @@ -0,0 +1,74 @@ +[ +{ + "carves": { + "Body Carve": 4, + "Tail Carve": 2 + }, + "monsters": [ + "Gravios", "Apex Gravios", "Black Gravios", + "Deviljho", "Apex Deviljho", "Savage Deviljho", + "Akantor", "Ukanlos", + "Monoblos", "White Monoblos" + ] +}, +{ + "carves": { + "Body Carve": 4, + "Tail Carve": 1 + }, + "monsters": [ + "Teostra", "Chameleos", "Raging Brachydios", + "Kushala Daora", "Rusted Kushala Daora" + ] +}, +{ + "monsters": ["Dah'ren Mohran"], + "carves": { + "Body Carve": 8, + "Mouth Carve": 2 + } +}, +{ + "monsters": ["Dalamadur", "Shah Dalamadur"], + "carves": { + "Upper Body Carve": 4, + "Lower Body Carve": 4, + "Head Carve": 2, + "Tail Carve": 1 + } +}, +{ + "monsters": ["Gogmazios"], + "carves": { + "Body Carve": 6, + "Tail Carve": 2 + } +}, +{ + "monsters": ["Fatalis", "Crimson Fatalis", "White Fatalis"], + "carves": { + "Body Carve": 9 + } +}, +{ + "carves": { + "Body Carve": 2 + }, + "monsters": ["Aptonoth", "Apceros", "Popo", "Rhenoplos", "Slagtoth", + "Jaggia"] +}, +{ + "monsters": ["Kelbi"], + "carves": { + "Body Carve": 1, + "Body Carve (KO)": 1, + "Body Carve (KO Large Kelbi)": 1 + } +}, +{ + "monsters": ["Gypceros", "Purple Gypceros"], + "carves": { + "Body Carve (Apparent Death)": 1 + } +} +] diff --git a/db/mh4u.db b/db/mh4u.db index 1bdca51..dd24b8b 100644 Binary files a/db/mh4u.db and b/db/mh4u.db differ diff --git a/db/set_carve_counts.py b/db/set_carve_counts.py new file mode 100755 index 0000000..2ec216d --- /dev/null +++ b/db/set_carve_counts.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python + +import os.path +import codecs +import json + +import _pathfix +from _pathfix import db_path + +from mhapi.db import MHDB + + +def get_utf8_writer(writer): + return codecs.getwriter("utf8")(writer) + + +def set_carve_counts(db, monster_carves): + monsters = db.get_monsters() + for m in monsters: + rewards = db.get_monster_rewards(m.id) + mc = monster_carves.get(m.name) + print "===", m.name + for r in rewards: + condition = r["condition"] + if "Carve" not in condition: + continue + if mc and condition in mc: + stack_size = mc[condition] + elif m["class"] == "Minion": + stack_size = 1 + elif m["class"] == "Boss": + if condition == "Body Carve": + stack_size = 3 + elif condition == "Tail Carve": + stack_size = 1 + else: + print "WARN: unknown condition %s.%s" \ + % (m.name, condition) + else: + assert False, "Unknown monster class: %s" % m["class"] + if r["stack_size"] == stack_size: + continue + print " ", condition, r["stack_size"], "=>", stack_size + cur = db.cursor() + cur.execute("""UPDATE hunting_rewards + SET stack_size=? WHERE _id=?""", + (stack_size, r["_id"])) + + +def load_carves_json(): + carves_json_path = os.path.join(db_path, "carves.json") + with open(carves_json_path) as f: + carves_list = json.load(f) + monster_carves = {} + for carves in carves_list: + for monster_name in carves["monsters"]: + monster_carves[monster_name] = carves["carves"] + return monster_carves + + +if __name__ == '__main__': + db_file = os.path.join(db_path, "mh4u.db") + db = MHDB(db_file) + + import sys + sys.stdout = get_utf8_writer(sys.stdout) + sys.stderr = get_utf8_writer(sys.stderr) + monster_carves = load_carves_json() + set_carve_counts(db, monster_carves) + db.commit() + db.close() diff --git a/mhapi/rewards.py b/mhapi/rewards.py index 50d6347..6d48a48 100644 --- a/mhapi/rewards.py +++ b/mhapi/rewards.py @@ -7,7 +7,6 @@ from __future__ import print_function from collections import OrderedDict from mhapi import stats -from mhapi.model import Quest from mhapi.skills import LuckSkill, CapSkill, CarvingSkill SKILL_CARVING = "carving" @@ -315,56 +314,25 @@ class HuntReward(object): return d def _calculate_evs(self): + counts = [self.stack_size] if self.condition == "Tail Carve": self.skill = SKILL_CARVING self.cap = True self.kill = True - counts = [ - 1 + stats.carve_delta_expected_c(skill) - for skill in xrange(CarvingSkill.PRO, - CarvingSkill.GOD+1) - ] elif self.condition == "Body Carve (Apparent Death)": - # Gypceros fake death. Assume one carve, it's dangerous to try - # for two. - counts = [1] + # Gypceros fake death self.cap = True self.kill = True - elif self.condition == "Body Carve": - # TODO: some monsters have 4 body carves + elif "Body Carve" in self.condition: self.skill = SKILL_CARVING self.cap = False self.kill = True - counts = [ - 3 + stats.carve_delta_expected_c(skill) - for skill in xrange(CarvingSkill.PRO, - CarvingSkill.GOD+1) - ] - elif self.condition.startswith("Body Carve (KO"): - # Kelbi - self.skill = SKILL_CARVING - self.cap = True - self.kill = True - counts = [ - 1 + stats.carve_delta_expected_c(skill) - for skill in xrange(CarvingSkill.PRO, - CarvingSkill.GOD+1) - ] elif "Carve" in self.condition: + # other live carves: # Mouth Carve: Dah'ren Mohran - # Upper Body Carve: Dalamadur - # Lower Body Carve: Dalamadur # Head Carve: Dalamadur - # TODO: separate these out, some have >3 carves, not sure - # about others - self.skill = SKILL_CARVING - self.cap = False + self.cap = True self.kill = True - counts = [ - 3 + stats.carve_delta_expected_c(skill) - for skill in xrange(CarvingSkill.PRO, - CarvingSkill.GOD+1) - ] elif self.condition == "Capture": self.skill = SKILL_CAP self.cap = True @@ -383,9 +351,7 @@ class HuntReward(object): # give more rewards or just higher rarity crystals? self.cap = True self.kill = True - counts = [1] else: - counts = [1] if self.condition.startswith("Shiny"): # don't include shiny in total, makes it easier to # calculate separately since shinys are variable by @@ -406,7 +372,15 @@ class HuntReward(object): raise ValueError("Unknown condition: '%s'" % self.condition) - evs = [(i * self.stack_size * self.percentage) for i in counts] + if self.skill == SKILL_CARVING: + counts = [ + self.stack_size + stats.carve_delta_expected_c(skill) + for skill in xrange(CarvingSkill.NONE, + CarvingSkill.GOD+1) + ] + + evs = [(i * self.percentage) for i in counts] + return evs