mirror of
https://github.com/misode/misode.github.io.git
synced 2026-05-02 07:55:29 +00:00
Improve filtering + add apply_bonus parameters
This commit is contained in:
@@ -5,7 +5,7 @@ $('#tableType').val("minecraft:generic");
|
|||||||
$('#indentationSelect').val("2");
|
$('#indentationSelect').val("2");
|
||||||
|
|
||||||
let indentation = 2;
|
let indentation = 2;
|
||||||
let luck_based = false;
|
let luckBased = false;
|
||||||
let table = {
|
let table = {
|
||||||
type: "minecraft:generic",
|
type: "minecraft:generic",
|
||||||
pools: [
|
pools: [
|
||||||
@@ -21,8 +21,8 @@ let table = {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
let historyBuffer = 100;
|
let historyBuffer = 100;
|
||||||
let history = [];
|
let history = ['{}'];
|
||||||
let historyIndex = -1;
|
let historyIndex = 0;
|
||||||
invalidated();
|
invalidated();
|
||||||
|
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
@@ -82,7 +82,7 @@ function updateTableType() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateLuckBased() {
|
function updateLuckBased() {
|
||||||
luck_based = $('#luckBased').prop('checked');
|
luckBased = $('#luckBased').prop('checked');
|
||||||
invalidated();
|
invalidated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -328,6 +328,99 @@
|
|||||||
"minecraft:copy_nbt"
|
"minecraft:copy_nbt"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "enchantment",
|
||||||
|
"type": "enum",
|
||||||
|
"source": "enchantment",
|
||||||
|
"values": [
|
||||||
|
"minecraft:aqua_affinity",
|
||||||
|
"minecraft:bane_of_arthropods",
|
||||||
|
"minecraft:blast_protection",
|
||||||
|
"minecraft:channeling",
|
||||||
|
"minecraft:binding_curse",
|
||||||
|
"minecraft:vanishing_curse",
|
||||||
|
"minecraft:depth_strider",
|
||||||
|
"minecraft:efficiency",
|
||||||
|
"minecraft:feather_falling",
|
||||||
|
"minecraft:fire_aspect",
|
||||||
|
"minecraft:fire_protection",
|
||||||
|
"minecraft:flame",
|
||||||
|
"minecraft:fortune",
|
||||||
|
"minecraft:frost_walker",
|
||||||
|
"minecraft:impaling",
|
||||||
|
"minecraft:infinity",
|
||||||
|
"minecraft:knockback",
|
||||||
|
"minecraft:looting",
|
||||||
|
"minecraft:loyalty",
|
||||||
|
"minecraft:luck_of_the_sea",
|
||||||
|
"minecraft:lure",
|
||||||
|
"minecraft:mending",
|
||||||
|
"minecraft:multishot",
|
||||||
|
"minecraft:piercing",
|
||||||
|
"minecraft:power",
|
||||||
|
"minecraft:projectile_protection",
|
||||||
|
"minecraft:protection",
|
||||||
|
"minecraft:punch",
|
||||||
|
"minecraft:quick_charge",
|
||||||
|
"minecraft:respiration",
|
||||||
|
"minecraft:riptide",
|
||||||
|
"minecraft:sharpness",
|
||||||
|
"minecraft:silk_touch",
|
||||||
|
"minecraft:smite",
|
||||||
|
"minecraft:sweeping",
|
||||||
|
"minecraft:thorns",
|
||||||
|
"minecraft:unbreaking"
|
||||||
|
],
|
||||||
|
"require": [
|
||||||
|
"minecraft:apply_bonus"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "formula",
|
||||||
|
"type": "enum",
|
||||||
|
"default": "minecraft:uniform_bonus_count",
|
||||||
|
"values": [
|
||||||
|
"minecraft:uniform_bonus_count",
|
||||||
|
"minecraft:binomial_with_bonus_count",
|
||||||
|
"minecraft:ore_drops"
|
||||||
|
],
|
||||||
|
"require": [
|
||||||
|
"minecraft:apply_bonus"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "parameters.bonusMultiplier",
|
||||||
|
"type": "float",
|
||||||
|
"default": 1,
|
||||||
|
"require": [
|
||||||
|
{
|
||||||
|
"function": "minecraft:apply_bonus",
|
||||||
|
"formula": "minecraft:uniform_bonus_count"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "parameters.extra",
|
||||||
|
"type": "int",
|
||||||
|
"default": 0,
|
||||||
|
"require": [
|
||||||
|
{
|
||||||
|
"function": "minecraft:apply_bonus",
|
||||||
|
"formula": "minecraft:binomial_with_bonus_count"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "parameters.probability",
|
||||||
|
"type": "float",
|
||||||
|
"default": 0.5,
|
||||||
|
"require": [
|
||||||
|
{
|
||||||
|
"function": "minecraft:apply_bonus",
|
||||||
|
"formula": "minecraft:binomial_with_bonus_count"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "conditions",
|
"id": "conditions",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function generateTable() {
|
|||||||
$('#structure').append($table);
|
$('#structure').append($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#luck-based').attr('checked', luck_based);
|
$('#luck-based').attr('checked', luckBased);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,24 +234,16 @@ function generateObject(data, struct) {
|
|||||||
let $el = $('<div/>').addClass('card bg-' + struct.color + ' mt-3');
|
let $el = $('<div/>').addClass('card bg-' + struct.color + ' mt-3');
|
||||||
let $header = $('<div class="card-header pb-1"></div>').appendTo($el);
|
let $header = $('<div class="card-header pb-1"></div>').appendTo($el);
|
||||||
let $body = $('<div class="card-body"></div>').appendTo($el);
|
let $body = $('<div class="card-body"></div>').appendTo($el);
|
||||||
let filter = struct.fields.find(e => e.type === 'enum');
|
|
||||||
$header.append('<button type="button" class="btn btn-danger mb-2 float-right" onclick="removeComponent(this)" data-i18n="remove_' + struct.id + '"></button>');
|
$header.append('<button type="button" class="btn btn-danger mb-2 float-right" onclick="removeComponent(this)" data-i18n="remove_' + struct.id + '"></button>');
|
||||||
if (data._collapsed) {
|
if (data._collapsed) {
|
||||||
return $el;
|
return $el;
|
||||||
}
|
}
|
||||||
for (let field of struct.fields) {
|
for (let field of struct.fields) {
|
||||||
if ((luck_based || !field.luck_based) && (!field.require || (filter && field.require.includes(data[filter.id])))) {
|
let $field = generateField(data, field, struct);
|
||||||
let $field;
|
if ($field !== false) {
|
||||||
try {
|
|
||||||
$field = generateComponent(data[field.id], field);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
$field = generateError('Failed generating "' + field.id + '" component');
|
|
||||||
}
|
|
||||||
if (field.class) {
|
|
||||||
$field.addClass(field.class);
|
|
||||||
}
|
|
||||||
if (field.type === 'array') {
|
if (field.type === 'array') {
|
||||||
|
console.log('array!');
|
||||||
|
console.log(field.id);
|
||||||
let color = field.color;
|
let color = field.color;
|
||||||
if (color === undefined) {
|
if (color === undefined) {
|
||||||
color = components.find(e => e.id === field.values).color;
|
color = components.find(e => e.id === field.values).color;
|
||||||
@@ -262,8 +254,6 @@ function generateObject(data, struct) {
|
|||||||
if (field.button === 'field') {
|
if (field.button === 'field') {
|
||||||
$body.append('<button type="button" class="btn btn-' + color + ' mr-3 mt-3" onclick="addComponent(this, \'' + field.id + '\')" data-i18n="add_' + field.values + '"></button>');
|
$body.append('<button type="button" class="btn btn-' + color + ' mr-3 mt-3" onclick="addComponent(this, \'' + field.id + '\')" data-i18n="add_' + field.values + '"></button>');
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$field.attr('data-field', field.id);
|
|
||||||
}
|
}
|
||||||
$body.append($field);
|
$body.append($field);
|
||||||
} else {
|
} else {
|
||||||
@@ -274,6 +264,53 @@ function generateObject(data, struct) {
|
|||||||
return $el;
|
return $el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateField(data, field, parent) {
|
||||||
|
if (!luckBased && field.luck_based) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (field.require) {
|
||||||
|
let passing = false;
|
||||||
|
let filter = parent.fields.find(e => e.type === 'enum');
|
||||||
|
for (let requirement of field.require) {
|
||||||
|
if (typeof requirement === 'string') {
|
||||||
|
if (requirement === data[filter.id]) {
|
||||||
|
passing = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let match = true;
|
||||||
|
for (let id in requirement) {
|
||||||
|
if (requirement.hasOwnProperty(id)) {
|
||||||
|
if (requirement[id] !== data[parent.fields.find(e => e.id === id).id]) {
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (match) {
|
||||||
|
passing = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!passing) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let $field;
|
||||||
|
try {
|
||||||
|
$field = generateComponent(data[field.id], field);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
$field = generateError('Failed generating "' + field.id + '" component');
|
||||||
|
}
|
||||||
|
if (field.class) {
|
||||||
|
$field.addClass(field.class);
|
||||||
|
}
|
||||||
|
if (field.type !== 'array') {
|
||||||
|
$field.attr('data-field', field.id);
|
||||||
|
}
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
|
||||||
function preventNewline(e) {
|
function preventNewline(e) {
|
||||||
if (e.which === 13) {
|
if (e.which === 13) {
|
||||||
$(e.target).trigger('change');
|
$(e.target).trigger('change');
|
||||||
|
|||||||
Reference in New Issue
Block a user