parent
9bad89b0af
commit
f6fa342ac4
Binary file not shown.
@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
import codecs
|
||||||
|
import csv
|
||||||
|
|
||||||
|
import _pathfix
|
||||||
|
|
||||||
|
from mhapi.db import MHDB
|
||||||
|
|
||||||
|
|
||||||
|
def set_upgrade_cost(db, item_id, upgrade_cost):
|
||||||
|
print "upgrade_cost", item_id, upgrade_cost
|
||||||
|
cur = db.cursor()
|
||||||
|
cur.execute("""UPDATE weapons SET
|
||||||
|
upgrade_cost=? WHERE _id=?""",
|
||||||
|
(upgrade_cost, item_id))
|
||||||
|
|
||||||
|
|
||||||
|
def set_creation_cost(db, item_id, creation_cost):
|
||||||
|
print "creation_cost", item_id, creation_cost
|
||||||
|
cur = db.cursor()
|
||||||
|
cur.execute("""UPDATE weapons SET
|
||||||
|
creation_cost=? WHERE _id=?""",
|
||||||
|
(creation_cost, item_id))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
db = MHDB()
|
||||||
|
delta_file_path = os.path.join(_pathfix.db_path, "weapons-delta.csv")
|
||||||
|
|
||||||
|
with open(delta_file_path) as f:
|
||||||
|
reader = csv.DictReader(f)
|
||||||
|
for row in reader:
|
||||||
|
item_id = row["id"]
|
||||||
|
creation_cost = row["creation_cost"]
|
||||||
|
upgrade_cost = row["upgrade_cost"]
|
||||||
|
if creation_cost:
|
||||||
|
set_creation_cost(db, item_id, creation_cost)
|
||||||
|
if upgrade_cost:
|
||||||
|
set_upgrade_cost(db, item_id, upgrade_cost)
|
||||||
|
|
||||||
|
db.commit()
|
||||||
|
db.close()
|
||||||
|
@ -1,65 +1,74 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Monster Hunter Item Search</title>
|
<title>Poogie's Toolbox</title>
|
||||||
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
|
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
|
||||||
|
|
||||||
<style>
|
<script src="js/common.js"></script>
|
||||||
.flex {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
label {
|
|
||||||
font-weight: bold;
|
|
||||||
font-family: sans, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
#output { flex: 99 1 auto; }
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#search").click(update_search);
|
setup_item_autocomplete("#item");
|
||||||
$("#item").keypress(function(e) {
|
setup_weapon_autocomplete("#weapon_type", "#weapon");
|
||||||
if (e.which == 13) { update_search(); }
|
|
||||||
});
|
|
||||||
setup_autocomplete();
|
|
||||||
});
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
function setup_autocomplete() {
|
<style>
|
||||||
$.getJSON("/mhapi/item_name_list",
|
label {
|
||||||
function(data) {
|
font-weight: bold;
|
||||||
$("#item").autocomplete({ source: data });
|
font-family: sans, sans-serif;
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_search() {
|
|
||||||
var item_name = $.trim($("#item").val());
|
|
||||||
|
|
||||||
$.get("/mhapi/rewards",
|
|
||||||
{ "item_name": item_name },
|
|
||||||
function(data) {
|
|
||||||
$("#output").text(data);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
</script>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="flex">
|
<form action="recommends.html" method="GET">
|
||||||
<div>
|
<fieldset>
|
||||||
<label for="item">Item:</label>
|
<legend title="Find the best quests and armor skills for farming an item."
|
||||||
<input id="item" type="text" size="20" />
|
>Poogie Recommends</legend>
|
||||||
<button id="search">Ask Poogie</button>
|
<label for="item">Item:</label>
|
||||||
<a href="https://github.com/bd4/monster-hunter-scripts/blob/master/RECOMMENDATIONS.adoc">Understanding Results</a>
|
<input id="item" name="item" type="text" size="20" />
|
||||||
(<a href="https://github.com/bd4/monster-hunter-scripts">source</a>)
|
<input type="submit" value="Ask Poogie" />
|
||||||
</div>
|
<p></p>
|
||||||
<br />
|
</fieldset>
|
||||||
<textarea readonly="true" rows="10" cols="80" id="output"></textarea>
|
</form>
|
||||||
</div>
|
<form action="weaponplanner.html" method="GET">
|
||||||
|
<fieldset>
|
||||||
|
<legend title="Compare the cost of making a weapon from different starting points in the tree"
|
||||||
|
>Poogie's Weapon Planner</legend>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><label for="type">Type:</label></td>
|
||||||
|
<td><select id="weapon_type" name="weapon_type">
|
||||||
|
<option value="All">All</option>
|
||||||
|
<option value="Great Sword">Great Sword</option>
|
||||||
|
<option value="Long Sword">Long Sword</option>
|
||||||
|
<option value="Sword and Shield">Sword and Shield</option>
|
||||||
|
<option value="Dual Blades">Dual Blades</option>
|
||||||
|
<option value="Hammer">Hammer</option>
|
||||||
|
<option value="Hunting Horn">Hunting Horn</option>
|
||||||
|
<option value="Lance">Lance</option>
|
||||||
|
<option value="Gunlance">Gunlance</option>
|
||||||
|
<option value="Switch Axe">Switch Axe</option>
|
||||||
|
<option value="Charge Blade">Charge Blade</option>
|
||||||
|
<option value="Insect Glaive">Insect Glaive</option>
|
||||||
|
<option value="Light Bowgun">Light Bowgun</option>
|
||||||
|
<option value="Heavy Bowgun">Heavy Bowgun</option>
|
||||||
|
<option value="Bow">Bow</option>
|
||||||
|
</select></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="weapon">Weapon:</label></td>
|
||||||
|
<td><input id="weapon" name="weapon" weapon="text" size="20" />
|
||||||
|
<input type="submit" value="Ask Poogie" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
<fieldset>
|
||||||
|
<legend title="Plan armor sets">Poogie Outfitters</legend>
|
||||||
|
<a href="outfitters.html">Armor set planner</a>
|
||||||
|
</fieldset>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -0,0 +1,109 @@
|
|||||||
|
WEAPON_NAME_IDX = {};
|
||||||
|
WEAPON_TYPE_IDX = {};
|
||||||
|
|
||||||
|
(function($) {
|
||||||
|
$.QueryString = (function(a) {
|
||||||
|
if (a == "") return {};
|
||||||
|
var b = {};
|
||||||
|
for (var i = 0; i < a.length; ++i)
|
||||||
|
{
|
||||||
|
var p=a[i].split('=');
|
||||||
|
if (p.length != 2) continue;
|
||||||
|
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
})(window.location.search.substr(1).split('&'))
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
|
||||||
|
function encode_utf8(s) {
|
||||||
|
return unescape(encodeURIComponent(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_base_path() {
|
||||||
|
var path = document.location.pathname;
|
||||||
|
return path.substring(0, path.lastIndexOf('/'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function normalize_name(s) {
|
||||||
|
var chars = s.split("");
|
||||||
|
var cap_next = true;
|
||||||
|
var i;
|
||||||
|
for (i=0; i<chars.length; i++) {
|
||||||
|
if (cap_next) {
|
||||||
|
chars[i] = chars[i].toUpperCase();
|
||||||
|
cap_next = false;
|
||||||
|
} else if (chars[i] == "." || chars[i] == " " || chars[i] == "-") {
|
||||||
|
cap_next = true;
|
||||||
|
} else {
|
||||||
|
chars[i] = chars[i].toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return chars.join("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setup_item_autocomplete(selector) {
|
||||||
|
var DATA_PATH = get_base_path() + "/rewards/";
|
||||||
|
$.getJSON(DATA_PATH + "items.json",
|
||||||
|
function(data) {
|
||||||
|
$(selector).autocomplete({ source: data });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setup_weapon_autocomplete(type_selector, weapon_selector, ready_fn,
|
||||||
|
change_fn) {
|
||||||
|
var DATA_PATH = get_base_path() + "/jsonapi/";
|
||||||
|
$.getJSON(DATA_PATH + "weapon/_index_name.json",
|
||||||
|
function(data) {
|
||||||
|
WEAPON_NAME_IDX = data;
|
||||||
|
$.getJSON(DATA_PATH + "weapon/_index_wtype.json",
|
||||||
|
function(data) {
|
||||||
|
WEAPON_TYPE_IDX = data;
|
||||||
|
if (ready_fn) {
|
||||||
|
ready_fn();
|
||||||
|
}
|
||||||
|
_setup_weapon_autocomplete(
|
||||||
|
$(type_selector).val(),
|
||||||
|
weapon_selector,
|
||||||
|
change_fn);
|
||||||
|
$(type_selector).change(function(evt) {
|
||||||
|
_setup_weapon_autocomplete(
|
||||||
|
$(type_selector).val(),
|
||||||
|
weapon_selector, change_fn);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function _setup_weapon_autocomplete(type, weapon_selector, change_fn) {
|
||||||
|
//alert("set weapon type " + type + " (" + weapon_selector + ")");
|
||||||
|
var source;
|
||||||
|
if (type == "All") {
|
||||||
|
source = Object.keys(WEAPON_NAME_IDX);
|
||||||
|
//alert(source[10]);
|
||||||
|
} else {
|
||||||
|
var object_list = WEAPON_TYPE_IDX[type];
|
||||||
|
source = [];
|
||||||
|
for (i=0; i<object_list.length; i++) {
|
||||||
|
source.push(object_list[i]["name"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(weapon_selector).autocomplete(
|
||||||
|
{ source: source,
|
||||||
|
change: function (event, ui) {
|
||||||
|
if (change_fn) {
|
||||||
|
change_fn(ui.item["value"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
$(weapon_selector).keypress(function(e) {
|
||||||
|
if (e.which == 13 && change_fn) {
|
||||||
|
change_fn($(weapon_selector).val());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Reference in new issue