From a8c0d5619ee6d518737628d6c585233d0bba23da Mon Sep 17 00:00:00 2001 From: louie Date: Sun, 20 Sep 2020 09:26:58 -0700 Subject: First commit --- 1.png | Bin 0 -> 9523 bytes 2.png | Bin 0 -> 11589 bytes 3.png | Bin 0 -> 14184 bytes 4.png | Bin 0 -> 15097 bytes 5.png | Bin 0 -> 17218 bytes 6.png | Bin 0 -> 19217 bytes 8-dots-dice-clipart.png | Bin 0 -> 80580 bytes debug.log | 1 + fo.js | 238 ++++++++++++++++++++++++++++++++++++++ free.html | 23 ++++ free.js | 223 ++++++++++++++++++++++++++++++++++++ game.html | 26 +++++ game.php | 41 +++++++ instructions.html | 35 ++++++ instructions.js | 127 ++++++++++++++++++++ instructions.php | 55 +++++++++ mode_select.html | 39 +++++++ mode_select.php | 33 ++++++ pong.html | 15 +++ scripts.php | 299 ++++++++++++++++++++++++++++++++++++++++++++++++ sql_00.php | 45 ++++++++ test.html | 1 + test.php | 17 +++ test2.html | 8 ++ test2.php | 6 + yahtzee.css | 277 ++++++++++++++++++++++++++++++++++++++++++++ yahtzee.html | 34 ++++++ yahtzee.php | 28 +++++ yahtzee_legacy.css | 276 ++++++++++++++++++++++++++++++++++++++++++++ 29 files changed, 1847 insertions(+) create mode 100644 1.png create mode 100644 2.png create mode 100644 3.png create mode 100644 4.png create mode 100644 5.png create mode 100644 6.png create mode 100644 8-dots-dice-clipart.png create mode 100644 debug.log create mode 100644 fo.js create mode 100644 free.html create mode 100644 free.js create mode 100644 game.html create mode 100644 game.php create mode 100644 instructions.html create mode 100644 instructions.js create mode 100644 instructions.php create mode 100644 mode_select.html create mode 100644 mode_select.php create mode 100644 pong.html create mode 100644 scripts.php create mode 100644 sql_00.php create mode 100644 test.html create mode 100644 test.php create mode 100644 test2.html create mode 100644 test2.php create mode 100644 yahtzee.css create mode 100644 yahtzee.html create mode 100644 yahtzee.php create mode 100644 yahtzee_legacy.css diff --git a/1.png b/1.png new file mode 100644 index 0000000..80b2c9e Binary files /dev/null and b/1.png differ diff --git a/2.png b/2.png new file mode 100644 index 0000000..cde64bf Binary files /dev/null and b/2.png differ diff --git a/3.png b/3.png new file mode 100644 index 0000000..da27dd3 Binary files /dev/null and b/3.png differ diff --git a/4.png b/4.png new file mode 100644 index 0000000..b1fea0b Binary files /dev/null and b/4.png differ diff --git a/5.png b/5.png new file mode 100644 index 0000000..c077edd Binary files /dev/null and b/5.png differ diff --git a/6.png b/6.png new file mode 100644 index 0000000..87039a3 Binary files /dev/null and b/6.png differ diff --git a/8-dots-dice-clipart.png b/8-dots-dice-clipart.png new file mode 100644 index 0000000..ca5fac9 Binary files /dev/null and b/8-dots-dice-clipart.png differ diff --git a/debug.log b/debug.log new file mode 100644 index 0000000..e91ca22 --- /dev/null +++ b/debug.log @@ -0,0 +1 @@ +[0712/152143.741:ERROR:crash_report_database_win.cc(428)] unexpected header diff --git a/fo.js b/fo.js new file mode 100644 index 0000000..d6776ef --- /dev/null +++ b/fo.js @@ -0,0 +1,238 @@ +var dice = { + + scoring:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + vals:[0,0,0,0,0], + holds:[0,0,0,0,0], + roll:-1, + round:0, + fhoak:0, //for use in determining full house + finish:false, //will be true when the game is over + + submit_round:function(){ + dice.roll = 3; + }, + + hold_func:function(n){ //called when a dice is clicked on + dice.holds[n] = !dice.holds[n]; + document.getElementById(`hold${n}`).innerHTML= (dice.holds[n]? "
HOLD
":' ') + }, + rand:function(){ //picks a random dice value + return Math.ceil(Math.random()*6); + }, + + oak: function(num_of_kind, repeat = 0){ //determines x of a kind scoring (including yahtzee) + let ret = 0, + count; + for(let n = 1; n <= 6; n++){ //each possible dice value is checked + if(n !== repeat){ + count = 0; + for(let i = 0; i < 5; i++){ //how many of this val do I have? lets look at each dice... + if(dice.vals[i] == n) count++; + } + } + if(count >= num_of_kind) { + dice.fhoak = n; + for(let i = 0; i < 5; i++){ + ret += dice.vals[i]; + } + } + } + return ret; + }, + + full_house: function(){ //determines full house scoring (using x of a kind and dice.fhoak) + return (dice.oak(3) ? (dice.oak(2, dice.fhoak) ? 25:0) : 0); + }, + + straight: function(size){ //determines small and large straight scoring + let str = ''; + let count; + let p = 0; + for(let val in dice.vals){ // 26345 + str += dice.vals[val]; + } + for(let a = size; a <= 6; a++){ // 4 : 4,5,6 + count = 0; + for(let b = 1+(a-size); b <= a; b++){ + if(str.includes(b)){ + count++; + } + } + if(count >= size){ + p = 30+(size-4)*10; + break; + } + } + return p; + }, + + chance:function(){ //determines chance scoring + let sum = 0; + //dice.vals.forEach(x => { sum+=x}); + for(let val in dice.vals){ + sum += dice.vals[val]; + } + return sum; + }, + + final_scoring:function(){ //called when dice.finish is set to true to determine the final score values + prepare_score(20, dice.scoring[8]); + for(let s = 9; s <= 15; s++){ + dice.scoring[19] += dice.scoring[s]; + } + dice.scoring[19] += dice.scoring[17]; + prepare_score(21, dice.scoring[19]); + dice.scoring[20] = dice.scoring[8]+dice.scoring[19]; + prepare_score(22, dice.scoring[20]); + dice.finish = true; + }, + + render_dice:function(dont_shuffle){ //main function called each time roll or submit is clicked on + //(dice.roll == -1 || dice.roll == 3 ? document.getElementById('submit').setAttribute('style', 'opacity:0') : document.getElementById('submit').setAttribute('style', 'opacity:1')); + document.getElementById('submit').setAttribute('style', 'opacity:'+(dice.roll == -1 || dice.roll == 3 ?'0':'1')); + document.getElementById('roll_display').innerText = (dice.roll == 2 ? 'Submit' : 'Roll!'); + + if(dice.roll == 3){ + + if(dice.round < 6){ //determine scores each upper round + for(let d = 0; d < 5; d++){ + if(dice.vals[d] == dice.round + 1){ + dice.scoring[dice.round] += dice.vals[d]; + } + } + prepare_score((dice.round+2), dice.scoring[dice.round]); + } + + if(dice.round == 5){ //determines final upper score + for(let d = 0; d < 6; d++){ + dice.scoring[6] += dice.scoring[d]; + } + prepare_score(8, dice.scoring[6]); + dice.scoring[7] = (dice.scoring[6] >= 63 ? 35 : 0); + prepare_score(9, dice.scoring[7]); + dice.scoring[8] = dice.scoring[6] + dice.scoring[7]; + prepare_score(10, (dice.scoring[8])); + } + + if(dice.round >= 6 && dice.round < 13){ //determines scores for each lower round + let calc=0; + switch(dice.round){ + case 6: calc = dice.oak(3); break; + case 7: calc = dice.oak(4); break; + case 8: calc = dice.full_house(); break; + case 9: calc = dice.straight(4); break; + case 10: calc = dice.straight(5); break; + case 11: calc = (dice.oak(5) ? 50:0); break; + case 12: calc = dice.chance(); break; + } + dice.scoring[dice.round+3] = calc; + prepare_score((dice.round+5), dice.scoring[dice.round+3]); + } + + if(dice.round == 12 && !dice.scoring[14]){ //if yahtzee was not met, get final scores and end the game + dice.final_scoring(); + } + + if(dice.round == 13){ //if yahtzee WAS met, play the yahtzee bonus round and then get final scores and end the game + dice.scoring[16] = (dice.oak(5) ? '✓' : '✗'); + dice.scoring[17] = (dice.oak(5) ? 100 : 0); + prepare_score(18, dice.scoring[16]); + prepare_score(19, dice.scoring[17]); + dice.final_scoring(); + } + + for(let i = 0; i < 5; i++){ //reset holds at the start of each round + dice.holds[i] = 0; + } + } + + update(); + let out = ''; + for(let i = 0; i < 5; i++){ + dice.vals[i] = dice.holds[i] || dont_shuffle ? dice.vals[i] : dice.rand(); + out += + ` + +
` + (dice.holds[i]? "
HOLD
":' ') + `
+
`; + } + if(!dice.finish){ //renders the main playfield + document.getElementsByClassName('dice_display')[0].innerHTML = out; + document.getElementById('roll_count').innerHTML = "Roll " + (dice.roll ? `#${dice.roll}` : 'the dice!'); + if(dice.round < 13) {document.getElementById('notice').innerHTML = roll_for()}; + if(dice.round >= 13 && dice.scoring[14]) {document.getElementById('notice').innerHTML ="

You are rolling for: Yahtzee Bonus

"}; + document.getElementById('roll_count').style.marginLeft = (dice.roll ? '120px' : '67.5px'); + //console.log(dice.scoring); + } + else{ //renders the game over screen if dice.finish is true + document.getElementById('notice').setAttribute('style', 'display:none'); + document.getElementsByClassName('dice_display')[0].setAttribute('style', 'display:none'); + document.getElementById('submit_line').setAttribute('style', 'display:none'); + document.getElementsByClassName('top_pad')[0].innerHTML = + ` +
Thanks for Playing!
+
Your Final Score: ${dice.scoring[20]}
+ + Click Here to Play Again + + + Click Here to Go Back + +
`; + } + } +} + +function make_head(header){ //creates the header + return ` ${header} `; +} + +function roll_for(){ + let arr = ['Aces', 'Twos', 'Threes', 'Fours', 'Fives', 'Sixes', + '3 of a Kind', '4 of a Kind', 'Full House', + 'Small Straight', 'Large Straight', 'YAHTZEE', 'Chance']; + return `

You are rolling for: ${arr[dice.round]}

`; +} + +function update(){ //increments dice.roll each time in dice.render + if(dice.roll < 3){ + dice.roll++ + } + else { + dice.roll = 0; + dice.round++; + } +} + +function render_scoreboard(){ //script to create the scoreboard layout + let round_val = + ['UPPER SECTION', 'Aces', 'Twos', 'Threes', 'Fours', 'Fives', 'Sixes', 'TOTAL SCORE', 'BONUS', 'TOTAL', + '3 of a Kind', '4 of a Kind', 'Full House', 'Small Straight', 'Large Straight', 'YAHTZEE', 'Chance', + 'YAHTZEE BONUS ✓s', 'YAHTZEE BONUS scoring', 'TOTAL UPPER', 'TOTAL LOWER', 'GRAND TOTAL']; + let out = ''; + + for(let a=1; a <= 2; a++){ + if(a == 2){ + out += "
LOWER SECTION
\n"; + } + out += `
\n`; + + for(let i=1; i <= (8+a*2); i++){ + out += `
"+ + round_val[(i-1)+(a-1)*10] + "
\n"; + } + out += '
'; + } + return out; +} + +function prepare_score(place, value){ //when called, updates a specific score + return document.getElementById(`grid_element${place}`).insertAdjacentHTML('beforeend', `${value}`) +} + +document.getElementsByClassName('shifted_head')[0].innerHTML = make_head("Now Playing: Forced Order Mode"); +dice.render_dice(); +document.getElementById('full_scoreboard').innerHTML = render_scoreboard(); \ No newline at end of file diff --git a/free.html b/free.html new file mode 100644 index 0000000..9c10169 --- /dev/null +++ b/free.html @@ -0,0 +1,23 @@ + + + Yahtzee + + + + + < Go Back +

+ +
+
+ + + + + +

Scoreboard

+
+ + + + \ No newline at end of file diff --git a/free.js b/free.js new file mode 100644 index 0000000..a0f0bc6 --- /dev/null +++ b/free.js @@ -0,0 +1,223 @@ +var dice = { + + // game ends when round = 13 (assuming yahtzee is not achieved) + scoring:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + scoring_set: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + vals:[0,0,0,0,0], + holds:[0,0,0,0,0], + roll:-1, + round:0, + fhoak:0, //for use in determining full house - keep + finish:false, //will be true when the game is over - keep + + hold_func:function(n){ //called when a dice is clicked on - keep + dice.holds[n] = !dice.holds[n]; + document.getElementById(`hold${n}`).innerHTML= (dice.holds[n]? "
HOLD
":' ') + }, + rand:function(){ //picks a random dice value - keep + return Math.ceil(Math.random()*6); + }, + + oak: function(num_of_kind, repeat = 0){ //determines x of a kind scoring (including yahtzee) -keep + let ret = 0; + let count; + for(let n = 1; n <= 6; n++){ //each possible dice value is checked + if(n !== repeat){ + count = 0; + for(let i = 0; i < 5; i++){ //how many of this val do I have? lets look at each dice... + if(dice.vals[i] == n) count++; + } + } + if(count >= num_of_kind) { + dice.fhoak = n; + for(let i = 0; i < 5; i++){ + ret += dice.vals[i]; + } + } + } + return ret; + }, + + full_house: function(){ //determines full house scoring (using x of a kind and dice.fhoak) - keep + return (dice.oak(3) ? (dice.oak(2, dice.fhoak) ? 25:0) : 0); + }, + + straight: function(size){ //determines small and large straight scoring - keep + let str = ''; + let count; + let p = 0; + for(let val in dice.vals){ + str += dice.vals[val]; + } + for(let a = size; a <= 6; a++){ + count = 0; + for(let b = 1+(a-size); b <= a; b++){ + if(str.includes(b)){ + count++; + } + } + if(count >= size){ + p = 30+(size-4)*10; + break; + } + } + return p; + }, + + chance:function(){ //determines chance scoring - keep + let sum = 0; + for(let val in dice.vals){ + sum += dice.vals[val]; + } + return sum; + }, + + final_scoring:function(){ //called when dice.finish is set to true to determine the final score values - keep, toChange + for(let d = 0; d < 6; d++){ + dice.scoring[6] += dice.scoring[d]; + } + + dice.scoring[7] = (dice.scoring[6] >= 63 ? 35 : 0); + dice.scoring[8] = dice.scoring[6] + dice.scoring[7]; + + if(dice.scoring[16] == '✓'){ + dice.scoring[17] = 100; + } + if(dice.scoring[16] == '✗'){ + dice.scoring[17] = 0; + } + + dice.scoring[18] = dice.scoring[8]; + for(let d = 9; d < 16; d++){ + dice.scoring[19] += dice.scoring[d]; + } + dice.scoring[19] += dice.scoring[17] + dice.scoring[20] = dice.scoring[18] + dice.scoring[19]; + + dice.finish = true; + }, + + score:function(element){ + dice.roll = 3; + + let calc_arr = [dice.oak(3), dice.oak(4), dice.full_house(), dice.straight(4), dice.straight(5), (dice.oak(5) ? 50:0), dice.chance(), (dice.oak(5) ? '✓':'✗')]; + + dice.scoring_set[element-2] = true; + if(element <= 7){ //determine scores each upper round + for(let d = 0; d < 5; d++){ + if(dice.vals[d] == element - 1){ + dice.scoring[element-2] += dice.vals[d]; + } + } + } + + if(element > 7){ //determines scores for each lower round + dice.scoring[element-2] = calc_arr[element-11]; + } + + if(dice.round == (12 + dice.scoring[14]/50)){ + dice.final_scoring(); + } + + for(let d = 0; d < 5; d++){ //reset holds at the start of each round + dice.holds[d] = 0; + } + }, + + render_dice:function(dont_shuffle){ //main function called each time roll or submit is clicked on -keep, toChange + + (dice.roll == 2 ? document.getElementById('roll_display_free').style.display = 'none' : document.getElementById('roll_display_free').style.display = 'unset'); + + update(); //keep + let out = ''; + for(let i = 0; i < 5; i++){ //keep + dice.vals[i] = dice.holds[i] || dont_shuffle ? dice.vals[i] : dice.rand(); + out += + ` + +
` + (dice.holds[i]? "
HOLD
":' ') + `
+
`; + } + + document.getElementById('full_scoreboard').innerHTML = render_scoreboard(); //keep + + if(!dice.finish){ //renders the main playfield - keep + document.getElementsByClassName('dice_display')[0].innerHTML = out; + document.getElementById('roll_count').innerHTML = "Roll " + (dice.roll ? `#${dice.roll}` : 'the dice!'); + document.getElementById('roll_count').style.marginLeft = (dice.roll ? '120px' : '67.5px'); + //console.log(dice.scoring); + } + else{ //renders the game over screen if dice.finish is true - keep + document.getElementById('grid_element8').insertAdjacentHTML('beforeend', `${dice.scoring[6]}`); + document.getElementById('grid_element9').insertAdjacentHTML('beforeend', `${dice.scoring[7]}`); + document.getElementById('grid_element10').insertAdjacentHTML('beforeend', `${dice.scoring[8]}`); + document.getElementById('grid_element19').insertAdjacentHTML('beforeend', `${dice.scoring[17]}`); + document.getElementById('grid_element20').insertAdjacentHTML('beforeend', `${dice.scoring[18]}`); + document.getElementById('grid_element21').insertAdjacentHTML('beforeend', `${dice.scoring[19]}`); + document.getElementById('grid_element22').insertAdjacentHTML('beforeend', `${dice.scoring[20]}`); + document.getElementsByClassName('dice_display')[0].setAttribute('style', 'display:none'); + document.getElementById('submit_line').setAttribute('style', 'display:none'); + document.getElementsByClassName('top_pad_free')[0].innerHTML = + ` +
Thanks for Playing!
+
Your Final Score: ${dice.scoring[20]}
+ + Click Here to Play Again + + + Click Here to Go Back + +
`; + } + } +} + +function make_head(header){ //creates the header - keep + return ` ${header} `; +} + +function update(){ //increments dice.roll each time in dice.render - keep, toChange + if(dice.roll < 3){ + dice.roll++ + } + else { + dice.roll = 0; + dice.round++; + } + console.log(dice.round); +} + +function render_scoreboard(){ //script to create the scoreboard layout - keep + let round_val = + ['UPPER SECTION', 'Aces', 'Twos', 'Threes', 'Fours', 'Fives', 'Sixes', 'TOTAL SCORE', 'BONUS', 'TOTAL', + '3 of a Kind', '4 of a Kind', 'Full House', 'Small Straight', 'Large Straight', 'YAHTZEE', 'Chance', + 'YAHTZEE BONUS ✓s', 'YAHTZEE BONUS scoring', 'TOTAL UPPER', 'TOTAL LOWER', 'GRAND TOTAL']; + let clickables = [2,3,4,5,6,7,11,12,13,14,15,16,17]; + if(dice.scoring[14] > 0){ + clickables.push(18); + } + let out = ''; + + for(let a=1; a <= 2; a++){ + if(a == 2){ + out += "
LOWER SECTION
\n"; + } + out += `
\n`; + + for(let i=1; i <= (8+a*2); i++){ + out += `
${round_val[(i-1)+(a-1)*10]}`; + out += (dice.scoring_set[(i + (a-1)*10) - 2] ? `${dice.scoring[(i + (a-1)*10) - 2]}` : '') + `
\n`; + } + out += '
'; + } + return out; +} + +document.getElementsByClassName('shifted_head')[0].innerHTML = make_head("Now Playing: Free Mode"); //keep +dice.render_dice(); //keep +document.getElementById('full_scoreboard').innerHTML = render_scoreboard(); //keep \ No newline at end of file diff --git a/game.html b/game.html new file mode 100644 index 0000000..5a54cee --- /dev/null +++ b/game.html @@ -0,0 +1,26 @@ + + + Yahtzee + + + + + < Go Back +

+ +
+ +
+
+ + + + + + +

Scoreboard

+
+ + + + \ No newline at end of file diff --git a/game.php b/game.php new file mode 100644 index 0000000..7f4715b --- /dev/null +++ b/game.php @@ -0,0 +1,41 @@ + + + + + Yahtzee + + + + + < Go Back +

+ +

+ + + +
+
+
+ +
+ > + > + Roll # + + > + + + + +
+ +

Scoreboard

+
+ +
+ + \ No newline at end of file diff --git a/instructions.html b/instructions.html new file mode 100644 index 0000000..85b476a --- /dev/null +++ b/instructions.html @@ -0,0 +1,35 @@ + + + Instructions + + + + + < Go Back +

+ +

In Yahtzee, you play with 5 Dice as seen below:

+ +
+ +

You get 3 chances to roll every round. Try the roll button below:

+ + + + +

Click on one of the Dice above to Hold it if you don't want to roll it again.
+ Doing so will display a hold icon below the die. Try it!

+ +

Every round, you will attempt to get different combinations with the dice.
+ Below are all the combinatinos from each round.
+ Click on one to see what it means. +

+ +
+ +
+ + + + + \ No newline at end of file diff --git a/instructions.js b/instructions.js new file mode 100644 index 0000000..258d98a --- /dev/null +++ b/instructions.js @@ -0,0 +1,127 @@ +var onOff = [0,0,0,0,0,0,0,0,0,0,0,0,0] , + dice = { + + vals:[0,0,0,0,0], + holds:[0,0,0,0,0], + + hold_func:function(n){ + dice.holds[n] = !dice.holds[n]; + document.getElementById(`hold${n}`).innerHTML= (dice.holds[n]? "
HOLD
":' ') + console.log(dice.holds); + }, + rand:function(){ + return Math.ceil(Math.random()*6); + }, + render_dice:function(dont_shuffle){ + let out = ''; + for(let i = 0; i < 5; i++){ + dice.vals[i] = dice.holds[i] || dont_shuffle ? dice.vals[i] : dice.rand(); + out += + ` + +
` + (dice.holds[i]? "
HOLD
":' ') + `
+
`; + } + document.getElementsByClassName('dice_display')[0].innerHTML = out; + } + } + +function write_round(start, len){ + dice.render_dice(); + var rl_arr=[ + 'Aces', 'Twos', 'Threes', 'Fours', 'Fives', 'Sixes', + '3 of a Kind', '4 of a Kind', 'Full House', 'Small Straight', + 'Large Straight', 'Yahtzee', 'Chance' + ], + r_array = [ + `Roll for ones. + You score the sum of each 'one' after your third roll.`, + + `Roll for twos. + You score the sum of each 'two' after your third roll, + where each two is worth two points.`, + + `Roll for threes. + You score the sum of each 'three' after your third roll, + where each three is worth three points.`, + + `Roll for fours. + You score the sum of each 'four' after your third roll, + where each four is worth four points.`, + + `Roll for fives. + You score the sum of each 'five' after your third roll, + where each five is worth five points.`, + + `Roll for sixes. + You score the sum of each 'six' after your third roll, + where each six is worth six points.`, + + `Roll to get three of the same dice. + If you have 3 of a kind at the end of your third roll, + you score the sum of all dice. Otherwise no points are earned.`, + + `Roll to get four of the same dice. + If you have 4 of a kind at the end of your third roll, + you score the sum of all dice. Otherwise no points are earned.`, + + `Roll to get three of one number dice and two of another (ex. 2 2 5 2 5). + If a full house is achieved at the end of your third roll, + you score 25 points. Otherwise no points are earned.`, + + `Roll to get a sequence of four dice (ex. 5 2 4 3 3). + If a small straight is achieved at the end of your third roll, + you score 30 points. Otherwise no points are earned.`, + + `Roll to get a sequence of five dice (ex. 1 4 2 5 3). + If a large straight is achieved at the end of your third roll, + you score 40 points. Otherwise no points are earned.`, + + `Roll to get all five of the same dice. + If you have a yahtzee at the end of your third roll, + you score 50 points and get the opportunity at the end of the game to score another Yahtzee, + called Yahtzee Bonus. If a Yahtzee Bonus is earned, you will score 100 points`, + + `Roll for high numbers. + At the end of your third roll, you will score the sum of your dice.` + ]; + let out = ''; + for(var i = start; i < len+start; i++){ + out += `
` + rl_arr[i] + + `v
+ `; + } + return out; +} + +function make_head(header){ + return ` ${header} `; +} + + +document.getElementById('round_list').innerHTML = write_round(0, 6); +document.getElementById('round_list2').innerHTML = write_round(6, 7); +document.getElementsByClassName('shifted_head')[0].innerHTML = make_head("How to Play Yahtzee"); + +function rule_show(occ) { + document.getElementsByClassName('rule_show')[occ].style.display=(onOff[occ]?'none':'block'); + onOff[occ]=!onOff[occ]; +} +/*setInterval(()=>{ + document.querySelectorAll('.small_dice').forEach( i => { i.src=dice.rand() } ) +},4250); */ + +/* +javascript is very new; it got some kick ass short hand and tricks no other language got yet. for example, the " " or ' ' or ` ` +setTimeout( function(){} , 250) <-- what function to call after 250 miliSeconds +setTimeout( ()=>{} , 250) <-- instead of "function()" you can type "()=>" + +function (a,b) { return a+b } +(a,b)=>a+b <-- auto return the function body if it is NOT serrounding with a curly ; similar to the ( logic ? return-when-true : return-when-false ) + + +*/ \ No newline at end of file diff --git a/instructions.php b/instructions.php new file mode 100644 index 0000000..83ae357 --- /dev/null +++ b/instructions.php @@ -0,0 +1,55 @@ + + + + + Instructions + + + + + 0 && $i<6 && $v>0 && $v<7) { + $_SESSION['dice'][$i-1]=$v; + print"set it up.... $i $v
\n"; + } else print"out of range $i $v
\n"; + } else print"Missing GET inputs
\n"; + + ?> + + I remember you... you have this setup:
+ + < Go Back +

+ +

In Yahtzee, you play with 5 Dice as seen below:

+ +
+ +

You get 3 chances to roll every round. Try the roll button below:

+ + +
Roll
+ +

Click on one of the Dice above to Hold it if you don't want to roll it again.
+ Doing so will display a hold icon below the die. Try it!

+ +

Every round, you will attempt to get different combinations with the dice.
+ Below are all the combinatinos from each round.
+ Click on one to see what it means. +

+ +
+ +
+ + + + + \ No newline at end of file diff --git a/mode_select.html b/mode_select.html new file mode 100644 index 0000000..3d7dcc2 --- /dev/null +++ b/mode_select.html @@ -0,0 +1,39 @@ + + + + + Yahtzee + + + + + + < Go Back +

+ + +
+ Click Here to Play in Forced Order Mode +
+
+ + +
+ Click Here to Play in Free Choice Mode +
+
+ + + + \ No newline at end of file diff --git a/mode_select.php b/mode_select.php new file mode 100644 index 0000000..9ac3224 --- /dev/null +++ b/mode_select.php @@ -0,0 +1,33 @@ + + + + + + + Yahtzee + + + + + + < Go Back +

+ +

+ + +
+ Click Here to Play in Forced Order Mode +
+
+ + +
+ Click Here to Play in Free Choice Mode +
+
+ + \ No newline at end of file diff --git a/pong.html b/pong.html new file mode 100644 index 0000000..e0194be --- /dev/null +++ b/pong.html @@ -0,0 +1,15 @@ +
+ +
+ \ No newline at end of file diff --git a/scripts.php b/scripts.php new file mode 100644 index 0000000..d04e7b2 --- /dev/null +++ b/scripts.php @@ -0,0 +1,299 @@ + $text "; + } + + function display_dice_practice(){ + $out = ''; + for($i=1; $i<=5; $i++){ + $see = ""; + $shuffle = dice_rand(); + if(isset($_GET["dice$i"]) && isset($_GET["held$i"]) && $_GET["dice$i"] == 'on'){ // isset(): exists? , empty() not set or the value is falsey like 0 or empty string + $see = 'checked'; + $shuffle = $_GET["held$i"]; + } + $out .= + " + + + +
HOLD
+
+ \n"; + + } + + return $out; + } + + + + function display_dice(){ + $out=''; + if(!$_GET["score21"]){ + for($i=1; $i<=5; $i++){ + $see = ""; + $shuffle = dice_rand(); + $show = ""; + $Aces = ""; + if($_GET["dice$i"] == 'on'){ + $see = 'checked'; + $shuffle = $_GET["held$i"]; + } + if(empty($_GET["roll_num"])) { + $see = ""; + $show = "style=opacity:0;"; + } + + $out .= + " + + + +
HOLD
+
+ \n"; + } + } + + else { + $out .= + " +
Thanks for Playing!
+
Your Final Score: " . $_GET['score21'] . "
+ + Click Here to Play Again + + + Click Here to Go Back + +
"; + } + + return $out; + } + + function roll_num(){ + return (empty($_GET["roll_num"])?"style=color:orange;":""); + } + + function show_roll(){ + return (isset($_GET["roll_num"]) && $_GET["roll_num"] == 3 ? "style=opacity:0":""); + } + + function next_level(){ + $roll = $_GET["roll_num"]+1; + $round = $_GET["round_num"]; + + if($roll > 3){ + $roll = 0; + $round = $_GET["round_num"]+1; + } + return + "\n" . + ""; + } + + function total_upper(){ + $ret = 0; + for($i = 1; $i <= 6; $i++){ + (is_numeric($_GET["score$i"])?$ret += $_GET["score$i"]:0); + } + return $ret; + } + + function bonus_bool(){ + return (isset($_GET["score7"]) && $_GET["score7"] >= 63 ? 35:0); + } + + function oak($num_of_kind,&$dice_number){ + $ret=0; + for($n = 1; $n <= 6; $n++) if ($n!=$dice_number) { // n is the dice number I am chekcing, like "5" + $count = 0; + for($i = 1; $i <= 5; $i++){ // how many "5"s I have + if($_GET["held$i"] == "$n.png") $count++; + } + if($count >= $num_of_kind) { + $dice_number = $n; + $n=99; + } + } + if($n>20){ + for($i = 1; $i <= 5; $i++) $ret += substr($_GET["held$i"], 0, 1); + } + return $ret; + } + + function is_full_house(){ + $dn=0; + if (oak(3,$dn)){ + if(oak(2,$dn)) return 25; + } + return 0; + } + + function straight($size){ + $str = ""; + $count = 0; + $p = 0; + for($i = 1; $i <= 5; $i++){ + $str .= substr($_GET["held$i"], 0, 1); + } + for($a = 4+($size-4); $a <= 6; $a++){ + $count = 0; + for($b = $a-3-($size-4); $b <= $a; $b++){ + if((strpos($str, (string)$b)) !== False) $count++; + } + if($count >= $size){ + $p = 30+(($size-4)*10); + break; + } + } + return $p; + } + + function Chance(){ + $sum = 0; + for($i = 1; $i <= 5; $i++){ + (is_numeric(substr($_GET["held$i"], 0, 1))? + $sum += substr($_GET["held$i"], 0, 1):0); + } + return $sum; + } + + function Yahtzee(){ + $x3 = 10; + return ((oak(5,$x3)) ? 50:0); + } + + function y_bonus(){ + return (Yahtzee() > 0 ? "✓":"test"); + } + + function total_lower(){ + $ret = 0; + for($i = 10; $i <= 18; $i++){ + (is_numeric($_GET["score$i"])?$ret += $_GET["score$i"]:0); + } + return $ret; + } + + function calc_score(){ + $score = ""; + ////array for scoring procedures//// + $x1 = 0; + $x2 = 9; + $cont = 0; + $scoring_array = + [oak(3,$x1), oak(4,$x2), is_full_house(), + straight(4), straight(5), Yahtzee(), Chance()]; + + if($_GET["score15"]){ + $cont++; + } + + $points = []; + for($a = 1; $a <= 21+$cont; $a++){ + $points[$a] = $_GET["score$a"]; + if($a <= 6) { + if(($_GET["roll_num"] == 0) && ($_GET["round_num"] == $a)){ + $points[$a] = 0; + for($i = 1; $i <= 5; $i++){ + if($_GET["held$i"] == "$a.png") $points[$a] += $a; + } + } + } + + elseif($_GET["round_num"] > 13){ + if($cont && ($_GET["roll_num"] == 0)){ + $points[17] = y_bonus(); + $points[18] = Yahtzee()*2; + } + } + + if($_GET["round_num"] >= 13+$cont){ + $points[19] = $points[9]; + $points[20] = total_lower(); + $points[21] = $points[9] + $points[20]; + } + + + if($a > 9 && $a < 17){ + if(($_GET["roll_num"] == 0) && ($_GET["round_num"] == $a-3)){ + $points[$a] = $scoring_array[$a-10]; + } + } + + elseif($_GET["round_num"] >= 6){ + $points[7] = total_upper(); + $points[8] = bonus_bool(); + $points[9] = total_upper() + bonus_bool(); + } + + + $score .= "\n"; + $_GET["score$a"]=$points[$a]; + } + return $score; + } + + function create_scoreboard(){ + $round_val = + ['UPPER SECTION', 'Aces', 'Twos', 'Threes', 'Fours', 'Fives', 'Sixes', 'TOTAL SCORE', 'BONUS', 'TOTAL', + '3 of a Kind', '4 of a Kind', 'Full House', 'Small Straight', 'Large Straight', 'YAHTZEE', 'Chance', + 'YAHTZEE BONUS ✓s', 'YAHTZEE BONUS scoring', 'TOTAL UPPER', 'TOTAL LOWER', 'GRAND TOTAL']; + $out = ''; + $score_val = []; + $score_val[0] = ""; + $score_val[1] = ""; + for($i=1; $i <= 21; $i++){ + $score_val[$i+1] = $_GET["score$i"]; + } + + for($a=1; $a <= 2; $a++){ + if($a == 2){ + $out .= "
LOWER SECTION
\n"; + } + $out .= "
\n"; + + for($i=1; $i <= 8+$a*2; $i++){ + $out .= "
" . + $round_val[($i-1)+($a-1)*10]; + if($a == 1) $out .= "" . $score_val[$i] . ""; + else $out .= "" . $score_val[$i+10] . ""; + $out .= "
\n"; + } + $out .= '
'; + } + return $out; + } + + function determine_reminder(){ + $r = $_GET["round_num"]; + $round_val = + ['Aces', 'Twos', 'Threes', 'Fours', 'Fives', 'Sixes', + '3 of a Kind', '4 of a Kind', 'Full House', + 'Small Straight', 'Large Straight', 'YAHTZEE', 'Chance']; + if($_GET["score15"]) array_push($round_val, 'YAHTZEE Bonus'); + return strtoupper($round_val[$r]); + } + + function check_end(){ + $out = ''; + if(!$_GET["score21"]){ + $out .= + "

You are rolling for: " . determine_reminder() . "

"; + } + return $out; + } + +?> \ No newline at end of file diff --git a/sql_00.php b/sql_00.php new file mode 100644 index 0000000..38ee4f2 --- /dev/null +++ b/sql_00.php @@ -0,0 +1,45 @@ +Debugging error: " . + mysqli_connect_error() . "
\n"); +} + +$q="select id,full_name,addr1,addr2,city,state,postal from amz_sh_customers where tel='' limit 10"; +if ($res=mysqli_query($db,$q)){ + while($r = mysqli_fetch_assoc($res)){ + print"{$r['id']}. Name: {$r['full_name']}
\n"; + // later when updating it will look like this: + // $q="update amz_sh_customers set tel='1',email='$email_list' where id={$r['id']}"; + } +} else print"$q failed: ".mysqli_error($db)."
\n"; + +mysqli_close($db); + + + +//2016-06-22 support for EmailOversight U: shai@inetb.com P: 5146_Drd +// documentation https://login.emailoversight.com/ApiPage/EmailAppend +/* +GET URL: https://api.emailoversight.com/api/EmailAppend?apitoken=2ed8c5a6-5597-4b69-bdb0-a854504d8472&lastname={LastName}&firstname={FirstName}&postalcode={PostalCode}&middlename=&formattedaddress=&zip4= +*/ +$url="https://api.emailoversight.com/api/EmailValidation?apitoken=2ed8c5a6-5597-4b69-bdb0-a854504d8472&listid=3117&email=$e"; + + +$ch = curl_init('http://google.com'); +curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ; +$res = curl_exec ($ch); +// if res is JSON, you can use $PHP_normal_assosiate_array = json_decode($res,1) +// to see the array visually, use print_r($arr); +curl_close ($ch); +print"After talking to google, I got back ".strlen($res). + " bytes back
The return starts like this".substr($res,200).""; +?> diff --git a/test.html b/test.html new file mode 100644 index 0000000..bdb3514 --- /dev/null +++ b/test.html @@ -0,0 +1 @@ +