Games / Stone-paper-scissors
<%@ page import="java.io.*,xml.*,java.util.*" %>
<%
int count=0;
if (request.getParameter("count")!=null) count=Integer.parseInt(request.getParameter("count"));
int x=0;
int check=0;
if (request.getParameter("check")!=null) check=Integer.parseInt(request.getParameter("check"));
int y=0;
if (request.getParameter("y")!=null) y=Integer.parseInt(request.getParameter("y"));
if (check==0) {
Random r=new Random();
x=r.nextInt(3);
}else {
if (request.getParameter("x")!=null) x=Integer.parseInt(request.getParameter("x"));
}
String obj="";
String res="";
if (check==1) {
if (x==1) {
obj="Paper";
}
if (x==2) {
obj="Scissors";
}
if (x==0) {
obj="Stone";
}
// You lost ;
if (x==0 && y==2) {
res="You lose ";
count=count-1;
}
if (x==2 && y==1) {
res="You lose ";
count=count-1;
}
if (x==1 && y==0) {
res="You lose ";
count=count-1;
}
// You win
if (y==0 && x==2) {
res="You win ";
count=count+1;
}
if (y==1 && x==0) {
res="You win ";
count=count+1;
}
if (y==2 && x==1) {
res="You win ";
count=count+1;
}
// A draw
if (y==0 && x==0) {
res="Draw";
}
if (y==1 && x==1) {
res="Draw";
}
if (y==2 && x==2) {
res="Empate";
}
}
if (check==1) {
%>
Mister-i: <%=obj%>
Result:<%=res%>
Points:<%=count%>
Play again
<%
}
%>
<%
if (check==0) {
%>
<%
}
%>
Back to games
Mister-i Menu