Skip to content

Commit

Permalink
Added biome to travel
Browse files Browse the repository at this point in the history
  • Loading branch information
Syndaryl committed Jun 2, 2018
1 parent 43c529e commit e37f300
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
3 changes: 2 additions & 1 deletion data/biomes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var biomes = [
{"Description": "Arctic", "Weight": 2},
{"Description": "Desert", "Weight": 2},
{"Description": "Island/Beach", "Weight": 2},
{ "Description": "Island", "Weight": 1 },
{ "Description": "Beach", "Weight": 1 },
{"Description": "Jungle", "Weight": 2},
{"Description": "Mountain", "Weight": 2},
{"Description": "Plains", "Weight": 2},
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ <h1>Room Key</h1>
<script type="text/javascript" src="lib/treasure_service.js"></script>
<script type="text/javascript" src="data/archesList.js"></script>
<script type="text/javascript" src="data/atmospheres.js"></script>
<script type="text/javascript" src="data/biomes.js"></script>
<script type="text/javascript" src="data/concealment.js"></script>
<script type="text/javascript" src="data/currency.js"></script>
<script type="text/javascript" src="data/decorationNumber.js"></script>
Expand Down
37 changes: 24 additions & 13 deletions lib/dungeon.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function html_sanctity(element, room) {
/**
*
* @param {object} element
* @param {Array} travel_distance
* @param {object} travel_distance
*/
function html_travel_time(element, travel_distance){
var container = document.createElement('div');
Expand All @@ -431,17 +431,17 @@ function html_travel_time(element, travel_distance){
var title = document.createElement('h3');
title.innerText = 'Travel Time';
container.appendChild(title);
travel_distance.forEach(element => {
var travel = dungeon_options['travel_distance'][travel_distance];
travel_distance.forEach(travelElement => {

var travel = dungeon_options['travel_distance'][travelElement['travel']];
var time = Math.max(0, roll_dice(travel.Time));
add_labeled_text(container,
travel.title + ': ',
'This dungeon is ' + (
(time == 0) ? 'right under town! ' :
(time + ' day' + ((time > 1 ) ? 's' : '')+ ' of travel away. ')
)

+ travel.Notes)
var travelText = 'This dungeon is ' + (
(time == 0) ? 'right under town! ' :
(time + ' day' + ((time > 1) ? 's' : '') + ' of travel away, through ' + travelElement['biome'] +'. ')
)
+ travel.Notes;

add_labeled_text(container, travel.title + ': ', travelText)

});

Expand Down Expand Up @@ -811,6 +811,7 @@ function sanctity_dungeon(dungeonOBJ) {
function travel_distance_dungeon(dungeonOBJ) {
console.log("travel_distance_dungeon is " + dungeonOBJ.travel_distance)
var travelDistance = {};

if (dungeon_options['travel_distance'][dungeonOBJ.travel_distance]["random"] == 1)
{
console.log("Random distance!");
Expand All @@ -825,10 +826,20 @@ function travel_distance_dungeon(dungeonOBJ) {
}
console.log("travel distance is using this object " + JSON.stringify(dungeon_options['travel_distance'][dungeonOBJ.travel_distance]));
if (travelDistance == {}) return dungeonOBJ;

var travelBiome = select_from_weighted_table(biomes).Description;


if (dungeonOBJ.dungeon_overall.travel_distance == undefined)
dungeonOBJ.dungeon_overall.travel_distance = [];
dungeonOBJ.dungeon_overall.travel_distance.push(travelDistance);
console.log("Travel Distance processed in travel_distance_dungeon() as " + JSON.stringify( travelDistance) );
var travel_biome = {
"travel": travelDistance,
"biome": travelBiome
};
dungeonOBJ.dungeon_overall.travel_distance.push(travel_biome);
console.log("dungeonOBJ.dungeon_overall.travel_distance is using this object " + JSON.stringify(dungeonOBJ.dungeon_overall.travel_distance));

console.log("Travel Distance processed in travel_distance_dungeon() as " + JSON.stringify(travelDistance));
return dungeonOBJ;
}
function flavor_text_room(room) {
Expand Down
2 changes: 1 addition & 1 deletion lib/treasure_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function treasure_room(room, dungeonCER, element, generosity, travel_distance) {
cer *= modify_cer_for_treasure(dungeonCER / cer);
var horde_min = cer * 5
* Number(dungeon_options.generosity[generosity].scale)
* Number(dungeon_options.travel_distance[travel_distance].scale);
* Number(dungeon_options.travel_distance[travel_distance[0]['travel']].scale);
var horde_max = horde_min * (1 + roll_dice('4d6') / 11);

horde_max = clean_number(horde_max, 2);
Expand Down

0 comments on commit e37f300

Please sign in to comment.