Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
Ygopro Arena Revive
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 Revive
Commits
9b9becee
Commit
9b9becee
authored
May 28, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
missing
parent
304381a7
Pipeline
#3393
passed with stages
in 2 minutes and 27 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
307 additions
and
0 deletions
+307
-0
src/card-info/card-info.service.spec.ts
src/card-info/card-info.service.spec.ts
+18
-0
src/card-info/card-info.service.ts
src/card-info/card-info.service.ts
+135
-0
src/elo/elo.service.spec.ts
src/elo/elo.service.spec.ts
+18
-0
src/elo/elo.service.ts
src/elo/elo.service.ts
+104
-0
src/http-response/http-response.service.spec.ts
src/http-response/http-response.service.spec.ts
+18
-0
src/http-response/http-response.service.ts
src/http-response/http-response.service.ts
+14
-0
No files found.
src/card-info/card-info.service.spec.ts
0 → 100644
View file @
9b9becee
import
{
Test
,
TestingModule
}
from
'
@nestjs/testing
'
;
import
{
CardInfoService
}
from
'
./card-info.service
'
;
describe
(
'
CardInfoService
'
,
()
=>
{
let
service
:
CardInfoService
;
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
CardInfoService
],
}).
compile
();
service
=
module
.
get
<
CardInfoService
>
(
CardInfoService
);
});
it
(
'
should be defined
'
,
()
=>
{
expect
(
service
).
toBeDefined
();
});
});
src/card-info/card-info.service.ts
0 → 100644
View file @
9b9becee
import
{
Injectable
}
from
'
@nestjs/common
'
;
@
Injectable
()
export
class
CardInfoService
{
private
cardInfo
=
{
cn
:
{
'
1010
'
:
'
地
'
,
'
1011
'
:
'
水
'
,
'
1012
'
:
'
炎
'
,
'
1013
'
:
'
风
'
,
'
1014
'
:
'
光
'
,
'
1015
'
:
'
暗
'
,
'
1016
'
:
'
神
'
,
'
1020
'
:
'
战士
'
,
'
1021
'
:
'
魔法师
'
,
'
1022
'
:
'
天使
'
,
'
1023
'
:
'
恶魔
'
,
'
1024
'
:
'
不死
'
,
'
1025
'
:
'
机械
'
,
'
1026
'
:
'
水
'
,
'
1027
'
:
'
炎
'
,
'
1028
'
:
'
岩石
'
,
'
1029
'
:
'
鸟兽
'
,
'
1030
'
:
'
植物
'
,
'
1031
'
:
'
昆虫
'
,
'
1032
'
:
'
雷
'
,
'
1033
'
:
'
龙
'
,
'
1034
'
:
'
兽
'
,
'
1035
'
:
'
兽战士
'
,
'
1036
'
:
'
恐龙
'
,
'
1037
'
:
'
鱼
'
,
'
1038
'
:
'
海龙
'
,
'
1039
'
:
'
爬虫
'
,
'
1040
'
:
'
念动力
'
,
'
1041
'
:
'
幻神兽
'
,
'
1042
'
:
'
创造神
'
,
'
1043
'
:
'
幻龙
'
,
'
1044
'
:
'
电子界
'
,
'
1050
'
:
'
怪兽
'
,
'
1051
'
:
'
魔法
'
,
'
1052
'
:
'
陷阱
'
,
'
1053
'
:
'
???
'
,
'
1054
'
:
'
通常
'
,
'
1055
'
:
'
效果
'
,
'
1056
'
:
'
融合
'
,
'
1057
'
:
'
仪式
'
,
'
1058
'
:
'
陷阱怪兽
'
,
'
1059
'
:
'
灵魂
'
,
'
1060
'
:
'
同盟
'
,
'
1061
'
:
'
二重
'
,
'
1062
'
:
'
调整
'
,
'
1063
'
:
'
同调
'
,
'
1064
'
:
'
衍生物
'
,
'
1065
'
:
'
???
'
,
'
1066
'
:
'
速攻
'
,
'
1067
'
:
'
永续
'
,
'
1068
'
:
'
装备
'
,
'
1069
'
:
'
场地
'
,
'
1070
'
:
'
反击
'
,
'
1071
'
:
'
反转
'
,
'
1072
'
:
'
卡通
'
,
'
1073
'
:
'
超量
'
,
'
1074
'
:
'
灵摆
'
,
},
en
:
{
'
1010
'
:
'
EARTH
'
,
'
1011
'
:
'
WATER
'
,
'
1012
'
:
'
FIRE
'
,
'
1013
'
:
'
WIND
'
,
'
1014
'
:
'
LIGHT
'
,
'
1015
'
:
'
DARK
'
,
'
1016
'
:
'
DIVINE
'
,
'
1020
'
:
'
Warrior
'
,
'
1021
'
:
'
Spellcaster
'
,
'
1022
'
:
'
Fairy
'
,
'
1023
'
:
'
Fiend
'
,
'
1024
'
:
'
Zombie
'
,
'
1025
'
:
'
Machine
'
,
'
1026
'
:
'
Aqua
'
,
'
1027
'
:
'
Pyro
'
,
'
1028
'
:
'
Rock
'
,
'
1029
'
:
'
Winged Beast
'
,
'
1030
'
:
'
Plant
'
,
'
1031
'
:
'
Insect
'
,
'
1032
'
:
'
Thunder
'
,
'
1033
'
:
'
Dragon
'
,
'
1034
'
:
'
Beast
'
,
'
1035
'
:
'
Beast-Warrior
'
,
'
1036
'
:
'
Dinosaur
'
,
'
1037
'
:
'
Fish
'
,
'
1038
'
:
'
Sea Serpent
'
,
'
1039
'
:
'
Reptile
'
,
'
1040
'
:
'
Psychic
'
,
'
1041
'
:
'
Divine-Beast
'
,
'
1042
'
:
'
Creator God
'
,
'
1043
'
:
'
Wyrm
'
,
'
1044
'
:
'
Cyberse
'
,
'
1050
'
:
'
Monster
'
,
'
1051
'
:
'
Spell
'
,
'
1052
'
:
'
Trap
'
,
'
1053
'
:
'
???
'
,
'
1054
'
:
'
Normal
'
,
'
1055
'
:
'
Effect
'
,
'
1056
'
:
'
Fusion
'
,
'
1057
'
:
'
Ritual
'
,
'
1058
'
:
'
Trap Monster
'
,
'
1059
'
:
'
Spirit
'
,
'
1060
'
:
'
Union
'
,
'
1061
'
:
'
Gemini
'
,
'
1062
'
:
'
Tuner
'
,
'
1063
'
:
'
Synchro
'
,
'
1064
'
:
'
Token
'
,
'
1065
'
:
'
???
'
,
'
1066
'
:
'
Quick-Play
'
,
'
1067
'
:
'
Continuous
'
,
'
1068
'
:
'
Equip
'
,
'
1069
'
:
'
Field
'
,
'
1070
'
:
'
Counter
'
,
'
1071
'
:
'
Flip
'
,
'
1072
'
:
'
Toon
'
,
'
1073
'
:
'
Xyz
'
,
'
1074
'
:
'
Pendulum
'
,
},
};
getStringValueByMysticalNumber
(
lang
:
string
,
offset
:
number
,
num
:
number
)
{
for
(
let
i
=
0
;
i
<
32
;
i
++
)
{
if
(
num
&
(
1
<<
i
))
{
const
index
=
offset
+
i
;
const
key
=
index
.
toString
();
return
this
.
cardInfo
[
lang
][
key
];
}
}
return
''
;
}
}
src/elo/elo.service.spec.ts
0 → 100644
View file @
9b9becee
import
{
Test
,
TestingModule
}
from
'
@nestjs/testing
'
;
import
{
EloService
}
from
'
./elo.service
'
;
describe
(
'
EloService
'
,
()
=>
{
let
service
:
EloService
;
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
EloService
],
}).
compile
();
service
=
module
.
get
<
EloService
>
(
EloService
);
});
it
(
'
should be defined
'
,
()
=>
{
expect
(
service
).
toBeDefined
();
});
});
src/elo/elo.service.ts
0 → 100644
View file @
9b9becee
import
{
Injectable
}
from
'
@nestjs/common
'
;
@
Injectable
()
export
class
EloService
{
getSqlString
(
num
:
number
)
{
if
(
num
===
0
||
!
num
)
{
return
''
;
}
else
if
(
num
>
0
)
{
return
`+
${
num
}
`
;
}
else
{
return
`-
${
-
num
}
`
;
}
}
getExpScore
(
expA
:
number
,
expB
:
number
,
scoreA
:
number
,
scoreB
:
number
)
{
let
rExpA
=
0
,
rExpB
=
0
;
if
(
scoreA
===
scoreB
)
{
rExpA
+=
0.5
;
rExpB
+=
0.5
;
}
else
if
(
scoreA
>
scoreB
)
{
rExpA
+=
1
;
if
(
expA
>
expB
)
rExpB
+=
0.5
;
}
else
if
(
scoreA
<
scoreB
)
{
rExpB
+=
1
;
if
(
expA
<
expB
)
rExpA
+=
0.5
;
}
return
{
expA
:
rExpA
,
expB
:
rExpB
};
}
getEloScore
(
rA
:
number
,
rB
:
number
,
sA
:
number
,
sB
:
number
)
{
//17.07.18 增加规则,平局不加分.
if
(
sA
===
sB
)
{
return
{
ptA
:
0
,
ptB
:
0
};
}
const
k
=
24
;
const
eA
=
1
/
(
1
+
Math
.
pow
(
10
,
(
rB
-
rA
)
/
400
));
const
eB
=
1
/
(
1
+
Math
.
pow
(
10
,
(
rA
-
rB
)
/
400
));
let
diffA
=
k
*
(
sA
-
eA
);
// 如果算出的变动分数小于8或者大于16就按8和16计
if
(
diffA
>
0
&&
diffA
>
16
)
{
//console.log("diffA 加分大于16 按16分结算", diffA);
diffA
=
16
;
}
if
(
diffA
>
0
&&
diffA
<
8
)
{
//console.log("diffA 加分小于8 按8分结算", diffA);
diffA
=
8
;
}
if
(
diffA
<
0
&&
diffA
>
-
8
)
{
//console.log("diffA 扣分小于8 按8分结算算", diffA);
diffA
=
-
8
;
}
if
(
diffA
<
0
&&
diffA
<
-
15
)
{
//console.log("diffA 扣分大于16 按16分结算", diffA);
diffA
=
-
15
;
}
//const rrA = rA + diffA;
let
diffB
=
k
*
(
sB
-
eB
);
// 如果算出的变动分数小于8或者大于16就按8和16计
if
(
diffB
>
0
&&
diffB
>
16
)
{
//console.log("diffB 加分大于16 按16分结算", diffB);
diffB
=
16
;
}
if
(
diffB
>
0
&&
diffB
<
8
)
{
//console.log("diffB 加分小于8 按8分结算", diffB);
diffB
=
8
;
}
if
(
diffB
<
0
&&
diffB
>
-
8
)
{
//console.log("diffB 扣分小于8 按8分结算算", diffB);
diffB
=
-
8
;
}
if
(
diffB
<
0
&&
diffB
<
-
15
)
{
//console.log("diffB 扣分大于16 按16分结算", diffB);
diffB
=
-
15
;
}
//const rrB = rB + diffB;
//console.log(diffA, diffB);
// // 加分高于16
// if( (rrB - rB) > 16 ) {
// rrB = rB + 16;
// }
// // 扣分低于8
// if( (rB - rrB) < 8 ) {
// rrB = rB - 8;
// }
return
{
ptA
:
diffA
,
ptB
:
diffB
};
}
}
src/http-response/http-response.service.spec.ts
0 → 100644
View file @
9b9becee
import
{
Test
,
TestingModule
}
from
'
@nestjs/testing
'
;
import
{
HttpResponseService
}
from
'
./http-response.service
'
;
describe
(
'
HttpResponseService
'
,
()
=>
{
let
service
:
HttpResponseService
;
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
HttpResponseService
],
}).
compile
();
service
=
module
.
get
<
HttpResponseService
>
(
HttpResponseService
);
});
it
(
'
should be defined
'
,
()
=>
{
expect
(
service
).
toBeDefined
();
});
});
src/http-response/http-response.service.ts
0 → 100644
View file @
9b9becee
import
{
HttpException
,
Injectable
}
from
'
@nestjs/common
'
;
import
{
CodeResponseDto
}
from
'
../dto/CodeResponse.dto
'
;
@
Injectable
()
export
class
HttpResponseService
{
async
handlePostCodeResponse
(
codePromise
:
Promise
<
number
>
)
{
const
code
=
await
codePromise
;
const
codeDto
=
new
CodeResponseDto
(
code
);
if
(
code
>=
400
)
{
throw
new
HttpException
(
codeDto
,
code
);
}
return
codeDto
;
}
}
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