Mercurial > hgrepos > hgweb.cgi > skipweb
changeset 3255:3304ef38a5d0
merge
author | OOTANI Hiroyuki <c115036@g.koeki-u.ac.jp> |
---|---|
date | Fri, 15 Jul 2016 14:26:06 +0900 |
parents | fcda35a306e0 (current diff) cf7524428295 (diff) |
children | 9a85a24d3c7c |
files | oasis2016/.htaccess oasis2016/tori/ckgame.html oasis2016/tori/ckgame.rb oasis2016/tori/ckgame2.rb oasis2016/tori/db/point.yaml oasis2016/tori/tori-0.jpg oasis2016/tori/tori-1.jpg oasis2016/tori/tori-2.jpg oasis2016/tori/tori-3.jpg oasis2016/tori/tori-4.jpg oasis2016/tori/tori-5.jpg oasis2016/tori/tori.jpg oasis2016/tori/tori2.png |
diffstat | 15 files changed, 15 insertions(+), 258 deletions(-) [+] |
line wrap: on
line diff
--- a/event/oasis2016/tori/ckgame.rb Fri Jul 15 14:25:08 2016 +0900 +++ b/event/oasis2016/tori/ckgame.rb Fri Jul 15 14:26:06 2016 +0900 @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- require 'yaml/store' file = "db/point.yaml" -bingoword = %w(a b c d e f) # 正解キーワード9つ +bingoword = %w(a b c d e g) # 正解キーワード9つ require 'cgi' c = CGI.new(:accept_charset => "UTF-8") @@ -77,7 +77,7 @@ kaisen4 = '<img src="tori-1.jpg" width="150px" height="225px">' elsif /e/ =~ f kaisen5 = '<img src="tori-4.jpg" width="150px" height="225px">' - elsif /f/ =~ f + elsif /g/ =~ f kaisen6 = '<img src="tori-5.jpg" width="150px" height="225px">' end end @@ -92,20 +92,14 @@ position: relative; width: 450px; height: 450px; border: 1px solid #f9f5a9; margin: 1em auto; } -div.don div {width: 150px; height: 225px; margin: 0px;} -div.don div:first-child {left: 0px; top: 0px} -div.don div:nth-child(2) {position: absolute; left: 150px; top: 0px; -} -div.don div:nth-child(3) {position: absolute; left: 0px; top: 225px; -} -div.don div:nth-child(4) {position: absolute; left: 300px; top: 0px; -;} -div.don div:nth-child(5) {position: absolute; left: 150px; top: 225px; -} -div.don div:nth-child(7) {position: absolute; left: 300px; top: 225px; -} -div.don div:nth-child(6) {position: absolute; left: 300px; top: 225px; -} +div.tori div {width: 150px; height: 225px; margin: 0px;} +div.tori div:first-child {left: 0px; top: 0px} +div.tori div:nth-child(2) {position: absolute; left: 150px; top: 0px;} +div.tori div:nth-child(3) {position: absolute; left: 0px; top: 225px;} +div.tori div:nth-child(4) {position: absolute; left: 300px; top: 0px;} +div.tori div:nth-child(5) {position: absolute; left: 150px; top: 225px;} +div.tori div:nth-child(7) {position: absolute; left: 300px; top: 225px;} +div.tori div:nth-child(6) {position: absolute; left: 300px; top: 225px;} body{text-align:center; @@ -134,7 +128,7 @@ <div>%s</div> <div>%s</div> <div>%s</div> -<div>%s</div></div> +</div> </body></html> EOF title, setumei, setumei2, hello, point, bingoword.length, bingos, guide, input, seikai, kaisen, kaisen4, kaisen7, kaisen2, kaisen5, kaisen8, kaisen6, kaisen3, kaisen9,)
--- a/event/oasis2016/tori/db/point.yaml Fri Jul 15 14:25:08 2016 +0900 +++ b/event/oasis2016/tori/db/point.yaml Fri Jul 15 14:26:06 2016 +0900 @@ -1,3 +1,6 @@ --- info: - 1468558266/30835: {} + 1468558266/30835: + name: otamesi + bingo: + e: true
--- a/oasis2016/.htaccess Fri Jul 15 14:25:08 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -AddHandler cgi-script .rb -Options +ExecCGI -AddType "text/html; charset=utf-8" .html
--- a/oasis2016/tori/ckgame.html Fri Jul 15 14:25:08 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -<!DOCTYPE html> -<html lang="ja"> -<head><title>○○ゲーム</title></head> -<body> -<h1>もっけ さんのホーム</h1> -<p></p> -<p>当てたキーワード(4/4): 「もっけ」, 「げっぱ」, 「はっこ」, 「やばち」 -</p> -<form action="?" method="POST"> -<p>キーワードを入れてください: <input name="keyword"><br> -<input type="submit" value="送信"> -<input type="reset" value="リセット"></p> -</form></body></html>
--- a/oasis2016/tori/ckgame.rb Fri Jul 15 14:25:08 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -#!/usr/bin/env ruby -# -*- coding: utf-8 -*- -require 'yaml/store' -file = "db/point.yaml" -bingoword = %w(a b c d e f) # 正解キーワード9つ - -require 'cgi' -c = CGI.new(:accept_charset => "UTF-8") - -# 前回のアクセスで既にcookieが定義されていたら取得 -# ブラウザからのcookieは、c.cookies[変数名][0] で受け取る -cookie_id=c.cookies["id"][0] - -# 前回のアクセスで入力された値を取得 -form_name=c["playname"] # nameをフォームから取得(もしあれば) -form_kwd=c["keyword"] # keywordも取得(もしあれば) - -if cookie_id == nil # (1)もしcookieからのidがなければ新規生成 - # 新規idは、現在時刻を秒(to_i)にした文字列(to_s)と乱数の組み合わせ - newid = Time.now.to_i.to_s + "/" + rand(99999).to_s - id=newid # 新規idをidとする -else # (2)cookieからのidがあればそれをidとする - id=cookie_id -end - -# idをすぐcookieで相手ブラウザに送る -# 変数の期限を24時間に設定し、expire変数に入れる -expire = (Time.now+24*3600).gmtime.strftime("%a, %d %b %Y %H:%M:%S GMT") -printf("Content-type: text/html; charset=UTF-8\n") -printf("Set-Cookie: id=%s; expires=%s\n\n", id, expire) - -db = YAML::Store.new(file) -db.transaction do - info = db["info"] = db.fetch("info", Hash.new) - if !info[id] # もしそのユーザ情報が未登録(空)なら - info[id] = Hash.new # 新規ハッシュを割り当てる - end - if form_name > "" # formからの名前設定がもしあれば - info[id]["name"] = form_name # それをユーザ情報に記録 - info[id]["bingo"] = Hash.new # 正解した単語保存用のハッシュも作成 - end - point = 0# 開始直後は0点 - if !info[id]["name"] # もしユーザのプレイ名が未設定なら - title = "ようこそ!" - hello = "まちがいさがしスタート" - guide = "あなたのプレイ名を決めます" - input = '<input name="playname">' - else # プレイ名設定済みならキーワード入力 - title = sprintf("%s さんのホーム", info[id]["name"]) - setumei = "海鳥の絵から間違いを3個見つけよう!" - setumei2 = "間違っている絵のパネルは全部で4個あるよ♪" - guide = "キーワードを入れてください" - input = '<input name="keyword">' - seikai = '<img src="tori.jpg" width="450px" height="450px">' - # プレイ名設定済みで、さらにキーワードが入力されていたら - if form_kwd > "" - index = bingoword.index(form_kwd) # 配列から入力単語(form_kwd)を探索 - hello = sprintf("現在のポイントは %dpt です。", 25*point) - if index - # 見付かった! その単語をハッシュのキーとして適当に値(true)を入れておく - info[id]["bingo"][bingoword[index]] = true - end - end - point = info[id]["bingo"].length # ハッシュの長さで正解数が分かる - bingos = info[id]["bingo"].keys.collect do |x| - "「" + x + "」"# collectメソッドで 「 」 で括った単語を集めて - end.join(", ")# joinメソッドで ,(カンマ) 区切りでつなげる - kaisen = ""; kaisen2 = ""; kaisen3 = ""; kaisen4 = ""; kaisen5 = ""; kaisen6 = '<img src="tori-5.jpg" width="150px" height="225px">'; kaisen7 = ""; kaisen8 = ""; kaisen9 = "" - info[id]["bingo"].keys.each do |f| - if /a/ =~ f - kaisen = '<img src="tori-0.jpg" width="150px" height="225px">' - elsif /b/ =~ f - kaisen2 = '<img src="tori-2.jpg" width="150px" height="225px">'#左下 - elsif /c/ =~ f - kaisen3 = '<img src="tori-3.jpg" width="150px" height="225px">' - elsif /d/ =~ f - kaisen4 = '<img src="tori-1.jpg" width="150px" height="225px">' - elsif /e/ =~ f - kaisen5 = '<img src="tori-4.jpg" width="150px" height="225px">' - elsif /f/ =~ f - kaisen6 = '<img src="tori-5.jpg" width="150px" height="225px">' - end - end - end -printf(<<-EOF, -<!DOCTYPE html> -<html lang="ja"> -<head><title>まちがいみつけでみっちゃ</title> -<style type="text/css"> -<!-- -div.don { - position: relative; width: 450px; height: 450px; - border: 1px solid #f9f5a9; margin: 1em auto; -} -div.don div {width: 150px; height: 225px; margin: 0px;} -div.don div:first-child {left: 0px; top: 0px} -div.don div:nth-child(2) {position: absolute; left: 150px; top: 0px; -} -div.don div:nth-child(3) {position: absolute; left: 0px; top: 225px; -} -div.don div:nth-child(4) {position: absolute; left: 300px; top: 0px; -;} -div.don div:nth-child(5) {position: absolute; left: 150px; top: 225px; -} -div.don div:nth-child(7) {position: absolute; left: 300px; top: 225px; -} -div.don div:nth-child(6) {position: absolute; left: 300px; top: 225px; -} - - -body{text-align:center; -background:#f9f5a9;} ---> -</style> -</head> -<body> -<img src="rogo.png" width="900px" height="100px"> -<h1>%s</h1> -<h2>%s</h2> -<h2>%s</h2> -<p>%s</p> -<p>開けたパネル(%d/%d): %s</p> -<form action="?" method="GET"> -<p>%s: %s<br> -<input type="submit" value="送信"> -<input type="reset" value="リセット"></p> -</form> -<p>%s</p> -<div class="don"> -<div>%s</div> -<div>%s</div> -<div>%s</div> -<div>%s</div> -<div>%s</div> -<div>%s</div> -<div>%s</div> -<div>%s</div></div> -</body></html> -EOF - title, setumei, setumei2, hello, point, bingoword.length, bingos, guide, input, seikai, kaisen, kaisen4, kaisen7, kaisen2, kaisen5, kaisen8, kaisen6, kaisen3, kaisen9,) -end
--- a/oasis2016/tori/ckgame2.rb Fri Jul 15 14:25:08 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -#!/usr/bin/env ruby -# -*- coding: utf-8 -*- - -bingoword = %w(もっけ やばち はっこ げっぱ) # 正解キーワード4つ - -require 'cgi' -c = CGI.new(:accept_charset => "UTF-8") - -# 前回のアクセスで既にcookieが定義されていたら取得 -# ブラウザからのcookieは、c.cookies[変数名][0] で受け取る -cookie_id=c.cookies["id"][0] - -# 前回のアクセスで入力された値を取得 -form_name=c["playname"] # nameをフォームから取得(もしあれば) -form_kwd=c["keyword"] # keywordも取得(もしあれば) - -if cookie_id == nil # (1)もしcookieからのidがなければ新規生成 - # 新規idは、現在時刻を秒(to_i)にした文字列(to_s)と乱数の組み合わせ - newid = Time.now.to_i.to_s + "/" + rand(99999).to_s - id=newid # 新規idをidとする -else # (2)cookieからのidがあればそれをidとする - id=cookie_id -end - -# idをすぐcookieで相手ブラウザに送る -# 変数の期限を24時間に設定し、expire変数に入れる -expire = (Time.now+24*3600).gmtime.strftime("%a, %d %b %Y %H:%M:%S GMT") -printf("Content-type: text/html; charset=UTF-8\n") -printf("Set-Cookie: id=%s; expires=%s\n\n", id, expire) - -db = YAML::Store.new(file) -db.transaction do - info = db["info"] = db.fetch("info", Hash.new) - if !info[id] # もしそのユーザ情報が未登録(空)なら - info[id] = Hash.new # 新規ハッシュを割り当てる - end - if form_name > "" # formからの名前設定がもしあれば - info[id]["name"] = form_name # それをユーザ情報に記録 - info[id]["bingo"] = Hash.new # 正解した単語保存用のハッシュも作成 - end - point = 0 # 開始直後は0点 - if !info[id]["name"] # もしユーザのプレイ名が未設定なら - title = "○○ゲームへようこそ!" - hello = "ポイントゲームを始めましょう。" - guide = "あなたのプレイ名を決めます" - input = '<input name="playname">' - else # プレイ名設定済みならキーワード入力 - title = sprintf("%s さんのホーム", info[id]["name"]) - guide = "キーワードを入れてください" - input = '<input name="keyword">' - # プレイ名設定済みで、さらにキーワードが入力されていたら - if form_kwd > "" - index = bingoword.index(form_kwd) # 配列から入力単語(form_kwd)を探索 - hello = sprintf("現在のポイントは %dpt です。", 25*point) - if index - # 見付かった! その単語をハッシュのキーとして適当に値(true)を入れておく - info[id]["bingo"][bingoword[index]] = true - end - end - point = info[id]["bingo"].length # ハッシュの長さで正解数が分かる - bingos = info[id]["bingo"].keys.collect do |x| - "「" + x + "」" # collectメソッドで 「 」 で括った単語を集めて - end.join(", ") # joinメソッドで ,(カンマ) 区切りでつなげる - end - printf(<<-EOF, - <!DOCTYPE html> - <html lang="ja"> - <head><title>○○ゲーム</title></head> - <body> - <h1>%s</h1> - <p>%s</p> - <p>当てたキーワード(%d/%d): %s</p> - <form action="?" method="POST"> - <p>%s: %s<br> - <input type="submit" value="送信"> - <input type="reset" value="リセット"></p> - </form></body></html> - EOF - title, hello, point, bingoword.length, bingos, guide, input) -end