Skip to content

Commit

Permalink
respect simulator tuto and stop sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Kivou-2000607 committed Nov 11, 2019
1 parent d79eb29 commit ae06007
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 35 deletions.
28 changes: 17 additions & 11 deletions chain/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,6 @@ def respectSimulator(request):
modModification = request.POST.get('modification')
modValue = request.POST.get('value')


# check consistency of the graph (necessary levels for the sub branches)
if modModification in ["level"]:
# modify the value in the simulation tree
Expand Down Expand Up @@ -968,8 +967,8 @@ def respectSimulator(request):
32: [[33, 9]], # oversea banking

# Supression
45: [[46, 3]], # maximum life
48: [[47, 7]], # escape
45: [[46, 3]], # maximum life
48: [[47, 7]], # escape

# Agression
44: [[43, 10]], # accuracy
Expand All @@ -990,7 +989,7 @@ def respectSimulator(request):
# Core
10: [[11, 2]], # chaining
12: [[11, 2]], # territory
}
}

if int(modId) in r and int(modValue):
for b, lvl in [(b[0], b[1]) for b in r[int(modId)]]:
Expand All @@ -1014,8 +1013,8 @@ def respectSimulator(request):
33: [[34, 2], [31, 3], [35, 8], [32, 9]], # travel capacity

# Supression
46: [[45, 3]], # defense
47: [[48, 7]], # dexterity
46: [[45, 3]], # defense
47: [[48, 7]], # dexterity

# Agression
43: [[44, 10]], # speed
Expand All @@ -1030,7 +1029,7 @@ def respectSimulator(request):

# Core
11: [[10, 2], [12, 2]], # capacity
}
}

if int(modId) in r:
for sb, lvl in [(sb[0], sb[1]) for sb in r[int(modId)]]:
Expand All @@ -1042,7 +1041,8 @@ def respectSimulator(request):
36: [37, 38, 39], # strength training
38: [39, 36, 37], # defense training
39: [38, 36, 37], # dexterity training
}
}

if int(modId) in r:
# max the close branch to 10
if int(modValue) > 10:
Expand All @@ -1058,15 +1058,15 @@ def respectSimulator(request):

# special case for core
r = {
1: [], # weapon armory
1: [], # weapon armory
2: [1], # armor armory
3: [1, 2], # tempory armory
4: [1, 2], # medical armory
5: [1, 2, 3], # booster armory
6: [1, 2, 4], # drug armory
7: [1, 2, 3, 4, 5, 6], # point storage
8: [1, 2, 3, 4, 5, 6, 7], # laboratory
}
}

if int(modId) in r:
if int(modValue):
Expand Down Expand Up @@ -1145,7 +1145,13 @@ def respectSimulator(request):
branchesCost[bname][5] = order

# upgrade key
context = {'player': player, 'chaincat': True, "faction": faction, "upgradeTree": upgradeTreeReshaped, "branchesCost": branchesCost, "totalRespect": totalRespect, 'view': {'simu': True}}
context = {'player': player,
'chaincat': True,
"faction": faction,
"upgradeTree": upgradeTreeReshaped,
"branchesCost": branchesCost,
"totalRespect": totalRespect,
'view': {'simu': True}}
if request.method == 'POST':
page = 'chain/content-reload.html' if request.POST.get('change') is None else 'chain/respect-simulator-table.html'
else:
Expand Down
68 changes: 45 additions & 23 deletions templates/chain/respect-simulator-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,34 @@
{% load app_filters %}

