Mercurial > hgrepos > hgweb.cgi > skipweb
changeset 883:5f56d9a6abed
preopen
author | ARAKI Tsuyohito <c113007@e.koeki-u.ac.jp> |
---|---|
date | Sat, 24 Oct 2015 11:07:58 +0900 |
parents | ff96f149289b |
children | 9e86f885c098 |
files | opencampus2015/accountcheck.rb opencampus2015/cookie.rb opencampus2015/prof.rb opencampus2015/profeel.css opencampus2015/quest.rb |
diffstat | 5 files changed, 190 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/opencampus2015/accountcheck.rb Sat Oct 24 08:32:26 2015 +0900 +++ b/opencampus2015/accountcheck.rb Sat Oct 24 11:07:58 2015 +0900 @@ -103,7 +103,7 @@ -expires = "SAT, 24 Oct 2015 00:00:00 GMT" +expires = "SUN, 25 Oct 2015 00:00:00 GMT" printf("Content-type: text/html; charset=UTF-8 Set-Cookie:id=%s ;expires=%s
--- a/opencampus2015/cookie.rb Sat Oct 24 08:32:26 2015 +0900 +++ b/opencampus2015/cookie.rb Sat Oct 24 11:07:58 2015 +0900 @@ -28,8 +28,10 @@ <title>Registering Account</title> </head> <body> -<h1>さかたっち</h1> -<h2>cookieを削除しました!</h2> -<a href="index.html">とうろくがめんへ!</a> +<h1>Miyazac Quest</h1> +<h2>記憶は消えた...</h2> + +<div class="f1"><div class="lets"> +<a href="index.html">新しい記録を作成</a></div></div> </body></html> _EOS_
--- a/opencampus2015/prof.rb Sat Oct 24 08:32:26 2015 +0900 +++ b/opencampus2015/prof.rb Sat Oct 24 11:07:58 2015 +0900 @@ -33,7 +33,7 @@ aria = cook[0][5] exp = cook[0][6] pt = cook[0][7] -lv = cook[0][8] +#lv = cook[0][8] rescue printf(<<_EOS_) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" @@ -196,31 +196,34 @@ ####################################################### ##################################レベル処理する#### -e1 = db.execute("select e1 from box where id = ?",id)[0].to_i#じぶんのidのboxにある一体目の経験値 -no1 = db.execute("select no1 from box where id = ?",id) -wlv = "select ? from zukan where no = ?" -lv2 = db.execute(wlv,lv2,no1)[0].to_i -lv3 = db.execute(wlv,lv3,no1)[0].to_i -lv4 = db.execute(wlv,lv4,no1)[0].to_i -lv5 = db.execute(wlv,lv5,no1)[0].to_i +lv = 1 +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 -end -################################################## +gage = 100-(e1-lv2)/(lv3-lv2.to_f)*100 +end######################################### - m1 = "馬小屋" - mimg1 = "./img/food.png" - m2 = "客室" - mimg2 = "./img/niku.png" image = "./img/#{cal}#{lv}.png" alt = "#{cal}.png" @@ -248,15 +251,29 @@ #exppoint = "select e1 from box where id = ?" #じぶんのidのboxにある一体目の経験値 #expp = db.execute(exppoint,id) #exp = expp[0][0].to_i -gage = 0 +#gage = 0 #gage2 = db.execute("select no1 from box where id = ?",id) #exp2 = exp #esa = "<br><br><br>" - - - - +wcname ="select name from zukan where no = ?" +cal1 = db.execute(wcname,no1)[0][0] +begin +cal2 = db.execute(wcname,no2.to_s)[0][0] +rescue +cal2 = db.execute(wcname,no2.to_s)[0] +end +begin +cal3 = db.execute(wcname,no3.to_s)[0][0] +rescue +cal3 = db.execute(wcname,no3.to_s)[0] +end +chengeform = '<select name="chenge"><option value = 0>' + "#{cal1}" +if no2 > 0 && no3 >0 + chengeform +="<option value = 2>#{cal2}<option value = 3>#{cal3}" +elsif no2 > 0 && no3 > 0 + chengeform +="<option value = 2>#{cal2}" +end ######################## ###lv==5のとき画像を変える### @@ -266,7 +283,7 @@ ###################################--HTML--################## ###################################--------################## -printf(<<_EOS_, per, gage, per, per, per, color, kakunin, kkget, image, alt, name, person, cal, lv, pt, m1, mimg1,m2,mimg2) +printf(<<_EOS_, per, gage, per, per, per, color, kakunin, kkget, image, alt, name, person, cal, lv, chengeform ,pt) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" @@ -329,28 +346,28 @@ </div> <form method="POST" action="quest.rb"> +%s <input type="submit" value="~魔王の迷宮へ~"> </form> <p>coin:%d$</p> <table><tr><td> -<!-- <form method="POST" action="gohan.rb"> <label><input type="checkbox" name="hdn">宿屋<div><br> -<label><input type="radio" name="gohan" value="g1">%s:0$<img src=%s width="16" height="16"></label><br> -<label><input type="radio" name="gohan" value="g2">%s:5$<img src=%s width="16" height="16"></label><br> +<label><input type="radio" name="gohan" value="g1">馬小屋:10$<img src="./img/food.png" width="16" height="16"></label><br> +<label><input type="radio" name="gohan" value="g2">客室:50$<img src="./img/niku.png" width="16" height="16"></label><br> <input type="reset" value="やめる"> -<input type="submit" value="泊まる"></div></label><br> - ---> - +<input type="submit" value="泊まる"></div></label> </div></label></form> </td><td> -</form> +<form method="POST" action="cookie.rb"> +<label><input type="checkbox" name="hdn">人生リセット<div><br><br><br> +<input type="reset" value="やめる"> +<input type="submit" value="記憶を消す"></div></label> +</div></label></form> </td></tr></table> <footer></footer> </body> </html> _EOS_ -print "#{expp}"
--- a/opencampus2015/profeel.css Sat Oct 24 08:32:26 2015 +0900 +++ b/opencampus2015/profeel.css Sat Oct 24 11:07:58 2015 +0900 @@ -68,3 +68,8 @@ background: #eef; border: solid 2px navy;} +div.calque {margin-left:auto; margin-right:auto; +width: 180px; height: 180px; +background: #eef; +border: solid 2px navy;} +
--- a/opencampus2015/quest.rb Sat Oct 24 08:32:26 2015 +0900 +++ b/opencampus2015/quest.rb Sat Oct 24 11:07:58 2015 +0900 @@ -7,11 +7,73 @@ c = CGI.new(:tag_maker => "html5", :accept_charest => "UTF-8") db = SQLite3::Database.new("sql/main.sq3") +id = c.cookies["id"][0].to_i +chenge = c["chenge"].to_i +box = db.execute("select * from box where id = ?",id) +no1 = box[0][1] +e1 = box[0][2] +t1 = box[0][3] +tm1 = box[0][4] +no2 = box[0][5] +e2 = box[0][6] +t2 = box[0][7] +tm2 = box[0][8] +no3 = box[0][9] +e3 = box[0][10] +t3 = box[0][11] +tm3 = box[0][12] +newname = "select name from zukan where no = ?" +if chenge == 2 + db.execute("update box set no1=?,e1=?,t1=?,tm1=?,no2=?,e2=?,t2=?,tm2=? where id = ?",no2,e2,t2,tm2,no1,e1,t1,tm1,id) +elsif chenge == 3 + db.execute("update box set no1=?,e1=?,t1=?,tm1=?,no3=?,e3=?,t3=?,tm3=? where id = ?",no3,e3,t3,tm3,no1,e1,t1,tm1,id) +end +calname = db.execute(newname,no1)[0][0] +db.execute("update test set cal = ? where id = ?",calname,id) -id = c.cookies["id"][0].to_i -cmps = c["cmps"] + + cmps = c["cmps"] x = 0 +per ="%" newone = "" + +data = "select * from test where id = ?" +cook = db.execute(data, id) +begin +cal = cook[0][2] +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@xxxx.co.jp</address> +<footer></footer> +</body> +</html> + +_EOS_ +exit(0) ##プログラム終了! これがないと以降のプログラムが動いてしまう。 +end ################################## #card = "select " 設定してる予定のi1,i2,i3を選びたい。どこから? メインテーブル? それようのテーブル? exppoint = "select e1 from box where id = ?" #じぶんのidのboxにある一体目の経験値 @@ -81,7 +143,55 @@ <input type="submit" name="cmps" value="↑"> <input type="submit" name="cmps" value="→">' end -printf(<<_EOS_,cmps,xs,newone,cmpsget) + +lv = 1 +gage = 0 +e1 = db.execute("select e1 from box where id = ?",id)[0][0]#じぶんのidのboxにある一体目の経験値 +no1 = db.execute("select no1 from box where id = ?",id)[0][0] +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 + + +################################################## +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 + +image = "./img/#{cal}#{lv}.png" +alt = "#{cal}.png" + + +printf(<<_EOS_,per,gage,per,per,per,color,cmps,xs,newone,image,alt,cmpsget) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" @@ -104,6 +214,20 @@ <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.calque div{float:center; border:solid %s;} + --> </style> </head> @@ -111,6 +235,12 @@ <body> <h1>だぁんじょん%s</h1> <p>%s %s</p> +<div class="calque"> +<div> +<img src=%s alt=%s width="172" height="172"> +</div> +</div> + <div class="gage"> <p class="gage">exp</p> </div>