#!/usr/bin/ruby
# coding: euc-jp
require 'rubygems'
require 'pg'
require 'cgi'
c = CGI.new(:accept_charset => "utf-8")
print"Content-type: text/html; charset=utf-8\n\n"
number = c["id"]
pswd = c["pass"]
log = c["Battle"]
check = 0
lvl = 0
ep = 0
qu = 0
namae = ""
myhp = 0
begin
conn = PGconn.connect('127.0.0.1','','','','semi','masahiro','l3nl3q1u')
a = "select id, password, name, level, exp, quest from userdata"
ip = conn.exec(a)
ip.each do |row|
if number == row["id"] && pswd == row["password"]
lvl = row["level"]
ep = row["exp"]
qu = row["quest"]
namae = row["name"]
myhp = lvl.to_i * 100
check = 1
end
if number == row["id"] && log == "1"
lvl = row["level"]
ep = row["exp"]
qu = row["quest"]
namae = row["name"]
myhp = lvl.to_i * 100
check = 1
end
end
end
print"<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<title>ユーザー登録</title>
<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">
</head>
<body>\n"
if check == 0
print"<h1>Error</h1><p>もう一度情報を確認してからログインしてください!</p>
<a href=\"login.html\">
<button class=\"css3button\">ログイン</button></a>\n"
elsif check == 1
print"<h1>ログイン完了</h1>
<p><span>Name:</span>#{namae}<br>
<span>Level:</span>#{lvl}<br>
<span>exp:</span>#{ep}</p>
<div class=\"center01\">
<h1>テストクエストステージ1</h1>
<h2>はじまりの森</h2>
<img src=\"forest.jpg\" width=\"480\" height=\"320\" alt=\"森\" title=\"森\">
<form method=\"POST\" action=\"battle.rb\">
<h1>はじまりの森</h1>
<button class=\"css3button\" type=\"submit\" name=\"thp\" value=\"100\">スタート</button>\n"
if qu > "0"
print"<h1>迷いの森の中で</h1>
<button class=\"css3button\" type=\"submit\" name=\"thp\" value=\"300\">スタート</button>\n"
end
if qu > "1"
print"<h1>右か左か・・・決断</h1>
<button class=\"css3button\" type=\"submit\" name=\"thp\" value=\"500\">スタート</button>\n"
end
if qu > "2"
print"<h1>森の中心部-聖域-</h1>
<button class=\"css3button\" type=\"submit\" name=\"thp\" value=\"1000\">スタート</button>\n"
end
print"<input type=\"hidden\" name=\"hp\" value=\"#{myhp}\">
<input type=\"hidden\" name=\"defohp\" value=\"#{myhp}\">
<input type=\"hidden\" name=\"namae\" value=\"#{namae}\">
<input type=\"hidden\" name=\"level\" value=\"#{lvl}\">
<input type=\"hidden\" name=\"exp\" value=\"#{ep}\">
<input type=\"hidden\" name=\"id\" value=\"#{number}\">
<input type=\"hidden\" name=\"count\" value=\"1\">\n"
end
print"</form></body>
</html>\n"