JSP 랜덤사용 채널추첨기


확인하기(새 창)



위의 내용은 새로고침시 변경됩니다.

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<%@ page import="java.util.*" %> 
<%! 
  int type = 0; 
  int channel = 0; 
  int first, last = 0; 
  String channelStr, channelStr2; 
%> 
<!DOCTYPE HTML> 
<html> 
<head> 
<meta charset = "UTF-8"> 
<title>에픽빔 발사!</title> 
</head> 
<body> 
<% 
  Random r = new Random(); 
  type = r.nextInt(3); 
  int channelrandom = 0; 
  boolean isSingle = false; 
   
  switch(type) { 
  case 0: 
    channelrandom = r.nextInt(12); 
    channelStr = "일반지역"; 
    break; 
  case 1: 
    channelrandom = r.nextInt(5); 
    channelStr = "특수지역"; 
    break; 
  case 2: 
    channelrandom = r.nextInt(2); 
    channelStr = "일반채널"; 
    break; 
  default: 
    break; 
  } 
   
  if(type == 0) { 
    if(channelrandom == 0) { 
      first = 1; 
      last = 20; 
      channelStr2 = "실버크라운"; 
    } 
    else if(channelrandom == 1 || channelrandom == 3 || channelrandom == 5) { 
      first = 1; 
      last = 10; 
      if(channelrandom == 1) { 
        channelStr2 = "멜트다운"; 
      } 
      else if(channelrandom == 3) { 
        channelStr2 = "역천의 폭포"; 
      } 
      else if(channelrandom == 5) { 
        channelStr2 = "안트베르 협곡"; 
      } 
    } 
    else if(channelrandom == 2 || channelrandom == 4 || channelrandom == 8) { 
      first = 11; 
      last = 20; 
      if(channelrandom == 2) { 
        channelStr2 = "표류동굴"; 
      } 
      else if(channelrandom == 4) { 
        channelStr2 = "체념의 빙벽"; 
      } 
      else if(channelrandom == 8) { 
        channelStr2 = "파워스테이션"; 
      } 
    } 
    else if(channelrandom == 6) { 
      first = 1; 
      last = 5; 
      channelStr2 = "해상열차"; 
    } 
    else if(channelrandom == 7) { 
      first = 1; 
      last = 26; 
      channelStr2 = "시간의 문"; 
    } 
    else if(channelrandom == 9) { 
      first = 21; 
      last = 39; 
      channelStr2 = "노블스카이"; 
    } 
    else if(channelrandom == 10) { 
      first = 21; 
      last = 25; 
      channelStr2 = "죽은자의 성"; 
    } 
    else if(channelrandom == 11) { 
      first = 30; 
      last = 47; 
      channelStr2 = "메트로센터"; 
    } 
    else { 
      out.print("error : type is " + type + ", channel is " + channel); 
    } 
  } 
  else if(type == 1) { 
    if(channelrandom == 0) { 
      first = 21; 
      last = 25; 
      channelStr2 = "망자의 협곡"; 
    } 
    else if(channelrandom == 1){ 
      first = 1; 
      last = 10; 
      channelStr2 = "차원의 균열"; 
    } 
    else if(channelrandom == 2) { 
      first = 1; 
      last = 13; 
      channelStr2 = "이계 던전"; 
    } 
    else if(channelrandom == 3) { 
      first = 15; 
      last = 19; 
      channelStr2 = "고대 던전"; 
    } 
    else if(channelrandom == 4) { 
      first = 61; 
      last = 62; 
      channelStr2 = "거래 - 경매장"; 
    } 
  } 
  else if(type == 2) { 
    if(channelrandom == 0) { 
      isSingle = true; 
      channelStr2 = "거래 - 경매장"; 
    } 
    else if(channelrandom == 1) { 
      first = 63; 
      last = 64; 
      channelStr2 = "일반"; 
    } 
    else { 
      out.print("error : type is " + type + ", channel is " + channel); 
    } 
  } 
  if(isSingle == false) { 
    channel = r.nextInt((last-first)+1) + first; 
  } 
  else { 
    channel = 65; 
  } 
%> 
<%= channelStr %> <br> 
<%= channelStr2 %> &nbsp; 
<%=channel%>채널 
</body> 
</html>