You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.7 KiB
76 lines
1.7 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>Jednoduchy Pribeh</title>
|
|
</head>
|
|
<body onload="storybegin()">
|
|
<h1>Příběh</h1>
|
|
|
|
<div id="mainstory" >
|
|
</div>
|
|
<textarea name="" id="player"></textarea>
|
|
<button onclick="storyline()">Potvrdit</button>
|
|
|
|
<script>
|
|
//ZACATEK PRIBEHU
|
|
function storybegin() {
|
|
storytell(scenar.zacatek.first);
|
|
storytell(scenar.zacatek.second);
|
|
storytell(scenar.zacatek.third);
|
|
}
|
|
|
|
function storyline() {
|
|
var text = document.getElementById("player").value;
|
|
//storytell(text);
|
|
|
|
if (text == "rozhlizet"){
|
|
storytell(scenar.mistnost1.rozhlizet);
|
|
}
|
|
else if (text == "sebrat"){
|
|
if (checkinv("klic1")){
|
|
storytell(scenar.mistnost1.sebrat2);
|
|
}else{
|
|
storytell(scenar.mistnost1.sebrat);
|
|
playerinv.push("klic1");
|
|
}
|
|
} else {
|
|
storytell("Neznám")
|
|
}
|
|
}
|
|
|
|
//Inventar
|
|
let playerinv = [];
|
|
//SCENAR
|
|
var scenar = {
|
|
zacatek: {
|
|
first: "Začal si žít",
|
|
second: "Probudil ses v prázné místnosti",
|
|
third: "Co budeš dělat?"
|
|
},
|
|
mistnost1:{
|
|
rozhlizet: "Jsi v bíle místnosti a něco se leskne",
|
|
sebrat: "Sebral si klic a objevili se dvere",
|
|
sebrat2: "Klič už si sebral"
|
|
}
|
|
}
|
|
|
|
//FUNKCE
|
|
function storytell(story) {
|
|
document.getElementById("mainstory").innerHTML += "<p>"+story+"</p>";
|
|
}
|
|
|
|
function checkinv(item) {
|
|
for (let k in playerinv) {
|
|
if (playerinv[k] === item) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|