Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
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
nanahira
srvpro
Commits
6bf0003b
Commit
6bf0003b
authored
Nov 15, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vip info
parent
56f15b58
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
669 additions
and
746 deletions
+669
-746
data-manager/DataManager.js
data-manager/DataManager.js
+20
-0
data-manager/DataManager.ts
data-manager/DataManager.ts
+21
-0
data-manager/entities/Ban.js
data-manager/entities/Ban.js
+23
-20
data-manager/entities/BasePlayer.js
data-manager/entities/BasePlayer.js
+17
-14
data-manager/entities/CloudReplay.js
data-manager/entities/CloudReplay.js
+41
-38
data-manager/entities/CloudReplayPlayer.js
data-manager/entities/CloudReplayPlayer.js
+25
-22
data-manager/entities/DuelLog.js
data-manager/entities/DuelLog.js
+71
-68
data-manager/entities/DuelLogPlayer.js
data-manager/entities/DuelLogPlayer.js
+83
-80
data-manager/entities/RandomDuelBan.js
data-manager/entities/RandomDuelBan.js
+34
-31
data-manager/entities/User.js
data-manager/entities/User.js
+40
-37
data-manager/entities/UserDialog.js
data-manager/entities/UserDialog.js
+25
-22
data-manager/entities/VipKey.js
data-manager/entities/VipKey.js
+32
-29
data/i18n.json
data/i18n.json
+2
-0
ygopro-server.coffee
ygopro-server.coffee
+87
-135
ygopro-server.js
ygopro-server.js
+148
-250
No files found.
data-manager/DataManager.js
View file @
6bf0003b
...
...
@@ -335,6 +335,10 @@ class DataManager {
user
.
chatColor
=
color
;
return
await
this
.
saveUser
(
user
);
}
async
isUserVip
(
key
)
{
const
user
=
await
this
.
getUser
(
key
);
return
user
?
user
.
isVip
()
:
false
;
}
async
getUserDialogueText
(
key
,
cardCode
)
{
try
{
const
dialogue
=
await
this
.
db
.
getRepository
(
UserDialog_1
.
UserDialog
)
...
...
@@ -395,6 +399,20 @@ class DataManager {
}
});
}
async
removeUserDialogues
(
key
,
cardCode
)
{
try
{
await
this
.
db
.
createQueryBuilder
()
.
delete
()
.
from
(
UserDialog_1
.
UserDialog
)
.
where
(
"
cardCode = :cardCode and userKey = :key
"
,
{
cardCode
,
key
})
.
execute
();
return
true
;
}
catch
(
e
)
{
this
.
log
.
warn
(
`Failed to remove dialogue:
${
e
.
toString
()}
`
);
return
false
;
}
}
async
migrateChatColors
(
data
)
{
await
this
.
transaction
(
async
(
mdb
)
=>
{
try
{
...
...
@@ -443,9 +461,11 @@ class DataManager {
});
try
{
await
this
.
db
.
manager
.
save
(
vipKeys
);
return
true
;
}
catch
(
e
)
{
this
.
log
.
warn
(
`Failed to generate keys of keyType
${
keyType
}
:
${
e
.
toString
()}
`
);
return
false
;
}
}
async
useVipKey
(
userKey
,
vipKeyText
)
{
...
...
data-manager/DataManager.ts
View file @
6bf0003b
...
...
@@ -359,6 +359,10 @@ export class DataManager {
user
.
chatColor
=
color
;
return
await
this
.
saveUser
(
user
);
}
async
isUserVip
(
key
:
string
)
{
const
user
=
await
this
.
getUser
(
key
);
return
user
?
user
.
isVip
()
:
false
;
}
async
getUserDialogueText
(
key
:
string
,
cardCode
:
number
)
{
try
{
const
dialogue
=
await
this
.
db
.
getRepository
(
UserDialog
)
...
...
@@ -418,6 +422,21 @@ export class DataManager {
}
async
removeUserDialogues
(
key
:
string
,
cardCode
:
number
)
{
try
{
await
this
.
db
.
createQueryBuilder
()
.
delete
()
.
from
(
UserDialog
)
.
where
(
"
cardCode = :cardCode and userKey = :key
"
,
{
cardCode
,
key
})
.
execute
();
return
true
;
}
catch
(
e
)
{
this
.
log
.
warn
(
`Failed to remove dialogue:
${
e
.
toString
()}
`
);
return
false
;
}
}
async
migrateChatColors
(
data
:
any
)
{
await
this
.
transaction
(
async
(
mdb
)
=>
{
try
{
...
...
@@ -467,8 +486,10 @@ export class DataManager {
});
try
{
await
this
.
db
.
manager
.
save
(
vipKeys
);
return
true
;
}
catch
(
e
)
{
this
.
log
.
warn
(
`Failed to generate keys of keyType
${
keyType
}
:
${
e
.
toString
()}
`
);
return
false
;
}
}
...
...
data-manager/entities/Ban.js
View file @
6bf0003b
...
...
@@ -11,25 +11,28 @@ var __metadata = (this && this.__metadata) || function (k, v) {
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
Ban
=
void
0
;
const
typeorm_1
=
require
(
"
typeorm
"
);
let
Ban
=
class
Ban
{
};
__decorate
([
let
Ban
=
/** @class */
(()
=>
{
let
Ban
=
class
Ban
{
};
__decorate
([
typeorm_1
.
PrimaryGeneratedColumn
({
unsigned
:
true
,
type
:
"
bigint
"
}),
__metadata
(
"
design:type
"
,
Number
)
],
Ban
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
],
Ban
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
typeorm_1
.
Index
(),
typeorm_1
.
Column
({
type
:
"
varchar
"
,
length
:
64
,
nullable
:
true
}),
__metadata
(
"
design:type
"
,
String
)
],
Ban
.
prototype
,
"
ip
"
,
void
0
);
__decorate
([
],
Ban
.
prototype
,
"
ip
"
,
void
0
);
__decorate
([
typeorm_1
.
Index
(),
typeorm_1
.
Column
({
type
:
"
varchar
"
,
length
:
20
,
nullable
:
true
}),
__metadata
(
"
design:type
"
,
String
)
],
Ban
.
prototype
,
"
name
"
,
void
0
);
Ban
=
__decorate
([
],
Ban
.
prototype
,
"
name
"
,
void
0
);
Ban
=
__decorate
([
typeorm_1
.
Entity
(),
typeorm_1
.
Unique
([
"
ip
"
,
"
name
"
])
],
Ban
);
],
Ban
);
return
Ban
;
})();
exports
.
Ban
=
Ban
;
//# sourceMappingURL=Ban.js.map
\ No newline at end of file
data-manager/entities/BasePlayer.js
View file @
6bf0003b
...
...
@@ -11,19 +11,22 @@ var __metadata = (this && this.__metadata) || function (k, v) {
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
BasePlayer
=
void
0
;
const
typeorm_1
=
require
(
"
typeorm
"
);
class
BasePlayer
{
}
__decorate
([
let
BasePlayer
=
/** @class */
(()
=>
{
class
BasePlayer
{
}
__decorate
([
typeorm_1
.
PrimaryGeneratedColumn
({
unsigned
:
true
,
type
:
"
bigint
"
}),
__metadata
(
"
design:type
"
,
Number
)
],
BasePlayer
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
],
BasePlayer
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
({
type
:
"
varchar
"
,
length
:
20
}),
__metadata
(
"
design:type
"
,
String
)
],
BasePlayer
.
prototype
,
"
name
"
,
void
0
);
__decorate
([
],
BasePlayer
.
prototype
,
"
name
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
({
type
:
"
tinyint
"
}),
__metadata
(
"
design:type
"
,
Number
)
],
BasePlayer
.
prototype
,
"
pos
"
,
void
0
);
],
BasePlayer
.
prototype
,
"
pos
"
,
void
0
);
return
BasePlayer
;
})();
exports
.
BasePlayer
=
BasePlayer
;
//# sourceMappingURL=BasePlayer.js.map
\ No newline at end of file
data-manager/entities/CloudReplay.js
View file @
6bf0003b
...
...
@@ -17,7 +17,8 @@ const typeorm_1 = require("typeorm");
const
CloudReplayPlayer_1
=
require
(
"
./CloudReplayPlayer
"
);
const
underscore_1
=
__importDefault
(
require
(
"
underscore
"
));
const
moment_1
=
__importDefault
(
require
(
"
moment
"
));
let
CloudReplay
=
class
CloudReplay
{
let
CloudReplay
=
/** @class */
(()
=>
{
let
CloudReplay
=
class
CloudReplay
{
fromBuffer
(
buffer
)
{
this
.
data
=
buffer
.
toString
(
"
base64
"
);
}
...
...
@@ -35,25 +36,27 @@ let CloudReplay = class CloudReplay {
getDisplayString
()
{
return
`R#
${
this
.
id
}
${
this
.
getPlayerNamesString
()}
${
this
.
getDateString
()}
`
;
}
};
__decorate
([
};
__decorate
([
typeorm_1
.
PrimaryColumn
({
unsigned
:
true
,
type
:
"
bigint
"
}),
__metadata
(
"
design:type
"
,
Number
)
],
CloudReplay
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
],
CloudReplay
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
({
type
:
"
text
"
}),
__metadata
(
"
design:type
"
,
String
)
],
CloudReplay
.
prototype
,
"
data
"
,
void
0
);
__decorate
([
],
CloudReplay
.
prototype
,
"
data
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
({
type
:
"
datetime
"
}),
__metadata
(
"
design:type
"
,
Date
)
],
CloudReplay
.
prototype
,
"
date
"
,
void
0
);
__decorate
([
],
CloudReplay
.
prototype
,
"
date
"
,
void
0
);
__decorate
([
typeorm_1
.
OneToMany
(()
=>
CloudReplayPlayer_1
.
CloudReplayPlayer
,
player
=>
player
.
cloudReplay
),
__metadata
(
"
design:type
"
,
Array
)
],
CloudReplay
.
prototype
,
"
players
"
,
void
0
);
CloudReplay
=
__decorate
([
],
CloudReplay
.
prototype
,
"
players
"
,
void
0
);
CloudReplay
=
__decorate
([
typeorm_1
.
Entity
()
],
CloudReplay
);
],
CloudReplay
);
return
CloudReplay
;
})();
exports
.
CloudReplay
=
CloudReplay
;
//# sourceMappingURL=CloudReplay.js.map
\ No newline at end of file
data-manager/entities/CloudReplayPlayer.js
View file @
6bf0003b
...
...
@@ -8,13 +8,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
var
__metadata
=
(
this
&&
this
.
__metadata
)
||
function
(
k
,
v
)
{
if
(
typeof
Reflect
===
"
object
"
&&
typeof
Reflect
.
metadata
===
"
function
"
)
return
Reflect
.
metadata
(
k
,
v
);
};
var
CloudReplayPlayer_1
;
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
CloudReplayPlayer
=
void
0
;
const
typeorm_1
=
require
(
"
typeorm
"
);
const
CloudReplay_1
=
require
(
"
./CloudReplay
"
);
const
BasePlayer_1
=
require
(
"
./BasePlayer
"
);
let
CloudReplayPlayer
=
CloudReplayPlayer_1
=
class
CloudReplayPlayer
extends
BasePlayer_1
.
BasePlayer
{
let
CloudReplayPlayer
=
/** @class */
(()
=>
{
var
CloudReplayPlayer_1
;
let
CloudReplayPlayer
=
CloudReplayPlayer_1
=
class
CloudReplayPlayer
extends
BasePlayer_1
.
BasePlayer
{
static
fromPlayerInfo
(
info
)
{
const
p
=
new
CloudReplayPlayer_1
();
p
.
key
=
info
.
key
;
...
...
@@ -22,18 +23,20 @@ let CloudReplayPlayer = CloudReplayPlayer_1 = class CloudReplayPlayer extends Ba
p
.
pos
=
info
.
pos
;
return
p
;
}
};
__decorate
([
};
__decorate
([
typeorm_1
.
Index
(),
typeorm_1
.
Column
({
type
:
"
varchar
"
,
length
:
40
}),
__metadata
(
"
design:type
"
,
String
)
],
CloudReplayPlayer
.
prototype
,
"
key
"
,
void
0
);
__decorate
([
],
CloudReplayPlayer
.
prototype
,
"
key
"
,
void
0
);
__decorate
([
typeorm_1
.
ManyToOne
(()
=>
CloudReplay_1
.
CloudReplay
,
replay
=>
replay
.
players
),
__metadata
(
"
design:type
"
,
CloudReplay_1
.
CloudReplay
)
],
CloudReplayPlayer
.
prototype
,
"
cloudReplay
"
,
void
0
);
CloudReplayPlayer
=
CloudReplayPlayer_1
=
__decorate
([
],
CloudReplayPlayer
.
prototype
,
"
cloudReplay
"
,
void
0
);
CloudReplayPlayer
=
CloudReplayPlayer_1
=
__decorate
([
typeorm_1
.
Entity
()
],
CloudReplayPlayer
);
],
CloudReplayPlayer
);
return
CloudReplayPlayer
;
})();
exports
.
CloudReplayPlayer
=
CloudReplayPlayer
;
//# sourceMappingURL=CloudReplayPlayer.js.map
\ No newline at end of file
data-manager/entities/DuelLog.js
View file @
6bf0003b
...
...
@@ -17,7 +17,8 @@ const typeorm_1 = require("typeorm");
const
DuelLogPlayer_1
=
require
(
"
./DuelLogPlayer
"
);
const
moment_1
=
__importDefault
(
require
(
"
moment
"
));
const
underscore_1
=
__importDefault
(
require
(
"
underscore
"
));
let
DuelLog
=
class
DuelLog
{
let
DuelLog
=
/** @class */
(()
=>
{
let
DuelLog
=
class
DuelLog
{
getViewString
()
{
const
viewPlayers
=
underscore_1
.
default
.
clone
(
this
.
players
);
viewPlayers
.
sort
((
p1
,
p2
)
=>
p1
.
pos
-
p2
.
pos
);
...
...
@@ -44,46 +45,48 @@ let DuelLog = class DuelLog {
};
return
data
;
}
};
__decorate
([
};
__decorate
([
typeorm_1
.
PrimaryGeneratedColumn
({
unsigned
:
true
,
type
:
"
bigint
"
}),
__metadata
(
"
design:type
"
,
Number
)
],
DuelLog
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
],
DuelLog
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
datetime
"
),
__metadata
(
"
design:type
"
,
Date
)
],
DuelLog
.
prototype
,
"
time
"
,
void
0
);
__decorate
([
],
DuelLog
.
prototype
,
"
time
"
,
void
0
);
__decorate
([
typeorm_1
.
Index
(),
typeorm_1
.
Column
({
type
:
"
varchar
"
,
length
:
20
}),
__metadata
(
"
design:type
"
,
String
)
],
DuelLog
.
prototype
,
"
name
"
,
void
0
);
__decorate
([
],
DuelLog
.
prototype
,
"
name
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
int
"
),
__metadata
(
"
design:type
"
,
Number
)
],
DuelLog
.
prototype
,
"
roomId
"
,
void
0
);
__decorate
([
],
DuelLog
.
prototype
,
"
roomId
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
bigint
"
),
__metadata
(
"
design:type
"
,
Number
)
],
DuelLog
.
prototype
,
"
cloudReplayId
"
,
void
0
);
__decorate
([
],
DuelLog
.
prototype
,
"
cloudReplayId
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
({
type
:
"
varchar
"
,
length
:
256
}),
__metadata
(
"
design:type
"
,
String
)
],
DuelLog
.
prototype
,
"
replayFileName
"
,
void
0
);
__decorate
([
],
DuelLog
.
prototype
,
"
replayFileName
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
tinyint
"
,
{
unsigned
:
true
}),
__metadata
(
"
design:type
"
,
Number
)
],
DuelLog
.
prototype
,
"
roomMode
"
,
void
0
);
__decorate
([
],
DuelLog
.
prototype
,
"
roomMode
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
tinyint
"
,
{
unsigned
:
true
}),
__metadata
(
"
design:type
"
,
Number
)
],
DuelLog
.
prototype
,
"
duelCount
"
,
void
0
);
__decorate
([
],
DuelLog
.
prototype
,
"
duelCount
"
,
void
0
);
__decorate
([
typeorm_1
.
OneToMany
(()
=>
DuelLogPlayer_1
.
DuelLogPlayer
,
player
=>
player
.
duelLog
),
__metadata
(
"
design:type
"
,
Array
)
],
DuelLog
.
prototype
,
"
players
"
,
void
0
);
DuelLog
=
__decorate
([
],
DuelLog
.
prototype
,
"
players
"
,
void
0
);
DuelLog
=
__decorate
([
typeorm_1
.
Entity
()
],
DuelLog
);
],
DuelLog
);
return
DuelLog
;
})();
exports
.
DuelLog
=
DuelLog
;
//# sourceMappingURL=DuelLog.js.map
\ No newline at end of file
data-manager/entities/DuelLogPlayer.js
View file @
6bf0003b
...
...
@@ -8,14 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
var
__metadata
=
(
this
&&
this
.
__metadata
)
||
function
(
k
,
v
)
{
if
(
typeof
Reflect
===
"
object
"
&&
typeof
Reflect
.
metadata
===
"
function
"
)
return
Reflect
.
metadata
(
k
,
v
);
};
var
DuelLogPlayer_1
;
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
DuelLogPlayer
=
void
0
;
const
typeorm_1
=
require
(
"
typeorm
"
);
const
BasePlayer_1
=
require
(
"
./BasePlayer
"
);
const
DuelLog_1
=
require
(
"
./DuelLog
"
);
const
DeckEncoder_1
=
require
(
"
../DeckEncoder
"
);
let
DuelLogPlayer
=
DuelLogPlayer_1
=
class
DuelLogPlayer
extends
BasePlayer_1
.
BasePlayer
{
let
DuelLogPlayer
=
/** @class */
(()
=>
{
var
DuelLogPlayer_1
;
let
DuelLogPlayer
=
DuelLogPlayer_1
=
class
DuelLogPlayer
extends
BasePlayer_1
.
BasePlayer
{
setStartDeck
(
deck
)
{
if
(
deck
===
null
)
{
this
.
startDeckBuffer
=
null
;
...
...
@@ -51,50 +52,52 @@ let DuelLogPlayer = DuelLogPlayer_1 = class DuelLogPlayer extends BasePlayer_1.B
p
.
setCurrentDeck
(
info
.
deck
);
return
p
;
}
};
__decorate
([
};
__decorate
([
typeorm_1
.
Index
(),
typeorm_1
.
Column
({
type
:
"
varchar
"
,
length
:
20
}),
__metadata
(
"
design:type
"
,
String
)
],
DuelLogPlayer
.
prototype
,
"
realName
"
,
void
0
);
__decorate
([
],
DuelLogPlayer
.
prototype
,
"
realName
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
({
type
:
"
varchar
"
,
length
:
64
,
nullable
:
true
}),
__metadata
(
"
design:type
"
,
String
)
],
DuelLogPlayer
.
prototype
,
"
ip
"
,
void
0
);
__decorate
([
],
DuelLogPlayer
.
prototype
,
"
ip
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
tinyint
"
,
{
unsigned
:
true
}),
__metadata
(
"
design:type
"
,
Number
)
],
DuelLogPlayer
.
prototype
,
"
isFirst
"
,
void
0
);
__decorate
([
],
DuelLogPlayer
.
prototype
,
"
isFirst
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
tinyint
"
),
__metadata
(
"
design:type
"
,
Number
)
],
DuelLogPlayer
.
prototype
,
"
score
"
,
void
0
);
__decorate
([
],
DuelLogPlayer
.
prototype
,
"
score
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
int
"
,
{
nullable
:
true
}),
__metadata
(
"
design:type
"
,
Number
)
],
DuelLogPlayer
.
prototype
,
"
lp
"
,
void
0
);
__decorate
([
],
DuelLogPlayer
.
prototype
,
"
lp
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
smallint
"
,
{
nullable
:
true
}),
__metadata
(
"
design:type
"
,
Number
)
],
DuelLogPlayer
.
prototype
,
"
cardCount
"
,
void
0
);
__decorate
([
],
DuelLogPlayer
.
prototype
,
"
cardCount
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
text
"
,
{
nullable
:
true
}),
__metadata
(
"
design:type
"
,
String
)
],
DuelLogPlayer
.
prototype
,
"
startDeckBuffer
"
,
void
0
);
__decorate
([
],
DuelLogPlayer
.
prototype
,
"
startDeckBuffer
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
text
"
,
{
nullable
:
true
}),
__metadata
(
"
design:type
"
,
String
)
],
DuelLogPlayer
.
prototype
,
"
currentDeckBuffer
"
,
void
0
);
__decorate
([
],
DuelLogPlayer
.
prototype
,
"
currentDeckBuffer
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
tinyint
"
),
__metadata
(
"
design:type
"
,
Number
)
],
DuelLogPlayer
.
prototype
,
"
winner
"
,
void
0
);
__decorate
([
],
DuelLogPlayer
.
prototype
,
"
winner
"
,
void
0
);
__decorate
([
typeorm_1
.
ManyToOne
(()
=>
DuelLog_1
.
DuelLog
,
duelLog
=>
duelLog
.
players
),
__metadata
(
"
design:type
"
,
DuelLog_1
.
DuelLog
)
],
DuelLogPlayer
.
prototype
,
"
duelLog
"
,
void
0
);
DuelLogPlayer
=
DuelLogPlayer_1
=
__decorate
([
],
DuelLogPlayer
.
prototype
,
"
duelLog
"
,
void
0
);
DuelLogPlayer
=
DuelLogPlayer_1
=
__decorate
([
typeorm_1
.
Entity
()
],
DuelLogPlayer
);
],
DuelLogPlayer
);
return
DuelLogPlayer
;
})();
exports
.
DuelLogPlayer
=
DuelLogPlayer
;
//# sourceMappingURL=DuelLogPlayer.js.map
\ No newline at end of file
data-manager/entities/RandomDuelBan.js
View file @
6bf0003b
...
...
@@ -11,36 +11,39 @@ var __metadata = (this && this.__metadata) || function (k, v) {
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
RandomDuelBan
=
void
0
;
const
typeorm_1
=
require
(
"
typeorm
"
);
let
RandomDuelBan
=
class
RandomDuelBan
{
let
RandomDuelBan
=
/** @class */
(()
=>
{
let
RandomDuelBan
=
class
RandomDuelBan
{
setNeedTip
(
need
)
{
this
.
needTip
=
need
?
1
:
0
;
}
getNeedTip
()
{
return
this
.
needTip
>
0
?
true
:
false
;
}
};
__decorate
([
};
__decorate
([
typeorm_1
.
PrimaryColumn
({
type
:
"
varchar
"
,
length
:
64
}),
__metadata
(
"
design:type
"
,
String
)
],
RandomDuelBan
.
prototype
,
"
ip
"
,
void
0
);
__decorate
([
],
RandomDuelBan
.
prototype
,
"
ip
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
datetime
"
),
__metadata
(
"
design:type
"
,
Date
)
],
RandomDuelBan
.
prototype
,
"
time
"
,
void
0
);
__decorate
([
],
RandomDuelBan
.
prototype
,
"
time
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
smallint
"
),
__metadata
(
"
design:type
"
,
Number
)
],
RandomDuelBan
.
prototype
,
"
count
"
,
void
0
);
__decorate
([
],
RandomDuelBan
.
prototype
,
"
count
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
({
type
:
"
simple-array
"
}),
__metadata
(
"
design:type
"
,
Array
)
],
RandomDuelBan
.
prototype
,
"
reasons
"
,
void
0
);
__decorate
([
],
RandomDuelBan
.
prototype
,
"
reasons
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
({
type
:
"
tinyint
"
,
unsigned
:
true
}),
__metadata
(
"
design:type
"
,
Number
)
],
RandomDuelBan
.
prototype
,
"
needTip
"
,
void
0
);
RandomDuelBan
=
__decorate
([
],
RandomDuelBan
.
prototype
,
"
needTip
"
,
void
0
);
RandomDuelBan
=
__decorate
([
typeorm_1
.
Entity
()
],
RandomDuelBan
);
],
RandomDuelBan
);
return
RandomDuelBan
;
})();
exports
.
RandomDuelBan
=
RandomDuelBan
;
//# sourceMappingURL=RandomDuelBan.js.map
\ No newline at end of file
data-manager/entities/User.js
View file @
6bf0003b
...
...
@@ -17,42 +17,45 @@ const typeorm_1 = require("typeorm");
const
UserDialog_1
=
require
(
"
./UserDialog
"
);
const
VipKey_1
=
require
(
"
./VipKey
"
);
const
moment_1
=
__importDefault
(
require
(
"
moment
"
));
let
User
=
class
User
{
let
User
=
/** @class */
(()
=>
{
let
User
=
class
User
{
isVip
()
{
return
this
.
vipExpireDate
&&
moment_1
.
default
().
isBefore
(
this
.
vipExpireDate
);
}
};
__decorate
([
};
__decorate
([
typeorm_1
.
PrimaryColumn
({
type
:
"
varchar
"
,
length
:
128
}),
__metadata
(
"
design:type
"
,
String
)
],
User
.
prototype
,
"
key
"
,
void
0
);
__decorate
([
],
User
.
prototype
,
"
key
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
varchar
"
,
{
length
:
16
,
nullable
:
true
}),
__metadata
(
"
design:type
"
,
String
)
],
User
.
prototype
,
"
chatColor
"
,
void
0
);
__decorate
([
],
User
.
prototype
,
"
chatColor
"
,
void
0
);
__decorate
([
typeorm_1
.
Index
(),
typeorm_1
.
Column
(
"
datetime
"
,
{
nullable
:
true
}),
__metadata
(
"
design:type
"
,
Date
)
],
User
.
prototype
,
"
vipExpireDate
"
,
void
0
);
__decorate
([
],
User
.
prototype
,
"
vipExpireDate
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
text
"
,
{
nullable
:
true
}),
__metadata
(
"
design:type
"
,
String
)
],
User
.
prototype
,
"
victory
"
,
void
0
);
__decorate
([
],
User
.
prototype
,
"
victory
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
text
"
,
{
nullable
:
true
}),
__metadata
(
"
design:type
"
,
String
)
],
User
.
prototype
,
"
words
"
,
void
0
);
__decorate
([
],
User
.
prototype
,
"
words
"
,
void
0
);
__decorate
([
typeorm_1
.
OneToMany
(()
=>
UserDialog_1
.
UserDialog
,
dialog
=>
dialog
.
user
),
__metadata
(
"
design:type
"
,
Array
)
],
User
.
prototype
,
"
dialogues
"
,
void
0
);
__decorate
([
],
User
.
prototype
,
"
dialogues
"
,
void
0
);
__decorate
([
typeorm_1
.
OneToMany
(()
=>
VipKey_1
.
VipKey
,
vipKey
=>
vipKey
.
usedBy
),
__metadata
(
"
design:type
"
,
Array
)
],
User
.
prototype
,
"
usedKeys
"
,
void
0
);
User
=
__decorate
([
],
User
.
prototype
,
"
usedKeys
"
,
void
0
);
User
=
__decorate
([
typeorm_1
.
Entity
()
],
User
);
],
User
);
return
User
;
})();
exports
.
User
=
User
;
//# sourceMappingURL=User.js.map
\ No newline at end of file
data-manager/entities/UserDialog.js
View file @
6bf0003b
...
...
@@ -12,27 +12,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports
.
UserDialog
=
void
0
;
const
typeorm_1
=
require
(
"
typeorm
"
);
const
User_1
=
require
(
"
./User
"
);
let
UserDialog
=
class
UserDialog
{
};
__decorate
([
let
UserDialog
=
/** @class */
(()
=>
{
let
UserDialog
=
class
UserDialog
{
};
__decorate
([
typeorm_1
.
PrimaryGeneratedColumn
({
unsigned
:
true
,
type
:
"
bigint
"
}),
__metadata
(
"
design:type
"
,
Number
)
],
UserDialog
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
],
UserDialog
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
typeorm_1
.
Index
(),
typeorm_1
.
Column
(
"
int
"
,
{
unsigned
:
true
}),
__metadata
(
"
design:type
"
,
Number
)
],
UserDialog
.
prototype
,
"
cardCode
"
,
void
0
);
__decorate
([
],
UserDialog
.
prototype
,
"
cardCode
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
text
"
),
__metadata
(
"
design:type
"
,
String
)
],
UserDialog
.
prototype
,
"
text
"
,
void
0
);
__decorate
([
],
UserDialog
.
prototype
,
"
text
"
,
void
0
);
__decorate
([
typeorm_1
.
ManyToOne
(()
=>
User_1
.
User
,
user
=>
user
.
dialogues
),
__metadata
(
"
design:type
"
,
User_1
.
User
)
],
UserDialog
.
prototype
,
"
user
"
,
void
0
);
UserDialog
=
__decorate
([
],
UserDialog
.
prototype
,
"
user
"
,
void
0
);
UserDialog
=
__decorate
([
typeorm_1
.
Entity
()
],
UserDialog
);
],
UserDialog
);
return
UserDialog
;
})();
exports
.
UserDialog
=
UserDialog
;
//# sourceMappingURL=UserDialog.js.map
\ No newline at end of file
data-manager/entities/VipKey.js
View file @
6bf0003b
...
...
@@ -12,34 +12,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports
.
VipKey
=
void
0
;
const
typeorm_1
=
require
(
"
typeorm
"
);
const
User_1
=
require
(
"
./User
"
);
let
VipKey
=
class
VipKey
{
let
VipKey
=
/** @class */
(()
=>
{
let
VipKey
=
class
VipKey
{
toJSON
()
{
return
{
key
:
this
.
key
,
type
:
this
.
type
};
}
};
__decorate
([
};
__decorate
([
typeorm_1
.
PrimaryGeneratedColumn
({
unsigned
:
true
,
type
:
"
bigint
"
}),
__metadata
(
"
design:type
"
,
Number
)
],
VipKey
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
],
VipKey
.
prototype
,
"
id
"
,
void
0
);
__decorate
([
typeorm_1
.
Index
({
unique
:
true
}),
typeorm_1
.
Column
(
"
varchar
"
,
{
length
:
30
}),
__metadata
(
"
design:type
"
,
String
)
],
VipKey
.
prototype
,
"
key
"
,
void
0
);
__decorate
([
],
VipKey
.
prototype
,
"
key
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
int
"
,
{
unsigned
:
true
}),
__metadata
(
"
design:type
"
,
Number
)
],
VipKey
.
prototype
,
"
type
"
,
void
0
);
__decorate
([
],
VipKey
.
prototype
,
"
type
"
,
void
0
);
__decorate
([
typeorm_1
.
Column
(
"
tinyint
"
,
{
unsigned
:
true
,
default
:
0
}),
__metadata
(
"
design:type
"
,
Number
)
],
VipKey
.
prototype
,
"
isUsed
"
,
void
0
);
__decorate
([
],
VipKey
.
prototype
,
"
isUsed
"
,
void
0
);
__decorate
([
typeorm_1
.
ManyToOne
(()
=>
User_1
.
User
,
user
=>
user
.
usedKeys
),
__metadata
(
"
design:type
"
,
User_1
.
User
)
],
VipKey
.
prototype
,
"
usedBy
"
,
void
0
);
VipKey
=
__decorate
([
],
VipKey
.
prototype
,
"
usedBy
"
,
void
0
);
VipKey
=
__decorate
([
typeorm_1
.
Entity
()
],
VipKey
);
],
VipKey
);
return
VipKey
;
})();
exports
.
VipKey
=
VipKey
;
//# sourceMappingURL=VipKey.js.map
\ No newline at end of file
data/i18n.json
View file @
6bf0003b
...
...
@@ -193,6 +193,7 @@
"vip_set_victory"
:
"Your victory word have been set."
,
"vip_password_changed"
:
"Password changed."
,
"vip_player_name_too_long"
:
"Your username or password is too long to log in. Please change your username and try again."
,
"vip_no_pass"
:
"You must use the name format of Name$Password to support."
,
"replay_hint_part1"
:
"Sending the replay of the duel number "
,
"replay_hint_part2"
:
"."
,
"arena_wait_hint"
:
"If you opponent does not appear within 25 seconds, you may quit without any penalty."
,
...
...
@@ -543,6 +544,7 @@
"vip_set_victory"
:
"已设置胜利台词。"
,
"vip_password_changed"
:
"密码修改成功。"
,
"vip_player_name_too_long"
:
"你的用户名或设置的密码太长,使用此用户名可能会无法登陆。请更换用户名重试。"
,
"vip_no_pass"
:
"为了保证未来可以识别您的身份,请使用 用户名$密码 的格式重试。"
,
"replay_hint_part1"
:
"正在发送第"
,
"replay_hint_part2"
:
"局决斗的录像。"
,
"arena_wait_hint"
:
"若对手在25秒内不进入游戏,您退房时不会进行扣分。"
,
...
...
ygopro-server.coffee
View file @
6bf0003b
...
...
@@ -128,69 +128,33 @@ setting_change = global.setting_change = (settings, path, val) ->
return
VIP_generate_cdkeys
=
global
.
VIP_generate_cdkeys
=
(
key_type
,
count
)
->
return
false
unless
settings
.
modules
.
vip
.
enabled
and
vip_info
.
cdkeys
[
key_type
]
for
i
in
[
0
...
count
]
key
=
Math
.
floor
(
Math
.
random
()
*
10000000000000000
).
toString
()
vip_info
.
cdkeys
[
key_type
].
push
(
key
)
setting_save
(
vip_info
)
log
.
info
(
"keys generated"
,
key_type
,
count
,
vip_info
.
cdkeys
[
key_type
].
length
)
return
true
return
false
unless
settings
.
modules
.
vip
.
enabled
return
await
dataManager
.
generateVipKeys
(
key_type
,
count
)
CLIENT_use_cdkey
=
global
.
CLIENT_use_cdkey
=
(
client
,
pkey
)
->
return
0
unless
settings
.
modules
.
vip
.
enabled
and
pkey
found_type
=
null
for
type
,
keys
of
vip_info
.
cdkeys
for
key
in
keys
when
pkey
==
key
or
pkey
==
(
type
+
"D"
+
settings
.
port
+
":"
+
key
)
# support web given format
found_type
=
parseInt
(
type
)
index
=
_
.
indexOf
(
keys
,
key
)
keys
.
splice
(
index
,
1
)
unless
index
==
-
1
break
if
found_type
break
if
!
found_type
return
0
if
!
vip_info
.
cdkeys
[
found_type
].
length
VIP_generate_cdkeys
(
found_type
,
settings
.
modules
.
vip
.
generate_count
)
client
.
vip
=
true
new_vip
=
false
if
vip_info
.
players
[
client
.
name
]
current_date
=
moment
()
if
current_date
.
isSameOrBefore
(
vip_info
.
players
[
client
.
name
].
expire_date
)
current_date
=
moment
(
vip_info
.
players
[
client
.
name
].
expire_date
,
'YYYY-MM-DD HH:mm:ss'
)
vip_info
.
players
[
client
.
name
].
expire_date
=
current_date
.
add
(
found_type
,
'd'
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
else
if
!
client
.
vpass
client
.
vpass
=
Math
.
floor
(
Math
.
random
()
*
100000
).
toString
()
vip_info
.
players
[
client
.
name
]
=
{
password
:
client
.
vpass
,
expire_date
:
moment
().
add
(
found_type
,
'd'
).
format
(
'YYYY-MM-DD HH:mm:ss'
),
dialogues
:
{}
}
new_vip
=
true
setting_save
(
vip_info
)
return
(
if
new_vip
then
1
else
2
)
key
=
CLIENT_get_authorize_key
(
client
)
return
await
dataManager
.
useVipKey
(
key
,
pkey
)
CLIENT_get_save_data
=
global
.
CLIENT_get_save_data
=
(
client
)
->
return
await
dataManager
.
getUser
(
CLIENT_get_authorize_key
(
client
))
CLIENT_check_vip
=
global
.
CLIENT_check_vip
=
(
client
)
->
if
!
settings
.
modules
.
vip
.
enabled
return
false
if
!
vip_info
.
players
[
client
.
name
]
return
false
if
vip_info
.
players
[
client
.
name
].
password
!=
client
.
vpass
return
false
return
moment
().
isSameOrBefore
(
vip_info
.
players
[
client
.
name
].
expire_date
)
key
=
CLIENT_get_authorize_key
(
client
)
return
await
dataManager
.
isUserVip
(
key
)
CLIENT_send_vip_status
=
global
.
CLIENT_send_vip_status
=
(
client
,
display
)
->
if
!
settings
.
modules
.
vip
.
enabled
return
false
if
client
.
vip
userData
=
await
CLIENT_get_save_data
(
client
)
if
userData
.
isVip
()
if
display
ygopro
.
stoc_send_chat
(
client
,
"${vip_remain_part1}"
+
vip_info
.
players
[
client
.
name
].
expire_date
+
"${vip_remain_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_remain_part1}"
+
moment
(
userData
.
vipExpireDate
).
format
(
"YYYY-MM-DD HH:mm:ss"
)
+
"${vip_remain_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
ygopro
.
stoc_send_chat
(
client
,
"${vip_remain}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
if
!
vip_info
.
players
[
client
.
name
]
or
vip_info
.
players
[
client
.
name
].
password
!=
client
.
vpass
else
if
!
userData
.
vipExpireDate
ygopro
.
stoc_send_chat
(
client
,
"${vip_not_bought}"
,
ygopro
.
constants
.
COLORS
.
RED
)
else
ygopro
.
stoc_send_chat
(
client
,
"${vip_expired_part1}"
+
vip_info
.
players
[
client
.
name
].
expire_date
+
"${vip_expired_part2}"
,
ygopro
.
constants
.
COLORS
.
RED
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_expired_part1}"
+
moment
(
userData
.
vipExpireDate
).
format
(
"YYYY-MM-DD HH:mm:ss"
)
+
"${vip_expired_part2}"
,
ygopro
.
constants
.
COLORS
.
RED
)
concat_name
=
global
.
concat_name
=
(
name
,
num
)
->
if
!
name
[
num
]
...
...
@@ -253,7 +217,6 @@ roomlist = null
settings
=
{}
tips
=
null
words
=
null
vip_info
=
null
dialogues
=
null
badwords
=
null
lflists
=
global
.
lflists
=
[]
...
...
@@ -402,6 +365,10 @@ init = () ->
settings
.
modules
.
chat_color
.
enabled
=
false
await
setting_save
(
settings
)
log
.
warn
(
"Chat color cannot be enabled because no MySQL."
)
if
settings
.
modules
.
vip
.
enabled
settings
.
modules
.
vip
.
enabled
=
false
await
setting_save
(
settings
)
log
.
warn
(
"VIP mode cannot be enabled because no MySQL."
)
# 读取数据
default_data
=
await
loadJSONAsync
(
'./data/default_data.json'
)
try
...
...
@@ -419,11 +386,14 @@ init = () ->
catch
words
=
global
.
words
=
default_data
.
words
await
setting_save
(
words
)
if
settings
.
modules
.
vip
.
enabled
and
await
checkFileExists
(
'./config/vip_info.json'
)
try
vip_info
=
global
.
vip_info
=
await
loadJSONAsync
(
'./config/vip_info.json'
)
vip_info
=
await
loadJSONAsync
(
'./config/vip_info.json'
)
if
vip_info
await
dataManager
.
migrateFromOldVipInfo
(
vip_info
);
await
fs
.
promises
.
rename
(
'./config/vip_info.json'
,
'./config/vip_info.json.bak'
)
log
.
info
(
"VIP info migrated."
)
catch
vip_info
=
global
.
vip_info
=
default_data
.
vip_info
await
setting_save
(
vip_info
)
try
badwords
=
global
.
badwords
=
await
loadJSONAsync
(
'./config/badwords.json'
)
catch
...
...
@@ -669,10 +639,6 @@ init = () ->
,
1000
if
settings
.
modules
.
vip
.
enabled
for
k
,
v
of
vip_info
.
cdkeys
when
v
.
length
==
0
VIP_generate_cdkeys
(
k
,
settings
.
modules
.
vip
.
generate_count
)
net
.
createServer
(
netRequestHandler
).
listen
settings
.
port
,
->
log
.
info
"server started"
,
settings
.
port
return
...
...
@@ -972,8 +938,6 @@ CLIENT_get_authorize_key = global.CLIENT_get_authorize_key = (client) ->
return
client
.
name_vpass
else
if
settings
.
modules
.
mycard
.
enabled
or
settings
.
modules
.
tournament_mode
.
enabled
or
settings
.
modules
.
challonge
.
enabled
or
client
.
is_local
return
client
.
name
else
if
client
.
vip
return
client
.
name
+
"$"
+
client
.
vpass
else
return
client
.
ip
+
":"
+
client
.
name
...
...
@@ -1847,6 +1811,10 @@ class Room
))
await
return
playLines
:
(
lines
)
->
for
line
in
_
.
lines
lines
ygopro
.
stoc_send_chat_to_room
(
this
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
# 网络连接
netRequestHandler
=
(
client
)
->
client
.
ip
=
client
.
remoteAddress
...
...
@@ -2075,7 +2043,7 @@ ygopro.ctos_follow 'PLAYER_INFO', true, (buffer, info, client, server, datas)->
client
.
vpass
=
vpass
client
.
name_vpass
=
if
vpass
then
name
+
"$"
+
vpass
else
name
#console.log client.name, client.vpass
if
settings
.
modules
.
vip
.
enabled
and
CLIENT_check_vip
(
client
)
if
settings
.
modules
.
vip
.
enabled
and
await
CLIENT_check_vip
(
client
)
client
.
vip
=
true
if
not
settings
.
modules
.
i18n
.
auto_pick
or
client
.
is_local
...
...
@@ -2275,12 +2243,12 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
client
.
setTimeout
(
300000
)
#连接后超时5分钟
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
)
client
.
is_post_watcher
=
true
if
settings
.
modules
.
vip
.
enabled
and
client
.
vip
and
vip_info
.
players
[
client
.
name
].
words
for
line
in
_
.
lines
vip_info
.
players
[
client
.
name
].
words
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
if
settings
.
modules
.
vip
.
enabled
and
await
CLIENT_check_vip
(
client
)
words
=
await
dataManager
.
getUserWords
(
CLIENT_get_authorize_key
(
client
))
if
words
room
.
playLines
(
words
)
else
if
settings
.
modules
.
words
.
enabled
and
words
.
words
[
client
.
name
]
for
line
in
_
.
lines
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
room
.
playLines
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
client
.
name
}
${watch_join}"
)
room
.
watchers
.
push
client
ygopro
.
stoc_send_chat
(
client
,
"${watch_watching}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
...
...
@@ -2466,12 +2434,12 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
#client.setTimeout(300000) #连接后超时5分钟
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
)
client
.
is_post_watcher
=
true
if
settings
.
modules
.
vip
.
enabled
and
client
.
vip
and
vip_info
.
players
[
client
.
name
].
words
for
line
in
_
.
lines
vip_info
.
players
[
client
.
name
].
words
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
if
settings
.
modules
.
vip
.
enabled
and
await
CLIENT_check_vip
(
client
)
words
=
await
dataManager
.
getUserWords
(
CLIENT_get_authorize_key
(
client
))
if
words
room
.
playLines
(
words
)
else
if
settings
.
modules
.
words
.
enabled
and
words
.
words
[
client
.
name
]
for
line
in
_
.
lines
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
room
.
playLines
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
client
.
name
}
${watch_join}"
)
room
.
watchers
.
push
client
ygopro
.
stoc_send_chat
(
client
,
"${watch_watching}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
...
...
@@ -2554,12 +2522,12 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
client
.
setTimeout
(
300000
)
#连接后超时5分钟
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
)
client
.
is_post_watcher
=
true
if
settings
.
modules
.
vip
.
enabled
and
client
.
vip
and
vip_info
.
players
[
client
.
name
].
words
for
line
in
_
.
lines
vip_info
.
players
[
client
.
name
].
words
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
if
settings
.
modules
.
vip
.
enabled
and
await
CLIENT_check_vip
(
client
)
words
=
await
dataManager
.
getUserWords
(
CLIENT_get_authorize_key
(
client
))
if
words
room
.
playLines
(
words
)
else
if
settings
.
modules
.
words
.
enabled
and
words
.
words
[
client
.
name
]
for
line
in
_
.
lines
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
room
.
playLines
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]
ygopro
.
stoc_send_chat_to_room
(
room
,
"
#{
client
.
name
}
${watch_join}"
)
room
.
watchers
.
push
client
ygopro
.
stoc_send_chat
(
client
,
"${watch_watching}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
...
...
@@ -2581,12 +2549,12 @@ ygopro.stoc_follow 'JOIN_GAME', false, (buffer, info, client, server, datas)->
return
unless
room
and
!
client
.
reconnecting
if
!
room
.
join_game_buffer
room
.
join_game_buffer
=
buffer
if
settings
.
modules
.
vip
.
enabled
and
client
.
vip
and
vip_info
.
players
[
client
.
name
].
words
for
line
in
_
.
lines
vip_info
.
players
[
client
.
name
].
words
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
if
settings
.
modules
.
vip
.
enabled
and
await
CLIENT_check_vip
(
client
)
words
=
await
dataManager
.
getUserWords
(
CLIENT_get_authorize_key
(
client
))
if
words
room
.
playLines
(
words
)
else
if
settings
.
modules
.
words
.
enabled
and
words
.
words
[
client
.
name
]
for
line
in
_
.
lines
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
room
.
playLines
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]
if
settings
.
modules
.
welcome
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
welcome
,
ygopro
.
constants
.
COLORS
.
GREEN
)
if
room
.
welcome
...
...
@@ -2804,12 +2772,14 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
if
room
.
match_kill
room
.
match_kill
=
false
room
.
scores
[
room
.
winner_name
]
=
99
if
settings
.
modules
.
vip
.
enabled
and
room
.
dueling_players
[
pos
].
vip
and
vip_info
.
players
[
room
.
dueling_players
[
pos
].
name
].
victory
for
line
in
_
.
lines
vip_info
.
players
[
room
.
dueling_players
[
pos
].
name
].
victory
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
else
if
room
.
hostinfo
.
mode
==
2
and
settings
.
modules
.
vip
.
enabled
and
room
.
dueling_players
[
pos
+
1
].
vip
and
vip_info
.
players
[
room
.
dueling_players
[
pos
+
1
].
name
].
victory
for
line
in
_
.
lines
vip_info
.
players
[
room
.
dueling_players
[
pos
+
1
].
name
].
victory
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
if
settings
.
modules
.
vip
.
enabled
victoryWordPlayerList
=
[
room
.
dueling_players
[
pos
]]
if
room
.
hostinfo
.
mode
==
2
victoryWordPlayerList
.
push
(
room
.
dueling_players
[
pos
+
1
])
for
player
in
victoryWordPlayerList
when
await
CLIENT_check_vip
(
player
)
and
await
dataManager
.
getUserVictoryWords
(
CLIENT_get_authorize_key
(
player
))
words
=
await
dataManager
.
getUserVictoryWords
(
CLIENT_get_authorize_key
(
player
))
room
.
playLines
(
words
)
break
if
room
.
death
if
settings
.
modules
.
http
.
quick_death_rule
==
1
or
settings
.
modules
.
http
.
quick_death_rule
==
3
room
.
death
=
-
1
...
...
@@ -2939,18 +2909,14 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
if
room
.
hostinfo
.
mode
==
2
act_pos
=
act_pos
*
2
if
ygopro
.
constants
.
MSG
[
msg
]
!=
'CHAINING'
or
(
trigger_location
&
0x8
)
and
client
.
ready_trap
if
settings
.
modules
.
vip
.
enabled
and
room
.
dueling_players
[
act_pos
].
vip
and
vip_info
.
players
[
room
.
dueling_players
[
act_pos
].
name
].
dialogues
[
card
]
for
line
in
_
.
lines
vip_info
.
players
[
room
.
dueling_players
[
act_pos
].
name
].
dialogues
[
card
]
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
else
if
settings
.
modules
.
vip
.
enabled
and
room
.
hostinfo
.
mode
==
2
and
room
.
dueling_players
[
act_pos
+
1
].
vip
and
vip_info
.
players
[
room
.
dueling_players
[
act_pos
+
1
].
name
].
dialogues
[
card
]
for
line
in
_
.
lines
vip_info
.
players
[
room
.
dueling_players
[
act_pos
+
1
].
name
].
dialogues
[
card
]
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
if
settings
.
modules
.
vip
.
enabled
and
await
CLIENT_check_vip
(
room
.
dueling_players
[
act_pos
])
and
await
dataManager
.
getUserDialogueText
(
CLIENT_get_authorize_key
(
room
.
dueling_players
[
act_pos
]),
card
)
room
.
playLines
await
dataManager
.
getUserDialogueText
(
CLIENT_get_authorize_key
(
room
.
dueling_players
[
act_pos
]),
card
)
else
if
settings
.
modules
.
vip
.
enabled
and
room
.
hostinfo
.
mode
==
2
and
await
CLIENT_check_vip
(
room
.
dueling_players
[
act_pos
+
1
])
and
await
dataManager
.
getUserDialogueText
(
CLIENT_get_authorize_key
(
room
.
dueling_players
[
act_pos
+
1
]),
card
)
room
.
playLines
await
dataManager
.
getUserDialogueText
(
CLIENT_get_authorize_key
(
room
.
dueling_players
[
act_pos
+
1
]),
card
)
else
if
settings
.
modules
.
dialogues
.
enabled
and
dialogues
.
dialogues
[
card
]
for
line
in
_
.
lines
dialogues
.
dialogues
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues
[
card
].
length
)]
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
room
.
playLines
dialogues
.
dialogues
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues
[
card
].
length
)]
else
if
settings
.
modules
.
dialogues
.
enabled
and
dialogues
.
dialogues_custom
[
card
]
for
line
in
_
.
lines
dialogues
.
dialogues_custom
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues_custom
[
card
].
length
)]
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
)
room
.
playLines
dialogues
.
dialogues_custom
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues_custom
[
card
].
length
)]
if
ygopro
.
constants
.
MSG
[
msg
]
==
'POS_CHANGE'
loc
=
buffer
.
readUInt8
(
6
)
ppos
=
buffer
.
readUInt8
(
8
)
...
...
@@ -3382,22 +3348,20 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
when
'status'
CLIENT_send_vip_status
(
client
,
true
)
when
'buy'
if
vip_info
.
players
[
client
.
name
]
and
vip_info
.
players
[
client
.
name
].
password
!=
client
.
vpass
ygopro
.
stoc_send_chat
(
client
,
"${vip_account_existed}"
,
ygopro
.
constants
.
COLORS
.
RED
)
else
if
(
!
client
.
vpass
and
client
.
name
.
length
>
13
)
or
(
client
.
vpass
and
(
client
.
name
.
length
+
client
.
vpass
.
length
)
>
18
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_player_name_too_long}"
,
ygopro
.
constants
.
COLORS
.
RED
)
if
!
client
.
vpass
ygopro
.
stoc_send_chat
(
client
,
"${vip_no_pass}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
key
=
cmd
[
2
]
buy_result
=
CLIENT_use_cdkey
(
client
,
key
)
buy_result
=
await
CLIENT_use_cdkey
(
client
,
key
)
switch
buy_result
when
0
ygopro
.
stoc_send_chat
(
client
,
"${vip_key_not_found}"
,
ygopro
.
constants
.
COLORS
.
RED
)
when
1
ygopro
.
stoc_send_chat
(
client
,
"${vip_success_new_part1}"
+
client
.
name
+
"$"
+
client
.
vpass
+
"${vip_success_new_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_success_new_part1}"
+
client
.
name
_
vpass
+
"${vip_success_new_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
when
2
ygopro
.
stoc_send_chat
(
client
,
"${vip_success_renew}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
when
'dialogues'
if
!
client
.
vip
if
!
await
CLIENT_check_vip
(
client
)
CLIENT_send_vip_status
(
client
)
else
code
=
cmd
[
2
]
...
...
@@ -3405,12 +3369,10 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
if
!
code
or
!
parseInt
(
code
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_invalid_card_code}"
,
ygopro
.
constants
.
COLORS
.
RED
)
else
if
!
word
delete
vip_info
.
players
[
client
.
name
].
dialogues
[
parseInt
(
code
)]
setting_save
(
vip_info
)
await
dataManager
.
removeUserDialogues
(
CLIENT_get_authorize_key
(
client
),
parseInt
(
code
))
ygopro
.
stoc_send_chat
(
client
,
"${vip_cleared_dialogues_part1}"
+
code
+
"${vip_cleared_dialogues_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
vip_info
.
players
[
client
.
name
].
dialogues
[
parseInt
(
code
)]
=
word
setting_save
(
vip_info
)
await
dataManager
.
setUserDialogues
(
CLIENT_get_authorize_key
(
client
),
parseInt
(
code
),
word
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_set_dialogues_part1}"
+
code
+
"${vip_set_dialogues_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
when
'words'
if
!
client
.
vip
...
...
@@ -3418,12 +3380,10 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
else
word
=
concat_name
(
cmd
,
2
)
if
!
word
delete
vip_info
.
players
[
client
.
name
].
words
setting_save
(
vip_info
)
await
dataManager
.
setUserWords
(
CLIENT_get_authorize_key
(
client
),
null
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_cleared_words}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
vip_info
.
players
[
client
.
name
].
words
=
word
setting_save
(
vip_info
)
await
dataManager
.
setUserWords
(
CLIENT_get_authorize_key
(
client
),
word
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_set_words}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
when
'victory'
if
!
client
.
vip
...
...
@@ -3431,23 +3391,21 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
else
word
=
concat_name
(
cmd
,
2
)
if
!
word
delete
vip_info
.
players
[
client
.
name
].
victory
setting_save
(
vip_info
)
await
dataManager
.
setUserVictoryWords
(
CLIENT_get_authorize_key
(
client
),
null
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_cleared_victory}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
vip_info
.
players
[
client
.
name
].
victory
=
word
setting_save
(
vip_info
)
await
dataManager
.
setUserVictoryWords
(
CLIENT_get_authorize_key
(
client
),
word
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_set_victory}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
when
'password'
if
!
client
.
vip
CLIENT_send_vip_status
(
client
)
else
word
=
cmd
[
2
]
if
word
and
(
client
.
name
.
length
+
word
.
length
)
<=
18
vip_info
.
players
[
client
.
name
].
password
=
word
client
.
vpass
=
word
setting_save
(
vip_info
)
ygopro
.
stoc_send_chat
(
client
,
"${vip_password_changed}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
#
when 'password'
#
if !client.vip
#
CLIENT_send_vip_status(client)
#
else
#
word = cmd[2]
#
if word and (client.name.length + word.length) <= 18
#
vip_info.players[client.name].password = word
#
client.vpass = word
#
setting_save(vip_info)
# ygopro.stoc_send_chat(client, "${vip_password_changed}", ygopro.constants.#
COLORS.BABYBLUE)
else
CLIENT_send_vip_status
(
client
)
...
...
@@ -3985,15 +3943,9 @@ if true
response
.
writeHead
(
200
)
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"Unauthorized."
))
return
else
if
!
u
.
query
.
keytype
or
!
vip_info
.
cdkeys
[
u
.
query
.
keytype
]
response
.
writeHead
(
200
)
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"Key type not found."
))
return
else
ret_keys
=
JSON
.
stringify
(
await
dataMager
.
getVipKeys
(
parseInt
(
u
.
query
.
keytype
)),
null
,
2
)
response
.
writeHead
(
200
)
ret_keys
=
""
for
key
in
vip_info
.
cdkeys
[
u
.
query
.
keytype
]
ret_keys
=
ret_keys
+
u
.
query
.
keytype
+
"D"
+
settings
.
port
+
":"
+
key
+
"
\n
"
response
.
end
(
addCallback
(
u
.
query
.
callback
,
ret_keys
))
else
if
u
.
pathname
==
'/api/archive.zip'
and
settings
.
modules
.
mysql
.
enabled
...
...
ygopro-server.js
View file @
6bf0003b
// Generated by CoffeeScript 2.5.1
(
function
()
{
// 标准库
var
CLIENT_check_vip
,
CLIENT_get_absolute_pos
,
CLIENT_get_authorize_key
,
CLIENT_get_kick_reconnect_target
,
CLIENT_get_partner
,
CLIENT_
heartbeat_register
,
CLIENT_heartbeat_unregister
,
CLIENT_import_data
,
CLIENT_is_able_to_kick_reconnect
,
CLIENT_is_able_to_reconnect
,
CLIENT_is_banned_by_mc
,
CLIENT_is_player
,
CLIENT_kick
,
CLIENT_kick_reconnect
,
CLIENT_pre_reconnect
,
CLIENT_reconnect
,
CLIENT_reconnect_register
,
CLIENT_reconnect_unregister
,
CLIENT_send_pre_reconnect_info
,
CLIENT_send_reconnect_info
,
CLIENT_send_replays
,
CLIENT_send_vip_status
,
CLIENT_use_cdkey
,
Q
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_clear_disconnect
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_pid
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_kick
,
ROOM_player_flee
,
ROOM_player_get_score
,
ROOM_player_lose
,
ROOM_player_win
,
ROOM_players_oppentlist
,
ROOM_players_scores
,
ROOM_unwelcome
,
ROOM_validate
,
ReplayParser
,
ResolveData
,
Room
,
SERVER_clear_disconnect
,
SERVER_kick
,
SOCKET_flush_data
,
VIP_generate_cdkeys
,
_
,
_async
,
addCallback
,
athleticChecker
,
auth
,
axios
,
badwords
,
ban_user
,
bunyan
,
challonge
,
challonge_cache
,
challonge_queue_callbacks
,
checkFileExists
,
concat_name
,
createDirectoryIfNotExists
,
crypto
,
dataManager
,
deck_name_match
,
dialogues
,
disconnect_list
,
exec
,
execFile
,
fs
,
geoip
,
getSeedTimet
,
get_callback
,
get_memory_usage
,
http
,
httpRequestListener
,
importOldConfig
,
import_datas
,
init
,
is_challonge_requesting
,
lflists
,
loadJSON
,
loadJSONAsync
,
loadLFList
,
loadRemoteData
,
load_dialogues
,
load_dialogues_custom
,
load_tips
,
load_tips_zh
,
load_words
,
log
,
long_resolve_cards
,
memory_usage
,
merge
,
moment
,
net
,
netRequestHandler
,
os
,
path
,
qs
,
real_windbot_server_ip
,
refresh_challonge_cache
,
release_disconnect
,
replaced_index
,
report_to_big_brother
,
request
,
roomlist
,
setting_change
,
setting_save
,
settings
,
spawn
,
spawnSync
,
spawn_windbot
,
tips
,
url
,
users_cache
,
util
,
vip_info
,
wait_room_start
,
wait_room_start_arena
,
windbot_looplimit
,
windbot_process
,
windbots
,
words
,
ygopro
,
zlib
;
var
CLIENT_check_vip
,
CLIENT_get_absolute_pos
,
CLIENT_get_authorize_key
,
CLIENT_get_kick_reconnect_target
,
CLIENT_get_partner
,
CLIENT_
get_save_data
,
CLIENT_heartbeat_register
,
CLIENT_heartbeat_unregister
,
CLIENT_import_data
,
CLIENT_is_able_to_kick_reconnect
,
CLIENT_is_able_to_reconnect
,
CLIENT_is_banned_by_mc
,
CLIENT_is_player
,
CLIENT_kick
,
CLIENT_kick_reconnect
,
CLIENT_pre_reconnect
,
CLIENT_reconnect
,
CLIENT_reconnect_register
,
CLIENT_reconnect_unregister
,
CLIENT_send_pre_reconnect_info
,
CLIENT_send_reconnect_info
,
CLIENT_send_replays
,
CLIENT_send_vip_status
,
CLIENT_use_cdkey
,
Q
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_clear_disconnect
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_pid
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_kick
,
ROOM_player_flee
,
ROOM_player_get_score
,
ROOM_player_lose
,
ROOM_player_win
,
ROOM_players_oppentlist
,
ROOM_players_scores
,
ROOM_unwelcome
,
ROOM_validate
,
ReplayParser
,
ResolveData
,
Room
,
SERVER_clear_disconnect
,
SERVER_kick
,
SOCKET_flush_data
,
VIP_generate_cdkeys
,
_
,
_async
,
addCallback
,
athleticChecker
,
auth
,
axios
,
badwords
,
ban_user
,
bunyan
,
challonge
,
challonge_cache
,
challonge_queue_callbacks
,
checkFileExists
,
concat_name
,
createDirectoryIfNotExists
,
crypto
,
dataManager
,
deck_name_match
,
dialogues
,
disconnect_list
,
exec
,
execFile
,
fs
,
geoip
,
getSeedTimet
,
get_callback
,
get_memory_usage
,
http
,
httpRequestListener
,
importOldConfig
,
import_datas
,
init
,
is_challonge_requesting
,
lflists
,
loadJSON
,
loadJSONAsync
,
loadLFList
,
loadRemoteData
,
load_dialogues
,
load_dialogues_custom
,
load_tips
,
load_tips_zh
,
load_words
,
log
,
long_resolve_cards
,
memory_usage
,
merge
,
moment
,
net
,
netRequestHandler
,
os
,
path
,
qs
,
real_windbot_server_ip
,
refresh_challonge_cache
,
release_disconnect
,
replaced_index
,
report_to_big_brother
,
request
,
roomlist
,
setting_change
,
setting_save
,
settings
,
spawn
,
spawnSync
,
spawn_windbot
,
tips
,
url
,
users_cache
,
util
,
wait_room_start
,
wait_room_start_arena
,
windbot_looplimit
,
windbot_process
,
windbots
,
words
,
ygopro
,
zlib
;
net
=
require
(
'
net
'
);
...
...
@@ -133,102 +133,45 @@
await
setting_save
(
settings
);
};
VIP_generate_cdkeys
=
global
.
VIP_generate_cdkeys
=
function
(
key_type
,
count
)
{
var
i
,
j
,
key
,
ref
;
if
(
!
(
settings
.
modules
.
vip
.
enabled
&&
vip_info
.
cdkeys
[
key_type
]))
{
VIP_generate_cdkeys
=
global
.
VIP_generate_cdkeys
=
async
function
(
key_type
,
count
)
{
if
(
!
settings
.
modules
.
vip
.
enabled
)
{
return
false
;
}
for
(
i
=
j
=
0
,
ref
=
count
;
(
0
<=
ref
?
j
<
ref
:
j
>
ref
);
i
=
0
<=
ref
?
++
j
:
--
j
)
{
key
=
Math
.
floor
(
Math
.
random
()
*
10000000000000000
).
toString
();
vip_info
.
cdkeys
[
key_type
].
push
(
key
);
}
setting_save
(
vip_info
);
log
.
info
(
"
keys generated
"
,
key_type
,
count
,
vip_info
.
cdkeys
[
key_type
].
length
);
return
true
;
return
(
await
dataManager
.
generateVipKeys
(
key_type
,
count
));
};
CLIENT_use_cdkey
=
global
.
CLIENT_use_cdkey
=
function
(
client
,
pkey
)
{
var
current_date
,
found_type
,
index
,
j
,
key
,
keys
,
len
,
new_vip
,
ref
,
type
;
if
(
!
(
settings
.
modules
.
vip
.
enabled
&&
pkey
))
{
return
0
;
}
found_type
=
null
;
ref
=
vip_info
.
cdkeys
;
for
(
type
in
ref
)
{
keys
=
ref
[
type
];
// support web given format
for
(
j
=
0
,
len
=
keys
.
length
;
j
<
len
;
j
++
)
{
key
=
keys
[
j
];
if
(
!
(
pkey
===
key
||
pkey
===
(
type
+
"
D
"
+
settings
.
port
+
"
:
"
+
key
)))
{
continue
;
}
found_type
=
parseInt
(
type
);
index
=
_
.
indexOf
(
keys
,
key
);
if
(
index
!==
-
1
)
{
keys
.
splice
(
index
,
1
);
}
break
;
}
if
(
found_type
)
{
break
;
}
}
if
(
!
found_type
)
{
return
0
;
}
if
(
!
vip_info
.
cdkeys
[
found_type
].
length
)
{
VIP_generate_cdkeys
(
found_type
,
settings
.
modules
.
vip
.
generate_count
);
}
client
.
vip
=
true
;
new_vip
=
false
;
if
(
vip_info
.
players
[
client
.
name
])
{
current_date
=
moment
();
if
(
current_date
.
isSameOrBefore
(
vip_info
.
players
[
client
.
name
].
expire_date
))
{
current_date
=
moment
(
vip_info
.
players
[
client
.
name
].
expire_date
,
'
YYYY-MM-DD HH:mm:ss
'
);
}
vip_info
.
players
[
client
.
name
].
expire_date
=
current_date
.
add
(
found_type
,
'
d
'
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
);
}
else
{
if
(
!
client
.
vpass
)
{
client
.
vpass
=
Math
.
floor
(
Math
.
random
()
*
100000
).
toString
();
}
vip_info
.
players
[
client
.
name
]
=
{
password
:
client
.
vpass
,
expire_date
:
moment
().
add
(
found_type
,
'
d
'
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
),
dialogues
:
{}
CLIENT_use_cdkey
=
global
.
CLIENT_use_cdkey
=
async
function
(
client
,
pkey
)
{
var
key
;
key
=
CLIENT_get_authorize_key
(
client
);
return
(
await
dataManager
.
useVipKey
(
key
,
pkey
));
};
new_vip
=
true
;
}
setting_save
(
vip_info
);
return
(
new_vip
?
1
:
2
);
CLIENT_get_save_data
=
global
.
CLIENT_get_save_data
=
async
function
(
client
)
{
return
(
await
dataManager
.
getUser
(
CLIENT_get_authorize_key
(
client
)));
};
CLIENT_check_vip
=
global
.
CLIENT_check_vip
=
function
(
client
)
{
if
(
!
settings
.
modules
.
vip
.
enabled
)
{
return
false
;
}
if
(
!
vip_info
.
players
[
client
.
name
])
{
return
false
;
}
if
(
vip_info
.
players
[
client
.
name
].
password
!==
client
.
vpass
)
{
return
false
;
}
return
moment
().
isSameOrBefore
(
vip_info
.
players
[
client
.
name
].
expire_date
);
CLIENT_check_vip
=
global
.
CLIENT_check_vip
=
async
function
(
client
)
{
var
key
;
key
=
CLIENT_get_authorize_key
(
client
);
return
(
await
dataManager
.
isUserVip
(
key
));
};
CLIENT_send_vip_status
=
global
.
CLIENT_send_vip_status
=
function
(
client
,
display
)
{
CLIENT_send_vip_status
=
global
.
CLIENT_send_vip_status
=
async
function
(
client
,
display
)
{
var
userData
;
if
(
!
settings
.
modules
.
vip
.
enabled
)
{
return
false
;
}
if
(
client
.
vip
)
{
userData
=
(
await
CLIENT_get_save_data
(
client
));
if
(
userData
.
isVip
())
{
if
(
display
)
{
return
ygopro
.
stoc_send_chat
(
client
,
"
${vip_remain_part1}
"
+
vip_info
.
players
[
client
.
name
].
expire_date
+
"
${vip_remain_part2}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
return
ygopro
.
stoc_send_chat
(
client
,
"
${vip_remain_part1}
"
+
moment
(
userData
.
vipExpireDate
).
format
(
"
YYYY-MM-DD HH:mm:ss
"
)
+
"
${vip_remain_part2}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
else
{
return
ygopro
.
stoc_send_chat
(
client
,
"
${vip_remain}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
else
if
(
!
vip_info
.
players
[
client
.
name
]
||
vip_info
.
players
[
client
.
name
].
password
!==
client
.
vpass
)
{
}
else
if
(
!
userData
.
vipExpireDate
)
{
return
ygopro
.
stoc_send_chat
(
client
,
"
${vip_not_bought}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
}
else
{
return
ygopro
.
stoc_send_chat
(
client
,
"
${vip_expired_part1}
"
+
vip_info
.
players
[
client
.
name
].
expire_date
+
"
${vip_expired_part2}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
return
ygopro
.
stoc_send_chat
(
client
,
"
${vip_expired_part1}
"
+
moment
(
userData
.
vipExpireDate
).
format
(
"
YYYY-MM-DD HH:mm:ss
"
)
+
"
${vip_expired_part2}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
}
};
...
...
@@ -318,8 +261,6 @@
words
=
null
;
vip_info
=
null
;
dialogues
=
null
;
badwords
=
null
;
...
...
@@ -413,7 +354,7 @@
};
init
=
async
function
()
{
var
AthleticChecker
,
DataManager
,
challonge_module_name
,
challonge_type
,
chat_color
,
config
,
cppversion
,
defaultConfig
,
default_data
,
dns
,
e
,
http_server
,
https
,
https_server
,
imported
,
j
,
k
,
l
,
len
,
len1
,
len2
,
m
,
mkdirList
,
options
,
pgClient
,
pg_client
,
pg_query
,
plugin_filename
,
plugin_list
,
plugin_path
,
postData
,
ref
,
ref1
,
v
;
var
AthleticChecker
,
DataManager
,
challonge_module_name
,
challonge_type
,
chat_color
,
config
,
cppversion
,
defaultConfig
,
default_data
,
dns
,
e
,
http_server
,
https
,
https_server
,
imported
,
j
,
l
,
len
,
len1
,
len2
,
m
,
mkdirList
,
options
,
pgClient
,
pg_client
,
pg_query
,
plugin_filename
,
plugin_list
,
plugin_path
,
postData
,
ref
,
vip_info
;
await
createDirectoryIfNotExists
(
"
./config
"
);
await
importOldConfig
();
defaultConfig
=
(
await
loadJSONAsync
(
'
./data/default_config.json
'
));
...
...
@@ -539,6 +480,11 @@
await
setting_save
(
settings
);
log
.
warn
(
"
Chat color cannot be enabled because no MySQL.
"
);
}
if
(
settings
.
modules
.
vip
.
enabled
)
{
settings
.
modules
.
vip
.
enabled
=
false
;
await
setting_save
(
settings
);
log
.
warn
(
"
VIP mode cannot be enabled because no MySQL.
"
);
}
}
// 读取数据
default_data
=
(
await
loadJSONAsync
(
'
./data/default_data.json
'
));
...
...
@@ -560,11 +506,17 @@
words
=
global
.
words
=
default_data
.
words
;
await
setting_save
(
words
);
}
if
(
settings
.
modules
.
vip
.
enabled
&&
(
await
checkFileExists
(
'
./config/vip_info.json
'
)))
{
try
{
vip_info
=
global
.
vip_info
=
(
await
loadJSONAsync
(
'
./config/vip_info.json
'
));
vip_info
=
(
await
loadJSONAsync
(
'
./config/vip_info.json
'
));
if
(
vip_info
)
{
await
dataManager
.
migrateFromOldVipInfo
(
vip_info
);
await
fs
.
promises
.
rename
(
'
./config/vip_info.json
'
,
'
./config/vip_info.json.bak
'
);
log
.
info
(
"
VIP info migrated.
"
);
}
}
catch
(
error1
)
{
vip_info
=
global
.
vip_info
=
default_data
.
vip_info
;
await
setting_save
(
vip_info
);
}
}
try
{
badwords
=
global
.
badwords
=
(
await
loadJSONAsync
(
'
./config/badwords.json
'
));
...
...
@@ -888,15 +840,6 @@
}
return
results
;
},
1000
);
if
(
settings
.
modules
.
vip
.
enabled
)
{
ref1
=
vip_info
.
cdkeys
;
for
(
k
in
ref1
)
{
v
=
ref1
[
k
];
if
(
v
.
length
===
0
)
{
VIP_generate_cdkeys
(
k
,
settings
.
modules
.
vip
.
generate_count
);
}
}
}
net
.
createServer
(
netRequestHandler
).
listen
(
settings
.
port
,
function
()
{
log
.
info
(
"
server started
"
,
settings
.
port
);
});
...
...
@@ -1312,8 +1255,6 @@
return
client
.
name_vpass
;
}
else
if
(
settings
.
modules
.
mycard
.
enabled
||
settings
.
modules
.
tournament_mode
.
enabled
||
settings
.
modules
.
challonge
.
enabled
||
client
.
is_local
)
{
return
client
.
name
;
}
else
if
(
client
.
vip
)
{
return
client
.
name
+
"
$
"
+
client
.
vpass
;
}
else
{
return
client
.
ip
+
"
:
"
+
client
.
name
;
}
...
...
@@ -2524,6 +2465,17 @@
}));
}
playLines
(
lines
)
{
var
j
,
len
,
line
,
ref
,
results
;
ref
=
_
.
lines
(
lines
);
results
=
[];
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
line
=
ref
[
j
];
results
.
push
(
ygopro
.
stoc_send_chat_to_room
(
this
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
));
}
return
results
;
}
};
// 网络连接
...
...
@@ -2816,7 +2768,7 @@
client
.
vpass
=
vpass
;
client
.
name_vpass
=
vpass
?
name
+
"
$
"
+
vpass
:
name
;
//console.log client.name, client.vpass
if
(
settings
.
modules
.
vip
.
enabled
&&
CLIENT_check_vip
(
client
))
{
if
(
settings
.
modules
.
vip
.
enabled
&&
(
await
CLIENT_check_vip
(
client
)
))
{
client
.
vip
=
true
;
}
if
(
!
settings
.
modules
.
i18n
.
auto_pick
||
client
.
is_local
)
{
...
...
@@ -2839,7 +2791,7 @@
});
ygopro
.
ctos_follow
(
'
JOIN_GAME
'
,
true
,
async
function
(
buffer
,
info
,
client
,
server
,
datas
)
{
var
available_logs
,
check_buffer_indentity
,
create_room_with_action
,
duelLog
,
exactBan
,
index
,
j
,
l
,
len
,
len1
,
len2
,
len3
,
len4
,
len5
,
line
,
m
,
n
,
name
,
o
,
p
,
pre_room
,
recover_match
,
ref
,
ref1
,
ref2
,
ref3
,
replay
,
replay_id
,
replays
,
room
,
struct
;
var
available_logs
,
check_buffer_indentity
,
create_room_with_action
,
duelLog
,
exactBan
,
index
,
j
,
l
,
len
,
len1
,
len2
,
len3
,
m
,
n
,
name
,
pre_room
,
recover_match
,
ref
,
ref1
,
replay
,
replay_id
,
replays
,
room
,
struct
;
//log.info info
info
.
pass
=
info
.
pass
.
trim
();
client
.
pass
=
info
.
pass
;
...
...
@@ -2917,7 +2869,7 @@
return
(
checksum
&
0xFF
)
===
0
;
};
create_room_with_action
=
async
function
(
buffer
,
decrypted_buffer
,
match_permit
)
{
var
action
,
len2
,
len3
,
len4
,
len5
,
line
,
m
,
n
,
name
,
o
,
opt1
,
opt2
,
opt3
,
options
,
p
,
player
,
ref
,
ref1
,
ref2
,
ref3
,
room
,
room_title
,
title
;
var
action
,
len2
,
len3
,
m
,
n
,
name
,
opt1
,
opt2
,
opt3
,
options
,
player
,
ref
,
ref1
,
room
,
room_title
,
title
;
if
(
client
.
closed
)
{
return
;
}
...
...
@@ -3044,25 +2996,20 @@
client
.
setTimeout
(
300000
);
//连接后超时5分钟
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
);
client
.
is_post_watcher
=
true
;
if
(
settings
.
modules
.
vip
.
enabled
&&
client
.
vip
&&
vip_info
.
players
[
client
.
name
].
words
)
{
ref1
=
_
.
lines
(
vip_info
.
players
[
client
.
name
].
words
);
for
(
n
=
0
,
len3
=
ref1
.
length
;
n
<
len3
;
n
++
)
{
line
=
ref1
[
n
];
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
if
(
settings
.
modules
.
vip
.
enabled
&&
(
await
CLIENT_check_vip
(
client
)))
{
words
=
(
await
dataManager
.
getUserWords
(
CLIENT_get_authorize_key
(
client
)));
if
(
words
)
{
room
.
playLines
(
words
);
}
}
else
if
(
settings
.
modules
.
words
.
enabled
&&
words
.
words
[
client
.
name
])
{
ref2
=
_
.
lines
(
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]);
for
(
o
=
0
,
len4
=
ref2
.
length
;
o
<
len4
;
o
++
)
{
line
=
ref2
[
o
];
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
room
.
playLines
(
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]);
}
ygopro
.
stoc_send_chat_to_room
(
room
,
`
${
client
.
name
}
\${watch_join}`
);
room
.
watchers
.
push
(
client
);
ygopro
.
stoc_send_chat
(
client
,
"
${watch_watching}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ref
3
=
room
.
watcher_buffers
;
for
(
p
=
0
,
len5
=
ref3
.
length
;
p
<
len5
;
p
++
)
{
buffer
=
ref
3
[
p
];
ref
1
=
room
.
watcher_buffers
;
for
(
n
=
0
,
len3
=
ref1
.
length
;
n
<
len3
;
n
++
)
{
buffer
=
ref
1
[
n
];
client
.
write
(
buffer
);
}
}
else
{
...
...
@@ -3220,7 +3167,7 @@
});
}
},
async
function
(
err
,
datas
)
{
var
create_room_name
,
found
,
k
,
len3
,
len4
,
len5
,
len6
,
line
,
match
,
n
,
o
,
p
,
player
,
q
,
ref1
,
ref2
,
ref3
,
ref4
,
ref5
,
ref6
,
user
;
var
create_room_name
,
found
,
k
,
len3
,
len4
,
match
,
n
,
o
,
player
,
ref1
,
ref2
,
ref3
,
ref4
,
user
;
if
(
client
.
closed
)
{
return
;
}
...
...
@@ -3278,25 +3225,20 @@
//client.setTimeout(300000) #连接后超时5分钟
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
);
client
.
is_post_watcher
=
true
;
if
(
settings
.
modules
.
vip
.
enabled
&&
client
.
vip
&&
vip_info
.
players
[
client
.
name
].
words
)
{
ref3
=
_
.
lines
(
vip_info
.
players
[
client
.
name
].
words
);
for
(
n
=
0
,
len3
=
ref3
.
length
;
n
<
len3
;
n
++
)
{
line
=
ref3
[
n
];
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
if
(
settings
.
modules
.
vip
.
enabled
&&
(
await
CLIENT_check_vip
(
client
)))
{
words
=
(
await
dataManager
.
getUserWords
(
CLIENT_get_authorize_key
(
client
)));
if
(
words
)
{
room
.
playLines
(
words
);
}
}
else
if
(
settings
.
modules
.
words
.
enabled
&&
words
.
words
[
client
.
name
])
{
ref4
=
_
.
lines
(
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]);
for
(
o
=
0
,
len4
=
ref4
.
length
;
o
<
len4
;
o
++
)
{
line
=
ref4
[
o
];
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
room
.
playLines
(
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]);
}
ygopro
.
stoc_send_chat_to_room
(
room
,
`
${
client
.
name
}
\${watch_join}`
);
room
.
watchers
.
push
(
client
);
ygopro
.
stoc_send_chat
(
client
,
"
${watch_watching}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ref
5
=
room
.
watcher_buffers
;
for
(
p
=
0
,
len5
=
ref5
.
length
;
p
<
len5
;
p
++
)
{
buffer
=
ref
5
[
p
];
ref
3
=
room
.
watcher_buffers
;
for
(
n
=
0
,
len3
=
ref3
.
length
;
n
<
len3
;
n
++
)
{
buffer
=
ref
3
[
n
];
client
.
write
(
buffer
);
}
}
else
{
...
...
@@ -3305,9 +3247,9 @@
}
else
if
(
room
.
hostinfo
.
no_watch
&&
room
.
players
.
length
>=
(
room
.
hostinfo
.
mode
===
2
?
4
:
2
))
{
ygopro
.
stoc_die
(
client
,
"
${watch_denied_room}
"
);
}
else
{
ref
6
=
room
.
get_playing_player
();
for
(
q
=
0
,
len6
=
ref6
.
length
;
q
<
len6
;
q
++
)
{
player
=
ref
6
[
q
];
ref
4
=
room
.
get_playing_player
();
for
(
o
=
0
,
len4
=
ref4
.
length
;
o
<
len4
;
o
++
)
{
player
=
ref
4
[
o
];
if
(
!
(
player
&&
player
!==
client
&&
player
.
challonge_info
.
id
===
client
.
challonge_info
.
id
))
{
continue
;
}
...
...
@@ -3379,25 +3321,20 @@
client
.
setTimeout
(
300000
);
//连接后超时5分钟
client
.
rid
=
_
.
indexOf
(
ROOM_all
,
room
);
client
.
is_post_watcher
=
true
;
if
(
settings
.
modules
.
vip
.
enabled
&&
client
.
vip
&&
vip_info
.
players
[
client
.
name
].
words
)
{
ref1
=
_
.
lines
(
vip_info
.
players
[
client
.
name
].
words
);
for
(
n
=
0
,
len3
=
ref1
.
length
;
n
<
len3
;
n
++
)
{
line
=
ref1
[
n
];
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
if
(
settings
.
modules
.
vip
.
enabled
&&
(
await
CLIENT_check_vip
(
client
)))
{
words
=
(
await
dataManager
.
getUserWords
(
CLIENT_get_authorize_key
(
client
)));
if
(
words
)
{
room
.
playLines
(
words
);
}
}
else
if
(
settings
.
modules
.
words
.
enabled
&&
words
.
words
[
client
.
name
])
{
ref2
=
_
.
lines
(
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]);
for
(
o
=
0
,
len4
=
ref2
.
length
;
o
<
len4
;
o
++
)
{
line
=
ref2
[
o
];
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
room
.
playLines
(
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]);
}
ygopro
.
stoc_send_chat_to_room
(
room
,
`
${
client
.
name
}
\${watch_join}`
);
room
.
watchers
.
push
(
client
);
ygopro
.
stoc_send_chat
(
client
,
"
${watch_watching}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ref
3
=
room
.
watcher_buffers
;
for
(
p
=
0
,
len5
=
ref3
.
length
;
p
<
len5
;
p
++
)
{
buffer
=
ref
3
[
p
];
ref
1
=
room
.
watcher_buffers
;
for
(
n
=
0
,
len3
=
ref1
.
length
;
n
<
len3
;
n
++
)
{
buffer
=
ref
1
[
n
];
client
.
write
(
buffer
);
}
}
else
{
...
...
@@ -3414,7 +3351,7 @@
});
ygopro
.
stoc_follow
(
'
JOIN_GAME
'
,
false
,
async
function
(
buffer
,
info
,
client
,
server
,
datas
)
{
var
j
,
l
,
len
,
len1
,
len2
,
line
,
m
,
player
,
recorder
,
ref
,
ref1
,
ref2
,
room
,
watcher
;
var
j
,
l
en
,
player
,
recorder
,
ref
,
room
,
watcher
;
//欢迎信息
room
=
ROOM_all
[
client
.
rid
];
if
(
!
(
room
&&
!
client
.
reconnecting
))
{
...
...
@@ -3423,18 +3360,13 @@
if
(
!
room
.
join_game_buffer
)
{
room
.
join_game_buffer
=
buffer
;
}
if
(
settings
.
modules
.
vip
.
enabled
&&
client
.
vip
&&
vip_info
.
players
[
client
.
name
].
words
)
{
ref
=
_
.
lines
(
vip_info
.
players
[
client
.
name
].
words
);
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
line
=
ref
[
j
];
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
if
(
settings
.
modules
.
vip
.
enabled
&&
(
await
CLIENT_check_vip
(
client
)))
{
words
=
(
await
dataManager
.
getUserWords
(
CLIENT_get_authorize_key
(
client
)));
if
(
words
)
{
room
.
playLines
(
words
);
}
}
else
if
(
settings
.
modules
.
words
.
enabled
&&
words
.
words
[
client
.
name
])
{
ref1
=
_
.
lines
(
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]);
for
(
l
=
0
,
len1
=
ref1
.
length
;
l
<
len1
;
l
++
)
{
line
=
ref1
[
l
];
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
room
.
playLines
(
words
.
words
[
client
.
name
][
Math
.
floor
(
Math
.
random
()
*
words
.
words
[
client
.
name
].
length
)]);
}
if
(
settings
.
modules
.
welcome
)
{
ygopro
.
stoc_send_chat
(
client
,
settings
.
modules
.
welcome
,
ygopro
.
constants
.
COLORS
.
GREEN
);
...
...
@@ -3465,9 +3397,9 @@
//client.score_shown = true
if
(
settings
.
modules
.
random_duel
.
record_match_scores
&&
room
.
random_type
===
'
M
'
)
{
ygopro
.
stoc_send_chat_to_room
(
room
,
ROOM_player_get_score
(
client
),
ygopro
.
constants
.
COLORS
.
GREEN
);
ref
2
=
room
.
players
;
for
(
m
=
0
,
len2
=
ref2
.
length
;
m
<
len2
;
m
++
)
{
player
=
ref
2
[
m
];
ref
=
room
.
players
;
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
player
=
ref
[
j
];
if
(
player
.
pos
!==
7
&&
player
!==
client
)
{
ygopro
.
stoc_send_chat
(
client
,
ROOM_player_get_score
(
player
),
ygopro
.
constants
.
COLORS
.
GREEN
);
}
...
...
@@ -3505,15 +3437,15 @@
ygopro
.
ctos_send
(
watcher
,
'
HS_TOOBSERVER
'
);
});
watcher
.
on
(
'
data
'
,
function
(
data
)
{
var
l
en3
,
n
,
ref3
,
w
;
var
l
,
len1
,
ref1
,
w
;
room
=
ROOM_all
[
client
.
rid
];
if
(
!
room
)
{
return
;
}
room
.
watcher_buffers
.
push
(
data
);
ref
3
=
room
.
watchers
;
for
(
n
=
0
,
len3
=
ref3
.
length
;
n
<
len3
;
n
++
)
{
w
=
ref
3
[
n
];
ref
1
=
room
.
watchers
;
for
(
l
=
0
,
len1
=
ref1
.
length
;
l
<
len1
;
l
++
)
{
w
=
ref
1
[
l
];
if
(
w
)
{
//a WTF fix
w
.
write
(
data
);
}
...
...
@@ -3539,7 +3471,7 @@
};
ygopro
.
stoc_follow
(
'
GAME_MSG
'
,
true
,
async
function
(
buffer
,
info
,
client
,
server
,
datas
)
{
var
act_pos
,
card
,
chain
,
check
,
count
,
cpos
,
deck_found
,
found
,
hint_type
,
i
,
id
,
j
,
l
,
len
,
len1
,
len2
,
len3
,
l
en4
,
len5
,
len6
,
len7
,
len8
,
limbo_found
,
line
,
loc
,
m
,
max_loop
,
msg
,
n
,
o
,
oppo_pos
,
p
,
phase
,
player
,
playertype
,
pos
,
ppos
,
q
,
r
,
r_player
,
reason
,
ref
,
ref1
,
ref10
,
ref2
,
ref3
,
ref4
,
ref5
,
ref6
,
ref7
,
ref8
,
ref9
,
room
,
s
,
t
,
trigger_location
,
val
,
win_pos
;
var
act_pos
,
card
,
chain
,
check
,
count
,
cpos
,
deck_found
,
found
,
hint_type
,
i
,
id
,
j
,
l
,
len
,
len1
,
len2
,
len3
,
l
imbo_found
,
loc
,
m
,
max_loop
,
msg
,
n
,
o
,
oppo_pos
,
phase
,
player
,
playertype
,
pos
,
ppos
,
r_player
,
reason
,
ref
,
ref1
,
ref2
,
ref3
,
ref4
,
room
,
trigger_location
,
val
,
victoryWordPlayerList
,
win_pos
;
room
=
ROOM_all
[
client
.
rid
];
if
(
!
(
room
&&
!
client
.
reconnecting
))
{
return
;
...
...
@@ -3715,17 +3647,19 @@
room
.
match_kill
=
false
;
room
.
scores
[
room
.
winner_name
]
=
99
;
}
if
(
settings
.
modules
.
vip
.
enabled
&&
room
.
dueling_players
[
pos
].
vip
&&
vip_info
.
players
[
room
.
dueling_players
[
pos
].
name
].
victory
)
{
ref1
=
_
.
lines
(
vip_info
.
players
[
room
.
dueling_players
[
pos
].
name
].
victory
);
for
(
l
=
0
,
len1
=
ref1
.
length
;
l
<
len1
;
l
++
)
{
line
=
ref1
[
l
];
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
if
(
settings
.
modules
.
vip
.
enabled
)
{
victoryWordPlayerList
=
[
room
.
dueling_players
[
pos
]];
if
(
room
.
hostinfo
.
mode
===
2
)
{
victoryWordPlayerList
.
push
(
room
.
dueling_players
[
pos
+
1
]);
}
}
else
if
(
room
.
hostinfo
.
mode
===
2
&&
settings
.
modules
.
vip
.
enabled
&&
room
.
dueling_players
[
pos
+
1
].
vip
&&
vip_info
.
players
[
room
.
dueling_players
[
pos
+
1
].
name
].
victory
)
{
ref2
=
_
.
lines
(
vip_info
.
players
[
room
.
dueling_players
[
pos
+
1
].
name
].
victory
);
for
(
m
=
0
,
len2
=
ref2
.
length
;
m
<
len2
;
m
++
)
{
line
=
ref2
[
m
];
ygopro
.
stoc_send_chat_to_room
(
room
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
for
(
l
=
0
,
len1
=
victoryWordPlayerList
.
length
;
l
<
len1
;
l
++
)
{
player
=
victoryWordPlayerList
[
l
];
if
(
!
((
await
CLIENT_check_vip
(
player
))
&&
(
await
dataManager
.
getUserVictoryWords
(
CLIENT_get_authorize_key
(
player
)))))
{
continue
;
}
words
=
(
await
dataManager
.
getUserVictoryWords
(
CLIENT_get_authorize_key
(
player
)));
room
.
playLines
(
words
);
break
;
}
}
}
...
...
@@ -3754,7 +3688,7 @@
if
(
room
.
dueling_players
[
pos
].
lp
<
0
)
{
room
.
dueling_players
[
pos
].
lp
=
0
;
}
if
((
0
<
(
ref
3
=
room
.
dueling_players
[
pos
].
lp
)
&&
ref3
<=
100
))
{
if
((
0
<
(
ref
1
=
room
.
dueling_players
[
pos
].
lp
)
&&
ref1
<=
100
))
{
ygopro
.
stoc_send_chat_to_room
(
room
,
"
${lp_low_opponent}
"
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
}
...
...
@@ -3793,7 +3727,7 @@
if
(
room
.
dueling_players
[
pos
].
lp
<
0
)
{
room
.
dueling_players
[
pos
].
lp
=
0
;
}
if
((
0
<
(
ref
4
=
room
.
dueling_players
[
pos
].
lp
)
&&
ref4
<=
100
))
{
if
((
0
<
(
ref
2
=
room
.
dueling_players
[
pos
].
lp
)
&&
ref2
<=
100
))
{
ygopro
.
stoc_send_chat_to_room
(
room
,
"
${lp_low_self}
"
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
}
...
...
@@ -3834,7 +3768,7 @@
max_loop
=
3
+
(
count
-
1
)
*
7
;
deck_found
=
0
;
limbo_found
=
0
;
// support custom cards which may be in location 0 in KoishiPro or EdoPro
for
(
i
=
n
=
3
,
ref5
=
max_loop
;
n
<=
ref5
;
i
=
n
+=
7
)
{
for
(
i
=
m
=
3
,
ref3
=
max_loop
;
m
<=
ref3
;
i
=
m
+=
7
)
{
loc
=
buffer
.
readInt8
(
i
+
5
);
if
((
loc
&
0x41
)
>
0
)
{
deck_found
++
;
...
...
@@ -3856,8 +3790,8 @@
if
(
ygopro
.
constants
.
MSG
[
msg
]
===
'
CHAINING
'
)
{
card
=
buffer
.
readUInt32LE
(
1
);
found
=
false
;
for
(
o
=
0
,
len3
=
long_resolve_cards
.
length
;
o
<
len3
;
o
++
)
{
id
=
long_resolve_cards
[
o
];
for
(
n
=
0
,
len2
=
long_resolve_cards
.
length
;
n
<
len2
;
n
++
)
{
id
=
long_resolve_cards
[
n
];
if
(
!
(
id
===
card
))
{
continue
;
}
...
...
@@ -3882,9 +3816,9 @@
chain
=
buffer
.
readInt8
(
1
);
// console.log(2,chain)
if
(
room
.
long_resolve_chain
[
chain
])
{
ref
6
=
room
.
get_playing_player
();
for
(
p
=
0
,
len4
=
ref6
.
length
;
p
<
len4
;
p
++
)
{
player
=
ref
6
[
p
];
ref
4
=
room
.
get_playing_player
();
for
(
o
=
0
,
len3
=
ref4
.
length
;
o
<
len3
;
o
++
)
{
player
=
ref
4
[
o
];
player
.
heartbeat_protected
=
true
;
}
}
...
...
@@ -3911,30 +3845,14 @@
act_pos
=
act_pos
*
2
;
}
if
(
ygopro
.
constants
.
MSG
[
msg
]
!==
'
CHAINING
'
||
(
trigger_location
&
0x8
)
&&
client
.
ready_trap
)
{
if
(
settings
.
modules
.
vip
.
enabled
&&
room
.
dueling_players
[
act_pos
].
vip
&&
vip_info
.
players
[
room
.
dueling_players
[
act_pos
].
name
].
dialogues
[
card
])
{
ref7
=
_
.
lines
(
vip_info
.
players
[
room
.
dueling_players
[
act_pos
].
name
].
dialogues
[
card
]);
for
(
q
=
0
,
len5
=
ref7
.
length
;
q
<
len5
;
q
++
)
{
line
=
ref7
[
q
];
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
}
else
if
(
settings
.
modules
.
vip
.
enabled
&&
room
.
hostinfo
.
mode
===
2
&&
room
.
dueling_players
[
act_pos
+
1
].
vip
&&
vip_info
.
players
[
room
.
dueling_players
[
act_pos
+
1
].
name
].
dialogues
[
card
])
{
ref8
=
_
.
lines
(
vip_info
.
players
[
room
.
dueling_players
[
act_pos
+
1
].
name
].
dialogues
[
card
]);
for
(
r
=
0
,
len6
=
ref8
.
length
;
r
<
len6
;
r
++
)
{
line
=
ref8
[
r
];
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
if
(
settings
.
modules
.
vip
.
enabled
&&
(
await
CLIENT_check_vip
(
room
.
dueling_players
[
act_pos
]))
&&
(
await
dataManager
.
getUserDialogueText
(
CLIENT_get_authorize_key
(
room
.
dueling_players
[
act_pos
]),
card
)))
{
room
.
playLines
((
await
dataManager
.
getUserDialogueText
(
CLIENT_get_authorize_key
(
room
.
dueling_players
[
act_pos
]),
card
)));
}
else
if
(
settings
.
modules
.
vip
.
enabled
&&
room
.
hostinfo
.
mode
===
2
&&
(
await
CLIENT_check_vip
(
room
.
dueling_players
[
act_pos
+
1
]))
&&
(
await
dataManager
.
getUserDialogueText
(
CLIENT_get_authorize_key
(
room
.
dueling_players
[
act_pos
+
1
]),
card
)))
{
room
.
playLines
((
await
dataManager
.
getUserDialogueText
(
CLIENT_get_authorize_key
(
room
.
dueling_players
[
act_pos
+
1
]),
card
)));
}
else
if
(
settings
.
modules
.
dialogues
.
enabled
&&
dialogues
.
dialogues
[
card
])
{
ref9
=
_
.
lines
(
dialogues
.
dialogues
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues
[
card
].
length
)]);
for
(
s
=
0
,
len7
=
ref9
.
length
;
s
<
len7
;
s
++
)
{
line
=
ref9
[
s
];
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
room
.
playLines
(
dialogues
.
dialogues
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues
[
card
].
length
)]);
}
else
if
(
settings
.
modules
.
dialogues
.
enabled
&&
dialogues
.
dialogues_custom
[
card
])
{
ref10
=
_
.
lines
(
dialogues
.
dialogues_custom
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues_custom
[
card
].
length
)]);
for
(
t
=
0
,
len8
=
ref10
.
length
;
t
<
len8
;
t
++
)
{
line
=
ref10
[
t
];
ygopro
.
stoc_send_chat
(
client
,
line
,
ygopro
.
constants
.
COLORS
.
PINK
);
}
room
.
playLines
(
dialogues
.
dialogues_custom
[
card
][
Math
.
floor
(
Math
.
random
()
*
dialogues
.
dialogues_custom
[
card
].
length
)]);
}
}
}
...
...
@@ -4586,19 +4504,17 @@
CLIENT_send_vip_status
(
client
,
true
);
break
;
case
'
buy
'
:
if
(
vip_info
.
players
[
client
.
name
]
&&
vip_info
.
players
[
client
.
name
].
password
!==
client
.
vpass
)
{
ygopro
.
stoc_send_chat
(
client
,
"
${vip_account_existed}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
}
else
if
((
!
client
.
vpass
&&
client
.
name
.
length
>
13
)
||
(
client
.
vpass
&&
(
client
.
name
.
length
+
client
.
vpass
.
length
)
>
18
))
{
ygopro
.
stoc_send_chat
(
client
,
"
${vip_player_name_too_long}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
if
(
!
client
.
vpass
)
{
ygopro
.
stoc_send_chat
(
client
,
"
${vip_no_pass}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
else
{
key
=
cmd
[
2
];
buy_result
=
CLIENT_use_cdkey
(
client
,
key
);
buy_result
=
(
await
CLIENT_use_cdkey
(
client
,
key
)
);
switch
(
buy_result
)
{
case
0
:
ygopro
.
stoc_send_chat
(
client
,
"
${vip_key_not_found}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
break
;
case
1
:
ygopro
.
stoc_send_chat
(
client
,
"
${vip_success_new_part1}
"
+
client
.
name
+
"
$
"
+
client
.
vpass
+
"
${vip_success_new_part2}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
ygopro
.
stoc_send_chat
(
client
,
"
${vip_success_new_part1}
"
+
client
.
name
_
vpass
+
"
${vip_success_new_part2}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
break
;
case
2
:
ygopro
.
stoc_send_chat
(
client
,
"
${vip_success_renew}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
...
...
@@ -4606,7 +4522,7 @@
}
break
;
case
'
dialogues
'
:
if
(
!
client
.
vip
)
{
if
(
!
(
await
CLIENT_check_vip
(
client
))
)
{
CLIENT_send_vip_status
(
client
);
}
else
{
code
=
cmd
[
2
];
...
...
@@ -4614,12 +4530,10 @@
if
(
!
code
||
!
parseInt
(
code
))
{
ygopro
.
stoc_send_chat
(
client
,
"
${vip_invalid_card_code}
"
,
ygopro
.
constants
.
COLORS
.
RED
);
}
else
if
(
!
word
)
{
delete
vip_info
.
players
[
client
.
name
].
dialogues
[
parseInt
(
code
)];
setting_save
(
vip_info
);
await
dataManager
.
removeUserDialogues
(
CLIENT_get_authorize_key
(
client
),
parseInt
(
code
));
ygopro
.
stoc_send_chat
(
client
,
"
${vip_cleared_dialogues_part1}
"
+
code
+
"
${vip_cleared_dialogues_part2}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
else
{
vip_info
.
players
[
client
.
name
].
dialogues
[
parseInt
(
code
)]
=
word
;
setting_save
(
vip_info
);
await
dataManager
.
setUserDialogues
(
CLIENT_get_authorize_key
(
client
),
parseInt
(
code
),
word
);
ygopro
.
stoc_send_chat
(
client
,
"
${vip_set_dialogues_part1}
"
+
code
+
"
${vip_set_dialogues_part2}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
...
...
@@ -4630,12 +4544,10 @@
}
else
{
word
=
concat_name
(
cmd
,
2
);
if
(
!
word
)
{
delete
vip_info
.
players
[
client
.
name
].
words
;
setting_save
(
vip_info
);
await
dataManager
.
setUserWords
(
CLIENT_get_authorize_key
(
client
),
null
);
ygopro
.
stoc_send_chat
(
client
,
"
${vip_cleared_words}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
else
{
vip_info
.
players
[
client
.
name
].
words
=
word
;
setting_save
(
vip_info
);
await
dataManager
.
setUserWords
(
CLIENT_get_authorize_key
(
client
),
word
);
ygopro
.
stoc_send_chat
(
client
,
"
${vip_set_words}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
...
...
@@ -4646,30 +4558,25 @@
}
else
{
word
=
concat_name
(
cmd
,
2
);
if
(
!
word
)
{
delete
vip_info
.
players
[
client
.
name
].
victory
;
setting_save
(
vip_info
);
await
dataManager
.
setUserVictoryWords
(
CLIENT_get_authorize_key
(
client
),
null
);
ygopro
.
stoc_send_chat
(
client
,
"
${vip_cleared_victory}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
else
{
vip_info
.
players
[
client
.
name
].
victory
=
word
;
setting_save
(
vip_info
);
await
dataManager
.
setUserVictoryWords
(
CLIENT_get_authorize_key
(
client
),
word
);
ygopro
.
stoc_send_chat
(
client
,
"
${vip_set_victory}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
break
;
case
'
password
'
:
if
(
!
client
.
vip
)
{
CLIENT_send_vip_status
(
client
);
}
else
{
word
=
cmd
[
2
];
if
(
word
&&
(
client
.
name
.
length
+
word
.
length
)
<=
18
)
{
vip_info
.
players
[
client
.
name
].
password
=
word
;
client
.
vpass
=
word
;
setting_save
(
vip_info
);
ygopro
.
stoc_send_chat
(
client
,
"
${vip_password_changed}
"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
}
}
else
{
//when 'password'
// if !client.vip
// CLIENT_send_vip_status(client)
// else
// word = cmd[2]
// if word and (client.name.length + word.length) <= 18
// vip_info.players[client.name].password = word
// client.vpass = word
// setting_save(vip_info)
// ygopro.stoc_send_chat(client, "${vip_password_changed}", ygopro.constants.#COLORS.BABYBLUE)
CLIENT_send_vip_status
(
client
);
}
}
...
...
@@ -5322,7 +5229,7 @@
return
callback
+
"
(
"
+
text
+
"
);
"
;
};
httpRequestListener
=
async
function
(
request
,
response
)
{
var
archive_args
,
archive_name
,
archive_process
,
buffer
,
check
,
death_room_found
,
duellog
,
e
,
err
,
error
,
filename
,
getpath
,
j
,
key
,
l
,
len
,
len1
,
parseQueryString
,
pass_validated
,
ref
,
ref1
,
ret_keys
,
roomsjson
,
success
,
u
;
var
archive_args
,
archive_name
,
archive_process
,
buffer
,
check
,
death_room_found
,
duellog
,
e
,
err
,
error
,
filename
,
getpath
,
j
,
len
,
parseQueryString
,
pass_validated
,
ref
,
ret_keys
,
roomsjson
,
success
,
u
;
parseQueryString
=
true
;
u
=
url
.
parse
(
request
.
url
,
parseQueryString
);
//pass_validated = u.query.pass == settings.modules.http.password
...
...
@@ -5393,18 +5300,9 @@
response
.
writeHead
(
200
);
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"
Unauthorized.
"
));
return
;
}
else
if
(
!
u
.
query
.
keytype
||
!
vip_info
.
cdkeys
[
u
.
query
.
keytype
])
{
response
.
writeHead
(
200
);
response
.
end
(
addCallback
(
u
.
query
.
callback
,
"
Key type not found.
"
));
return
;
}
else
{
ret_keys
=
JSON
.
stringify
((
await
dataMager
.
getVipKeys
(
parseInt
(
u
.
query
.
keytype
))),
null
,
2
);
response
.
writeHead
(
200
);
ret_keys
=
""
;
ref
=
vip_info
.
cdkeys
[
u
.
query
.
keytype
];
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
key
=
ref
[
j
];
ret_keys
=
ret_keys
+
u
.
query
.
keytype
+
"
D
"
+
settings
.
port
+
"
:
"
+
key
+
"
\n
"
;
}
response
.
end
(
addCallback
(
u
.
query
.
callback
,
ret_keys
));
}
}
else
if
(
u
.
pathname
===
'
/api/archive.zip
'
&&
settings
.
modules
.
mysql
.
enabled
)
{
...
...
@@ -5417,9 +5315,9 @@
archive_name
=
moment
().
format
(
'
YYYY-MM-DD HH-mm-ss
'
)
+
"
.zip
"
;
archive_args
=
[
"
a
"
,
"
-mx0
"
,
"
-y
"
,
archive_name
];
check
=
false
;
ref
1
=
(
await
dataManager
.
getAllReplayFilenames
());
for
(
l
=
0
,
len1
=
ref1
.
length
;
l
<
len1
;
l
++
)
{
filename
=
ref
1
[
l
];
ref
=
(
await
dataManager
.
getAllReplayFilenames
());
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
filename
=
ref
[
j
];
check
=
true
;
archive_args
.
push
(
filename
);
}
...
...
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