Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
52aedd5
split into two modules
zhvkgj Apr 25, 2021
873430e
add core functionality
zhvkgj Apr 25, 2021
cc280a7
add application configuration file
zhvkgj Apr 25, 2021
0b87f1f
fix problems with serialization
zhvkgj Apr 25, 2021
7ce9fc0
add level generation
zhvkgj Apr 25, 2021
2aba3f4
extend configuration data with player position info
zhvkgj Apr 25, 2021
37bf9f8
client movements
skychik Apr 26, 2021
07fddb9
client: map reloads when ended the level; bug fix, refactoring, polis…
skychik May 1, 2021
c7dedc6
review fixes, add npc and combat interaction
zhvkgj May 2, 2021
fb27b4e
client: small fixes
skychik May 2, 2021
6e4e747
Merge branch 'level-and-moving' into combat-system
skychik May 2, 2021
d00cfdf
client: new api support
skychik May 3, 2021
41132fd
bug fix and add java docs
zhvkgj May 3, 2021
bbcd9f6
update generator, add algorithm for determining visibility of player
zhvkgj May 3, 2021
c592241
client: new api support
skychik May 3, 2021
6fbbe2d
refactoring and bug fixes
zhvkgj May 3, 2021
cdced7a
server: serialization fix
skychik May 3, 2021
741f62f
add restart game method
zhvkgj May 3, 2021
7ea04c8
client: stable version
skychik May 4, 2021
a4d7fe7
client: added menu with restart; map resizes
skychik May 4, 2021
b0a3da5
improve npc movement algorithm
zhvkgj May 6, 2021
dce8150
fix comments
zhvkgj May 7, 2021
764dc8f
some fixes and changes
skychik May 25, 2021
aeae507
review fixes
zhvkgj May 25, 2021
7a75570
Merge remote-tracking branch 'origin/combat-system' into multiplayer-…
skychik May 25, 2021
21cad62
add multiplayer supporting
zhvkgj May 25, 2021
6bf66ac
Merge remote-tracking branch 'origin/multiplayer-server' into multipl…
skychik May 25, 2021
9e57ff4
update server api
zhvkgj May 25, 2021
50737d7
Merge remote-tracking branch 'origin/multiplayer-server' into multipl…
skychik May 25, 2021
100c2f6
can play in multiplayer
skychik May 25, 2021
f100d81
update game state dto
zhvkgj May 26, 2021
4ae6f52
Merge remote-tracking branch 'origin/multiplayer-server' into multipl…
skychik May 26, 2021
e51b6e3
fix disconnect method
zhvkgj May 28, 2021
3c6b20b
Merge remote-tracking branch 'origin/multiplayer-server' into multipl…
skychik May 28, 2021
3ceb666
fix naming
zhvkgj May 28, 2021
83ea3be
Merge remote-tracking branch 'origin/multiplayer-server' into multipl…
skychik May 28, 2021
7c5e414
multiplayer fix
skychik May 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
223 changes: 0 additions & 223 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,18 @@ gradle-app.setting

.idea

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Kotlin template
# Compiled class file
*.class
Expand All @@ -89,192 +55,3 @@ fabric.properties

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Kotlin template
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### Gradle template
.gradle
**/build/
!client/src/**/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

35 changes: 6 additions & 29 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
plugins {
application
kotlin("jvm") version "1.4.32"
kotlin("plugin.serialization") version "1.4.32"
id("io.gitlab.arturbosch.detekt") version "1.16.0-RC2"
allprojects {
repositories {
jcenter()
}
}

group = "ru.ifmo.jb"
version = "1.0-SNAPSHOT"
val ktor_version = "1.5.3"

application {
mainClass.set("ru.ifmo.sd.MainKt")
}

repositories {
mavenCentral()
}

dependencies {
implementation("io.ktor:ktor-websockets:$ktor_version")
implementation("io.ktor:ktor-client-cio:$ktor_version")
implementation("io.ktor:ktor-client-gson:$ktor_version")
implementation("io.ktor:ktor-gson:$ktor_version")
implementation("io.ktor:ktor-server-core:$ktor_version")
implementation("io.ktor:ktor-server-netty:$ktor_version")
testImplementation("io.ktor:ktor-server-tests:$ktor_version")
}

tasks.test {
useJUnit()
subprojects {
version = "1.0"
}
31 changes: 31 additions & 0 deletions game-client/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
plugins {
java
application
kotlin("jvm") version "1.4.21"
}

group = "ru.ifmo.jb"
version = "1.0-SNAPSHOT"
val ktor_version = "1.5.2"

repositories {
mavenCentral()
}

dependencies {
implementation(kotlin("stdlib"))
implementation("org.jetbrains.kotlin:kotlin-reflect:1.4.32")
implementation("io.ktor:ktor-client-cio:$ktor_version")
implementation("io.ktor:ktor-client-gson:$ktor_version")
implementation("io.ktor:ktor-client-jackson:$ktor_version")
implementation("io.ktor:ktor-client-serialization:1.5.2")
implementation(project(":game-server"))
}

application {
mainClass.set("ru.ifmo.sd.MainKt")
}

tasks.test {
useJUnitPlatform()
}
74 changes: 74 additions & 0 deletions game-client/src/main/kotlin/ru/ifmo/sd/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package ru.ifmo.sd

import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.features.json.*
import io.ktor.client.features.json.serializer.*
import ru.ifmo.sd.httpapi.models.*
import ru.ifmo.sd.stuff.GUI
import ru.ifmo.sd.stuff.ServerAPI
import java.awt.EventQueue
import javax.swing.JFrame
import javax.swing.JOptionPane

private val inputNameFrame = JFrame()

fun main() {
ServerAPI.client = HttpClient(CIO) {
install(JsonFeature) {
serializer = KotlinxSerializer()
}
}
// ServerAPI.initLocalServer()
val response = inputName()
println(ServerAPI.nickname)
if (ServerAPI.nickname == null) {
ServerAPI.client!!.close()
inputNameFrame.dispose()
} else {
println(response)
EventQueue.invokeLater { createAndShowGUI(response!!) }
}
}

private fun createAndShowGUI(config: JoinGameInfo) {

val frame = GUI("Roguelike", config)
frame.isVisible = true
}

private fun inputName(): JoinGameInfo? {
inputNameFrame.isVisible = true
inputNameFrame.defaultCloseOperation = JFrame.EXIT_ON_CLOSE
inputNameFrame.setLocationRelativeTo(null)

var isNameTaken = false
var isNameValid = true
var response: JoinGameInfo? = null
while (true) {
val message = "Type your nickname" +
if (!isNameValid) " (name should contain latin letters or digits)"
else if (isNameTaken) " (choose another one)"
else ""
ServerAPI.nickname = JOptionPane.showInputDialog(inputNameFrame, message)

isNameValid = validateNickname(ServerAPI.nickname)
if (!isNameValid) continue

var success = true
try {
response = ServerAPI.joinMultiplayer()
} catch (e: Exception) {
println(e.localizedMessage)
success = false
isNameTaken = true
}
if (success) break
}
inputNameFrame.isVisible = false
return response
}

private fun validateNickname(name: String?): Boolean {
return name != null && name.length < 20 && name.matches("[a-zA-Z0-9]+".toRegex())
}
Loading