Commit b6998834 authored by 神楽坂玲奈's avatar 神楽坂玲奈

新主页

parent eab3a90f
......@@ -99,3 +99,30 @@ task :refresh_user_count => :environment do
puts "(#{user.id}/#{count})#{user.name}"
end
end
task :refresh_user_pass => :environment do
require 'cgi'
require 'open-uri'
servers = Server.all
users = []
User.find_each do |user|
if user.password.nil?
print "#{user.id} #{user.name} ..无密码\n"
next
end
users << user
end
threads = []
100.times do |i|
threads << Thread.new do
while user = users.pop
out = "#{user.id} #{user.name} "
servers.each do |server|
open("http://#{server.ip}:#{server.http_port}/?pass=#{server.password}&operation=forceuserpass&username=#{CGI.escape user.name}&password=#{CGI.escape user.password}"){|f|out << f.read + " "} rescue out << $!.inspect.encode("UTF-8", :invalid => :replace, :undef => :replace)
end
print out+"\n"
end
end
end
threads.each{|thread|thread.join}
end
\ No newline at end of file
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
/*!
* jQuery Cycle Lite Plugin
* http://malsup.com/jquery/cycle/lite/
* Copyright (c) 2008-2012 M. Alsup
* Version: 1.5 (05-MAR-2012)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Requires: jQuery v1.3.2 or later
*/
;(function($) {
var ver = 'Lite-1.5';
$.fn.cycle = function(options) {
return this.each(function() {
options = options || {};
if (this.cycleTimeout) clearTimeout(this.cycleTimeout);
this.cycleTimeout = 0;
this.cyclePause = 0;
var $cont = $(this);
var $slides = options.slideExpr ? $(options.slideExpr, this) : $cont.children();
var els = $slides.get();
if (els.length < 2) {
window.console && console.log('terminating; too few slides: ' + els.length);
return; // don't bother
}
// support metadata plugin (v1.0 and v2.0)
var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
if (meta)
opts = $.extend(opts, meta);
opts.before = opts.before ? [opts.before] : [];
opts.after = opts.after ? [opts.after] : [];
opts.after.unshift(function(){ opts.busy=0; });
// allow shorthand overrides of width, height and timeout
var cls = this.className;
opts.width = parseInt((cls.match(/w:(\d+)/)||[])[1]) || opts.width;
opts.height = parseInt((cls.match(/h:(\d+)/)||[])[1]) || opts.height;
opts.timeout = parseInt((cls.match(/t:(\d+)/)||[])[1]) || opts.timeout;
if ($cont.css('position') == 'static')
$cont.css('position', 'relative');
if (opts.width)
$cont.width(opts.width);
if (opts.height && opts.height != 'auto')
$cont.height(opts.height);
var first = 0;
$slides.css({position: 'absolute', top:0}).each(function(i) {
$(this).css('z-index', els.length-i)
});
$(els[first]).css('opacity',1).show(); // opacity bit needed to handle reinit case
if ($.browser.msie) els[first].style.removeAttribute('filter');
if (opts.fit && opts.width)
$slides.width(opts.width);
if (opts.fit && opts.height && opts.height != 'auto')
$slides.height(opts.height);
if (opts.pause)
$cont.hover(function(){this.cyclePause=1;}, function(){this.cyclePause=0;});
var txFn = $.fn.cycle.transitions[opts.fx];
txFn && txFn($cont, $slides, opts);
$slides.each(function() {
var $el = $(this);
this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height();
this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width();
});
if (opts.cssFirst)
$($slides[first]).css(opts.cssFirst);
if (opts.timeout) {
// ensure that timeout and speed settings are sane
if (opts.speed.constructor == String)
opts.speed = {slow: 600, fast: 200}[opts.speed] || 400;
if (!opts.sync)
opts.speed = opts.speed / 2;
while((opts.timeout - opts.speed) < 250)
opts.timeout += opts.speed;
}
opts.speedIn = opts.speed;
opts.speedOut = opts.speed;
opts.slideCount = els.length;
opts.currSlide = first;
opts.nextSlide = 1;
// fire artificial events
var e0 = $slides[first];
if (opts.before.length)
opts.before[0].apply(e0, [e0, e0, opts, true]);
if (opts.after.length > 1)
opts.after[1].apply(e0, [e0, e0, opts, true]);
if (opts.click && !opts.next)
opts.next = opts.click;
if (opts.next)
$(opts.next).unbind('click.cycle').bind('click.cycle', function(){return advance(els,opts,opts.rev?-1:1)});
if (opts.prev)
$(opts.prev).unbind('click.cycle').bind('click.cycle', function(){return advance(els,opts,opts.rev?1:-1)});
if (opts.timeout)
this.cycleTimeout = setTimeout(function() {
go(els,opts,0,!opts.rev)
}, opts.timeout + (opts.delay||0));
});
};
function go(els, opts, manual, fwd) {
if (opts.busy) return;
var p = els[0].parentNode, curr = els[opts.currSlide], next = els[opts.nextSlide];
if (p.cycleTimeout === 0 && !manual)
return;
if (manual || !p.cyclePause) {
if (opts.before.length)
$.each(opts.before, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
var after = function() {
if ($.browser.msie)
this.style.removeAttribute('filter');
$.each(opts.after, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
queueNext();
};
if (opts.nextSlide != opts.currSlide) {
opts.busy = 1;
$.fn.cycle.custom(curr, next, opts, after);
}
var roll = (opts.nextSlide + 1) == els.length;
opts.nextSlide = roll ? 0 : opts.nextSlide+1;
opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
} else {
queueNext();
}
function queueNext() {
if (opts.timeout)
p.cycleTimeout = setTimeout(function() { go(els,opts,0,!opts.rev) }, opts.timeout);
}
};
// advance slide forward or back
function advance(els, opts, val) {
var p = els[0].parentNode, timeout = p.cycleTimeout;
if (timeout) {
clearTimeout(timeout);
p.cycleTimeout = 0;
}
opts.nextSlide = opts.currSlide + val;
if (opts.nextSlide < 0) {
opts.nextSlide = els.length - 1;
}
else if (opts.nextSlide >= els.length) {
opts.nextSlide = 0;
}
go(els, opts, 1, val>=0);
return false;
};
$.fn.cycle.custom = function(curr, next, opts, cb) {
var $l = $(curr), $n = $(next);
$n.css(opts.cssBefore);
var fn = function() {$n.animate(opts.animIn, opts.speedIn, opts.easeIn, cb)};
$l.animate(opts.animOut, opts.speedOut, opts.easeOut, function() {
$l.css(opts.cssAfter);
if (!opts.sync) fn();
});
if (opts.sync) fn();
};
$.fn.cycle.transitions = {
fade: function($cont, $slides, opts) {
$slides.not(':eq(0)').hide();
opts.cssBefore = { opacity: 0, display: 'block' };
opts.cssAfter = { display: 'none' };
opts.animOut = { opacity: 0 };
opts.animIn = { opacity: 1 };
},
fadeout: function($cont, $slides, opts) {
opts.before.push(function(curr,next,opts,fwd) {
$(curr).css('zIndex',opts.slideCount + (fwd === true ? 1 : 0));
$(next).css('zIndex',opts.slideCount + (fwd === true ? 0 : 1));
});
$slides.not(':eq(0)').hide();
opts.cssBefore = { opacity: 1, display: 'block', zIndex: 1 };
opts.cssAfter = { display: 'none', zIndex: 0 };
opts.animOut = { opacity: 0 };
}
};
$.fn.cycle.ver = function() { return ver; };
// @see: http://malsup.com/jquery/cycle/lite/
$.fn.cycle.defaults = {
animIn: {},
animOut: {},
fx: 'fade',
after: null,
before: null,
cssBefore: {},
cssAfter: {},
delay: 0,
fit: 0,
height: 'auto',
metaAttr: 'cycle',
next: null,
pause: 0,
prev: null,
speed: 1000,
slideExpr: null,
sync: 1,
timeout: 4000
};
})(jQuery);
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
//= require jquery.cycle.lite
\ No newline at end of file
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
// Place all the styles related to the decks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
// Place all the styles related to the libraries controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
// Place all the styles related to the mycard controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
*{
margin:0;
padding:0;
}
body{
background:#244470 image-url("index/background.png");
font-family:"\5FAE\8F6F\96C5\9ED1";
}
a{
text-shadow:1px 1px 1px #0C2549;
text-decoration:none;
}
#nav a{
transition:all .3s ease-in-out;
text-decoration:none;
}
#nav a:link{
color:white;
}
#nav a:hover{
color:white;
margin-left:10px;
}
#nav a:visited{
color:white;
}
#nav{
width:900px;
height:50px;
background:#244470;
border-width:0 1px 1px 0;
border-style:solid;
border-color:#5B82B7;
border-radius:0 0 5px 5px;
color:white;
margin:0 auto;
font:small-caps 12px "\5FAE\8F6F\96C5\9ED1";
text-shadow:1px 1px 2px #0C2549;
}
.nav_logo{
width:120px;
height:30px;
margin:10px;
padding:0 0 0 5px;
border-width:0 1px 0 0;
border-style:solid;
border-color:#354e70;
display:block;
font:25px bold 'Nunito',sans-serif;
float:left;
}
.nav_link{
width:80px;
height:30px;
padding:0;
margin:10px;
border-width:0 1px 0 0;
border-style:solid;
border-color:#354e70;
display:block;
font:15px/30px "\5FAE\8F6F\96C5\9ED1";
float:left;
}
#main{
width:99.99%;
height:310px;
margin:60px 0 0 0;
background:rgba(243,243,243,0.6);
border-width:1px 0 0 1px;
border-style:solid;
border-color:#e1e1e1;
}
#main_sub{
width:900px;
margin:0 auto;
padding:30px 0 0 0;
}
#information{
width:390px;
float:left;
}
.title{
font:45px bold 'Nunito',sans-serif;
}
.subtitle{
font:30px "\5FAE\8F6F\96C5\9ED1";
}
.subinc{
font-size:15px;
color:#525252;
text-shadow:1px 1px 1px #f1f1f1;
margin:0 0 0 140px;
}
#download{
width:200px;
height:60px;
background:#AA7B2D;
border:rgba(255,255,255,0.3) solid 3px;
border-radius:10px;
margin:50px auto 0 auto;
}
.download_active{
color:white;
text-shadow:0px 0px 5px rgba(255,255,255,0.6);
font-size:25px;
text-align:center;
margin:5px 0 0 0;
display:block;
}
.download_information{
color:#f1f1f1;
text-shadow:0px 0px 2px rgba(255,255,255,0.4);
font-size:10px;
display:block;
text-align:center;
}
#slider{
clear:both;
width:500px;
padding:0;
margin:0 auto;
z-index:0;
clear:both;
display:block;
float:right;
}
.show1{
width:500px;
height:275px;
background:image-url("index/01.png");
margin:-215px 0 0 -10px;
border-radius:10px;
}
.show2{
width:500px;
height:275px;
background:image-url("index/02.png");
margin:-215px 0 0 -10px;
border-radius:10px;
}
.show3{
width:500px;
height:275px;
background:image-url("index/03.png");
margin:-210px 0 0 -10px;
border-radius:10px;
}
footer{
width:900px;
margin:0 auto;
}
#footer1{
height:200px;
width:300px;
border-right:1px #bfbfbf dashed;
margin-top:10px;
float:left;
}
#footer1 h2{
font:bold 15px/130% "\5FAE\8F6F\96C5\9ED1";
color:#2e2e2e;
text-shadow:1px 1px 1px #dedede;
}
#footer1 a{
font:12px/130% "\5FAE\8F6F\96C5\9ED1";
color:#2a2a2a;
text-shadow:1px 1px 1px #dedede;
}
#footer2{
height:200px;
width:300px;
border-right:1px #bfbfbf dashed;
margin-top:10px;
float:left;
}
#footer3{
width:280px;
float:left;
margin-top:10px;
padding-left:10px;
}
#footer3 h2{
font:bold 15px/130% "\5FAE\8F6F\96C5\9ED1";
color:#2e2e2e;
text-shadow:1px 1px 1px #dedede;
}
#footer3 a{
font:12px/130% "\5FAE\8F6F\96C5\9ED1";
color:#2a2a2a;
text-shadow:1px 1px 1px #dedede;
}
\ No newline at end of file
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }
p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }
pre {
background-color: #eee;
padding: 10px;
font-size: 11px; }
a {
color: #000;
&:visited {
color: #666; }
&:hover {
color: #fff;
background-color: #000; } }
div {
&.field, &.actions {
margin-bottom: 10px; } }
#notice {
color: green; }
.field_with_errors {
padding: 2px;
background-color: red;
display: table; }
#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff; }
ul li {
font-size: 12px;
list-style: square; } }
// Place all the styles related to the servers controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
......@@ -25,7 +25,7 @@ class CardsController < ApplicationController
@card = Card.find(params[:id])
@actions = [{"YGO战网" => users_path}, {"卡片列表" => cards_path}, @card]
respond_to do |format|
format.html # show.html.erb
format.html { redirect_to "http://www.ourocg.cn/Cards/View-#{@card.id}"}
format.json { render json: @card }
format.png { redirect_to @card.image }
end
......
class DecksController < ApplicationController
layout 'ygo'
# GET /decks
# GET /decks.json
def index
@decks = Deck.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @decks }
end
end
# GET /decks/1
# GET /decks/1.json
def show
@deck = Deck.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @deck }
end
end
# GET /decks/new
# GET /decks/new.json
def new
@deck = Deck.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @deck }
end
end
# GET /decks/1/edit
def edit
@deck = Deck.find(params[:id])
end
# POST /decks
# POST /decks.json
def create
@deck = Deck.new(params[:deck])
respond_to do |format|
if @deck.save
format.html { redirect_to @deck, notice: 'Deck was successfully created.' }
format.json { render json: @deck, status: :created, location: @deck }
else
format.html { render action: "new" }
format.json { render json: @deck.errors, status: :unprocessable_entity }
end
end
end
# PUT /decks/1
# PUT /decks/1.json
def update
@deck = Deck.find(params[:id])
respond_to do |format|
if @deck.update_attributes(params[:deck])
format.html { redirect_to @deck, notice: 'Deck was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @deck.errors, status: :unprocessable_entity }
end
end
end
# DELETE /decks/1
# DELETE /decks/1.json
def destroy
@deck = Deck.find(params[:id])
@deck.destroy
respond_to do |format|
format.html { redirect_to decks_url }
format.json { head :no_content }
end
end
end
#encoding: UTF-8
class LibrariesController < ApplicationController
layout 'ygo'
# GET /libraries
# GET /libraries.json
def index
@libraries = Library.all
@actions = [{t('mycard.battlenet') => users_path}, '卡组排行']
respond_to do |format|
format.html # index.html.erb
format.json { render json: @libraries }
end
end
# GET /libraries/1
# GET /libraries/1.json
def show
@library = Library.find(params[:id])
@actions = [{t('mycard.battlenet') => users_path}, {'卡组排行'=>libraries_path}, @library.name]
respond_to do |format|
format.html # show.html.erb
format.json { render json: @library }
end
end
# GET /libraries/new
# GET /libraries/new.json
def new
@library = Library.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @library }
end
end
# GET /libraries/1/edit
def edit
@library = Library.find(params[:id])
end
# POST /libraries
# POST /libraries.json
def create
@library = Library.new(params[:library])
respond_to do |format|
if @library.save
format.html { redirect_to @library, notice: 'Library was successfully created.' }
format.json { render json: @library, status: :created, location: @library }
else
format.html { render action: "new" }
format.json { render json: @library.errors, status: :unprocessable_entity }
end
end
end
# PUT /libraries/1
# PUT /libraries/1.json
def update
@library = Library.find(params[:id])
respond_to do |format|
if @library.update_attributes(params[:library])
format.html { redirect_to @library, notice: 'Library was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @library.errors, status: :unprocessable_entity }
end
end
end
# DELETE /libraries/1
# DELETE /libraries/1.json
def destroy
@library = Library.find(params[:id])
@library.destroy
respond_to do |format|
format.html { redirect_to libraries_url }
format.json { head :no_content }
end
end
end
......@@ -8,18 +8,21 @@ class RoomsController < ApplicationController
respond_to do |format|
format.html # index.html.erb
format.json do
open('http://140.113.242.66:7922/?operation=getroomjson', 'r:GBK') do |file|
JSON.parse(file.read.encode("UTF-8"))["rooms"].each do |r|
room = {id: r["roomid"].to_i, name: r["roomname"], status: r["istart"].to_sym, users: []}
r["users"].each do |u|
if u["id"] == "0"
user = {player: u["pos"].to_i%2+1, id: 0, name: u["name"], certified: false}
else
user = {player: u["pos"].to_i%2+1, id: User.find_by_name(u["name"]).id, name: u["name"], certified: true}
Server.all.each_with_index do |server, index|
open("http://#{server.ip}:#{server.http_port}/?operation=getroomjson", 'r:GBK') do |file|
JSON.parse(file.read.encode("UTF-8"))["rooms"].each do |r|
room = {id: ('A'.ord+index).chr + r["roomid"], name: r["roomname"], status: r["istart"].to_sym, users: []}
r["users"].each do |u|
if u["id"] == "0"
user = {player: u["pos"].to_i%2+1, id: 0, name: u["name"], certified: false}
else
user = User.find_by_name(u["name"])
user = {player: u["pos"].to_i%2+1, id: user ? user.id : 0, name: u["name"], certified: true}
end
room[:users] << user
end
room[:users] << user
@rooms << room
end
@rooms << room
end
end
render json: @rooms
......
class ServersController < ApplicationController
# GET /servers
# GET /servers.json
def index
@servers = Server.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @servers }
end
end
# GET /servers/1
# GET /servers/1.json
def show
@server = Server.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @server }
end
end
# GET /servers/new
# GET /servers/new.json
def new
@server = Server.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @server }
end
end
# GET /servers/1/edit
def edit
@server = Server.find(params[:id])
end
# POST /servers
# POST /servers.json
def create
@server = Server.new(params[:server])
respond_to do |format|
if @server.save
format.html { redirect_to @server, notice: 'Server was successfully created.' }
format.json { render json: @server, status: :created, location: @server }
else
format.html { render action: "new" }
format.json { render json: @server.errors, status: :unprocessable_entity }
end
end
end
# PUT /servers/1
# PUT /servers/1.json
def update
@server = Server.find(params[:id])
respond_to do |format|
if @server.update_attributes(params[:server])
format.html { redirect_to @server, notice: 'Server was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @server.errors, status: :unprocessable_entity }
end
end
end
# DELETE /servers/1
# DELETE /servers/1.json
def destroy
@server = Server.find(params[:id])
@server.destroy
respond_to do |format|
format.html { redirect_to servers_url }
format.json { head :no_content }
end
end
end
......@@ -21,7 +21,7 @@ class UsersController < ApplicationController
@actions = [{t('mycard.battlenet') => users_path}, @user]
respond_to do |format|
format.html # show.html.erb
#format.xml { render :xml => @user }
format.json { render :json => {id: @user.id, name: @user.name, nickname: @user.nickname} }
format.png {redirect_to @user.avatar.url(:middle)}
end
end
......@@ -63,28 +63,10 @@ class UsersController < ApplicationController
@actions = [User.human_attribute_name(:register)]
respond_to do |format|
if @user.save
reply = begin
open("http://140.113.242.66:7922/?pass=zh99998&operation=forceuserpass&username=#{CGI.escape @user.name}&password=#{CGI.escape @user.password}", 'r:GBK') do |file|
case reply = file.read.encode("UTF-8", :invalid=>:replace, :undef=>:replace )
when "ok"
open("http://140.113.242.66:7922/?pass=zh99998&operation=saveuser"){} rescue nil
true
else
reply
end
end
rescue Exception => exception
([exception] + exception.backtrace).join("\n")
end
if reply == true
session[:user_id] = @user.id
format.html { redirect_to(@user, :notice => '注册成功') }
format.xml { render :xml => @user, :status => :created, :location => @user }
else
@user.errors.add :name, "注册失败,可能是服务器故障,请与管理员联系 Email/GT/QQ: zh99998@gmail.com 详情: #{reply}"
format.html { render :action => "new" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
boardcast_user(@user)
session[:user_id] = @user.id
format.html { redirect_to(@user, :notice => '注册成功') }
format.xml { render :xml => @user, :status => :created, :location => @user }
else
format.html { render :action => "new" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
......@@ -138,32 +120,29 @@ class UsersController < ApplicationController
elsif user.nil? or user.password.nil?
username = params[:user][:name]
password = params[:user][:password]
open("http://140.113.242.66:7922/?operation=passcheck&username=#{CGI.escape username}&pass=#{CGI.escape password}") do |file|
file.set_encoding("GBK")
case file.read.encode("UTF-8")
when "true"
if user
Server.each do |server|
open("http://#{server.ip}:#{server.http_port}/?operation=passcheck&username=#{CGI.escape username}&pass=#{CGI.escape password}") do |file|
if file.read == "true"
user.password = password
@user = user
@user.save
else
@user = User.create(:name => username, :password => password)
break
end
end
end rescue nil
end rescue nil
break if @user
end
end
respond_to do |format|
if @user
session[:user_id] = @user.id
@user.update_attribute(:lastloginip, request.remote_ip)
boardcast_user(@user)
format.html { redirect_to(@user, :notice => 'Login Successfully.') }
format.xml { head :ok }
format.json { render json: @user }
else
@user = User.new(params[:user])
#@user.errors.add 'incorrent_username_or_password' #TODO: 查API
return render :text => 'incorrent_username_or_password'
format.html { render :action => "login" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
format.html { render :text => 'incorrent_username_or_password' }
format.json { head json: nil }
end
end
......@@ -189,4 +168,14 @@ class UsersController < ApplicationController
format.xml { head :ok }
end
end
end
def boardcast_user(user)
Server.find_each do |server|
url = "http://#{server.ip}:#{server.http_port}/?pass=#{server.password}&operation=forceuserpass&username=#{CGI.escape user.name}&password=#{CGI.escape user.password}"
if RUBY_PLATFORM["win"] || RUBY_PLATFORM["ming"]
open(url){} rescue nil
else
Process.spawn('curl', url)
end
end
end
end
\ No newline at end of file
module DecksHelper
end
module LibrariesHelper
end
module ServersHelper
end
class Deck < ActiveRecord::Base
#has_many :cards, :through =>
belongs_to :user
belongs_to :duel
belongs_to :library
end
class Library < ActiveRecord::Base
belongs_to :parent, :class_name => "Library"
has_many :decks
#has_many :cards, :through => :decks
def cards
#Card.joins(:duel_user_cards).
end
end
class Server < ActiveRecord::Base
end
......@@ -9,10 +9,10 @@ class User < ActiveRecord::Base
belongs_to :role
validates :name, :presence => true,
:length => {:minimum => 1, :maximum => 254},
:uniqueness => true
:uniqueness => {:case_sensitive => false}
validates :email, :presence => true,
:length => {:minimum => 3, :maximum => 254},
:uniqueness => true,
:uniqueness => {:case_sensitive => false},
:format => {:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i}
has_many :topics
has_many :posts, :through => :topics
......
<%= form_for(@deck) do |f| %>
<% if @deck.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@deck.errors.count, "error") %> prohibited this deck from being saved:</h2>
<ul>
<% @deck.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :string %><br />
<%= f.text_field :string %>
</div>
<div class="field">
<%= f.label :category %><br />
<%= f.text_field :category %>
</div>
<div class="field">
<%= f.label :user_id %><br />
<%= f.text_field :user_id %>
</div>
<div class="field">
<%= f.label :duel_id %><br />
<%= f.text_field :duel_id %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
<h1>Editing deck</h1>
<%= render 'form' %>
<%= link_to 'Show', @deck %> |
<%= link_to 'Back', decks_path %>
<h1>Listing decks</h1>
<table>
<tr>
<th>卡组</th>
<th>数量</th>
</tr>
<% Deck.find(:all, select: "*, count(*) as count", group: :category, order: "count DESC").each do |deck| %>
<tr>
<td><%= deck.category %></td>
<td><%= deck.count %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Deck', new_deck_path %>
<h1>New deck</h1>
<%= render 'form' %>
<%= link_to 'Back', decks_path %>
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @deck.name %>
</p>
<p>
<b>String:</b>
<%= @deck.string %>
</p>
<p>
<b>Category:</b>
<%= @deck.category %>
</p>
<p>
<b>User:</b>
<%= @deck.user_id %>
</p>
<p>
<b>Duel:</b>
<%= @deck.duel_id %>
</p>
<%= link_to 'Edit', edit_deck_path(@deck) %> |
<%= link_to 'Back', decks_path %>
<div id="onlineuser">
<strong><%=t 'stat.onlineuser' %></strong>
- <%=t 'stat.total' %> <em>0</em>
- <%=t 'stat.max' %> <em>0</em> <%=t 'stat.at' %> <em><%=l Time.now, :format => :long %> </em>.
<%=l Time.now, :format => :long %>
</div>
\ No newline at end of file
<%= form_tag :controller => :topics do %>
<%= form_tag :controller => :topics, :html => {id: search} do %>
<%= text_field_tag "keyword" %>
<%= submit_tag t("search.search") %>
<%= link_to t("search.advanced") %>
......
<div id="user">
<% if logged? %>
<cite><a href="space.php?uid=359" class="noborder"><%= @current_user %> </a></cite>
<span class="pipe">|</span>
<%= link_to t('user.my'), @current_user %>
<%= link_to t('user.space'), @current_user %>
<%#= link_to t('user.notice'), @current_user %>
<span id="myprompt_check"></span>
<%= link_to t('user.pm'), pms_path %>
<span class="pipe">|</span>
<%= link_to t('user.logout'), logout_path %>
<%= link_to @current_user.name, @current_user %>
<%= link_to Pm.model_name.human, pms_path %>
<%= link_to User.human_attribute_name('logout'), logout_path %>
<% else %>
<%= link_to t('user.login'), login_path %>
<%= link_to t('user.register'), new_user_path %>
<%= link_to User.human_attribute_name('login'), login_path %>
<%= link_to User.human_attribute_name('register'), register_path %>
<% end %>
</div>
\ No newline at end of file
......@@ -6,7 +6,7 @@
<%= stylesheet_link_tag 'common' %>
<%= stylesheet_link_tag params[:controller] %>
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag 'common' %>
<%= javascript_include_tag params[:controller] %>
<%= csrf_meta_tags %>
......@@ -21,12 +21,11 @@
<div class="header">
<embed src="<%= image_path('common/banner.swf') %>" quality="high" wmode="transparent" style="float:left;" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="898" height="116"></embed>
<div class="bg-dmenuleft"></div>
</div>
<div id="dmenu" class="bg-dmenu">
<nav id="menu">
<%= render "entries/navigation" %>
</nav>
<div id="dmenu" class="bg-dmenu">
<nav id="menu">
<%= render "entries/navigation" %>
</nav>
</div>
</div>
</header>
<nav id="actions">
......
<%= form_for(@library) do |f| %>
<% if @library.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@library.errors.count, "error") %> prohibited this library from being saved:</h2>
<ul>
<% @library.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :contents %><br />
<%= f.text_area :contents %>
</div>
<div class="field">
<%= f.label :parent %><br />
<%= f.text_field :parent %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
<h1>Editing library</h1>
<%= render 'form' %>
<%= link_to 'Show', @library %> |
<%= link_to 'Back', libraries_path %>
<table>
<tr>
<th>卡组</th>
<th>数量</th>
</tr>
<% Library.joins(:decks).group('library_id').order("COUNT(*) DESC").select('*, COUNT(*) as count').each do |library| %>
<tr>
<td><%= link_to library.name, library %></td>
<td><%= library.count %></td>
</tr>
<% end %>
</table>
\ No newline at end of file
<h1>New library</h1>
<%= render 'form' %>
<%= link_to 'Back', libraries_path %>
<meta charset="UTF-8" />
<%= @site.name %> <br />
<br />
<%= link_to User.human_attribute_name(:register), register_path %><br />
<br />
<%= link_to User.human_attribute_name(:login), login_path %><br />
<%= link_to t('mycard.download'), mycard_download_path %><br />
<br />
<%= link_to User.human_attribute_name(:index), users_path %><br />
<%= link_to User.human_attribute_name(:show), logged? ? @current_user : User.first %><br />
<%= link_to Card.human_attribute_name(:index), cards_path %><br />
<%= link_to Card.human_attribute_name(:show), Card.first %><br />
<%= link_to Duel.human_attribute_name(:index), duels_path %><br />
<%= link_to Duel.human_attribute_name(:show), Duel.last %><br />
<%= link_to Board.human_attribute_name(:index), boards_path %><br />
<%= link_to 'API', '/api' %><br />
\ No newline at end of file
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<link href='http://fonts.googleapis.com/css?family=Nunito:700' rel='stylesheet' type='text/css'>
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag 'mycard' %>
<%= stylesheet_link_tag 'mycard' %>
<title>Mycard - 萌卡</title>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#slider').cycle({
fx: 'fade', //特效 speed: 7500,
timeout: 7200,
random: 1
});
}); </script>
</head>
<body>
<header>
<nav id="nav">
<a class="nav_logo">MyCard</a>
<%= link_to "在线大厅", rooms_path, :class => "nav_link" %>
<%= link_to "用户排行", users_path,:class => "nav_link" %>
<%= link_to "常用卡片", cards_path, :class => "nav_link" %>
<%= link_to "常用卡组", decks_path, :class => "nav_link" %>
<%= link_to "论坛", boards_path, :class => "nav_link" %>
</nav>
</header>
<div id="main">
<div id="main_sub">
<div id="information">
<div>
<a class="title">Mycard</a>
<a class="subtitle">萌卡</a>
</br>
<a class="subinc">——大家一起萌起来 (/ ̄▽ ̄)/~</a>
<div id="download">
<%= link_to t('mycard.download'), mycard_download_path, :class => "download_active" %>
<a class="download_information">最新版本:<%= Dir.glob('public/mycard/mycard-*-win32.7z').max =~ /mycard\/mycard-(.*)-win32.7z/; $1 %></a>
</div>
</div>
</div>
<div id="slider">
<div class="show1"></div>
<div class="show2"></div>
<div class="show3"></div>
</div>
</div>
</div>
<footer>
<div id="footer1">
<h2>其他服务</h2>
<a href="/api">API</a>
</div>
<div id="footer2">
</div>
<div id="footer3">
<h2>版权申明</h2>
<a href="http://oapo.qzworld.net">
本作品的创作传播应遵循OAPO协议。
<img src="http://oapo.qzworld.net/images/icons/fee.png"></img>
<img src="http://oapo.qzworld.net/images/icons/use.png"></img>
</a>
</div>
</footer>
</body>
\ No newline at end of file
<%= form_for(@server) do |f| %>
<% if @server.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@server.errors.count, "error") %> prohibited this server from being saved:</h2>
<ul>
<% @server.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.text_field :password %>
</div>
<div class="field">
<%= f.label :ip %><br />
<%= f.text_field :ip %>
</div>
<div class="field">
<%= f.label :port %><br />
<%= f.number_field :port %>
</div>
<div class="field">
<%= f.label :http_port %><br />
<%= f.number_field :http_port %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
<h1>Editing server</h1>
<%= render 'form' %>
<%= link_to 'Show', @server %> |
<%= link_to 'Back', servers_path %>
<h1>Listing servers</h1>
<table>
<tr>
<th>Name</th>
<th>Password</th>
<th>Ip</th>
<th>Port</th>
<th>Http port</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @servers.each do |server| %>
<tr>
<td><%= server.name %></td>
<td><%= server.password %></td>
<td><%= server.ip %></td>
<td><%= server.port %></td>
<td><%= server.http_port %></td>
<td><%= link_to 'Show', server %></td>
<td><%= link_to 'Edit', edit_server_path(server) %></td>
<td><%= link_to 'Destroy', server, confirm: 'Are you sure?', method: :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Server', new_server_path %>
<h1>New server</h1>
<%= render 'form' %>
<%= link_to 'Back', servers_path %>
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @server.name %>
</p>
<p>
<b>Password:</b>
<%= @server.password %>
</p>
<p>
<b>Ip:</b>
<%= @server.ip %>
</p>
<p>
<b>Port:</b>
<%= @server.port %>
</p>
<p>
<b>Http port:</b>
<%= @server.http_port %>
</p>
<%= link_to 'Edit', edit_server_path(@server) %> |
<%= link_to 'Back', servers_path %>
......@@ -28,6 +28,8 @@
#error_explanation h2{background:#FF0066;margin:0;padding:4px 4px 4px 8px;font-size:14px;color:#ffffff;text-align:left; letter-spacing:0px}
#error_explanation h4{margin:4px 0 0 4px;padding:4px;text-align:left; font-weight:normal;font-size:12px;}
#error_explanation ul{padding:0 0 0 40px; text-align:left;font-size:12px;}
.field_with_errors label{color:#FF0066; text-shadow:1px 1px 5px #cccccc;font-weight:bold;}
.field_with_errors input{border:1px solid #FF0066;box-shadow:1px 1px 5px #999999,0px 0px 2px #999999 inset;}
</style>
<script type="text/javascript">
......@@ -76,25 +78,25 @@
<div class="main_div">
<div style="font-size:18px;margin:20px 0 10px 25px;padding:0 0 10px 0;border-bottom:1px solid #eeeeee;width:450px;"><%=t User.human_attribute_name :register %> </div>
<div class="inner_div">
<div class="floatleft form_label"><%= f.label :name %></div>
<div class="floatleft form_label"><%= f.label :name %></div>
<div class="floatleft">
<%= f.text_field :name, :id => :username, :class => :from_input %>
</div>
</div>
<div class="inner_div">
<div class="floatleft form_label"><%= f.label :password %></div>
<div class="floatleft form_label"><%= f.label :password %></div>
<div class="floatleft">
<%= f.text_field :password, :id => :password, :class => :from_input %>
<%= f.password_field :password, :id => :password, :class => :from_input %>
</div>
</div>
<div class="inner_div">
<div class="floatleft form_label"><%= f.label :password_repeat %></div>
<div class="floatleft form_label"><%= f.label :password_repeat %></div>
<div class="floatleft">
<%= f.text_field :password, :id => :rePassword, :class => :from_input %>
<%= f.password_field :password, :id => :rePassword, :class => :from_input %>
</div>
</div>
<div class="inner_div">
<div class="floatleft form_label"><%= f.label :email %></div>
<div class="floatleft form_label"><%= f.label :email %></div>
<div class="floatleft">
<%= f.text_field :email, :id => :email, :class => :from_input %>
</div>
......
#encoding: UTF-8
STDOUT.set_encoding("GBK", "UTF-8")
require 'yaml'
y = YAML.load_file 'deck.yml'
$sql = 'insert into decks (duel_id, user_id, library_id) select duel_id, user_id, (case ' + "\n"
ancestor = nil
ancestor_id = nil
has_child = false
y.each_with_index do |item, index|
key, values = item
id = index + 1
if values.first["parent"]
raise if values.shift["parent"] != ancestor #目前只允许一层嵌套
if has_child
else
$sql << "then case\n"
has_child = true
end
else
if ancestor
if has_child
$sql << "else '#{ancestor_id}' end\n"
else
$sql << "then '#{ancestor_id}'\n"
end
end
ancestor = key
ancestor_id = id
has_child = false
end
$sql << " when "
first = true
values.each do |value|
value["operator"] = '=' if value["operator"].nil?
condition = case value["operator"]
when 'instr'
result = "INSTR(#{value.keys.first}, '#{value[value.keys.first]}')"
if ancestor == key
result = "!(!(#{result}))"
end
result
when '=', '>=', '<=', '>', '<', '!='
"#{value.keys.first} #{value["operator"]} '#{value[value.keys.first]}'"
else
raise "UNKNOWN OPERATOR: #{value["operator"]}, #{key}, '#{value}'"
end
if first
first = false
else
$sql << "and "
end
if ancestor == key
$sql << "sum(#{condition}) >= #{value["count"]} "
else
$sql << "(select count(*) from duels_users_cards t left join cards c on t.card_id=c.id where t.duel_id = a.duel_id and t.user_id = a.user_id and #{condition}) >= #{value['count']} "
end
end
if ancestor != key
$sql << "then '#{id}'\n"
end
end
if has_child
$sql << "else '#{ancestor_id}' end\n"
else
$sql << "then '#{ancestor_id}'\n"
end
$sql << ' end
) as library_id from duels_users_cards a
left join cards b on a.card_id=b.id group by a.duel_id, a.user_id'
#puts $sql
db = YAML.load_file('database.yml')["development"]
require 'mysql2'
Mysql = Mysql2::Client.new(host: db["host"], username: db["username"], password: db["password"])
Mysql.query('use `mycard_production`')
Mysql.query('truncate table decks')
Mysql.query($sql)
圣刻:
- name: 圣刻龙
operator: instr
count: 3
圣刻遗式:
- parent: 圣刻
- card_type: 仪式魔法
count: 3
- name: 邪遗式熏风乌贼怪
count: 1
甲虫:
- name: 甲虫装机
operator: instr
count: 6
发条甲虫:
- parent: 甲虫
- name: 发条猎人
count: 1
- name: 发条鼠
count: 1
- name: 发条空母 发条巨舰
count: 1
发条:
- name: 发条
operator: instr
count: 6
暗黑界:
- name: 暗黑界
operator: instr
count: 6
技抽暗黑界:
- parent: 暗黑界
- name: 技能吸收
count: 2
代行:
- name: 神圣球体
count: 3
TG代行:
- name: 科技属 突击兵
count: 1
- name: 科技属 狼人
count: 1
神光代行:
- name: 神光之宣告者
count: 1
:
- name:
operator: instr
count: 3
- card_type: 场地魔法
count: 3
技抽罪:
- parent:
- name: 技能吸收
count: 2
守墓罪:
- parent:
- name: 守墓
operator: instr
count: 2
齿车罪:
- parent:
- name: 齿车街
count: 2
EH:
- name: 元素英雄
operator: instr
count: 4
光2HB:
- parent: EH
- name: 二重电光
count: 2
废二:
- name: 废品同调士
count: 2
- name: 二重身战士
count: 2
王道废二:
- parent: 废二
- name: 王道战士
count: 2
TG废二:
- parent: 废二
- name: 科技属 突击兵
count: 1
- name: 科技属 狼人
count: 1
遗式:
- name: 遗式
operator: instr
count: 4
- card_type: 仪式魔法
count: 1
手控向遗式:
- parent: 遗式
- name: 邪遗式熏风乌贼怪
count: 2
L10遗式:
- parent: 遗式
- name: 邪遗式魂魄巨灵
count: 2
冰结界:
- name: 冰结界
operator: instr
count: 6
苏生冰结界:
- parent: 冰结界
- name: 冰结界的传道师
count: 2
:
- name:
operator: instr
count: 4
蛙帝:
- parent:
- name: 黄泉青蛙
count: 1
次元帝:
- parent:
- name: 异次元的侦察机
count: 1
埃及使者:
- name: 被封印
operator: instr
count: 3
书抽:
- parent: 埃及使者
- name: 王立魔法图书馆
count: 2
龙抽:
- parent: 埃及使者
- name: 调和的宝札
count: 2
竹光抽:
- parent: 埃及使者
- name: 黄金色的竹光
count: 2
凡骨抽:
- parent: 埃及使者
- name: 凡人的意志
count: 1
兔超量:
- name: 救援兔
count: 2
侏罗纪入魔兔:
- parent: 兔超量
- type: 恐龙
count: 2
- name: 入魔
operator: instr
count: 2
侏罗纪忍者兔:
- parent: 兔超量
- type: 恐龙
count: 2
- name: 忍法 超变化之术
count: 2
暗轴入魔兔:
- parent: 兔超量
- name: 入魔
operator: instr
count: 4
- name: 侵略的泛发感染
count: 1
六武众:
- name: 六武众
operator: instr
count: 4
荒行六武:
- parent: 六武众
- name: 六武众的荒行
count: 2
水火六武:
- parent: 六武众
- name: 真六武众 瑞穗
count: 1
- name: 真六武众 竹刀
count: 1
永火:
- name: 永火
operator: instr
count: 4
剑斗兽:
- name: 剑斗
operator: instr
count: 4
到来斗:
- parent: 剑斗兽
- name: 英雄到来
count: 1
鸟斗:
- parent: 剑斗兽
- name: 神鸟攻击
count: 1
X剑士:
- name: X-剑士
operator: instr
count: 6
- name: XX-剑士
operator: instr
count: 2
光帝剑:
- name: 光帝 克赖斯
count: 1
- name: 凤凰剑圣 基亚·弗里德
count: 1
不死:
- type: 不死
count: 6
- name: 僵尸带菌者
count: 1
倒计时:
- name: 终焉的倒计时
count: 2
入魔:
- name: 入魔
operator: instr
count: 6
壶削:
- name: 日全食之书
count: 1
- name: 太阳之书
count: 1
虫削:
- parent: 壶削
- name: 针虫
count: 2
次元削:
- parent: 壶削
- name: 次元裂缝
count: 1
黑羽:
- name: 黑羽
operator: instr
count: 6
旋风黑羽:
- parent: 黑羽
- name: 黑旋风
count: 1
墓地黑羽:
- parent: 黑羽
- name: 黑羽-大旆之伐由
count: 2
变形斗士:
- name: 变形斗士
operator: instr
count: 4
- name: 动力工具龙
count: 2
副作用:
- name: 药物的副作用
count: 2
命运女郎:
- name: 命运女郎
operator: instr
count: 4
大日:
- name: 大日
operator: instr
count: 4
波纹大日:
- parent: 大日
- name: 静寂之杖-波纹
count: 2
双剑大日:
- parent: 大日
- name: 闪光之双剑-雷震
count: 2
机巧:
- name: 机巧
operator: instr
count: 5
机甲机巧:
- parent: 机巧
- name: 机甲
operator: instr
count: 3
齿轮:
- name: 齿轮
operator: instr
count: 4
血代齿轮:
- parent: 齿轮
- name: 血之代偿
count: 2
机甲齿轮:
- parent: 齿轮
- name: 机甲
operator: instr
count: 3
龙族:
- type:
count: 6
- name: 真红眼暗铁龙
count: 1
次元龙族:
- parent: 龙族
- name: 日食翼龙
count: 2
光道:
- name: 光道
operator: instr
count: 6
混沌光道:
- parent: 光道
- monster_attribute:
count: 4
光化光道:
- parent: 光道
- name: 光芒使者
operator: instr
count: 3
熔岩:
- name: 熔岩
operator: instr
count: 4
星圣:
- name: 星圣
operator: instr
count: 4
守墓:
- name: 守墓
operator: instr
count: 6
云魔物:
- name: 云魔物
operator: instr
count: 4
亚马逊:
- name: 亚马逊
operator: instr
count: 6
反击天使:
- type: 天使
count: 4
- card_type: 反击陷阱
count: 7
宝玉兽:
- name: 宝玉兽
operator: instr
count: 4
宝石骑士:
- name: 宝石骑士
operator: instr
count: 5
- name: 宝石骑士融合
count: 1
薰风:
- name: 薰风
operator: instr
count: 6
风暗薰风:
- parent: 薰风
- name: 暗黑神鸟 斯摩夫
count: 1
念动力薰风:
- parent: 薰风
- type: 念动力
count: 7
核成:
- name: 核成
operator: instr
count: 6
废铁:
- name: 废铁奇美拉
count: 2
异虫:
- name: 异虫
operator: instr
count: 4
忍者:
- name: 忍者
operator: instr
count: 6
机巧:
- name: 机巧
operator: instr
count: 5
极星:
- name: 极星
operator: instr
count: 6
火山:
- name: 火山
operator: instr
count: 6
电子:
- name: 电子龙
operator: instr
count: 4
电池人:
- name: 电池人
operator: instr
count: 4
- name: 漏电
count: 1
白骨:
- name: 白骨
operator: instr
count: 6
神居天使:
- name: 神之居城
count: 2
- monster_level: 5
operator: ">="
count: 1
自然:
- name: 自然
operator: instr
count: 6
连锁BURN:
- name: 连锁暴击
count: 1
邪心英雄:
- name: 邪心英雄
operator: instr
count: 4
命运英雄:
- name: 命运英雄
operator: instr
count: 6
龙骑士D:
- parent: 命运英雄
- name: 龙骑士 D-终
count: 1
魔轰神:
- name: 魔轰神
operator: instr
count: 7
龙骑兵团:
- name: 龙骑兵团
operator: instr
count: 4
龙骑星爆:
- parent: 龙骑兵团
- name: 爆裂模式
count: 1
R6龙骑:
- parent: 龙骑兵团
- name: 圣刻龙王-阿图姆龙王
count: 1
\ No newline at end of file
......@@ -258,7 +258,10 @@ zh-CN:
board:
index: "论坛"
mycard:
download: "mycard下载"
download: "立即下载"
battlenet: "YGO战网"
more:
"更多..."
\ No newline at end of file
"更多..."
search:
search: "搜索"
advanced: "高级搜索"
\ No newline at end of file
MycardServerHttp::Application.routes.draw do
resources :servers
resources :libraries
resources :decks
get "rooms/index"
get "mycard/update"
......
class CreateLibraries < ActiveRecord::Migration
def change
create_table :libraries do |t|
t.string :name
t.text :contents
t.references :parent
t.timestamps
end
add_index :libraries, :parent_id
libraries = {}
YAML.load_file('config/deck.yml').each do |key, values|
libraries[key] = Library.create(name: key, contents:nil, parent: libraries[values.first["parent"]])
end
end
end
class CreateDecks < ActiveRecord::Migration
def change
create_table :decks do |t|
t.references :library
t.references :user
t.references :duel
t.timestamps
end
add_index :decks, :library_id
add_index :decks, :user_id
add_index :decks, :duel_id
end
end
class CreateServers < ActiveRecord::Migration
def change
create_table :servers do |t|
t.string :name
t.string :password
t.string :ip
t.integer :port
t.integer :http_port
t.timestamps
end
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120402031416) do
ActiveRecord::Schema.define(:version => 20120417233009) do
create_table "boards", :force => true do |t|
t.string "name", :default => "", :null => false
......@@ -56,19 +56,31 @@ ActiveRecord::Schema.define(:version => 20120402031416) do
t.datetime "updated_at", :null => false
end
create_table "decks", :force => true do |t|
t.integer "library_id"
t.integer "user_id"
t.integer "duel_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "decks", ["duel_id"], :name => "index_decks_on_duel_id"
add_index "decks", ["library_id"], :name => "index_decks_on_library_id"
add_index "decks", ["user_id"], :name => "index_decks_on_user_id"
create_table "duels", :force => true do |t|
t.integer "user1_id"
t.integer "user2_id"
t.integer "winner_id"
t.integer "winreason", :default => 0, :null => false
t.string "replay", :default => "", :null => false
t.integer "user1_credits", :default => 0, :null => false
t.integer "user2_credits", :default => 0, :null => false
t.integer "winreason"
t.string "replay"
t.integer "user1_credits"
t.integer "user2_credits"
t.integer "version"
t.boolean "user1_public", :default => true, :null => false
t.boolean "user2_public", :default => true, :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "user1_public", :default => true, :null => false
t.boolean "user2_public", :default => true, :null => false
end
add_index "duels", ["user1_id"], :name => "index_duels_on_user1_id"
......@@ -85,6 +97,16 @@ ActiveRecord::Schema.define(:version => 20120402031416) do
add_index "duels_users_cards", ["duel_id"], :name => "index_duels_users_cards_on_duel_id"
add_index "duels_users_cards", ["user_id"], :name => "index_duels_users_cards_on_user_id"
create_table "libraries", :force => true do |t|
t.string "name"
t.text "contents"
t.integer "parent_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "libraries", ["parent_id"], :name => "index_libraries_on_parent_id"
create_table "links", :force => true do |t|
t.string "name"
t.string "url"
......@@ -156,6 +178,16 @@ ActiveRecord::Schema.define(:version => 20120402031416) do
t.boolean "topic_lock", :default => false, :null => false
end
create_table "servers", :force => true do |t|
t.string "name"
t.string "password"
t.string "ip"
t.integer "port"
t.integer "http_port"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "settings", :primary_key => "name", :force => true do |t|
t.text "value"
end
......@@ -214,4 +246,39 @@ ActiveRecord::Schema.define(:version => 20120402031416) do
add_index "users", ["name"], :name => "index_users_on_name"
create_table "users_copy", :force => true do |t|
t.string "name", :null => false
t.string "password"
t.string "email", :default => "", :null => false
t.string "nickname", :default => "", :null => false
t.text "signature"
t.integer "credits", :default => 0, :null => false
t.integer "credit1", :default => 0, :null => false
t.integer "credit2", :default => 0, :null => false
t.integer "credit3", :default => 0, :null => false
t.integer "credit4", :default => 0, :null => false
t.integer "credit5", :default => 0, :null => false
t.integer "credit6", :default => 0, :null => false
t.integer "credit7", :default => 0, :null => false
t.integer "credit8", :default => 0, :null => false
t.integer "win", :default => 0, :null => false
t.integer "lost", :default => 0, :null => false
t.integer "role_id", :default => 5, :null => false
t.boolean "locked", :default => false, :null => false
t.string "regip", :default => "", :null => false
t.string "lastloginip", :default => "", :null => false
t.integer "viewnum", :default => 0, :null => false
t.integer "onlinetime", :default => 0, :null => false
t.string "locale"
t.string "theme"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "avatar_file_name"
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
end
add_index "users_copy", ["name"], :name => "index_users_on_name"
end
This diff is collapsed.
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
name: MyString
string: MyString
category: MyString
user_id:
duel_id:
two:
name: MyString
string: MyString
category: MyString
user_id:
duel_id:
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
name: MyString
contents: MyText
parent:
two:
name: MyString
contents: MyText
parent:
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
name: MyString
password: MyString
ip: MyString
port: 1
http_port: 1
two:
name: MyString
password: MyString
ip: MyString
port: 1
http_port: 1
require 'test_helper'
class DecksControllerTest < ActionController::TestCase
setup do
@deck = decks(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:decks)
end
test "should get new" do
get :new
assert_response :success
end
test "should create deck" do
assert_difference('Deck.count') do
post :create, deck: @deck.attributes
end
assert_redirected_to deck_path(assigns(:deck))
end
test "should show deck" do
get :show, id: @deck
assert_response :success
end
test "should get edit" do
get :edit, id: @deck
assert_response :success
end
test "should update deck" do
put :update, id: @deck, deck: @deck.attributes
assert_redirected_to deck_path(assigns(:deck))
end
test "should destroy deck" do
assert_difference('Deck.count', -1) do
delete :destroy, id: @deck
end
assert_redirected_to decks_path
end
end
require 'test_helper'
class LibrariesControllerTest < ActionController::TestCase
setup do
@library = libraries(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:libraries)
end
test "should get new" do
get :new
assert_response :success
end
test "should create library" do
assert_difference('Library.count') do
post :create, library: @library.attributes
end
assert_redirected_to library_path(assigns(:library))
end
test "should show library" do
get :show, id: @library
assert_response :success
end
test "should get edit" do
get :edit, id: @library
assert_response :success
end
test "should update library" do
put :update, id: @library, library: @library.attributes
assert_redirected_to library_path(assigns(:library))
end
test "should destroy library" do
assert_difference('Library.count', -1) do
delete :destroy, id: @library
end
assert_redirected_to libraries_path
end
end
require 'test_helper'
class ServersControllerTest < ActionController::TestCase
setup do
@server = servers(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:servers)
end
test "should get new" do
get :new
assert_response :success
end
test "should create server" do
assert_difference('Server.count') do
post :create, server: @server.attributes
end
assert_redirected_to server_path(assigns(:server))
end
test "should show server" do
get :show, id: @server
assert_response :success
end
test "should get edit" do
get :edit, id: @server
assert_response :success
end
test "should update server" do
put :update, id: @server, server: @server.attributes
assert_redirected_to server_path(assigns(:server))
end
test "should destroy server" do
assert_difference('Server.count', -1) do
delete :destroy, id: @server
end
assert_redirected_to servers_path
end
end
require 'test_helper'
class DeckTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class DecksHelperTest < ActionView::TestCase
end
require 'test_helper'
class LibrariesHelperTest < ActionView::TestCase
end
require 'test_helper'
class ServersHelperTest < ActionView::TestCase
end
require 'test_helper'
class LibraryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
require 'test_helper'
class ServerTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment