-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3687837
commit 265dd49
Showing
6 changed files
with
229 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package room | ||
|
||
import game.GameMode | ||
import game.GameSettings | ||
import util.ServerGlobals | ||
|
||
object RoomFactory { | ||
fun registerStarterRooms() { | ||
makeStarterRooms().forEach(ServerGlobals.server::registerNewRoom) | ||
} | ||
|
||
private fun makeStarterRooms(): List<Room> { | ||
val elementGenerator = getElementNames().iterator() | ||
|
||
return GameMode.entries.flatMap { gameMode -> | ||
val configs = getConfigs(gameMode) | ||
val capacities = listOf(2, 3, 4) | ||
|
||
capacities.flatMap { capacity -> | ||
configs.map { Room(elementGenerator.next(), it, capacity) } | ||
} | ||
} | ||
} | ||
|
||
private fun getElementNames(): List<String> { | ||
val inputStream = | ||
javaClass.getResourceAsStream("/elements.txt") | ||
?: throw RuntimeException("Unable to read elements list") | ||
|
||
return inputStream.bufferedReader().readLines() | ||
} | ||
|
||
private fun getConfigs(mode: GameMode): List<GameSettings> = | ||
listOf( | ||
GameSettings(mode), | ||
GameSettings(mode, illegalAllowed = true), | ||
GameSettings(mode, jokerQuantity = 2, jokerValue = 2), | ||
GameSettings(mode, includeMoons = true, includeStars = true), | ||
GameSettings(mode, includeMoons = true, includeStars = true, cardReveal = true), | ||
GameSettings( | ||
mode, | ||
jokerQuantity = 2, | ||
jokerValue = 2, | ||
negativeJacks = true, | ||
cardReveal = true | ||
), | ||
GameSettings(mode, includeMoons = true, includeStars = true, negativeJacks = true), | ||
GameSettings( | ||
mode, | ||
jokerQuantity = 2, | ||
jokerValue = 2, | ||
includeMoons = true, | ||
includeStars = true, | ||
illegalAllowed = true | ||
) | ||
) | ||
} |
Oops, something went wrong.