武侠末世(真香游戏V2.0)

该HTML引用了jquery,自行引用即可
后续还会优化,只要我有时间 诶嘿


<html>
	<head>
		<meta charset="utf-8">
		<title>title>
		<style type="text/css">
			body {
				font-size: 10px;
			}

			#title {
				text-align: center;
				position: sticky;
				top: 0;
				background-color: #F2F2F2;
				/* border: 2px solid #4CAF50; */
			}
		style>
	head>
	<body>
		<div id="title">
			<h1>武俠末世h1>
			<em><input type="text" name="" id="yourName" value="" placeholder="請輸入你的名字" oninput="changeName()" />em> 
			<i>VSi>  
			<em><input type="text" name="" id="theyName" value="" placeholder="請輸入你的對手" oninput="changeName()" />em>
			<br>
			<button type="button" id="continueButton">點擊繼續button>
			<button type="button" id="continueButton2">走一年試試button>
			<br />
			出道時18歲,遊戲進行30年
			<div id="start">div>
			<br />
		div>
		<div id="log">div>
	body>
	<script src="jquery-3.4.1.min.js" type="text/javascript" charset="utf-8">script>
	<script type="text/javascript">
		var count = 0;
		var allBoss = 0;
		var finish = 0;
		var yourHP = 200 + 100 * allBoss;
		var youATK = 20 + 20 * allBoss;
		var theyHP = 200;
		var theyATK = 30;

		function toEnd(){
			$('body,html').animate({
				scrollTop: $('body,html')[0].scrollHeight
			}, 6);
		}

		function changeName() {
			yourHP = 200 + 100 * allBoss;
			youATK = 0 + 10 * allBoss;
			theyHP = 200 + 200 * allBoss;
			theyATK = 30 + 20 * allBoss;
			$("#start").html($("#yourName").val() + "初始攻擊力" + youATK + "點
"
+ $("#theyName").val() + "初始攻擊力" + theyATK + "點
"
); } function theyAttack() { $("#log").append($("#theyName").val() + "出手,當前剩餘血量:" + theyHP + "點
"
); if (theyHP >= 120) { theyATK += 1; $("#log").append($("#theyName").val() + "發動了攻擊,造成" + theyATK + "點傷害
"
); yourHP -= theyATK; return 0; } else if (theyHP >= 80) { theyATK -= 1; $("#log").append($("#theyName").val() + "感覺事情不妙,小幅度回復自身生命" + theyATK + "點
"
); theyHP += theyATK; return 0; } else if (theyHP <= 32) { theyATK = 30; $("#log").append($("#theyName").val() + "感覺事情不妙,回復自身生命" + theyATK + "點
"
); theyHP += theyATK; return 0; } theyATK += 1; $("#log").append($("#theyName").val() + "發動了攻擊,造成" + theyATK + "點傷害
"
); yourHP -= theyATK; return 0; } function youAttack() { $("#log").append($("#yourName").val() + "出手,當前剩餘血量:" + yourHP + "點
"
); youATKNow = Math.floor(Math.random() * youATK + youATK); if (yourHP <= theyATK) { $("#log").append($("#yourName").val() + "發動了技能:'真香炒飯,啊,真香!由於吃過炒飯,心境平和,攻擊力減少20點',恢復全部體力
"
); yourHP = 200 + 100 * allBoss; youATK -= 10; return 0; } if (yourHP >= 100) { $("#log").append($("#yourName").val() + "發動了技能:'我就是餓死、死外面、從這兒跳下去,也不會吃你們一口東西!',嘲諷對手,並增加自身攻擊力10點,造成了" + (youATKNow + 10) + "點傷害
"
); theyHP -= (youATKNow + 10); youATK += 10; $("#log").append($("#theyName").val() + "被激怒了!反擊攻擊造成5點傷害
"
); yourHP -= 5; return 0; } $("#log").append($("#yourName").val() + "發動了攻擊,造成" + youATKNow + "點傷害
"
); theyHP -= youATKNow; } function action() { if (finish < 0) { $("#log").append("遊戲結束,共打敗了" + allBoss + "個人,在歷史上畫下了濃墨重彩的一筆
"
); toEnd(); return; } if (theyHP <= 0) { $("#log").append("" + $("#theyName").val() + "累了,厭倦了江湖的打打殺殺,隱退了
"
); $("#log").append("該對手已經再起不能。。。。
"
); toEnd(); return; } if (yourHP <= 0) { $("#log").append("" + $("#yourName").val() + "累了,厭倦了江湖的打打殺殺,在" + (Math.floor(count / 12 + 0.99) + 18) + "歲隱退了
"
); $("#log").append("你已經再起不能。。。。
"
); $("#log").append("遊戲結束,共打敗了" + allBoss + "個人,在歷史上畫下了濃墨重彩的一筆
"
); toEnd(); return; } if ($("#yourName").val().toString().trim() == "") { $("#yourName").val("王境澤"); changeName(); } if ($("#theyName").val().toString().trim() == "") { $("#theyName").val("無名之輩"); changeName(); } count++; var month = (count % 12 == 0) ? 12 : count % 12; $("#log").append("

第" + Math.floor(count / 12 + 0.99) + "年 第" + month + "月

"
); if (count > 30 * 12) { $("#log").append("" + $("#yourName").val() + "累了,厭倦了江湖的打打殺殺,在48歲隱退了
"
); finish -= 1; toEnd(); return; } var i = theyAttack(); if (yourHP <= 0) { $("#log").append($("#yourName").val() + "掛了
"
); return -1; } var j = youAttack(); if (theyHP <= 0) { $("#log").append($("#theyName").val() + "掛了
"
); allBoss += 1; return -1; } toEnd(); } $("#continueButton").click(function(){ action(); }); $("#continueButton2").click(function(){ for(var cc = 0;cc<12;cc++) action(); } );
script> html>

你可能感兴趣的:(html,真香游戏V2.0)