Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7071045

Browse files
committed
adjust MinPlayerStartup and check mode
1 parent 2519d58 commit 7071045

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

‎models/room/room.go‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const (
2222

2323
// Limits etc
2424
PlayerLimit = 100
25-
MinPlayerStartup = 4
26-
WaitingTime = time.Second*2
25+
MinPlayerStartup = 2
26+
WaitingTime = 120000
2727

2828
// States
2929
WaitingState = 0
@@ -62,6 +62,10 @@ func New(mode uint8) *Room {
6262
r.Players = make([]*player.Player, 0)
6363
r.Items = make([]*item.Item, 0)
6464

65+
if mode == EliminationMode {
66+
r.State = WaitingState
67+
}
68+
6569
Rooms[r.ID] = &r
6670

6771
return &r
@@ -136,3 +140,27 @@ func (r *Room) RemovePlayer(index int) bool {
136140
r.Players = r.Players[:len(r.Players)-1]
137141
return true
138142
}
143+
144+
func (r *Room) StartsAt() int64 {
145+
if r.State == WaitingState {
146+
return 0
147+
}
148+
149+
return r.CountdownStarted + WaitingTime
150+
}
151+
152+
func (r *Room) IsSingle() bool {
153+
return len(r.Players) == 0
154+
}
155+
156+
func FindLobbyByWebsocketID(id string) *Room {
157+
for i, r := range Rooms {
158+
pl := r.GetPlayerIndexByWebSocketID(id)
159+
if pl < 0 {
160+
continue
161+
}
162+
163+
return Rooms[i]
164+
}
165+
return nil
166+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /