diff --git a/db/mh4u.db b/db/mh4u.db index 5022c7b..dd8053a 100644 Binary files a/db/mh4u.db and b/db/mh4u.db differ diff --git a/db/mh4u/weapon_shop.csv b/db/mh4u/weapon_shop.csv new file mode 100644 index 0000000..c848d36 --- /dev/null +++ b/db/mh4u/weapon_shop.csv @@ -0,0 +1,38 @@ +Iron Sword,1500 +Buster Sword,2550 +Giant Jawblade,5250 +Ravager Blade,5250 +Iron Katana,1500 +Canine Katana,3300 +Eager Cleaver,10950 +Hunter's Knife,1500 +Assassin's Dagger,3300 +Chief Kris,4200 +Matched Slicers,1500 +Chief's Scythes,3300 +Dual Hatchets,4200 +War Hammer,1500 +War Mace,2550 +Bone Bludgeon+,4200 +Iron Striker+,5250 +Metal Bagpipe,1500 +Hunter's Horn,4200 +Heavy Bagpipe+,5250 +Iron Lance,1500 +Knight Lance,2550 +Rampart,5250 +Spiked Javelin,6450 +Iron Gunlance,1500 +Jaggid Gunlance,4200 +Defender's Gunlance,6450 +Bone Axe,1950 +Wild Axe,4200 +Power Gasher,5250 +Elite Blad,1950 +Bone Staff,3300 +Cross Bowgun,2550 +Cross Bowgun+,4200 +Bone Shooter,2100 +Bone Shooter+,5400 +Hunter's Bow I,1500 +Hunter's Stoutbow I,4200 diff --git a/db/set_weapon_buy.py b/db/set_weapon_buy.py new file mode 100755 index 0000000..84bb496 --- /dev/null +++ b/db/set_weapon_buy.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python2 + +import os.path +import codecs +import csv + +import _pathfix + +from mhapi.db import MHDB + + +def set_buy(db, item_id, buy): + print "buy", item_id, buy + cur = db.cursor() + cur.execute("""UPDATE items SET + buy=? WHERE _id=?""", + (buy, item_id)) + +def set_buy_by_name(db, name, buy): + cur = db.cursor() + cur.execute("""UPDATE items SET + buy=? WHERE name=?""", + (buy, name)) + rowid = cur.lastrowid + print "buy", rowid, name, buy + +if __name__ == '__main__': + db = MHDB(game="4u") + delta_file_path = os.path.join(_pathfix.db_path, "mh4u", "weapon_shop.csv") + + with open(delta_file_path) as f: + reader = csv.reader(f) + for row in reader: + name = row[0] + value = int(row[1]) + set_buy_by_name(db, name, value) + + db.commit() + db.close() diff --git a/mhapi/model.py b/mhapi/model.py index 451dc84..f132372 100644 --- a/mhapi/model.py +++ b/mhapi/model.py @@ -641,6 +641,11 @@ def get_costs(db, weapon): for item in weapon.create_components: create_cost["components"][item.name] = item.quantity costs = [create_cost] + costs + if weapon.buy: + buy_cost = dict(zenny=int(weapon.buy), + path=[weapon], + components={}) + costs = [buy_cost] + costs return costs @@ -678,6 +683,10 @@ class ItemStars(object): costs = get_costs(self.db, weapon) # find least 'expensive' path for c in costs: + # don't calculate stars from buy cost (buys aren't available + # until after item is craftable, sometimes much later) + if not c["components"]: + continue current_stars = self._get_component_stars(c) for k, v in current_stars.iteritems(): if v is None: