From 46c97fc5b4099fedb2f8d8abe95075f199af7fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=C3=BCttner?= Date: Tue, 4 Apr 2017 14:25:07 +0200 Subject: [PATCH 1/4] fixes #277 --- src/mods/tier.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/mods/tier.js b/src/mods/tier.js index d034060..1852139 100644 --- a/src/mods/tier.js +++ b/src/mods/tier.js @@ -187,6 +187,21 @@ idrinth.tier = { var ln = { type: 'td' }; + if ( + idrinth.tier.list[listKey].hasOwnProperty ( 'loot' ) && + idrinth.tier.list[listKey].loot.hasOwnProperty ( difficulty ) && + idrinth.tier.list[listKey].loot[difficulty].hasOwnProperty ( ic ) && + idrinth.tier.list[listKey].loot[difficulty][ic] + ) { + ln.attributes = ln.attributes?ln.attributes:new Array(); + var title = ""; + for(var key in idrinth.tier.list[listKey].loot[difficulty][ic]) { + if(idrinth.tier.list[listKey].loot[difficulty][ic].hasOwnProperty (key)) { + title += key.toUpperCase()+": "+idrinth.tier.list[listKey].loot[difficulty][ic][key]+"\n"; + } + } + ln.attributes.push({name:'title',value:title}); + } if ( idrinth.tier.list[listKey].hasOwnProperty ( difficulty ) && idrinth.tier.list[listKey][difficulty].hasOwnProperty ( ic ) From 43ded8276df0f76a2386d1141aa0f3a68a2a9978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=C3=BCttner?= Date: Tue, 4 Apr 2017 14:40:09 +0200 Subject: [PATCH 2/4] making it nicer to read --- src/mods/tier.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mods/tier.js b/src/mods/tier.js index 1852139..e5dc02d 100644 --- a/src/mods/tier.js +++ b/src/mods/tier.js @@ -197,7 +197,7 @@ idrinth.tier = { var title = ""; for(var key in idrinth.tier.list[listKey].loot[difficulty][ic]) { if(idrinth.tier.list[listKey].loot[difficulty][ic].hasOwnProperty (key)) { - title += key.toUpperCase()+": "+idrinth.tier.list[listKey].loot[difficulty][ic][key]+"\n"; + title += idrinth.tier.list[listKey].loot[difficulty][ic][key]+" "+idrinth.text.get ('tier.loot.'+key)+"\n"; } } ln.attributes.push({name:'title',value:title}); From b7fa3ea0b0eaae821dc7faa6eab6634c0426b878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=C3=BCttner?= Date: Tue, 4 Apr 2017 16:18:21 +0200 Subject: [PATCH 3/4] fixing issue found by automatic CR --- src/mods/tier.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mods/tier.js b/src/mods/tier.js index e5dc02d..8225553 100644 --- a/src/mods/tier.js +++ b/src/mods/tier.js @@ -193,7 +193,7 @@ idrinth.tier = { idrinth.tier.list[listKey].loot[difficulty].hasOwnProperty ( ic ) && idrinth.tier.list[listKey].loot[difficulty][ic] ) { - ln.attributes = ln.attributes?ln.attributes:new Array(); + ln.attributes = ln.attributes?ln.attributes:[]; var title = ""; for(var key in idrinth.tier.list[listKey].loot[difficulty][ic]) { if(idrinth.tier.list[listKey].loot[difficulty][ic].hasOwnProperty (key)) { From 40a0fac862727fb8281bd1474ec3464eadb6ea43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=C3=BCttner?= Date: Tue, 4 Apr 2017 16:33:52 +0200 Subject: [PATCH 4/4] fixes #297 --- src/mods/core.js | 69 +++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/src/mods/core.js b/src/mods/core.js index bf4c352..00a64d9 100644 --- a/src/mods/core.js +++ b/src/mods/core.js @@ -220,43 +220,52 @@ idrinth.core = { var min = 10; /** * - * @param {Number} durationLeft - * @param {Number} minDuration + * @param {Number} min + * @param {Number} property * @returns {Number} */ - var getVal = function ( durationLeft, minDuration ) { - if ( durationLeft < 0.1 ) { - return 0.1; + var check = function(min, property, date) { + /** + * + * @param {Number} durationLeft + * @param {string} minDuration + * @returns {Number} + */ + var getVal = function ( durationLeft, minDuration ) { + if ( durationLeft < 0.1 ) { + return 0.1; + } + return durationLeft < minDuration ? durationLeft : minDuration; + }; + /** + * + * @param {string} property + * @returns {undefined} + */ + var handle = function ( property, min ) { + idrinth.core.timeouts.list[property].func (); + idrinth.core.timeouts.list[property].repeats = Math.max ( -1, idrinth.core.timeouts.list[property].repeats - 1 ); + if ( idrinth.core.timeouts.list[property].repeats ) { + min = getVal ( idrinth.core.timeouts.list[property].duration, min ); + idrinth.core.timeouts.list[property].next = date + idrinth.core.timeouts.list[property].duration / 1000; + } else { + delete idrinth.core.timeouts.list[property]; + } + return min; + }; + if ( date < idrinth.core.timeouts.list[property].next ) { + return getVal ( idrinth.core.timeouts.list[property].next - date, min ); } - return durationLeft < minDuration ? durationLeft : minDuration; - }; - /** - * - * @param {string} property - * @returns {undefined} - */ - var handle = function ( property, min ) { - idrinth.core.timeouts.list[property].func (); - idrinth.core.timeouts.list[property].repeats = Math.max ( -1, idrinth.core.timeouts.list[property].repeats - 1 ); - if ( idrinth.core.timeouts.list[property].repeats ) { - min = getVal ( idrinth.core.timeouts.list[property].duration, min ); - idrinth.core.timeouts.list[property].next = date + idrinth.core.timeouts.list[property].duration / 1000; - } else { - delete idrinth.core.timeouts.list[property]; + try { + return handle ( property, min ); + } catch ( e ) { + idrinth.core.log ( e.message ? e.message : e.getMessage () ); + return min; } - return min; }; for (var property in idrinth.core.timeouts.list) { if ( idrinth.core.timeouts.list.hasOwnProperty ( property ) ) { - if ( date >= idrinth.core.timeouts.list[property].next ) { - try { - min = handle ( property, min ); - } catch ( e ) { - idrinth.core.log ( e.message ? e.message : e.getMessage () ); - } - } else { - min = getVal ( idrinth.core.timeouts.list[property].next - date, min ); - } + min = check(min, property, date); } } if ( Object.keys ( idrinth.core.timeouts.list ).length ) {