Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-arena-api
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-api
Commits
4c4c886f
Commit
4c4c886f
authored
Feb 26, 2018
by
ganjingcun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deck print
parent
f1bafc93
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
190 additions
and
1 deletion
+190
-1
routes/api.js
routes/api.js
+189
-0
ygopro-database
ygopro-database
+1
-1
No files found.
routes/api.js
View file @
4c4c886f
...
...
@@ -10,6 +10,7 @@ var sqlite3 = require('sqlite3').verbose();
var
moment
=
require
(
'
moment
'
)
var
_
=
require
(
'
lodash
'
)
var
async
=
require
(
'
async
'
)
var
fs
=
require
(
'
fs
'
);
var
config
=
require
(
'
../db.config
'
)
var
cardinfo
=
require
(
'
../cardinfo
'
)
...
...
@@ -1302,6 +1303,194 @@ var file = require("./file.js");
router
.
post
(
'
/upload
'
,
file
.
upload
);
router
.
get
(
'
/download/:id
'
,
file
.
download
);
router
.
get
(
'
/deckdata/:id
'
,
function
(
req
,
res
)
{
var
filename
=
req
.
params
.
id
var
filepath
=
'
upload/
'
+
filename
var
contents
=
fs
.
readFileSync
(
filepath
,
'
utf8
'
);
contents
=
contents
.
split
(
/
\r?\n
/
)
var
main
=
[]
var
extra
=
[]
var
side
=
[]
var
current
;
_
.
each
(
contents
,
function
(
text
)
{
if
(
text
===
"
#main
"
)
{
current
=
main
}
if
(
text
===
"
#extra
"
)
{
current
=
extra
}
if
(
text
===
"
!side
"
)
{
current
=
side
}
if
(
text
===
"
#main
"
||
text
===
"
#extra
"
||
text
===
"
!side
"
)
{
return
}
if
(
text
.
indexOf
(
"
created
"
)
!==
-
1
)
{
return
}
if
(
text
.
trim
()
===
""
)
{
return
}
current
.
push
(
text
)
})
main
=
_
.
countBy
(
main
,
Math
.
floor
);
extra
=
_
.
countBy
(
extra
,
Math
.
floor
);
side
=
_
.
countBy
(
side
,
Math
.
floor
);
var
mainCardArr
=
[]
var
extraCardArr
=
[]
var
sideCardArr
=
[]
var
masterCardArr
=
[]
var
trapCardArr
=
[]
var
spellCardArr
=
[]
_
.
each
(
main
,
function
(
value
,
key
)
{
mainCardArr
.
push
({
id
:
key
,
num
:
value
})
})
_
.
each
(
extra
,
function
(
value
,
key
)
{
extraCardArr
.
push
({
id
:
key
,
num
:
value
})
})
_
.
each
(
side
,
function
(
value
,
key
)
{
sideCardArr
.
push
({
id
:
key
,
num
:
value
})
})
var
db
=
dbCn
;
var
lang
=
"
cn
"
async
.
waterfall
([
function
(
callback
)
{
async
.
each
(
mainCardArr
,
function
(
item
,
callback2
)
{
db
.
serialize
(
function
()
{
db
.
get
(
`SELECT a.id, a.name ,b.type from texts a left JOIN datas b on a.id=b.id where a.id =
${
item
.
id
}
`
,
function
(
err
,
row
)
{
if
(
err
)
{
console
.
error
(
err
)
return
callback2
();
}
if
(
!
row
)
{
console
.
error
(
"
card not found in database
"
)
item
.
name
=
"
Not found in database
"
item
.
type
=
"
怪兽
"
return
callback2
();
}
item
.
name
=
row
.
name
item
.
type
=
getStringValueByMysticalNumber
(
lang
,
typeOffset
,
row
.
type
)
if
(
item
.
type
===
"
怪兽
"
)
{
masterCardArr
.
push
(
item
)
}
else
if
(
item
.
type
===
"
魔法
"
)
{
trapCardArr
.
push
(
item
)
}
else
if
(
item
.
type
===
"
陷阱
"
)
{
spellCardArr
.
push
(
item
)
}
else
{
masterCardArr
.
push
(
item
)
}
callback2
()
});
});
},
function
(
err
)
{
callback
(
err
)
});
},
function
(
callback
)
{
async
.
each
(
extraCardArr
,
function
(
item
,
callback2
)
{
db
.
serialize
(
function
()
{
db
.
get
(
`SELECT a.id, a.name ,b.type from texts a left JOIN datas b on a.id=b.id where a.id =
${
item
.
id
}
`
,
function
(
err
,
row
)
{
if
(
err
)
{
console
.
error
(
err
)
return
callback2
();
}
if
(
!
row
)
{
console
.
error
(
"
card not found in database
"
)
item
.
name
=
"
Not found in database
"
item
.
type
=
"
怪兽
"
return
callback2
();
}
item
.
name
=
row
.
name
item
.
type
=
getStringValueByMysticalNumber
(
lang
,
typeOffset
,
row
.
type
)
callback2
()
});
});
},
function
(
err
)
{
callback
(
err
)
});
},
function
(
callback
)
{
async
.
each
(
sideCardArr
,
function
(
item
,
callback2
)
{
db
.
serialize
(
function
()
{
db
.
get
(
`SELECT a.id, a.name ,b.type from texts a left JOIN datas b on a.id=b.id where a.id =
${
item
.
id
}
`
,
function
(
err
,
row
)
{
if
(
err
)
{
console
.
error
(
err
)
return
callback2
();
}
if
(
!
row
)
{
console
.
error
(
"
card not found in database
"
)
item
.
name
=
"
Not found in database
"
item
.
type
=
"
怪兽
"
return
callback2
();
}
item
.
name
=
row
.
name
item
.
type
=
getStringValueByMysticalNumber
(
lang
,
typeOffset
,
row
.
type
)
callback2
()
});
});
},
function
(
err
)
{
callback
(
err
)
});
}
],
function
(
err
)
{
res
.
json
({
deck
:
{
monster
:
masterCardArr
,
spells
:
spellCardArr
,
traps
:
trapCardArr
,
extra
:
extraCardArr
,
side
:
sideCardArr
}
});
});
})
//卡组范例提交
...
...
ygopro-database
@
4de45a81
Subproject commit 4
a5c640a574f071fdbcd9375b31026e554f3c603
Subproject commit 4
de45a81145925de8fac46eb1ee2efd9ed11a665
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