Tjena
jag håller på med ett text-baserat spel i JS men skriptet funkar inte!
vad gör jag fel???
skriptet ser ut så här:
liv = 100
att = 10
peng = 100
ver = 1
fh = 50
fi = "Goblin"
fa = 5
ex = 0
lvl = 0
attg = 0
miss = Math.random()*3
function start()
{
if(ver == 1)
{
f1()
}
else if(ver == 2)
{
f2()
}
else if(ver == 3)
{
f3()
}
else if(ver == 4)
{
f4()
}
else if(ver == 5)
{
f1()
}
else if(ver == 6)
{
f1()
}
else if(ver == 7)
{
f1()
}
else if(ver == 8)
{
f1()
}
else if(ver == 9)
{
f1()
}
else if(ver == 10)
{
slut()
}
}
function f1()
{
if(attg == 1)
{
atta()
}
else if(attg == 3)
{
atta()
}
else if(attg == 5)
{
atta()
}
else if(attg == 7)
{
atta()
}
else if(attg == 9)
{
atta()
}
else if(attg == 11)
{
atta()
}
else if(attg == 13)
{
atta()
}
else if(attg == 15)
{
atta()
}
else if(attg == 17)
{
atta()
}
else if(attg == 19)
{
atta()
}
else
{
attack()
}
function atta()
{
if(miss == 0)
{
document.form1.text1.value = document.form1.text1.value + "Miss<p>"
miss = Math.random()*3
attag++
f1()
}
else
{
liv = liv - fa
document.form1.text1.value = document.form1.text1.value + "Din HP är =" + liv + "!"
miss = Math.random()*3
attag++
if(liv <= 0)
{
document.form1.text1.value = document.form1.text1.value + "du är död!"
}
else
{
f1()
}
}
}
function attack()
{
if(miss == 0)
{
document.form1.text1.value = document.form1.text1.value + "Miss<p>"
miss = Math.random()*3
attag++
f1()
}
else
{
fh = fh - att
document.form1.text1.value = document.form1.text1.value + fh + "<p>"
miss = Math.random()*3
attag++
if(fh <= 0)
{
if(ex >= liv)
{
ver++
fh = fh + fh
fa = fa + fa
liv = liv + liv
ex = ex + liv
att = att + att
document.form1.text1.value = document.form1.text1.value + fi + " är död!<br>Din exp =" + ex + "!"
peng = peng + fh
attag = 0
}
else
{
attag = 0
ver++
fh = fh + fh
fa = fa + fa
peng = peng + fh
document.form1.text1.value = document.form1.text1.value + fi + " är död!<br>Din exp =" + ex + "!"
}
}
else
{
f1()
}
}
}
function slut()
{
document.form1.text1.value = document.form1.text1.value + "Grattis du klarade av alla nivåer!<br>Jag kommer snart ut med en fortsättning!<p>Detta spel är programmerat av mig.<br>maila mig på theef89@hotmail.com!<br><br>THE END"
}}