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
MyCard
Ygopro Arena Web
Commits
1d328f50
Commit
1d328f50
authored
Jun 13, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
临时
parent
7e8ae488
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-1
app/controllers/duels_controller.rb
app/controllers/duels_controller.rb
+17
-4
No files found.
app/controllers/application_controller.rb
View file @
1d328f50
class
ApplicationController
<
ActionController
::
Base
Themes_Dir
=
File
.
expand_path
'app/themes'
,
Rails
.
root
protect_from_forgery
#
protect_from_forgery
before_filter
:load_settings
before_filter
:load_user
before_filter
:load_locale
...
...
app/controllers/duels_controller.rb
View file @
1d328f50
...
...
@@ -56,13 +56,26 @@ class DuelsController < ApplicationController
@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
]
return
if
@duel
.
user1
==
@duel
.
user2
[
params
[
:duel
][
:user1_main
],
params
[
:duel
][
:user1_extra
],
params
[
:duel
][
:user2_main
],
params
[
:duel
][
:user2_extra
]].
each_with_index
do
|
cards
,
index
|
card_numbers_arr
=
[
params
[
:duel
][
:user1_main
],
params
[
:duel
][
:user1_extra
],
params
[
:duel
][
:user2_main
],
params
[
:duel
][
:user2_extra
]]
card_numbers
=
[]
card_numbers_arr
.
each
do
|
zone
|
card_numbers
+=
zone
.
split
(
','
)
end
sql
=
Card
.
where
(
number:
card_numbers
).
select
([
:id
,
:number
]).
order
(
:id
).
group
(
:number
).
to_sql
card_number_id
=
{}
Duel
.
connection
.
execute
(
sql
).
each
do
|
id
,
number
|
card_number_id
[
number
]
=
id
end
card_numbers_arr
.
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
)
card_number
=
card_number
.
to_i
if
!
card_number_id
[
card_number
]
Card
.
create
(
:id
=>
card_number
,
:name
=>
card_number
,
:number
=>
card_number
)
card_number_id
[
card_number
]
=
card_number
end
@duel
.
duel_user_cards
<<
DuelUserCard
.
new
(
user:
user
,
card_id:
card_number_id
[
card_number
],
main:
main
)
end
end
@duel
.
winner
=
params
[
:duel
][
:winner_pos
]
==
"true"
?
@duel
.
user1
:
@duel
.
user2
...
...
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