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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
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
srvpro
Commits
d3b9a3f6
Commit
d3b9a3f6
authored
Jan 05, 2016
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
separate banned players
parent
522627c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
18 deletions
+54
-18
room.coffee
room.coffee
+20
-7
room.js
room.js
+34
-11
No files found.
room.coffee
View file @
d3b9a3f6
...
...
@@ -58,12 +58,14 @@ class Room
bannedplayer
=
_
.
find
Room
.
players_banned
,
(
bannedplayer
)
->
ip
==
bannedplayer
.
ip
if
bannedplayer
bantime
=
Math
.
pow
(
2
,
bannedplayer
.
count
)
*
30
bannedplayer
.
time
=
if
moment
()
<
bannedplayer
.
time
then
moment
(
bannedplayer
.
time
).
add
(
bantime
,
's'
)
else
moment
().
add
(
bantime
,
's'
)
bannedplayer
.
count
=
bannedplayer
.
count
+
1
bannedplayer
.
reason
=
reason
bantime
=
if
bannedplayer
.
count
>
3
then
Math
.
pow
(
2
,
bannedplayer
.
count
-
3
)
*
2
else
0
bannedplayer
.
time
=
if
moment
()
<
bannedplayer
.
time
then
moment
(
bannedplayer
.
time
).
add
(
bantime
,
'm'
)
else
moment
().
add
(
bantime
,
'm'
)
bannedplayer
.
reasons
.
push
(
reason
)
if
not
_
.
find
bannedplayer
.
reasons
,
(
bannedreason
)
->
bannedreason
==
reason
bannedplayer
.
need_tip
=
true
;
else
Room
.
players_banned
.
push
{
"ip"
:
ip
,
"time"
:
moment
()
.
add
(
30
,
's'
),
"count"
:
1
,
"reason"
:
reason
}
Room
.
players_banned
.
push
{
"ip"
:
ip
,
"time"
:
moment
()
,
"count"
:
1
,
"reasons"
:
[
reason
],
"need_tip"
:
true
}
@
find_or_create_by_name
:
(
name
,
player_ip
)
->
if
settings
.
modules
.
enable_random_duel
and
(
name
==
''
or
name
.
toUpperCase
()
==
'S'
or
name
.
toUpperCase
()
==
'M'
or
name
.
toUpperCase
()
==
'T'
)
...
...
@@ -78,11 +80,21 @@ class Room
@
find_or_create_random
:
(
type
,
player_ip
)
->
bannedplayer
=
_
.
find
Room
.
players_banned
,
(
bannedplayer
)
->
return
player_ip
==
bannedplayer
.
ip
if
bannedplayer
and
moment
()
<
bannedplayer
.
time
return
{
"error"
:
"因为您近期在游戏中
#{
bannedplayer
.
reason
}
,您已被禁止使用随机对战功能,将在
#{
moment
(
bannedplayer
.
time
).
fromNow
(
true
)
}
后解封"
}
if
bannedplayer
if
bannedplayer
.
count
>
6
and
moment
()
<
bannedplayer
.
time
return
{
"error"
:
"因为您近期在游戏中多次
#{
bannedplayer
.
reasons
.
join
(
'、'
)
}
,您已被禁止使用随机对战功能,将在
#{
moment
(
bannedplayer
.
time
).
fromNow
(
true
)
}
后解封"
}
if
bannedplayer
.
count
>
3
and
moment
()
<
bannedplayer
.
time
and
bannedplayer
.
need_tip
bannedplayer
.
need_tip
=
false
return
{
"error"
:
"因为您近期在游戏中
#{
bannedplayer
.
reasons
.
join
(
'、'
)
}
,在
#{
moment
(
bannedplayer
.
time
).
fromNow
(
true
)
}
内您随机对战时只能遇到其他违规玩家"
}
else
if
bannedplayer
.
need_tip
bannedplayer
.
need_tip
=
false
return
{
"error"
:
"系统检测到您近期在游戏中
#{
bannedplayer
.
reasons
.
join
(
'、'
)
}
,若您违规超过3次,将受到惩罚"
}
else
if
bannedplayer
.
count
>
2
bannedplayer
.
need_tip
=
true
max_player
=
if
type
==
'T'
then
4
else
2
playerbanned
=
(
bannedplayer
and
bannedplayer
.
count
>
3
and
moment
()
<
bannedplayer
.
time
)
result
=
_
.
find
@
all
,
(
room
)
->
r
oom
.
random_type
!=
''
and
!
room
.
started
and
((
type
==
''
and
room
.
random_type
!=
'T'
)
or
room
.
random_type
==
type
)
and
room
.
get_playing_player
().
length
<
max_player
and
(
room
.
get_host
()
==
null
or
room
.
get_host
().
remoteAddress
!=
Room
.
players_oppentlist
[
player_ip
]
)
r
eturn
room
.
random_type
!=
''
and
!
room
.
started
and
((
type
==
''
and
room
.
random_type
!=
'T'
)
or
room
.
random_type
==
type
)
and
room
.
get_playing_player
().
length
<
max_player
and
(
room
.
get_host
()
==
null
or
room
.
get_host
().
remoteAddress
!=
Room
.
players_oppentlist
[
player_ip
])
and
(
playerbanned
==
room
.
deprecated
)
if
result
result
.
welcome
=
'对手已经在等你了,开始决斗吧!'
#log.info 'found room', player_name
...
...
@@ -93,6 +105,7 @@ class Room
result
.
random_type
=
type
result
.
max_player
=
max_player
result
.
welcome
=
'已建立随机对战房间,正在等待对手!'
result
.
deprecated
=
playerbanned
#log.info 'create room', player_name, name
return
result
...
...
room.js
View file @
d3b9a3f6
...
...
@@ -74,16 +74,22 @@
return
ip
===
bannedplayer
.
ip
;
});
if
(
bannedplayer
)
{
bantime
=
Math
.
pow
(
2
,
bannedplayer
.
count
)
*
30
;
bannedplayer
.
time
=
moment
()
<
bannedplayer
.
time
?
moment
(
bannedplayer
.
time
).
add
(
bantime
,
'
s
'
)
:
moment
().
add
(
bantime
,
'
s
'
);
bannedplayer
.
count
=
bannedplayer
.
count
+
1
;
return
bannedplayer
.
reason
=
reason
;
bantime
=
bannedplayer
.
count
>
3
?
Math
.
pow
(
2
,
bannedplayer
.
count
-
3
)
*
2
:
0
;
bannedplayer
.
time
=
moment
()
<
bannedplayer
.
time
?
moment
(
bannedplayer
.
time
).
add
(
bantime
,
'
m
'
)
:
moment
().
add
(
bantime
,
'
m
'
);
if
(
!
_
.
find
(
bannedplayer
.
reasons
,
function
(
bannedreason
)
{
return
bannedreason
===
reason
;
}))
{
bannedplayer
.
reasons
.
push
(
reason
);
}
return
bannedplayer
.
need_tip
=
true
;
}
else
{
return
Room
.
players_banned
.
push
({
"
ip
"
:
ip
,
"
time
"
:
moment
()
.
add
(
30
,
'
s
'
)
,
"
time
"
:
moment
(),
"
count
"
:
1
,
"
reason
"
:
reason
"
reasons
"
:
[
reason
],
"
need_tip
"
:
true
});
}
};
...
...
@@ -103,18 +109,34 @@
};
Room
.
find_or_create_random
=
function
(
type
,
player_ip
)
{
var
bannedplayer
,
max_player
,
name
,
result
;
var
bannedplayer
,
max_player
,
name
,
playerbanned
,
result
;
bannedplayer
=
_
.
find
(
Room
.
players_banned
,
function
(
bannedplayer
)
{
return
player_ip
===
bannedplayer
.
ip
;
});
if
(
bannedplayer
&&
moment
()
<
bannedplayer
.
time
)
{
return
{
"
error
"
:
"
因为您近期在游戏中
"
+
bannedplayer
.
reason
+
"
,您已被禁止使用随机对战功能,将在
"
+
(
moment
(
bannedplayer
.
time
).
fromNow
(
true
))
+
"
后解封
"
};
if
(
bannedplayer
)
{
if
(
bannedplayer
.
count
>
6
&&
moment
()
<
bannedplayer
.
time
)
{
return
{
"
error
"
:
"
因为您近期在游戏中多次
"
+
(
bannedplayer
.
reasons
.
join
(
'
、
'
))
+
"
,您已被禁止使用随机对战功能,将在
"
+
(
moment
(
bannedplayer
.
time
).
fromNow
(
true
))
+
"
后解封
"
};
}
if
(
bannedplayer
.
count
>
3
&&
moment
()
<
bannedplayer
.
time
&&
bannedplayer
.
need_tip
)
{
bannedplayer
.
need_tip
=
false
;
return
{
"
error
"
:
"
因为您近期在游戏中
"
+
(
bannedplayer
.
reasons
.
join
(
'
、
'
))
+
"
,在
"
+
(
moment
(
bannedplayer
.
time
).
fromNow
(
true
))
+
"
内您随机对战时只能遇到其他违规玩家
"
};
}
else
if
(
bannedplayer
.
need_tip
)
{
bannedplayer
.
need_tip
=
false
;
return
{
"
error
"
:
"
系统检测到您近期在游戏中
"
+
(
bannedplayer
.
reasons
.
join
(
'
、
'
))
+
"
,若您违规超过3次,将受到惩罚
"
};
}
else
if
(
bannedplayer
.
count
>
2
)
{
bannedplayer
.
need_tip
=
true
;
}
}
max_player
=
type
===
'
T
'
?
4
:
2
;
playerbanned
=
bannedplayer
&&
bannedplayer
.
count
>
3
&&
moment
()
<
bannedplayer
.
time
;
result
=
_
.
find
(
this
.
all
,
function
(
room
)
{
return
room
.
random_type
!==
''
&&
!
room
.
started
&&
((
type
===
''
&&
room
.
random_type
!==
'
T
'
)
||
room
.
random_type
===
type
)
&&
room
.
get_playing_player
().
length
<
max_player
&&
(
room
.
get_host
()
===
null
||
room
.
get_host
().
remoteAddress
!==
Room
.
players_oppentlist
[
player_ip
]);
return
room
.
random_type
!==
''
&&
!
room
.
started
&&
((
type
===
''
&&
room
.
random_type
!==
'
T
'
)
||
room
.
random_type
===
type
)
&&
room
.
get_playing_player
().
length
<
max_player
&&
(
room
.
get_host
()
===
null
||
room
.
get_host
().
remoteAddress
!==
Room
.
players_oppentlist
[
player_ip
])
&&
(
playerbanned
===
room
.
deprecated
)
;
});
if
(
result
)
{
result
.
welcome
=
'
对手已经在等你了,开始决斗吧!
'
;
...
...
@@ -125,6 +147,7 @@
result
.
random_type
=
type
;
result
.
max_player
=
max_player
;
result
.
welcome
=
'
已建立随机对战房间,正在等待对手!
'
;
result
.
deprecated
=
playerbanned
;
}
return
result
;
};
...
...
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