User:Oreocooke/murder.js
// warning - this code isn't guaranteed to work. it's probably a bit of a mess as well.
// initialize variables
let team; let win; let time; let elite; let coins; let others;
// initialize maps/arrays
const ynm = new Map(); ynm.set({'y': 1, 'yes': 1, 'n': 0, 'no': 0, '?': Math.floor(2*Math.random())});
const tmm = new Map(); tmm.set({'normal' : 0, 'killer' : 1, 'gunner' : 2, '?' : Math.floor(3*Math.random()), 'guilty' : Math.floor(2*Math.random()+1)});
const xca = [5,700,320];
// functions
/* (fun fact: all this code was originally written in python,
and this is probably the only part i didn't translate to js entirely by myself
due to not being sure how to translate a certain feature (at first anyway)) */
/* (however i did reformat to my liking and rewrite the sorry jobs that were done for them,
and since i rewrote them i'd say that's close enough) */
function ynq(isfor, question) {
while (true) {
let raw = prompt(question + '? [Y/N]').trim().toLowerCase();
try {windows[isfor] = ynm.get(raw)}
catch {console.log('invalid'); continue}
break}}
function gnum(isfor, question, min, max) {
while (true) {
let raw = prompt(question).trim(); let raw2 = parseInt(raw);
if (!isNaN(raw2)) {
if (raw2 => min && raw2 <= max) {
window[isfor] = num; break;
} else {console.log('invalid'); continue}
} else {
if (raw == '?') {window[isfor] = Math.floor(Math.random() * (max - min + 1)) + min; break}
else {console.log('invalid non-numerical'); continue}}}}
// interact
while (true) {let teamt = prompt("what team were you?").strip().toLowerCase();
try {team = tmm.get(teamt)}
catch {console.log('invalid team'); continue}
break}
ynq('win', 'did you win'); const shl = (team == 2 && !win);
gnum('time', 'how many seconds did you last',0,180);
ynq('elite', 'were you elite'); const cmax = (elite ? 50 : 40);
gnum('coins', 'how many coins did you get',0,cmax); const full = (coins == cmax);
gnum('others', 'how many other than yourself did your actions affect',0,team-1 ? 10 : 11);
// calculations of total
if (shl) {const total = 100}
else {
const oxp = xca[team]*(team ? others : time);
const bxp = ((team ? win : full) ? 900 : 0);
const wmp = (team ? 1 : 1.5**win); const emp = 1.5**elite;
const total = Math.floor((oxp+bxp)*wmp*emp); console.log(`assuming a certain thing about killers, total xp is: \n ${txp}`)}
// detailed summary
/* fun fact: this was at least 10 lines in it's most original form,
but i managed to get it all the way down to a single one (but am expanding to 3 here for a bit of clarity) */
console.log(team ? guilty : normal + `\n${elite ? 'elite bonus x1.5 xp \n' : ''}(${coins} coins, total xp: {total})`);
var guilty = shl ? 'defeat... 100xp' : `${team-1 ? 'saved': 'eliminated'} ${others} normals ${oxp} xp ${win ? ('\n'+(team-1 ? 'gunner' : 'killer')+'victory 900xp') : ''}`;
var normal = `survived ${floor(time/60)}m${time%60}s ${oxp}xp ${full ? '\nfull coin thing 900xp' : ''} ${win ? '\nvictory bonus x1.5 xp' : ''}`;
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.