Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
Ygopro Arena Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GaiaXalter
Ygopro Arena Web
Commits
27403848
Commit
27403848
authored
Mar 30, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
公测
parent
a843e94a
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
89 additions
and
30 deletions
+89
-30
app/assets/stylesheets/ygo.css
app/assets/stylesheets/ygo.css
+2
-2
app/controllers/cards_controller.rb
app/controllers/cards_controller.rb
+10
-2
app/controllers/duels_controller.rb
app/controllers/duels_controller.rb
+29
-2
app/controllers/mycard_controller.rb
app/controllers/mycard_controller.rb
+1
-1
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+29
-18
app/models/duel.rb
app/models/duel.rb
+9
-0
app/views/duels/index.html.erb
app/views/duels/index.html.erb
+1
-1
app/views/layouts/ygo.html.erb
app/views/layouts/ygo.html.erb
+5
-3
app/views/users/index.html.erb
app/views/users/index.html.erb
+1
-1
config/initializers/mime_types.rb
config/initializers/mime_types.rb
+1
-0
config/routes.rb
config/routes.rb
+1
-0
No files found.
app/assets/stylesheets/ygo.css
View file @
27403848
...
@@ -9,7 +9,7 @@ a:visited{ color: #ffcc66;}
...
@@ -9,7 +9,7 @@ a:visited{ color: #ffcc66;}
a
:hover
{
text-decoration
:
underline
}
a
:hover
{
text-decoration
:
underline
}
nav
{
width
:
750px
;
font-size
:
14px
;
padding-bottom
:
10px
;
line-height
:
40px
;
color
:
#ffcc66
;
text-align
:
left
;
margin-left
:
auto
;
margin-right
:
auto
;}
nav
{
width
:
750px
;
font-size
:
14px
;
padding-bottom
:
10px
;
line-height
:
40px
;
color
:
#ffcc66
;
text-align
:
left
;
margin-left
:
auto
;
margin-right
:
auto
;}
nav
a
{
color
:
#ffcc66
}
nav
a
{
color
:
#ffcc66
}
#footer
{
line-height
:
50px
;
padding-top
:
20px
;
padding-bottom
:
10px
;
font-size
:
12px
;
color
:
#0099FF
;
clear
:
both
;
text-align
:
center
;
margin-left
:
auto
;
margin-right
:
auto
;}
#footer
{
padding-top
:
20px
;
padding-bottom
:
10px
;
font-size
:
12px
;
color
:
#0099FF
;
clear
:
both
;
text-align
:
center
;
margin-left
:
auto
;
margin-right
:
auto
;}
#header
{
width
:
600px
;
margin-left
:
auto
;
margin-right
:
auto
;}
#header
{
width
:
600px
;
margin-left
:
auto
;
margin-right
:
auto
;}
#title
{
width
:
600px
;
font-size
:
30px
;
padding-bottom
:
20px
;
color
:
#ffcc66
;
text-align
:
right
;
padding-top
:
150px
;}
#title
{
width
:
600px
;
font-size
:
30px
;
padding-bottom
:
20px
;
color
:
#ffcc66
;
text-align
:
right
;
padding-top
:
150px
;}
#main
{
width
:
600px
;
margin-left
:
auto
;
margin-right
:
auto
;
;
display
:
none
;}
#main
{
width
:
600px
;
margin-left
:
auto
;
margin-right
:
auto
;
display
:
none
;}
\ No newline at end of file
\ No newline at end of file
app/controllers/cards_controller.rb
View file @
27403848
...
@@ -23,14 +23,22 @@ class CardsController < ApplicationController
...
@@ -23,14 +23,22 @@ class CardsController < ApplicationController
# GET /cards/1.json
# GET /cards/1.json
def
show
def
show
@card
=
Card
.
find
(
params
[
:id
])
@card
=
Card
.
find
(
params
[
:id
])
@actions
=
[{
"YGO战网"
=>
users_path
},
{
"
YGO战网
"
=>
cards_path
},
@card
]
@actions
=
[{
"YGO战网"
=>
users_path
},
{
"
卡片列表
"
=>
cards_path
},
@card
]
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# show.html.erb
format
.
html
# show.html.erb
format
.
json
{
render
json:
@card
}
format
.
json
{
render
json:
@card
}
format
.
png
{
redirect_to
@card
.
image
}
format
.
png
{
redirect_to
@card
.
image
}
end
end
end
end
def
search
@cards
=
Card
.
where
(
:name
=>
params
[
:name
].
split
(
','
))
respond_to
do
|
format
|
#format.html { render }
format
.
json
{
render
json:
@cards
}
format
.
jsonp
{
render
text:
"
#{
params
[
:callback
]
}
(
#{
@cards
.
to_json
}
)"
}
end
end
# GET /cards/new
# GET /cards/new
# GET /cards/new.json
# GET /cards/new.json
def
new
def
new
...
...
app/controllers/duels_controller.rb
View file @
27403848
...
@@ -49,8 +49,35 @@ class DuelsController < ApplicationController
...
@@ -49,8 +49,35 @@ class DuelsController < ApplicationController
# POST /duels
# POST /duels
# POST /duels.json
# POST /duels.json
def
create
def
create
@duel
=
Duel
.
new
(
params
[
:duel
])
@duel
=
Duel
.
new
@duel
.
winreason
=
params
[
:duel
][
:winreason
]
@duel
.
replay
=
params
[
:duel
][
:replay
]
@duel
.
version
=
params
[
:duel
][
:version
]
@duel
.
user1
=
User
.
find_by_name
params
[
:duel
][
:user1_name
]
if
params
[
:duel
][
:user1_name
]
@duel
.
user2
=
User
.
find_by_name
params
[
:duel
][
:user2_name
]
if
params
[
:duel
][
:user2_name
]
[
params
[
:duel
][
:user1_main
],
params
[
:duel
][
:user1_extra
],
params
[
:duel
][
:user2_main
],
params
[
:duel
][
:user2_extra
]].
each_with_index
do
|
cards
,
index
|
user
=
index
/
2
==
0
?
@duel
.
user1
:
@duel
.
user2
main
=
index
%
2
==
0
cards
.
split
(
','
).
collect
do
|
card_number
|
card
=
Card
.
find_by_number
(
card_number
)
card
=
Card
.
create
(
:id
=>
card_number
,
:name
=>
card_number
,
:number
=>
card_number
)
if
card
.
nil?
@duel
.
duel_user_cards
<<
DuelUserCard
.
new
(
user:
user
,
card:
card
,
main:
main
)
end
end
@duel
.
winner
=
params
[
:duel
][
:winner_pos
]
==
"true"
?
@duel
.
user1
:
@duel
.
user2
if
params
[
:duel
][
:credits
]
==
"true"
if
@duel
.
winner
==
@duel
.
user1
@duel
.
user1_credits
=
10
@duel
.
user2_credits
=
-
10
else
@duel
.
user1_credits
=
-
10
@duel
.
user2_credits
=
10
end
else
@duel
.
user1_credits
=
0
@duel
.
user2_credits
=
0
end
@duel
.
created_at
=
Time
.
zone
.
parse
params
[
:duel
][
:created_at
]
#.to_i
respond_to
do
|
format
|
respond_to
do
|
format
|
if
@duel
.
save
if
@duel
.
save
format
.
html
{
redirect_to
@duel
,
notice:
'Duel was successfully created.'
}
format
.
html
{
redirect_to
@duel
,
notice:
'Duel was successfully created.'
}
...
...
app/controllers/mycard_controller.rb
View file @
27403848
...
@@ -14,7 +14,7 @@ class MycardController < ApplicationController
...
@@ -14,7 +14,7 @@ class MycardController < ApplicationController
end
end
end
end
def
download
def
download
file
=
Dir
.
glob
(
'public/mycard/mycard-*-win32.7z'
).
last
file
=
Dir
.
glob
(
'public/mycard/mycard-*-win32.7z'
).
max
if
file
if
file
file
=
File
.
basename
(
file
)
file
=
File
.
basename
(
file
)
respond_to
do
|
format
|
respond_to
do
|
format
|
...
...
app/controllers/users_controller.rb
View file @
27403848
...
@@ -12,7 +12,7 @@ class UsersController < ApplicationController
...
@@ -12,7 +12,7 @@ class UsersController < ApplicationController
@actions
=
[{
"YGO战网"
=>
users_path
},
"用户排行"
]
@actions
=
[{
"YGO战网"
=>
users_path
},
"用户排行"
]
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# index.html.erb
format
.
html
# index.html.erb
format
.
xml
{
render
:xml
=>
@users
}
#
format.xml { render :xml => @users }
end
end
end
end
...
@@ -50,26 +50,37 @@ class UsersController < ApplicationController
...
@@ -50,26 +50,37 @@ class UsersController < ApplicationController
@user
=
User
.
new
(
params
[
:user
])
@user
=
User
.
new
(
params
[
:user
])
#验证ygocore服务器是否可注册,true为成功,false为重名,nil为异常
#验证ygocore服务器是否可注册,true为成功,false为重名,nil为异常
success
=
open
(
"http://140.113.242.66:7922/?userregist=NEW&username=
#{
CGI
.
escape
@user
.
name
}
&password=
#{
CGI
.
escape
@user
.
password
}
"
)
do
|
file
|
reply
=
""
file
.
set_encoding
(
"GBK"
)
success
=
begin
case
file
.
read
.
encode
(
"UTF-8"
)
open
(
"http://140.113.242.66:7922/?userregist=NEW&username=
#{
CGI
.
escape
@user
.
name
}
&password=
#{
CGI
.
escape
@user
.
password
}
"
)
do
|
file
|
when
"注册成功"
file
.
set_encoding
(
"GBK"
)
open
(
"http://140.113.242.66:7922/?pass=zh99998&operation=saveuser"
){}
rescue
nil
case
reply
=
file
.
read
.
encode
(
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
)
true
when
/注册成功/
when
"用户已存在"
open
(
"http://140.113.242.66:7922/?pass=zh99998&operation=saveuser"
){}
rescue
nil
@user
.
errors
.
add
:name
,
"用户已存在"
true
false
when
"用户已存在"
else
@user
.
errors
.
add
:name
,
"用户已存在"
nil
false
else
nil
end
end
end
end
rescue
nil
rescue
Exception
=>
exception
@user
.
errors
.
add
:name
,
"注册失败,可能是服务器故障,请与管理员联系 Email/GT/QQ: zh99998@gmail.com"
if
success
.
nil?
reply
=
([
exception
]
+
exception
.
backtrace
).
join
(
"
\n
"
)
nil
end
@user
.
errors
.
add
:name
,
"注册失败,可能是服务器故障,请与管理员联系 Email/GT/QQ: zh99998@gmail.com 详情:
#{
reply
}
"
if
success
.
nil?
respond_to
do
|
format
|
respond_to
do
|
format
|
if
success
and
@user
.
save
if
success
session
[
:user_id
]
=
@user
.
id
if
@user
.
save
format
.
html
{
redirect_to
(
@user
,
:notice
=>
'注册成功'
)
}
session
[
:user_id
]
=
@user
.
id
format
.
xml
{
render
:xml
=>
@user
,
:status
=>
:created
,
:location
=>
@user
}
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
}
end
else
else
format
.
html
{
render
:action
=>
"new"
}
format
.
html
{
render
:action
=>
"new"
}
format
.
xml
{
render
:xml
=>
@user
.
errors
,
:status
=>
:unprocessable_entity
}
format
.
xml
{
render
:xml
=>
@user
.
errors
,
:status
=>
:unprocessable_entity
}
...
...
app/models/duel.rb
View file @
27403848
...
@@ -12,6 +12,15 @@ class Duel < ActiveRecord::Base
...
@@ -12,6 +12,15 @@ class Duel < ActiveRecord::Base
result
=
cards
.
where
(
'user_id=? and main = ?'
,
user
,
main
)
result
=
cards
.
where
(
'user_id=? and main = ?'
,
user
,
main
)
result
.
order
(
"field(card_type,
#{
(
main
?
main_order
:
extra_order
).
collect
{
|
type
|
"'
#{
type
}
'"
}
.join(',')})"
,
'cards.id'
)
result
.
order
(
"field(card_type,
#{
(
main
?
main_order
:
extra_order
).
collect
{
|
type
|
"'
#{
type
}
'"
}
.join(',')})"
,
'cards.id'
)
end
end
def
user1
super
||
User
::
Guest
end
def
user2
super
||
User
::
Guest
end
def
winner
super
||
User
::
Guest
end
def
user1_main
def
user1_main
user_cards
(
user1
,
true
)
user_cards
(
user1
,
true
)
end
end
...
...
app/views/duels/index.html.erb
View file @
27403848
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
<tr><td
colspan=
"7"
>
<%=
will_paginate
@duels
%>
</td></tr>
<tr><td
colspan=
"7"
>
<%=
will_paginate
@duels
%>
</td></tr>
</tfoot>
</tfoot>
<tbody>
<tbody>
<%
first_index
=
@user
.
duels
.
where
(
"id<=?"
,
@duels
.
to_enum
.
first
.
id
).
count
if
@user
%>
<!--这里的效率很低,待优化-->
<%
first_index
=
@user
.
duels
.
where
(
"id<=?"
,
@duels
.
to_enum
.
first
.
id
).
count
if
@user
and
!
@user
.
duels
.
empty?
%>
<!--这里的效率很低,待优化-->
<%
@duels
.
each_with_index
do
|
duel
,
index
|
%>
<%
@duels
.
each_with_index
do
|
duel
,
index
|
%>
<tr>
<tr>
<%
if
@user
%>
<%
if
@user
%>
...
...
app/views/layouts/ygo.html.erb
View file @
27403848
...
@@ -18,11 +18,13 @@
...
@@ -18,11 +18,13 @@
<nav
id=
"actions"
>
<nav
id=
"actions"
>
<%=
render
'entries/action'
%>
<%=
render
'entries/action'
%>
</nav>
</nav>
<div
id=
"main"
>
<div
align=
"center"
>
<!--不加这个的话 飞入效果会抽一下,直接加到下面那个div上不管用,style="text-align:center; float:center"也不管用-->
<%=
yield
%>
<div
id=
"main"
>
<%=
yield
%>
</div>
</div>
</div>
<footer
id=
"footer"
>
<footer
id=
"footer"
>
YGO DULE BATTLENET
YGO DULE BATTLENET
</footer>
</footer>
</body>
</body>
</html>
</html>
\ No newline at end of file
app/views/users/index.html.erb
View file @
27403848
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<tbody>
<tbody>
<%
top_users
=
User
.
order
(
:credits
).
reverse_order
.
limit
(
10
)
%>
<%
top_users
=
User
.
order
(
:credits
).
reverse_order
.
limit
(
10
)
%>
<%
if
logged?
&&
!
top_users
.
include?
(
@current_user
)
%>
<%
if
logged?
&&
!
top_users
.
include?
(
@current_user
)
%>
<%
top_users
+=
@current_user
%>
<%
top_users
<<
@current_user
%>
<%
my_index
=
User
.
where
(
"credits>=?"
,
@current_user
.
credits
).
count
%>
<%
my_index
=
User
.
where
(
"credits>=?"
,
@current_user
.
credits
).
count
%>
<%
end
%>
<%
end
%>
<%
top_users
.
each_with_index
do
|
user
,
index
|
%>
<%
top_users
.
each_with_index
do
|
user
,
index
|
%>
...
...
config/initializers/mime_types.rb
View file @
27403848
...
@@ -3,3 +3,4 @@
...
@@ -3,3 +3,4 @@
# Add new mime types for use in respond_to blocks:
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
# Mime::Type.register_alias "text/html", :iphone
Mime
::
Type
.
register
"application/json-p"
,
:jsonp
\ No newline at end of file
config/routes.rb
View file @
27403848
...
@@ -11,6 +11,7 @@ MycardServerHttp::Application.routes.draw do
...
@@ -11,6 +11,7 @@ MycardServerHttp::Application.routes.draw do
get
'user2_deck.:format'
=>
"duels#user2_deck"
get
'user2_deck.:format'
=>
"duels#user2_deck"
end
end
resources
:cards
resources
:cards
get
'search/cards'
=>
'cards#search'
resources
:users
do
resources
:users
do
resources
:duels
resources
:duels
resources
:cards
resources
:cards
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment