Gp/Xp spoil share calculator page
This commit is contained in:
parent
5a64f3bb2e
commit
7d9b8ac6e0
@ -2,6 +2,7 @@
|
||||
('/npc/spells', 'spells', 'Spells', false),
|
||||
('/worldmap', 'worldmap', 'Maps', false),
|
||||
('/player_tokens', 'tokens', 'Tokens', false),
|
||||
('/shares_calculator', 'shares_calc', 'Spoil Shares', false),
|
||||
('https://reddit.com/r/PalismaACKS/wiki', 'redditwiki', 'Wiki', true),
|
||||
] %}
|
||||
{% set judge_bar = [
|
||||
|
145
acks/templates/shares_calc.html
Normal file
145
acks/templates/shares_calc.html
Normal file
@ -0,0 +1,145 @@
|
||||
{% extends "base.html" %}
|
||||
{% set active_page = "shares_calc" %}
|
||||
|
||||
{% block title %}Spoil Shares Calculator{% endblock %}
|
||||
{% block content %}
|
||||
<div class="uk-flex uk-flex-center uk-margin-bottom uk-margin-top">
|
||||
<h1 class="uk-text-center"><strong>Adventurer Conqueror King</strong>Spoil Shares Calculator</h1>
|
||||
</div>
|
||||
|
||||
<div class="uk-grid-divider" uk-grid>
|
||||
<div class="uk-width-1-3">
|
||||
<h3>Session Info</h3>
|
||||
<form class="uk-form-horizontal uk-margin-large">
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for="player_count">Number of players</label>
|
||||
<div class="uk-form-controls">
|
||||
<select name="player_count" id="player_count" class="uk-select">
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7">7</option>
|
||||
<option value="8">8</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for="hench_count">Number of henchmen</label>
|
||||
<div class="uk-form-controls">
|
||||
<input class="uk-input" id="hench_count" name="hench_count" type="number" value="0">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for="gp_recovered">GP value recovered</label>
|
||||
<div class="uk-form-controls">
|
||||
<input class="uk-input" id="gp_recovered" name="gp_recovered" type="number" value="0">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for="xp_earned">XP earned from monsters</label>
|
||||
<div class="uk-form-controls">
|
||||
<input class="uk-input" id="xp_earned" name="xp_earned" type="number" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" id="share_calc_button" class="uk-button uk-button-primary">Calculate</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="uk-width-1-3">
|
||||
<h4>Henchmen GP Shares</h4>
|
||||
<table id="hench_shares" class="uk-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bonus XP Rate</th>
|
||||
<th>Share Per-Henchman</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="uk-width-1-3">
|
||||
<h4>Player XP Shares</h4>
|
||||
<table id="player_shares" class="uk-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bonus XP Rate</th>
|
||||
<th>Share Per-Player</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
||||
<h4>Player GP Share</h4>
|
||||
<span id="pc_gp_share"></span>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<style>
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script type="text/javascript">
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
var calc = document.querySelector('button#share_calc_button');
|
||||
calc.addEventListener("click", calculateShares);
|
||||
});
|
||||
|
||||
function calculateShares() {
|
||||
var player_shares = document.querySelector('table#player_shares > tbody');
|
||||
var hench_shares = document.querySelector('table#hench_shares > tbody');
|
||||
|
||||
player_shares.innerHTML = '';
|
||||
hench_shares.innerHTML = '';
|
||||
|
||||
var player_count = parseInt(document.querySelector('select#player_count').value);
|
||||
var hench_count = parseInt(document.querySelector('input#hench_count').value);
|
||||
|
||||
var gp = parseInt(document.querySelector('input#gp_recovered').value);
|
||||
var xp = parseInt(document.querySelector('input#xp_earned').value);
|
||||
|
||||
let total_xp = gp + xp;
|
||||
let pc_base_xp_share = total_xp / (player_count + hench_count / 2.0);
|
||||
|
||||
let response = '';
|
||||
for(let i = 0; i < 5; i ++) {
|
||||
// Build player rows
|
||||
const row = document.createElement("tr");
|
||||
const c1 = document.createElement("td");
|
||||
const c2 = document.createElement("td");
|
||||
|
||||
c1.appendChild(document.createTextNode(`@ ${5 * i}%`));
|
||||
c2.appendChild(document.createTextNode(`${Math.floor(pc_base_xp_share * (1 + 0.05 * i))} xp`));
|
||||
|
||||
row.appendChild(c1);
|
||||
row.appendChild(c2);
|
||||
|
||||
player_shares.appendChild(row);
|
||||
|
||||
// Build hench rows
|
||||
const hrow = document.createElement("tr");
|
||||
const hc1 = document.createElement("td");
|
||||
const hc2 = document.createElement("td");
|
||||
|
||||
hc1.appendChild(document.createTextNode(`@ ${5 * i}%`));
|
||||
hc2.appendChild(document.createTextNode(`${Math.floor(pc_base_xp_share * (1 + 0.05 * i) / 2.0)} xp`));
|
||||
|
||||
hrow.appendChild(hc1);
|
||||
hrow.appendChild(hc2);
|
||||
|
||||
hench_shares.appendChild(hrow);
|
||||
}
|
||||
|
||||
var pc_gp_share = document.querySelector('span#pc_gp_share');
|
||||
let gpshare = Math.floor(gp / (player_count + hench_count / 6.0))
|
||||
pc_gp_share.appendChild(document.createTextNode(`${gpshare} gold per player.`));
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
@ -95,3 +95,6 @@ def generate_wandering_monster():
|
||||
monster = wandering_monster.generate_wilderness_monster(data['check_mod'], data['terrain_type'], data['reaction_mod'], data['surprise_mod'])
|
||||
return monster
|
||||
|
||||
@default_views.route('/shares_calculator')
|
||||
def shares_calculator():
|
||||
return render_template('shares_calc.html')
|
||||
|
Loading…
x
Reference in New Issue
Block a user