File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
src/main/kotlin/org/gitanimals/guild/domain Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ class Guild(
91
91
contributions = memberContributions,
92
92
personaType = memberPersonaType,
93
93
)
94
+ require(members.size < MAX_MEMBER_SIZE ) {
95
+ " Cannot join guild cause already has 15 members."
96
+ }
94
97
members.add(member)
95
98
return
96
99
}
@@ -109,6 +112,10 @@ class Guild(
109
112
fun getLeaderUserId (): Long = leader.userId
110
113
111
114
fun accept (acceptUserId : Long ) {
115
+ require(members.size < MAX_MEMBER_SIZE ) {
116
+ " Cannot accept member cause already has 15 members."
117
+ }
118
+
112
119
val acceptUser = waitMembers.firstOrNull { it.userId == acceptUserId }
113
120
? : throw IllegalArgumentException (" Cannot find waitMember by userId: \" $acceptUserId \" " )
114
121
waitMembers.remove(acceptUser)
@@ -233,6 +240,9 @@ class Guild(
233
240
234
241
companion object {
235
242
243
+ private const val LEADER_SIZE = 1
244
+ private const val MAX_MEMBER_SIZE = 15 - LEADER_SIZE
245
+
236
246
fun create (
237
247
guildIcon : String ,
238
248
title : String ,
You can’t perform that action at this time.
0 commit comments