<script>
$(document).ready(function() {

$.tablesorter.addParser({
// set a unique id
id: 'dataVal',
// check if cell value has a numerical value
is: function(s, table, cell, $cell) {
return !isNaN($cell.attr("data-val"));
},
// format data for normalization
format: function(s, table, cell, cellIndex) {
return parseInt($(cell).attr("data-val"));
},
// set type, either numeric or text
type: 'numeric'
});

$("#chain-tree-sum").tablesorter({cssAsc: 'up', cssDesc: 'down', sortList: [[3,0]]});
$("#chain-tree").tablesorter({headers: {5: {sorter: 'dataVal'}, 6: {sorter: 'dataVal'}}, cssAsc: 'up', cssDesc: 'down', sortList: [[2,0]]});
});
// $(document).ready(function() {
//
// $.tablesorter.addParser({
// // set a unique id
// id: 'dataVal',
// // check if cell value has a numerical value
// is: function(s, table, cell, $cell) {
// return !isNaN($cell.attr("data-val"));
// },
// // format data for normalization
// format: function(s, table, cell, cellIndex) {
// return parseInt($(cell).attr("data-val"));
// },
// // set type, either numeric or text
// type: 'numeric'
// });
//
// $("#chain-tree-sum").tablesorter({cssAsc: 'up', cssDesc: 'down', sortList: [[3,0]]});
// $("#chain-tree-sum").tablesorter({sortList: [[3,0]]});
// $("#chain-tree").tablesorter({headers: {5: {sorter: 'dataVal'}, 6: {sorter: 'dataVal'}}, cssAsc: 'up', cssDesc: 'down', sortList: [[2,0]]});
// $("#chain-tree").tablesorter({headers: {5: {sorter: 'dataVal'}, 6: {sorter: 'dataVal'}}, sortList: [[2,0]]});
// });
</script>

<table class="center chain-tree-sum sticky">
<thead>
<tr>
<th colspan="6">Faction wise summary</th>
</tr>
<tr>
<th></th>
<th colspan="2">Current state</th>
Expand Down Expand Up @@ -76,6 +80,9 @@
<br>
<table id="chain-tree-sum" class="center-medium chain-tree-sum trshadow">
<thead>
<tr>
<th colspan="10">Branch wise summary</th>
</tr>
<tr>
<th></th>
<th colspan="3">Current State</th>
Expand Down Expand Up @@ -113,11 +120,13 @@
{% endfor %}
</tbody>
</table>

<hr class="sep">
<br>

<table id="chain-tree" class="center-medium chain-tree">
<thead>
<tr>
<th colspan="11">Simulator</th>
</tr>
<tr>
<th></th>
<th></th>
Expand Down Expand Up @@ -179,3 +188,16 @@
{% endfor %}
</tbody>
</table>

<hr class="sep">
<p>
To do a simulation, modify the <b>order</b> of a branch or the <b>level</b> of an upgrade in the table above by clicking on the corresponding number (available modifications are in bold).<br>
Colored numbers will show you the difference between the current state and the simulation.
<ul>
<li>If you modify the <b>order</b> of an upgrade, the whole branch order will be modified and, if needed, the order of another branch will be swap to two identical orders.</li>
<li>If you modify the <b>level</b> of an upgrade, the order of all the branches will be modified to <span class="valid">minimize the respect used</span> and, if needed, the levels of other upgrades of the branch will be <span class="valid">set to their minimal required values</span>.</li>
</ul>
</p>
<p><i class="fas fa-toilet-paper"></i>&nbsp;&nbsp;You can reset to simulation to the current state by clicking on the reset button on the top right.
</p>
<p><span class="warning">Warning:</span> the simulations are saved on the fly for the faction (not for a member). Modifications of the upgrades by two members at the same time can lead to strange behaviors!</p>
2 changes: 1 addition & 1 deletion templates/chain/respect-simulator.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% load mathfilters %}
{% load app_filters %}

<h2 class="title">Upgrades Respect Simulator<span id="faction-tree-reset" class="flush-right"><a href=""><i class="fas fa-toilet-paper"></i>&nbsp;&nbsp;Reset faction tree</a></span></h2>
<h2 class="title">Upgrades Respect Simulator<span id="faction-tree-reset" class="flush-right"><a href=""><i class="fas fa-toilet-paper"></i>&nbsp;&nbsp;Reset simulation</a></span></h2>
<div id="faction-upgrade-tree" class="module">
{% include "chain/respect-simulator-table.html" %}
</div>

0 comments on commit ae06007

Please sign in to comment.