-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
585 lines (539 loc) · 18.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Primary Meta Tags -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Eclipse Phase 2ed Helpers</title>
<meta name="title" content="Eclipse Phase 2ed Helpers">
<meta name="description" content="Online character editor, database of game items/morphs, etc.">
<base href="/eclipsehelper/">
<!-- Libs -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/3.4.5/fuse.min.js" integrity="sha256-Yrh3VGzE4d9b4KANknPJAhfcKt9SgHTL0v/FrJFoPzw=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js" integrity="sha256-ufGElb3TnOtzl5E4c/qQnZFGP+FYEZj5kbSEdJNrw0A=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-router/3.1.2/vue-router.js" integrity="sha256-J8FoD0Yt1A0YS9yENPIEWQBbjAi+w9eE2wH/KqGTb2g=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.7.7/semantic.js" integrity="sha256-vma2DJ+AbxsPuvzFC6PezrSzM2kMTxRA4rhGapnkM6A=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lz-string/1.4.4/lz-string.min.js" integrity="sha256-nRoO8HoupfqozUr7YKBRgHXmdx40Hl/04OSBzv7e7L8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js" integrity="sha256-VeNaFBVDhoX3H+gJ37DpT/nTuZTdjYro9yBruHjVmoQ=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.10.0/Sortable.min.js" integrity="sha256-h5esCRvE+shjlH7Dtl7ly6ByDKH5bI9PFvM8OeThBTM=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/15.0.0/vuedraggable.min.js" integrity="sha256-kZmY4LUwE53ceTqZXPto8gMELhExZWBrmzOCZgzyY0Y=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.7.7/semantic.min.css" integrity="sha256-R5nBNKPoJrsn3nPBR6SnXHR0612Bd8Siru2igAua8JU=" crossorigin="anonymous" />
<script src="js/character.js"></script>
<script src="js/gear_templates.js"></script>
<script src="js/sheet_templates.js"></script>
<script src="js/components.js"></script>
<script src="js/tablesort.js"></script>
<script src="js/routing.js"></script>
<style>
body {
margin: 0.5rem;
background-color: #000;
}
.ui.segment.tab {
margin: 0px;
}
.ui.inverted.menu .active.item {
color: #10A3A3 !important;
}
.ui.inverted.menu .active.item:hover {
color: #40D3D3 !important;
}
.ui.message {
color: white;
background-color: #99999910;
}
.ui.vertical.tabular.menu .active.item {
background-color: #3D3E3F;
}
.draggable {
cursor: pointer;
margin: 3px !important;
}
.draggable:hover {
background-color: #777777 !important;
}
/* Link underliney */
a {
position: relative;
color: #10A3A3 !important;
text-decoration: none;
}
a:hover {
color: #40D3D3 !important;
}
a:before {
content: "";
position: absolute;
width: 100%;
height: 1px;
bottom: 0;
left: 0;
background-color: #40D3D3;
visibility: hidden;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
a:hover:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.ui.dropdown {
color: #10A3A3 !important;
}
.ui.labeled.icon.button, .ui.labeled.icon.buttons .button {
padding-left:2.5em !important;
padding-right:1em !important;
}
/* Hide sub-menus until parent menu item is active. */
.item .menu {
display: none;
}
.item.active .menu {
display: inherit;
}
#datadropdown.fakeactive {
border-bottom-color: #fff;
font-weight: 700;
color: #10A3A3 !important;
margin-bottom: -2px; !important;
}
/* Mostly for the roller */
.rainbow-text {
background-image: repeating-linear-gradient(45deg, violet, indigo, blue, green, yellow, orange, red, violet);
background-size: 800% 800%;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: rainbow 8s ease infinite;
font-weight: bold;
}
@keyframes rainbow {
0%{background-position:0% 50%}
50%{background-position:100% 25%}
100%{background-position:0% 50%}
}
/* Morph stuff */
.morph-pic {
text-align: center;
}
.morph-pic img {
width: auto;
height: auto;
max-width: 100%;
max-height: 24rem;
}
.ui.horizontal.segments.inverted {
border: 1px solid rgba(255, 255, 255, 0.15);
}
/* Charsheet stuff */
.centerflow {
width: 100%;
text-align: center;
}
.prop:empty {
display: inline-block;
background: dimgray;
width:4em;
height:1em;
}
tr td:first-child.selectable {
padding-left:1rem !important;
}
.transparent {
background-color: #00000000 !important;
}
.addbutton {
display: none !important;
}
td:hover .addbutton {
display: inline-block !important;
}
/* For sortable tables to omit some headers */
.ui.inverted.sortable.table>thead>tr>th.no-sort {
cursor: inherit !important;
}
.ui.inverted.sortable.table>thead>tr>th.no-sort:hover {
background: rgba(0,0,0,0.15) !important;
color: inherit !important;
}
/* I want MORE compact */
.ui.compact.table>tbody>tr>td, .ui.compact.table>tr>td {
padding: .2em .3em;
}
</style>
</head>
<body>
<div id="app">
<div id="global-tabs" class="ui large top secondary inverted stackable pointing menu">
<router-link class="item" to="/primer">EP2 Primer</router-link>
<router-link class="item" to="/quickrules">Quick Rules</router-link>
<router-link class="item" to="/chargen">Chargen Guide</router-link>
<router-link class="item" to="/sheet">Char. Sheet</router-link>
<router-link class="item" to="/tracker">Char. Tracker</router-link>
<div id="datadropdown" class="ui inverted dropdown item">
Data Pages
<i class="dropdown icon"></i>
<div class="ui menu inverted">
<router-link class="item" to="/morphs">Data - Morphs</router-link>
<router-link class="item" to="/gear">Data - Gear</router-link>
<router-link class="item" to="/traits">Data - Traits</router-link>
<router-link class="item" to="/sleights">Data - Sleights</router-link>
</div>
</div>
</div>
<keep-alive>
<router-view></router-view>
</keep-alive>
<div style="color:white;text-align:center;">
Data and text used on this website is from <a href="https://eclipsephase.com">Eclipse Phase books by Posthuman Studios</a>, licensed <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a>.<br>
The website itself is the same license where possible (libraries are under their own licenses). <a href="https://github.com/Arokha/EP2-Data">Data GitHub</a> - <a href="https://github.com/Arokha/ep2-helper">Website GitHub</a>
</div>
</div>
</body>
<script>
//Initialize lots of ajax loading of json data
var unsorted_gear = [];
var traits = [];
var morphs = [];
var backgrounds = [];
var careers = [];
var interests = [];
var factions = [];
var aptemps = [];
var reputations = [];
var gearpacks = [];
var skills = [];
var aptitudes = [];
var morph_types = [];
var sleights = [];
var gear_types = [];
//Create the vue instance
var mainVue = new Vue({
el: "#app",
router: vr_router
});
$.getJSON('data/backgrounds.json').then( json => backgrounds.push(...json) );
$.getJSON('data/careers.json').then( json => careers.push(...json) );
$.getJSON('data/interests.json').then( json => interests.push(...json) );
$.getJSON('data/factions.json').then( json => factions.push(...json) );
$.getJSON('data/aptitude_templates.json').then( json => aptemps.push(...json) );
$.getJSON('data/reputations.json').then( json => reputations.push(...json) );
$.getJSON('data/skills.json').then( json => skills.push(...json) );
$.getJSON('data/morphs.json').then( json => morphs.push(...json) );
$.getJSON('data/traits.json').then( json => traits.push(...json) );
$.getJSON('data/aptitudes.json').then( json => aptitudes.push(...json) );
$.getJSON('data/morph_types.json').then( json => morph_types.push(...json) );
$.getJSON('data/sleights.json').then( json => sleights.push(...json) );
$.getJSON('data/gear_categories.json').then( json => gear_types.push(...json) );
var gear_jsons = [
"gear_bots.json",
"gear_comms.json",
"gear_creatures.json",
"gear_drugs.json",
"gear_items.json",
"gear_mission.json",
"gear_nano.json",
"gear_security.json",
"gear_software.json",
"gear_swarms.json",
"gear_vehicles.json",
"gear_ware.json",
"services.json",
"weapons_melee.json",
"weapons_ranged.json",
"weapons_ammo.json",
"gear_armor.json"
];
//Compile all the promises from gear loading into an array
let gear_promises = [];
gear_jsons.forEach( file => gear_promises.push($.getJSON('data/'+file)) );
//When done loading gear...
Promise.all(gear_promises).then( function(results_array) {
results_array.forEach( json => unsorted_gear.push(...json) );
//Depends on gear, so only do it after.
$.getJSON('data/gear_packs_custom.json').then( json => gearpacks.push(...json) );
});
//Fuse.js fuzzy search object for gear searching
var gear_fuse = new Fuse(unsorted_gear,{
keys: [
{
name: 'name',
weight: 0.7
},
{
name: 'description',
weight: 0.3
},
{
name: 'summary',
weight: 0.3
},
{
name: 'notes',
weight: 0.3
},
],
threshold: 0.35,
shouldSort: true,
includeScore: true,
includeMatches: true
});
//Helper functions
function global_despace(value){
return value.toString().replace(/[^#A-Za-z0-9]/g, "_");
}
function icon_swap(element, from, to) {
$(element).siblings("a").find("."+from).removeClass(from).addClass(to);
}
function isNumeric(value) {
//*sigh* Empty string is falsey which is '0' for isNaN and considerd a number.
if(value === ""){
return false;
}
return !isNaN(value);
}
//Gets a skill's total given a skill and a character
function skillTotal(skill,character){
if(!skill instanceof Skill){
console.error("Asked to total non-skill: ",skill);
return
}
if(!character instanceof Character){
console.error("Asked to total non-character: ",skill);
return
}
let aptitude = character[skill.aptitude];
let skillName = colon_truncate(skill.name).toLowerCase();
if(['fray','perceive'].includes(skillName)) {
aptitude *= 2; //That's just how the rules are, yo.
}
return skill.rank + skill.mod + aptitude;
}
//Consume a dice string and produce a roll as the dice string dictates
function parse_and_roll(dicestr){
let parsed = parse_dice(dicestr);
if(!parsed){
show_toast("No valid dice notation found.","Something like '3d6+2' please.","warning");
return;
}
let roll = roll_dice(0,parsed.dietype,parsed.diecount,parsed.modifier);
roll['dicestr'] = parsed.dicestr;
return roll;
}
//Consume a dice string and return an object with info about the dice string
function parse_dice(dicestr){
let reg = /(?:^|[ :\(-])(\d+)d(\d+)([+-]\d+)?/;
let parse = reg.exec(dicestr);
if(parse && parse.length >= 3) {
//parse[0] is the full text of the resulting area
return {
diecount: parseInt(parse[1]),
dietype: parseInt(parse[2]),
modifier: (typeof parse[3] == 'undefined') ? 0 : parseInt(parse[3]),
dicestr: parse[0]
};
}
}
//Roll some dice, and if it's eclipse-phase-style dice, add fancy text
function roll_dice(target, dietype = 100, diecount = 1, modifier = 0){
var result = 0;
var dice = [];
for(let i = 1; i <= diecount; i++) {
let rand = Math.random() * dietype;
if(dietype != 100) {
rand++; //So, EP treats d100s as 00-99, but most die are 1-6 etc and need +1 to the random number
}
rand = Math.floor(rand);
result += rand;
dice.push(rand);
}
var success = null;
var text = null;
if((diecount == 1) && (dietype == 100)) { //Only on %ile rolls
var success = (result <= target);
var text = success ? "Success!" : "Failure!";
//"Superiors"
if(target){
//Success
if((result >= 66) && (success)){text = "Two Superior Successes!";} else
if((result >= 33) && (success)){text = "One Superior Success!";} else
//Failure
if((result <= 33) && (!success)){text = "Two Superior Failures!";} else
if((result <= 66) && (!success)){text = "One Superior Failure!";}
}
//Criticals
if(result === 0){text = "Critical Success!";} else
if(result === 99){text = "Critical Failure!";} else
if((result % 11) === 0) {
if(success) {
text = "Critical Success!";
} else {
text = "Critical Failure!";
}
}
}
if(modifier){
result += modifier;
}
//Return our results
return {
result,
success,
text,
dice,
modifier
};
}
//Clone an object to another object using a template to determine what to copy
function export_properties(from,to,template){
//For each key in the template
Object.keys(template).forEach(function(key,index) {
//If it's an array
if(Array.isArray(template[key])) {
let newArray = [];
//For the elements in the from array
from[key].forEach(function(element){
//If it's an object
if(typeof element === 'object'){
//It has a serialize method
if("serialize" in element){
//We use their serializer
newArray.push(element.serialize());
} else {
//We use a generic method
newArray.push($.extend(true,{},element));
}
}
});
to[key] = newArray;
} else if(typeof(template[key]) === 'object' && template[key] !== null){
export_properties(from[key],to[key],template[key]);
} else {
to[key] = from[key];
}
});
}
//Clone an object to another object, using a template WITH HINTS ON WHAT TO INSTANTIATE
function import_properties(from,to,template){
//For each key in the template
Object.keys(template).forEach(function(key,index) {
//If it's an array
if(Array.isArray(template[key])) {
//The array contains a class hint
if(template[key].length){
let hint = template[key][0];
let inflatedArray = [];
from[key].forEach(function(deflated){
inflatedArray.push(hint.deserialize(deflated,hint));
});
to[key] = inflatedArray;
} else {
//Generic array copy w/o stealing reference
to[key] = from[key].slice();
}
} else if(typeof(template[key]) === 'object' && template[key] !== null){
import_properties(from[key],to[key],template[key]);
} else {
to[key] = from[key];
}
});
}
//Mostly a wrapper for a character's add_to()
function add_to_character(location,item,message){
if(character_loaded) {
character_loaded.add_to(location,item,message);
} else {
show_toast("Character must be loaded first.","Taking you there now then adding item.","warning",7000);
vr_router.push("/sheet").then( () => character_loaded.add_to(location,item,message) );
}
}
//Pop up a message in the corner of the screen
function show_toast(title, message, style = "info", displayTime = 5000, compact = false) {
$('body').toast({
title,
class: style,
message,
displayTime,
compact,
showProgress: "bottom"
});
}
//Finds by 'name' key, with case insensitivity and 'colon truncate' as we use in several places like the character sheet
function find_by_name(array,name){
return array.find( element => colon_truncate( name.toLowerCase() ) == colon_truncate( element.name.toLowerCase() ) );
}
//Truncates anything after a colon in a string
function colon_truncate(string){
let colonated = string.indexOf(":");
if(colonated > -1){
string = string.substring(0, colonated);
}
return string;
}
// https://github.com/gouch/to-title-case/blob/master/to-title-case.js
// License: http://www.opensource.org/licenses/mit-license.php
String.prototype.toTitleCase = function () {
'use strict'
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i
var alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/
var wordSeparators = /([ /:–—-])/ //Added foward slash -Aro
return this.split(wordSeparators)
.map(function (current, index, array) {
/* Check for abbreviation - Aro added this */
if ((current.match(/\./g) || []).length > 1) {
current = current.toUpperCase();
/* Check for non-abbreviated ending (plural abbreviations, etc) */
let ending = current.search(/[^.]+$/g);
if(ending > -1){
current = current.substr(0,ending) + current.substr(ending).toLowerCase();
}
return current;
}
if (
/* Check for small words */
current.search(smallWords) > -1 &&
/* Skip first and last word */
index !== 0 &&
index !== array.length - 1 &&
/* Ignore title end and subtitle start */
array[index - 3] !== ':' &&
array[index + 1] !== ':' &&
/* Ignore small words that start a hyphenated phrase */
(array[index + 1] !== '-' ||
(array[index - 1] === '-' && array[index + 1] === '-'))
) {
return current.toLowerCase();
}
/* Ignore intentional capitalization */
if (current.substr(1).search(/[A-Z]|\../) > -1) {
return current;
}
/* Ignore URLs */
if (array[index + 1] === ':' && array[index + 2] !== '') {
return current;
}
/* Capitalize the first letter */
return current.replace(alphanumericPattern, function (match) {
return match.toUpperCase();
})
})
.join('')
}
/////////////////////////////////////////////////////// End License
//Simulates a download link that is a text file containing the contents of a variable
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
//Hover on menu dropdowns (for the top bar)
$(function() {
$(".ui.dropdown").dropdown({on: "hover"});
});
</script>