Created
September 28, 2017 18:19
-
-
Save cerkauskas/141240345ca1c232e714b403c0cf02ee to your computer and use it in GitHub Desktop.
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" | |
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Drakonų skerdiks</title> | |
<script type="text/javascript"> | |
var drakonas = 1000; | |
var zmogus = 200; | |
while ((zmogus > 0) && (drakonas > 0)) { | |
var ataka = window.prompt('Kokiu budu atakuosi drakona?'); | |
if (ataka == 1) { | |
var dmg = randomnr(150,250); | |
drakonas = drakonas - dmg; | |
console.log('Drakonas gavo kamehames ' + dmg); | |
} | |
else if (ataka == 2) { | |
var dmg = randomnr(0,800); | |
drakonas = drakonas - dmg; | |
console.log('Drakonas gavo dragon kicka ' + dmg); | |
} | |
else if (ataka == 3) { | |
var dmg = randomnr(100,400); | |
drakonas = drakonas - dmg; | |
console.log('Drakonas gavo pliuxa ' + dmg); | |
} | |
else { | |
alert('Tu idiotas!'); | |
} | |
if (drakonas <= 0) { | |
console.log('Zmogus nugaletojas'); | |
break; | |
} | |
var zdmg = randomnr(30,80); | |
zmogus = zmogus - zdmg; | |
if (zmogus < 0) { | |
zmogus = 0; | |
} | |
console.log('Zmogus gavo zuvies ' + zdmg); | |
console.log('Zmogaus hp po atakos ' + zmogus); | |
console.log('Drakono hp po atakos ' + drakonas); | |
if (zmogus <= 0) { | |
console.log('Drakonas cempionas'); | |
} | |
} | |
function randomnr (min, max) { | |
var b = Math.random(); | |
var kaka = parseInt(b*(max-min)+min); | |
return kaka; | |
} | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment