Kittens Game Data output

enter something useful

当前为 2015-06-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Kittens Game Data output
// @namespace    https://greasyfork.org/en/scripts/10234-kittens-game-data-output
// @version      0.2.3
// @description  enter something useful
// @author       Yuriy
// @match        http://bloodrizer.ru/games/kittens/
// @grant        none
// ==/UserScript==

function initiate_script() {
    var data_out = document.createElement('div');
    data_out.id = 'data_container';
    data_out.style.width = '100%';
    data_out.style.bottom = '0px';
    data_out.style.verticalAlign = 'bottom';
    data_out.innerHTML = '<div style="width: 340px;"> <table id="food_table_season" table-layout: fixed;></table></div></div><div> <p id="food_balance_info"></p> </div>';
    right_col = document.getElementById('rightColumn')
    right_col.style.width = '360px';
    before_child = document.getElementById('clearLog')
    right_col.insertBefore(data_out, before_child);
}

if (!document.getElementById('data_container')) {
  initiate_script();
}

function calculate_food_income_data(weather_ratio_val, seconds) {
    var total = 0;
    var subtotal = 0;
    
    total += gamePage.getEffect("catnip" + "PerTickBase")*5
    total *= 1+weather_ratio_val;
    
    var resMapProduction = gamePage.village.getResProduction();
    subtotal = resMapProduction['catnip']*5 || 0;
    subtotal *= (1 + gamePage.workshop.getEffect('catnip' + "Ratio"))
    
    total += subtotal;
    
    total *= (1 + gamePage.bld.getEffect('catnip' + "Ratio"))
    
    total *= (1 + gamePage.space.getEffect('catnip' + "Ratio"))
    
    total *= (1 + gamePage.religion.getEffect('catnip' + "Ratio"))
    
    var paragonRatio = gamePage.resPool.get("paragon").value * 0.01;
    paragonRatio = gamePage.bld.getHyperbolicEffect(paragonRatio, 2);
    
    total *= 1+paragonRatio
    
    if (gamePage.religion.getRU("solarRevolution").researched){
        total *= 1+(gamePage.religion.getProductionBonus() / 100)
	}
    
    total *= seconds;
    
    return total;
}

function calculate_food_data(weather_ratio_val, seconds) {
    var total = calculate_food_income_data(weather_ratio_val, seconds);
    
    var resMapConsumption = gamePage.village.getResConsumption();
    var resConsumption = resMapConsumption['catnip'] || 0;
    resConsumption = resConsumption * (1 + gamePage.bld.getEffect('catnip' + "DemandRatio", true));
    resConsumption *= 5;
    resConsumption *= seconds;
    
    total += resConsumption;
    
    return total
}

function val_to_printable(total) {
    var total_value = '';
    
    if(Math.abs(total)>1000){
        total = total / 1000;
        total = total.toFixed(1);
        total_value += total;
        total_value += ' k';
    }else{
        total = total.toFixed(2);
        total_value += total;
    }
    
    return total_value;
    
}

function generate_food_table(seconds, label) {
    var contents = '';
    //Define the table colomn widths
    contents += '<col width="100">';
    contents += '<col width="60">';
    contents += '<col width="60">';
    contents += '<col width="60">';
    contents += '<col width="60">';
    //The top of the table, describing what it is showing. Leave once cell blank at the start
    contents += '<tr>';
    contents += '<td style="text-align:center">'
    contents += ' '
    contents += '</td>';
    contents += '<td style="text-align:center" colspan="4">'
    contents += label
    contents += '</td>';
    contents += '</tr>';
    //Second level of the top of the table, describing what it is showing. Leave once cell blank at the start
    contents += '<tr>';
    contents += '<td style="text-align:center">'
    contents += ' '
    contents += '</td>';
    contents += '<td style="text-align:center">'
    contents += 'Winter'
    contents += '</td> <td style="text-align:center">'
    contents += 'Spring'
    contents += '</td> <td style="text-align:center">'
    contents += 'Summer'
    contents += '</td> <td style="text-align:center">'
    contents += 'Fall'
    contents += '</td>';
    contents += '</tr>';
    //Data for a good season
    contents += '<tr>';
    contents += '<td style="text-align:center">'
    contents += 'Good season'
    contents += '</td>';
    contents += '<td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(-0.60, seconds))
    contents += '</td> <td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(0.65, seconds))
    contents += '</td> <td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(0.15, seconds))
    contents += '</td> <td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(0.15, seconds))
    contents += '</td>';
    contents += '</tr>';
    //Data for an average season
    contents += '<tr>';
    contents += '<td style="text-align:center">'
    contents += 'Normal season'
    contents += '</td>';
    contents += '<td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(-0.75, seconds))
    contents += '</td> <td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(0.50, seconds))
    contents += '</td> <td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(0.0, seconds))
    contents += '</td> <td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(0.0, seconds))
    contents += '</td>';
    contents += '</tr>';
    //Data for a bad season
    contents += '<tr>';
    contents += '<td style="text-align:center">'
    contents += 'Bad season'
    contents += '</td>';
    contents += '<td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(-0.90, seconds))
    contents += '</td> <td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(0.35, seconds))
    contents += '</td> <td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(-0.15, seconds))
    contents += '</td> <td style="text-align:center">'
    contents += val_to_printable(calculate_food_data(-0.15, seconds))
    contents += '</td>';
    contents += '</tr>';
    return contents
}

