阴阳师御魂模拟器

仅供娱乐,更改一下jquery的引用位置即可,+15功能有点bug
有兴趣的人可以在这个基础上加一个定制御魂功能
(请给我双速18招财头!)


<html>
	<head>
		<meta charset="utf-8">
		<title>title>
	head>
	<body>
		<h1>陰陽師御魂模擬器h1>
		<input type="radio" name="location" value="1" >1號位
		<input type="radio" name="location" value="2" >2號位
		<input type="radio" name="location" value="3" >3號位
		<input type="radio" name="location" value="4" >4號位
		<input type="radio" name="location" value="5" >5號位
		<input type="radio" name="location" value="6" >6號位
		<br>
		<button type="button" id="generate">generatebutton>
		<div id="result">
			<span style="display: none;" id="upCount">0span>
		div>
		<input type="radio" name="upy" value="1" >+3
		<input type="radio" name="upy" value="2" >+6
		<input type="radio" name="upy" value="3" >+9
		<input type="radio" name="upy" value="4" >+12
		<input type="radio" name="upy" value="5" >+15
		<br>
		<button type="button" id="upy">upybutton>
		<div id="resultHistoryList">
			
		div>
	body>
	<script src="jquery-3.4.1.min.js" type="text/javascript" charset="utf-8">script>
	<script type="text/javascript">
		var arrAll = ['攻擊加成','防禦加成','生命加成','速度','效果命中','效果抵抗','暴擊傷害','暴擊'];
		var arr1 = ['攻擊加成','防禦加成','生命加成','速度'];
		var arr2 = ['攻擊加成','防禦加成','生命加成','效果命中','效果抵抗'];
		var arr3 = ['攻擊加成','防禦加成','生命加成','暴擊傷害','暴擊'];
		function addStatusPreMain(type){
			switch (type){
				case '攻擊':
					return 81;
				case '防禦':
					return 14;
				case '生命':
					return 342;
				case '攻擊加成':
				case '防禦加成':
				case '生命加成':
				case '暴擊':
				case '效果命中':
				case '效果抵抗':
					return 10;
				case '速度':
					return 12;
				case '暴擊傷害':
					return 14;
				default:
					break;
			}
		}
		
		function addStatusMain(type){
			switch (type){
				case '攻擊':
					return 27;
				case '防禦':
					return 6;
				case '生命':
					return 114;
				case '攻擊加成':
				case '防禦加成':
				case '生命加成':
				case '暴擊':
				case '效果命中':
				case '效果抵抗':
				case '速度':
					return 3;
				case '暴擊傷害':
					return 5;
				default:
					break;
			}
		}
		
		function addStatusOther(type){
			switch (type){
				case '攻擊':
					return Math.random()*7+20;
				case '防禦':
					return Math.random()*2+4;
				case '生命':
					return Math.random()*14+100;;
				case '攻擊加成':
				case '防禦加成':
				case '生命加成':
				case '暴擊':
				case '速度':
					return Math.random()+2;
				case '效果命中':
				case '效果抵抗':
				case '暴擊傷害':
					return Math.random()+3;
				default:
					break;
			}
		}
		
		function addMain(arr){
			switch($("input[name='location']:checked").val()){
				case '1':
					arr.main1 = "攻擊";
					arr.main1Status = addStatusPreMain(arr.main1);
					break;
				case '2':
					arr.main1 = arr1[Math.floor(Math.random() * (arr1.length))];
					arr.main1Status = addStatusPreMain(arr.main1);
					break;
				case '3':
					arr.main1 = "防禦";
					arr.main1Status = addStatusPreMain(arr.main1);
					break;
				case '4':
					arr.main1 = arr2[Math.floor(Math.random() * (arr1.length))];
					arr.main1Status = addStatusPreMain(arr.main1);
					break;
				case '5':
					arr.main1 = "生命";
					arr.main1Status = addStatusPreMain(arr.main1);
					break;
				case '6':
					arr.main1 = arr3[Math.floor(Math.random() * (arr1.length))];
					arr.main1Status = addStatusPreMain(arr.main1);
					break;
				default:
					break;
			}
		}
		
		function getRandNum(arr,otherTime){
			if(arr == null){
				arr = [];
				for (i = 0 ;i<otherTime;i++) {
					var ran = Math.floor(Math.random() * (arrAll.length));
					while(isExist(arr,ran)){
						ran = Math.floor(Math.random() * (arrAll.length));
					}
					arr[i] = ran;
				}
				return arr;
			}else{
				var newArr = [];
				for (i = 0 ;i<otherTime;i++) {
					var ran = Math.floor(Math.random() * (arrAll.length));
					while(isExist(arr,ran)){
						ran = Math.floor(Math.random() * (arrAll.length));
					}
					newArr[i] = ran;
				}
				return newArr;
			}
		}
		
		function isExist(arr,ran){
			for (j=0;j<arr.length;j++) {
				if(arr[j] == ran){
					return true;
				}
			}
			return false;
		}
		
		function addOther(arr,otherTime){
			var otherNums = getRandNum(null,otherTime);
			arr.otherNums = otherNums;
			switch (otherTime){
				case 4:
					arr.other4 = arrAll[otherNums[3]];
					arr.other4Status = addStatusOther(arr.other4);
				case 3:
					arr.other3 = arrAll[otherNums[2]];
					arr.other3Status = addStatusOther(arr.other3);
				case 2:
					arr.other2 = arrAll[otherNums[1]];
					arr.other2Status = addStatusOther(arr.other2);
				case 1:
					arr.other1 = arrAll[otherNums[0]];
					arr.other1Status = addStatusOther(arr.other1);
					break;
				default:
					break;
			}
		}
		
		function addNowStatus(arr){
			var key = "other"+Math.floor(Math.random() * arr.otherTime + 1);
			var num = arr[key+"Status"];
			num += addStatusOther(arr[key]);
			arr[key+"Status"] = num;
		}
		
		function addNewStatus(arr,position){
			var otherNums = getRandNum(arr.otherNums,1);
			arr.otherNums[position-1] = otherNums[0];
			arr["other"+position] = arrAll[otherNums[0]];
			arr["other"+position+"Status"] = addStatusOther(arr["other"+position]);
		}
		
		var arr = new Object();
		$("#generate").click(function(){
			resultHistoryList
			$("#resultHistoryList").append($("#result").html());
			$("#result").html("");
			arr = new Object();
			addMain(arr);
			var otherTime = Math.floor(Math.random()*3+2);
			addOther(arr,otherTime);
			arr.otherTime = otherTime;
			arr.upTime = 0;
			$.each(arr,function(index,value){
				if(!(index == "otherNums" || index == "upTime" || index == "otherTime")){
					$("#result").append(arr[index]+"
"
); } }) }) $("#upy").click(function(){ if(arr.otherTime == undefined){ alert("先生成一個"); return; } var type = parseInt($("input[name='upy']:checked").val()); for (i=0;i<type;i++) { if(arr.upTime >= 5){ break; } arr.upTime++; arr.main1Status = (arr.main1Status+=(addStatusMain(arr.main1)*3)) if(arr.otherTime < 4){ if(Math.random() > 0.5){ arr.otherTime = arr.otherTime + 1; addNewStatus(arr,arr.otherTime); }else{ addNowStatus(arr); } }else{ addNowStatus(arr); } } $("#result").html(""); $.each(arr,function(index,value){ if(!(index == "otherNums" || index == "upTime" || index == "otherTime")){ $("#result").append(arr[index]+"
"
); } }) })
script> html>

你可能感兴趣的:(js游乐系列)