-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
346 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode/launch.json | ||
.vscode/settings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,55 @@ | ||
const JSON_PATH = '../data/kData.json' | ||
const computerChoice = document.getElementById('computer-choice') | ||
const userChoice = document.getElementById('user-choice') | ||
const outcome = document.getElementById('outcome') | ||
const kView = document.getElementById('k-display') | ||
const validChoices = document.querySelectorAll('.option') | ||
const kSpace = document.getElementById('k-container') | ||
var buttonContainer = document.getElementById('buttons') | ||
const choiceHead = document.getElementById('choice-header') | ||
const buttonContainer = document.getElementById('buttons-home') | ||
const lifeChoices = document.getElementById('life-choices') | ||
|
||
|
||
let k = 0 | ||
kView.innerHTML = k | ||
let weapons_info = [] | ||
const k = new oddInteger() | ||
kView.innerHTML = k | ||
choiceHead.innerHTML = 'Choose Wisely' | ||
|
||
|
||
function populateWeapons() { | ||
|
||
function populate() { | ||
weapons_info = [] | ||
let n = 2*k + 1 | ||
fetch(JSON_PATH) | ||
.then(res => res.json()) | ||
.then(data => { | ||
let mixer = Array.from({ length: data['weapons'].length }, (value, index) => index) | ||
var mixed = mixer.sort(function(){ return 0.5 - Math.random() }) | ||
var picks = mixed.slice(0,n) | ||
let i = 0 | ||
let mixed = mixer.sort(function(){ return 0.5 - Math.random() }) | ||
let picks = mixed.slice(0,k.getN()) | ||
|
||
picks.forEach(element => { | ||
weapons_info.push(data['weapons'][element]) | ||
var button = document.createElement("button") | ||
button.setAttribute("value", i) | ||
i++ | ||
let button = document.createElement("button") | ||
button.setAttribute("value", (weapons_info.length-1)) | ||
button.setAttribute("class", 'option') | ||
button.setAttribute("name", data['weapons'][element]['name']) | ||
button.style.backgroundImage = 'url(' + data['weapons'][element]['image'] + ')' | ||
button.innerHTML=data['weapons'][element]['name'] | ||
buttons.appendChild(button); | ||
button.setAttribute("title", data['weapons'][element]['alt']) | ||
console.log(data['weapons'][element]['alt']) | ||
buttonContainer.appendChild(button) | ||
|
||
button.addEventListener("click", function(event) { | ||
var btn = event.target; | ||
var page = btn.getAttribute("pageto"); | ||
options.appendChild(btn); | ||
alert(page); | ||
}) | ||
let choice = event.target | ||
// userChoice.innerHTML = choice.name | ||
// play(choice.value) | ||
}) | ||
}) | ||
|
||
|
||
}) | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// var button = document.createElement('button') | ||
// button.setAttribute('value', i) | ||
// button.setAttribute('name', weapon['name']) | ||
// button.setAttribute('class', 'option') | ||
// button.innerHTML=weapon['name'] | ||
// button.addEventListener('click', (e) => { | ||
// userChoice.innerHTML = e.target.name | ||
// }) | ||
// optionButtons.appendChild(button) | ||
// i++ | ||
// }) | ||
|
||
|
||
|
||
|
||
|
||
}) | ||
} | ||
|
||
function kPlusPlus() { | ||
k++ | ||
k.plusPlus() | ||
kView.innerHTML = k | ||
buttonContainer.textContent = '' | ||
populateWeapons() | ||
populate() | ||
} | ||
|
||
populateWeapons() | ||
function play(node) { | ||
const selector = Math.floor(Math.random() * defineNumbers[n]) | ||
let choiceString = ('selector') | ||
lifeChoices.innerHTML = choiceString | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
class oddInteger { | ||
|
||
#k; | ||
#n; | ||
|
||
constructor(k=0) { | ||
this.#k = k | ||
this.#n = 2*k + 1 | ||
} | ||
|
||
plusPlus() { | ||
this.#k++ | ||
this.#n += 2 | ||
} | ||
|
||
minusMinus() { | ||
this.#k-- | ||
this.#n -= 2 | ||
} | ||
|
||
reset() { | ||
this.#k = 0 | ||
this.#n = 1 | ||
} | ||
|
||
getK() { | ||
return this.#k | ||
} | ||
|
||
getN() { | ||
return this.#n | ||
} | ||
|
||
valueOf() { | ||
return this.getK() | ||
} | ||
|
||
toString() { | ||
return this.getK() | ||
} | ||
|
||
makeDiff(a, b) { | ||
return (((a - b) % this.#n) + this.#n) % this.#n | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// const k = { | ||
|
||
// k: 0, | ||
// n: 1, | ||
|
||
// plusPlus() { | ||
// this.k++ | ||
// this.n = 2 * this.k + 1 | ||
// }, | ||
|
||
// minusMinus() { | ||
// this.k-- | ||
// this.n = 2 * this.k + 1 | ||
// }, | ||
|
||
// setValue(k) { | ||
// this.k = k | ||
// this.n = 2 * k + 1 | ||
// }, | ||
|
||
// getK() { | ||
// return this.k | ||
// }, | ||
|
||
// getN() { | ||
// return this.n | ||
// }, | ||
|
||
// valueOf() { | ||
// return this.getK() | ||
// }, | ||
|
||
// toString() { | ||
// return this.getK() | ||
// } | ||
|
||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,4 +185,8 @@ footer { | |
padding: 16px; | ||
background: #09183380; | ||
color: #bdbdbd; | ||
} | ||
|
||
.hidden { | ||
visibility: hidden; | ||
} |
Oops, something went wrong.