-
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
kasparkivistik
committed
Dec 12, 2017
1 parent
118e345
commit 68038fa
Showing
6 changed files
with
77 additions
and
64 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
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
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,52 @@ | ||
<?php | ||
function upload_my_file($fileid) { | ||
echo "starting"; | ||
$target_dir = "uploads/"; | ||
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); | ||
|
||
echo "<p>$target_file " . $target_file; | ||
$uploadOk = 1; | ||
$imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); | ||
echo "<p>$imageFileType " . $imageFileType; | ||
$saved_file = $target_dir . $fileid . "." . $imageFileType; | ||
// Check if image file is a actual image or fake image | ||
if (isset($_POST["submit"])) { | ||
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); | ||
if ($check !== false) { | ||
echo "File is an image - " . $check["mime"] . "."; | ||
$uploadOk = 1; | ||
} else { | ||
echo "File is not an image."; | ||
$uploadOk = 0; | ||
} | ||
} | ||
echo "all is fine before checks"; | ||
// Check if file already exists | ||
if (file_exists($target_file)) { | ||
echo "Sorry, file already exists."; | ||
$uploadOk = 0; | ||
} | ||
// Check file size | ||
if ($_FILES["fileToUpload"]["size"] > 5000000) { | ||
echo "Sorry, your file is too large."; | ||
$uploadOk = 0; | ||
} | ||
// Allow certain file formats | ||
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { | ||
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; | ||
$uploadOk = 0; | ||
} | ||
// Check if $uploadOk is set to 0 by an error | ||
if ($uploadOk == 0) { | ||
echo "Sorry, your file was not uploaded."; | ||
// if everything is ok, try to upload file | ||
} else { | ||
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $saved_file)) { | ||
echo "<p>The file " . basename($_FILES["fileToUpload"]["name"]) . " has been uploaded."; | ||
} else { | ||
echo "<p>Sorry, there was an error uploading your file."; | ||
} | ||
} | ||
} | ||
|
||
upload_my_file(10); |
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,56 +1,3 @@ | ||
var playerPicks = []; | ||
|
||
var paper = 0; | ||
var rock = 1; | ||
var scissors = 2; | ||
|
||
|
||
function play(choice) { | ||
|
||
if (playerPicks.length < 3) { | ||
makeRandomChoice(choice); | ||
} else { | ||
//control if player chose more than 3 same in a row | ||
if (playerPicks[playerPicks.length - 1] === playerPicks[playerPicks.length - 2] | ||
&& playerPicks[playerPicks.length - 2] === playerPicks[playerPicks.length - 3]) { | ||
|
||
console.log('other person TURN'); | ||
|
||
if (playerPicks[playerPicks.length - 1] === 0) { | ||
makeTurn(choice, 2); | ||
} else { | ||
makeTurn(choice, playerPicks[playerPicks.length - 1] - 1); | ||
} | ||
} else { | ||
makeRandomChoice(choice); | ||
} | ||
|
||
} | ||
playerPicks.push(choice); | ||
} | ||
|
||
function makeTurn(playerChoice, secondPlayerChoice) { | ||
if (!(playerChoice === 0 && secondPlayerChoice === 2) | ||
&& ((playerChoice === 2 && secondPlayerChoice === 0) | ||
|| playerChoice < secondPlayerChoice)) { | ||
//WON | ||
console.log('Win ' + playerChoice + ' ' + secondPlayerChoice); | ||
} else if (playerChoice === secondPlayerChoice) { | ||
//DRAW | ||
console.log('Draw ' + playerChoice + ' ' + secondPlayerChoice); | ||
} else { | ||
//LOSE | ||
console.log('Lose ' + playerChoice + ' ' + secondPlayerChoice); | ||
} | ||
} | ||
|
||
$('#playerpaper').click(function () { | ||
play(paper); | ||
}); | ||
$('#playerrock').click(function () { | ||
play(rock); | ||
}); | ||
$('#playerscissors').click(function () { | ||
play(scissors); | ||
}); | ||
function move(move) { | ||
|
||
} |