function generate_food_balance_data() {
    var contents = '';
    contents += "Yearly food produced (avg): ";
    contents += val_to_printable(calculate_food_income_data(-0.75, 200)+calculate_food_income_data(0.50, 200)+calculate_food_income_data(0.0, 200)+calculate_food_income_data(0.0, 200))
    contents += "<br>";
    var resMapConsumption = gamePage.village.getResConsumption();
    var resConsumption = resMapConsumption['catnip'] || 0;
    resConsumption = resConsumption * (1 + gamePage.bld.getEffect('catnip' + "DemandRatio", true));
    resConsumption *= 5;
    resConsumption *= 800;
    contents += "Yearly food consumed (avg): ";
    contents += val_to_printable(-resConsumption);
    contents += "<br>";
    contents += "Surplus (or deficit): ";
    contents += val_to_printable(calculate_food_income_data(-0.75, 200)+calculate_food_income_data(0.50, 200)+calculate_food_income_data(0.0, 200)+calculate_food_income_data(0.0, 200)+resConsumption);
    contents += "<br>";
    contents += "Surplus/consumed: ";
    if((calculate_food_income_data(-0.75, 200)+calculate_food_income_data(0.50, 200)+calculate_food_income_data(0.0, 200)+calculate_food_income_data(0.0, 200)+resConsumption)/(-resConsumption)*100 >= 15) {
        contents += '<span style="color: green;">'
    }else if((calculate_food_income_data(-0.75, 200)+calculate_food_income_data(0.50, 200)+calculate_food_income_data(0.0, 200)+calculate_food_income_data(0.0, 200)+resConsumption)/(-resConsumption)*100 <= 5 && (calculate_food_income_data(-0.75, 200)+calculate_food_income_data(0.50, 200)+calculate_food_income_data(0.0, 200)+calculate_food_income_data(0.0, 200)+resConsumption)/(-resConsumption)*100 >= 0) {
        contents += '<span style="color: yellow;">'
    }else if((calculate_food_income_data(-0.75, 200)+calculate_food_income_data(0.50, 200)+calculate_food_income_data(0.0, 200)+calculate_food_income_data(0.0, 200)+resConsumption)/(-resConsumption)*100 <= 5 && (calculate_food_income_data(-0.75, 200)+calculate_food_income_data(0.50, 200)+calculate_food_income_data(0.0, 200)+calculate_food_income_data(0.0, 200)+resConsumption)/(-resConsumption)*100 < 0) {
        contents += '<span style="color: red;">'
    }else{
        contents += '<span">'
    }
    contents += val_to_printable((calculate_food_income_data(-0.75, 200)+calculate_food_income_data(0.50, 200)+calculate_food_income_data(0.0, 200)+calculate_food_income_data(0.0, 200)+resConsumption)/(-resConsumption)*100);
    contents += "%";
    contents += '</span>'
    contents += "<br>";
    return contents;
}

function output_data() {
    document.getElementById('food_table_season').innerHTML = generate_food_table(200, 'Food during seasons (/season)');
    document.getElementById('food_balance_info').innerHTML = generate_food_balance_data();
}

setInterval(output_data, 200);