view opencampus2015/battle.rb @ 893:056a01b67a81

battle.rb
author ARAKI Tsuyohito <c113007@e.koeki-u.ac.jp>
date Wed, 28 Oct 2015 00:35:43 +0900
parents
children
line wrap: on
line source

#!/usr/bin/env ruby22
# -*- coding: utf-8 -*-
require 'cgi'
require 'sqlite3'
require 'kconv'
id = c.cookies["id"][0]
person = id.to_i

data = "select * from test where id = ?"
cook = db.execute(data, person)
printf("Content-type: text/html; charset=UTF-8\n\n")

begin
name = cook[0][1]
cal = cook[0][2]
age = cook[0][3]
sex = cook[0][4]
aria = cook[0][5]
exp = cook[0][6]
pt = cook[0][7]
lv = cook[0][8]
rescue
printf(<<_EOS_)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta name="viewport"
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<link media="only screen and (max-device-width:480px)"
href="smart.css" type="text/css" rel="stylesheet" />
<link media="screen and (min-device-width:481px)" href="profeel.css"
type="text/css" rel="stylesheet" />
<link rel="shortcut icon" href="./img/cabage.png"/>
<title>Miyazac Quest</title>
<style type="text/css">
<!--
-->
</style>
</head>

<body>
<header></header>
<h1>記録が無くなったようだ...</h1><h2>記憶も消してやりなおしたまえ......</h2>
<div class="f1"><a href="index.html"><div class="lets"><span>新規記憶の作成</span></div></a></div>
<div class="f1"><a href="cookie.rb"><div class="lets"><span>作成前に記憶を消す</span></div></a></div>
<address>skip&#x40;xxxx.co.jp</address>
<footer></footer>
</body>
</html>

_EOS_
exit(0)            ##プログラム終了! これがないと以降のプログラムが動いてしまう。
end


kkget = ""

########################~ここまでpt処理~###################
#######################################################

##################################レベル処理する####
gage = 0
e1 = db.execute("select e1 from box where id = ?",person)[0][0]#じぶんのidのboxにある一体目の経験値
no1 = db.execute("select no1 from box where id = ?",person)[0][0]
no2 = db.execute("select no2 from box where id = ?",person)[0][0].to_i#2体目id
no3 = db.execute("select no3 from box where id = ?",person)[0][0].to_i#3体目id
lv2 = db.execute("select lv2 from zukan where no = ?",no1)[0][0].to_i
lv3 = db.execute("select lv3 from zukan where no = ?",no1)[0][0].to_i
lv4 = db.execute("select lv4 from zukan where no = ?",no1)[0][0].to_i
lv5 = db.execute("select lv5 from zukan where no = ?",no1)[0][0].to_i
if e1 < lv2
lv = 1
gage = 100-(e1/lv2.to_f*100)
elsif e1 >= lv5
lv = 5
gage = 0
elsif e1 >= lv4
lv = 4
gage = 100-(e1-lv4)/(lv5-lv4.to_f)*100
elsif e1 >= lv3
lv = 3
gage = 100-(e1-lv3)/(lv4-lv3.to_f)*100
elsif e1 >= lv2
lv = 2
gage = 100-(e1-lv2)/(lv3-lv2.to_f)*100
end#########################################


image = "./img/#{cal}#{lv}.png"
alt = "#{cal}.png"



if lv == 1
  color = "black"
elsif lv == 2
  color = "navy"
elsif lv == 3
  color = "green"
elsif lv == 4
  color = "red"
elsif lv == 5
  color = "yellow"
else
  color = "pink"
  image = "./img/snail.png"
  alt = "snails_bug"
end

printf(<<_EOS_, per, gage, per, per, per, color, kakunin, kkget, image, alt, name, person, cal, lv)


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>

<meta name="viewport"
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<link media="only screen and (max-device-width:480px)"
href="smart.css" type="text/css" rel="stylesheet" />
<link media="screen and (min-device-width:481px)" href="profeel.css"
type="text/css" rel="stylesheet" />




<link rel="shortcut icon" href="./img/cabage.png"/>
<title>ほげほげ!</title>
<style type="text/css">
<!--
p.gage{
background:#adf;
margin-left:0%s;
margin-right:%d%s;
text-align:left;
border-radius: 10ex;
}
div.gage{
background:#ddf;
margin-left:20%s;
margin-right:20%s;
border-radius: 10ex;
}
div.cal div{float:left; border:solid %s;}

-->
</style>
</head>

<body>
<header><p>%s</p></header>
<h1>Miyazac Quest</h1>
<h2>%s</h2>

<div class="cal">
<div>
<img src=%s alt=%s width="172" height="172">
</div>
<table class="state"><tr><td>name</td><td>:%s</td></tr>
<tr><td>id</td><td>:%04d</td></tr>
<tr><td>cara</td><td>:%s</td></tr>
<tr><td>lv.</td><td>%d</td></tr>
</table>
</div>

<div class="gage">
<p class="gage">exp</p>
</div>

<footer></footer>
</body>
</html>

_EOS_

yatex.org