mirror of
https://github.com/bartvdbraak/SlayerWeightCalculator.git
synced 2025-04-27 09:41:19 +00:00
functionality for unlocks, filtering and percentages
This commit is contained in:
parent
2cdb340edd
commit
1c816c74ad
5 changed files with 274 additions and 184 deletions
|
@ -1 +0,0 @@
|
|||
,bartvdbraak,BART-MINT,24.04.2019 02:32,file:///home/bartvdbraak/.config/libreoffice/4;
|
|
@ -1,28 +1,28 @@
|
|||
monster,taskweight
|
||||
Ankou,6
|
||||
Aviansie,7
|
||||
Bandit,4
|
||||
Bear,6
|
||||
Black demon,7
|
||||
Black dragon,4
|
||||
Chaos druid,5
|
||||
Dark warrior,4
|
||||
Earth warrior,6
|
||||
Ent,5
|
||||
Fire giant,7
|
||||
Greater demon,8
|
||||
Green dragon,4
|
||||
Hellhound,7
|
||||
Ice giant,6
|
||||
Ice warrior,7
|
||||
Lava dragon,3
|
||||
Lesser demon,6
|
||||
Magic axe,7
|
||||
Mammoth,6
|
||||
Revenant,5
|
||||
Rogue,5
|
||||
Scorpion,6
|
||||
Skeleton,5
|
||||
Spider,6
|
||||
Spiritual creatures,6
|
||||
Bosses,8
|
||||
monster,taskweight,slayer_req
|
||||
Ankou,6,1
|
||||
Aviansie,7,1
|
||||
Bandit,4,1
|
||||
Bear,6,1
|
||||
Black demon,7,1
|
||||
Black dragon,4,1
|
||||
Chaos druid,5,1
|
||||
Dark warrior,4,1
|
||||
Earth warrior,6,1
|
||||
Ent,5,1
|
||||
Fire giant,7,1
|
||||
Greater demon,8,1
|
||||
Green dragon,4,1
|
||||
Hellhound,7,1
|
||||
Ice giant,6,1
|
||||
Ice warrior,7,1
|
||||
Lava dragon,3,1
|
||||
Lesser demon,6,1
|
||||
Magic axe,7,1
|
||||
Mammoth,6,1
|
||||
Revenant,5,1
|
||||
Rogue,5,1
|
||||
Scorpion,6,1
|
||||
Skeleton,5,1
|
||||
Spider,6,1
|
||||
Spiritual creatures,6,63
|
||||
Bosses,8,1
|
||||
|
|
|
|
@ -1,112 +1,137 @@
|
|||
{
|
||||
"data": [
|
||||
{
|
||||
"monster": "Ankou",
|
||||
"taskweight": 6
|
||||
},
|
||||
{
|
||||
"monster": "Aviansie",
|
||||
"taskweight": 7
|
||||
},
|
||||
{
|
||||
"monster": "Bandit",
|
||||
"taskweight": 4
|
||||
},
|
||||
{
|
||||
"monster": "Bear",
|
||||
"taskweight": 6
|
||||
},
|
||||
{
|
||||
"monster": "Black demon",
|
||||
"taskweight": 7
|
||||
},
|
||||
{
|
||||
"monster": "Black dragon",
|
||||
"taskweight": 4
|
||||
},
|
||||
{
|
||||
"monster": "Chaos druid",
|
||||
"taskweight": 5
|
||||
},
|
||||
{
|
||||
"monster": "Dark warrior",
|
||||
"taskweight": 4
|
||||
},
|
||||
{
|
||||
"monster": "Earth warrior",
|
||||
"taskweight": 6
|
||||
},
|
||||
{
|
||||
"monster": "Ent",
|
||||
"taskweight": 5
|
||||
},
|
||||
{
|
||||
"monster": "Fire giant",
|
||||
"taskweight": 7
|
||||
},
|
||||
{
|
||||
"monster": "Greater demon",
|
||||
"taskweight": 8
|
||||
},
|
||||
{
|
||||
"monster": "Green dragon",
|
||||
"taskweight": 4
|
||||
},
|
||||
{
|
||||
"monster": "Hellhound",
|
||||
"taskweight": 7
|
||||
},
|
||||
{
|
||||
"monster": "Ice giant",
|
||||
"taskweight": 6
|
||||
},
|
||||
{
|
||||
"monster": "Ice warrior",
|
||||
"taskweight": 7
|
||||
},
|
||||
{
|
||||
"monster": "Lava dragon",
|
||||
"taskweight": 3
|
||||
},
|
||||
{
|
||||
"monster": "Lesser demon",
|
||||
"taskweight": 6
|
||||
},
|
||||
{
|
||||
"monster": "Magic axe",
|
||||
"taskweight": 7
|
||||
},
|
||||
{
|
||||
"monster": "Mammoth",
|
||||
"taskweight": 6
|
||||
},
|
||||
{
|
||||
"monster": "Revenant",
|
||||
"taskweight": 5
|
||||
},
|
||||
{
|
||||
"monster": "Rogue",
|
||||
"taskweight": 5
|
||||
},
|
||||
{
|
||||
"monster": "Scorpion",
|
||||
"taskweight": 6
|
||||
},
|
||||
{
|
||||
"monster": "Skeleton",
|
||||
"taskweight": 5
|
||||
},
|
||||
{
|
||||
"monster": "Spider",
|
||||
"taskweight": 6
|
||||
},
|
||||
{
|
||||
"monster": "Spiritual creatures",
|
||||
"taskweight": 6
|
||||
},
|
||||
{
|
||||
"monster": "Bosses",
|
||||
"taskweight": 8
|
||||
}
|
||||
]
|
||||
}
|
||||
[
|
||||
{
|
||||
"monster": "Ankou",
|
||||
"taskweight": 6,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Aviansie",
|
||||
"taskweight": 7,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Bandit",
|
||||
"taskweight": 4,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Bear",
|
||||
"taskweight": 6,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Black demon",
|
||||
"taskweight": 7,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Black dragon",
|
||||
"taskweight": 4,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Chaos druid",
|
||||
"taskweight": 5,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Dark warrior",
|
||||
"taskweight": 4,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Earth warrior",
|
||||
"taskweight": 6,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Ent",
|
||||
"taskweight": 5,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Fire giant",
|
||||
"taskweight": 7,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Greater demon",
|
||||
"taskweight": 8,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Green dragon",
|
||||
"taskweight": 4,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Hellhound",
|
||||
"taskweight": 7,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Ice giant",
|
||||
"taskweight": 6,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Ice warrior",
|
||||
"taskweight": 7,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Lava dragon",
|
||||
"taskweight": 3,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Lesser demon",
|
||||
"taskweight": 6,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Magic axe",
|
||||
"taskweight": 7,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Mammoth",
|
||||
"taskweight": 6,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Revenant",
|
||||
"taskweight": 5,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Rogue",
|
||||
"taskweight": 5,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Scorpion",
|
||||
"taskweight": 6,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Skeleton",
|
||||
"taskweight": 5,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Spider",
|
||||
"taskweight": 6,
|
||||
"slayer_req": 1
|
||||
},
|
||||
{
|
||||
"monster": "Spiritual creatures",
|
||||
"taskweight": 6,
|
||||
"slayer_req": 63
|
||||
},
|
||||
{
|
||||
"monster": "Bosses",
|
||||
"taskweight": 8,
|
||||
"slayer_req": 1
|
||||
}
|
||||
]
|
34
index.html
34
index.html
|
@ -30,20 +30,20 @@
|
|||
<div class="col-6">
|
||||
<p>Unlocks:</p>
|
||||
<form>
|
||||
<ul><input type="checkbox" name="reddrags" id="reddrags">
|
||||
Seeing red (Unlocks Red Dragons)</ul>
|
||||
<ul><input type="checkbox" name="mithdrags" id="mithdrags">
|
||||
I hope you mith me (Unlocks Mithril Dragons)</ul>
|
||||
<ul><input type="checkbox" name="aviansie" id="aviansie">
|
||||
Watch the birdie (Unlocks Aviansies)</ul>
|
||||
<ul><input type="checkbox" name="tzhaars" id="tzhaars">
|
||||
Hot stuff (Unlocks TzHaars)</ul>
|
||||
<ul><input type="checkbox" name="lizardmen" id="lizardmen">
|
||||
Reptile got ripped (Unlocks Lizardmen)</ul>
|
||||
<ul><input type="checkbox" name="bosses" id="bosses">
|
||||
Like a boss (Unlocks Bosses)</ul>
|
||||
<ul><input type="checkbox" name="fossilwyverns" id="fossilwyverns">
|
||||
Stop the Wyvern (Disables Fossil Island Wyverns)</ul>
|
||||
<ul><label><input type="checkbox" name="reddrags" id="reddrags">
|
||||
Seeing red (Unlocks Red Dragons)</label></ul>
|
||||
<ul><label><input type="checkbox" name="mithdrags" id="mithdrags">
|
||||
I hope you mith me (Unlocks Mithril Dragons)</label></ul>
|
||||
<ul><label><input type="checkbox" name="aviansies" id="aviansies">
|
||||
Watch the birdie (Unlocks Aviansies)</label></ul>
|
||||
<ul><label><input type="checkbox" name="tzhaar" id="tzhaar">
|
||||
Hot stuff (Unlocks TzHaars)</label></ul>
|
||||
<ul><label><input type="checkbox" name="lizardmen" id="lizardmen">
|
||||
Reptile got ripped (Unlocks Lizardmen)</label></ul>
|
||||
<ul><label><input type="checkbox" name="bosses" id="bosses">
|
||||
Like a boss (Unlocks Bosses)</label></ul>
|
||||
<ul><label><input type="checkbox" name="fossilwyverns" id="fossilwyverns">
|
||||
Stop the Wyvern (Disables Fossil Island Wyverns)</label></ul>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
|
@ -59,17 +59,17 @@
|
|||
</div>
|
||||
<div class="col-6 text-center">
|
||||
Slayer level:
|
||||
<input type="text" name="slayerlevel" value="">
|
||||
<input type="text" min="1" max="99" name="slayerlevel" id="slayerlevel" maxlength="2" placeholder="99" value="99">
|
||||
</div>
|
||||
<div class="col-6 text-center">
|
||||
<input type="submit" value="Apply changes" onclick="applyChanges()">
|
||||
<input type="submit" value="Apply changes" onclick="applyChanges('krystilia')">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>Krystilia</h3>
|
||||
<p>Krystilia is a Slayer master found in Edgeville's jail north-east of the bank. When spoken to, she expresses her love for magic and the Wilderness, and claims the guards locked her in the cell for trouble-making.</p>
|
||||
<table id="example" class="display nowrap" width="100%">
|
||||
<table id="master" class="display nowrap" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Monster</th>
|
||||
|
|
118
js/script.js
118
js/script.js
|
@ -1,32 +1,98 @@
|
|||
$(document).ready(function() {
|
||||
$('#example').DataTable({
|
||||
ajax: "data/krystilia.json",
|
||||
columns: [
|
||||
jQuery.fn.dataTable.Api.register( 'sum()', function ( ) {
|
||||
return this.flatten().reduce( function ( a, b ) {
|
||||
if ( typeof a === 'string' ) {
|
||||
a = a.replace(/[^\d.-]/g, '') * 1;
|
||||
}
|
||||
if ( typeof b === 'string' ) {
|
||||
b = b.replace(/[^\d.-]/g, '') * 1;
|
||||
}
|
||||
|
||||
return a + b;
|
||||
}, 0 );
|
||||
} );
|
||||
|
||||
function filterTasks(data) {
|
||||
index_list = []
|
||||
|
||||
for (i = 0; i < data.length; i++) {
|
||||
switch (data[i].monster) {
|
||||
case 'Red dragons':
|
||||
if ($("#reddrags").prop("checked") == false) {
|
||||
index_list.push(i)
|
||||
}
|
||||
break;
|
||||
case 'Mithril dragons':
|
||||
if ($("#mithdrags").prop("checked") == false) {
|
||||
index_list.push(i)
|
||||
}
|
||||
break;
|
||||
case 'Aviansie':
|
||||
if ($("#aviansies").prop("checked") == false) {
|
||||
index_list.push(i)
|
||||
}
|
||||
break;
|
||||
case 'Tzhaar':
|
||||
if ($("#tzhaar").prop("checked") == false) {
|
||||
index_list.push(i)
|
||||
}
|
||||
break;
|
||||
case 'Lizardmen':
|
||||
if ($("#lizardmen").prop("checked") == false) {
|
||||
index_list.push(i)
|
||||
}
|
||||
break;
|
||||
case 'Bosses':
|
||||
if ($("#bosses").prop("checked") == false) {
|
||||
index_list.push(i)
|
||||
}
|
||||
break;
|
||||
case 'Fossil Island Wyverns':
|
||||
if ($("#wyverns").prop("checked") == true) {
|
||||
index_list.push(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(index_list,data)
|
||||
return data
|
||||
}
|
||||
|
||||
function sumWeights(data) {
|
||||
var total = 0;
|
||||
for (var i in data) {
|
||||
total += data[i].taskweight
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
var table;
|
||||
|
||||
function deleteOldDataTable(table) {
|
||||
if ( $.fn.dataTable.isDataTable( '#master' ) ) {
|
||||
table.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
function applyChanges(master) {
|
||||
deleteOldDataTable();
|
||||
|
||||
$.getJSON( "data/"+master+".json", function( data ) {
|
||||
|
||||
var data = filterTasks(data),
|
||||
totalweight = sumWeights(data);
|
||||
|
||||
$(document).ready(function() {
|
||||
table = $('#master').DataTable({
|
||||
"data": data,
|
||||
"columns": [
|
||||
{ data: 'monster'},
|
||||
{ data: 'taskweight'},
|
||||
{
|
||||
data: null,
|
||||
render: function ( data, type, row ) {
|
||||
return Math.round( col.taskweight * row.taskweight * 100 )+'%';
|
||||
{ data: null, render: function ( data, type, row ) {
|
||||
return (row.taskweight / totalweight * 100 ).toFixed(2)+'%';
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
function filterEntries() {
|
||||
|
||||
}
|
||||
|
||||
function addPercentages() {
|
||||
|
||||
}
|
||||
|
||||
function applyChanges() {
|
||||
filterEntries();
|
||||
addPercentages();
|
||||
alert('Done.')
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue