mirror of
https://github.com/RDCN-Community-Developers/rdkt.git
synced 2026-09-04 17:25:33 +08:00
Initial commit.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
|
||||
|
||||
name: Java CI with Gradle
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
workflow_call:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- target: iosSimulatorArm64Test
|
||||
os: macos-latest
|
||||
- target: jvmTest
|
||||
os: ubuntu-latest
|
||||
- target: linuxX64Test
|
||||
os: ubuntu-latest
|
||||
- target: testDebugUnitTest
|
||||
os: ubuntu-latest
|
||||
- target: testReleaseUnitTest
|
||||
os: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/actions/wrapper-validation@v3
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.konan
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
- name: Build with Gradle
|
||||
uses: gradle/gradle-build-action@ce999babab2de1c4b649dc15f0ee67e6246c994f
|
||||
with:
|
||||
arguments: ${{ matrix.target }}
|
||||
@@ -0,0 +1,25 @@
|
||||
name: Publish
|
||||
on:
|
||||
release:
|
||||
types: [ released, prereleased ]
|
||||
jobs:
|
||||
publish:
|
||||
name: Release build and publish
|
||||
runs-on: macOS-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: 11
|
||||
- name: Publish to MavenCentral
|
||||
run: ./gradlew publishToMavenCentral --no-configuration-cache
|
||||
env:
|
||||
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
|
||||
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
|
||||
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
|
||||
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
|
||||
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
*.iml
|
||||
.gradle
|
||||
.idea
|
||||
.DS_Store
|
||||
build
|
||||
captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
xcuserdata
|
||||
.kotlin
|
||||
#So we don't accidentally commit our private keys
|
||||
*.gpg
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2023 JetBrains s.r.o. and and respective authors and developers.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,5 @@
|
||||
# RDKT: An Rhythm Doctor Kotlin Library
|
||||
|
||||
---
|
||||
|
||||
Working in progress...
|
||||
@@ -0,0 +1,14 @@
|
||||
plugins {
|
||||
alias(libs.plugins.androidLibrary) apply false
|
||||
alias(libs.plugins.kotlinMultiplatform) apply false
|
||||
alias(libs.plugins.vanniktech.mavenPublish) apply false
|
||||
|
||||
kotlin("plugin.serialization") version "2.1.20" apply false
|
||||
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.17.0" apply false
|
||||
|
||||
id("org.jetbrains.dokka") version "2.0.0"
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply(plugin = "org.jetbrains.dokka")
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
import com.vanniktech.maven.publish.SonatypeHost
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
alias(libs.plugins.androidLibrary)
|
||||
alias(libs.plugins.vanniktech.mavenPublish)
|
||||
|
||||
kotlin("plugin.serialization") version "2.1.20"
|
||||
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.17.0"
|
||||
}
|
||||
|
||||
group = "cn.rdlevel"
|
||||
version = "0.1.0"
|
||||
|
||||
kotlin {
|
||||
// jvm
|
||||
jvm {
|
||||
compilerOptions {
|
||||
jvmTarget.set(JvmTarget.JVM_11)
|
||||
}
|
||||
}
|
||||
|
||||
// android
|
||||
androidTarget {
|
||||
publishLibraryVariants("release")
|
||||
compilerOptions {
|
||||
jvmTarget.set(JvmTarget.JVM_11)
|
||||
}
|
||||
}
|
||||
|
||||
// native
|
||||
// t1
|
||||
macosX64()
|
||||
macosArm64()
|
||||
iosSimulatorArm64()
|
||||
iosX64()
|
||||
iosArm64()
|
||||
// t2
|
||||
linuxX64()
|
||||
linuxArm64()
|
||||
watchosSimulatorArm64()
|
||||
watchosX64()
|
||||
watchosArm32()
|
||||
watchosArm64()
|
||||
tvosSimulatorArm64()
|
||||
tvosX64()
|
||||
tvosArm64()
|
||||
// t3
|
||||
androidNativeArm32()
|
||||
androidNativeArm64()
|
||||
androidNativeX86()
|
||||
androidNativeX64()
|
||||
mingwX64()
|
||||
watchosDeviceArm64()
|
||||
|
||||
// js
|
||||
js {
|
||||
browser { }
|
||||
nodejs { }
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
// wasm
|
||||
@OptIn(ExperimentalWasmDsl::class)
|
||||
wasmJs {
|
||||
browser()
|
||||
nodejs()
|
||||
d8()
|
||||
binaries.executable()
|
||||
}
|
||||
@OptIn(ExperimentalWasmDsl::class)
|
||||
wasmWasi {
|
||||
nodejs()
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
explicitApi()
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "cn.rdlevel.rdkt"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
|
||||
mavenPublishing {
|
||||
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
|
||||
|
||||
signAllPublications()
|
||||
|
||||
coordinates(group.toString(), "rdkt-core", version.toString())
|
||||
|
||||
pom {
|
||||
name = "rdkt"
|
||||
description = "A library to write Rhythm Doctor levels on Kotlin."
|
||||
inceptionYear = "2025"
|
||||
url = "https://github.com/RDCN-Community-Developers/rdkt/"
|
||||
licenses {
|
||||
license {
|
||||
name = "XXX"
|
||||
url = "YYY"
|
||||
distribution = "ZZZ"
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = "XXX"
|
||||
name = "YYY"
|
||||
url = "ZZZ"
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url = "XXX"
|
||||
connection = "YYY"
|
||||
developerConnection = "ZZZ"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.rdlevel.rdkt.core
|
||||
|
||||
import cn.rdlevel.rdkt.core.settings.LevelSettings
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
public data class RDLevel(
|
||||
public val settings: LevelSettings,
|
||||
) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.rdlevel.rdkt.core.annotations
|
||||
|
||||
/**
|
||||
* This annotation marks APIs that are intended for internal use within the rdkt library.
|
||||
*
|
||||
* It is not recommended for general use and may change without notice.
|
||||
*/
|
||||
@MustBeDocumented
|
||||
@Target(
|
||||
AnnotationTarget.CLASS,
|
||||
AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.PROPERTY,
|
||||
AnnotationTarget.TYPEALIAS,
|
||||
AnnotationTarget.CONSTRUCTOR,
|
||||
)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@RequiresOptIn(
|
||||
"This API is intended for internal use within the rdkt library and may change without notice. Use with caution.",
|
||||
RequiresOptIn.Level.WARNING,
|
||||
)
|
||||
public annotation class RDKTInternalAPI
|
||||
@@ -0,0 +1,431 @@
|
||||
@file:OptIn(RDKTInternalAPI::class)
|
||||
@file:JvmName("SelectedRoomsUtils")
|
||||
|
||||
package cn.rdlevel.rdkt.core.data
|
||||
|
||||
import cn.rdlevel.rdkt.core.annotations.RDKTInternalAPI
|
||||
import cn.rdlevel.rdkt.core.serializers.TransformSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.builtins.SetSerializer
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmStatic
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* Represents a collection of selected rooms, including the top layer.
|
||||
*
|
||||
* All implementations of this interface must contain at least one room, or the top layer.
|
||||
* Failing to do so will result in an exception.
|
||||
*/
|
||||
@Serializable(SelectedRoomsAndTopLayer.Serializer::class)
|
||||
public sealed interface SelectedRoomsAndTopLayer {
|
||||
/**
|
||||
* The room IDs that are selected.
|
||||
*/
|
||||
public val rooms: Set<Int>
|
||||
|
||||
/**
|
||||
* Whether the selected rooms contain a room with the given [id].
|
||||
*
|
||||
* @param id The ID of the room to check.
|
||||
*/
|
||||
public fun containsRoom(id: Int): Boolean {
|
||||
return id in rooms
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the selected rooms contain the top layer room.
|
||||
*/
|
||||
public fun containsTop(): Boolean {
|
||||
return TOP_LAYER in rooms
|
||||
}
|
||||
|
||||
public operator fun plus(other: SelectedRoomsAndTopLayer): SelectedRoomsAndTopLayer {
|
||||
return of(rooms + other.rooms)
|
||||
}
|
||||
|
||||
private class Impl(override val rooms: Set<Int>) : AbstractSelectedRoomsAndTopLayer(), SelectedRoomsAndTopLayer {
|
||||
init {
|
||||
requireNotEmpty()
|
||||
requireAllRoomsOrTopLayer()
|
||||
}
|
||||
}
|
||||
|
||||
public companion object {
|
||||
/**
|
||||
* Creates a new instance of [SelectedRoomsAndTopLayer].
|
||||
*
|
||||
* @param rooms The set of selected room IDs.
|
||||
* @return A new instance of [SelectedRoomsAndTopLayer] with the specified room IDs.
|
||||
*/
|
||||
@JvmStatic
|
||||
public fun of(rooms: Set<Int>): SelectedRoomsAndTopLayer {
|
||||
return Impl(rooms)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of [SelectedRoomsAndTopLayer] with the specified room IDs.
|
||||
*
|
||||
* @param room The ID of the first selected room.
|
||||
* @param rooms Additional room IDs to include in the selection.
|
||||
* @return A new instance of [SelectedRoomsAndTopLayer] containing the specified room IDs.
|
||||
*/
|
||||
@JvmStatic
|
||||
public fun of(room: Int, vararg rooms: Int): SelectedRoomsAndTopLayer {
|
||||
return of(setOf(room) + rooms.toSet())
|
||||
}
|
||||
}
|
||||
|
||||
public object Serializer :
|
||||
TransformSerializer<SelectedRoomsAndTopLayer, Set<Int>>(SetSerializer(Int.serializer())) {
|
||||
override fun toData(value: SelectedRoomsAndTopLayer): Set<Int> {
|
||||
return value.rooms
|
||||
}
|
||||
|
||||
override fun fromData(data: Set<Int>): SelectedRoomsAndTopLayer {
|
||||
return of(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public operator fun SelectedRoomsAndTopLayer.contains(id: Int): Boolean {
|
||||
return containsRoom(id)
|
||||
}
|
||||
|
||||
private fun SelectedRoomsAndTopLayer.requireNotEmpty() {
|
||||
require(rooms.isNotEmpty()) { "Selected rooms must not be empty." }
|
||||
}
|
||||
|
||||
private fun SelectedRoomsAndTopLayer.requireAllRoomsOrTopLayer() {
|
||||
require(rooms.all { it in ROOM1..TOP_LAYER }) {
|
||||
"Selected rooms must only contain room IDs from 0 to 3 or the top layer."
|
||||
}
|
||||
}
|
||||
|
||||
private fun SelectedRoomsAndTopLayer.requireAllRooms() {
|
||||
require(rooms.all { it in ROOM1..ROOM4 }) {
|
||||
"Selected rooms must only contain room IDs from 0 to 3."
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class AbstractSelectedRoomsAndTopLayer : SelectedRoomsAndTopLayer {
|
||||
override operator fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is SelectedRoomsAndTopLayer) return false
|
||||
return rooms == other.rooms
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return rooms.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a collection of either normal rooms or the top layer.
|
||||
*/
|
||||
@Serializable(SelectedRoomsOrTopLayer.Serializer::class)
|
||||
public sealed interface SelectedRoomsOrTopLayer : SelectedRoomsAndTopLayer {
|
||||
public object Serializer :
|
||||
TransformSerializer<SelectedRoomsOrTopLayer, Set<Int>>(SetSerializer(Int.serializer())) {
|
||||
override fun toData(value: SelectedRoomsOrTopLayer): Set<Int> {
|
||||
return value.rooms
|
||||
}
|
||||
|
||||
override fun fromData(data: Set<Int>): SelectedRoomsOrTopLayer {
|
||||
return roomsOf(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a collection of either a normal room or the top layer.
|
||||
*/
|
||||
@Serializable(SingleSelectedRoomOrTopLayer.Serializer::class)
|
||||
public sealed interface SingleSelectedRoomOrTopLayer : SelectedRoomsOrTopLayer {
|
||||
/**
|
||||
* The single selected room ID.
|
||||
*/
|
||||
public val room: Int
|
||||
|
||||
override val rooms: Set<Int>
|
||||
get() = setOf(room)
|
||||
|
||||
override fun containsRoom(id: Int): Boolean {
|
||||
return room == id
|
||||
}
|
||||
|
||||
override fun containsTop(): Boolean {
|
||||
return room == TOP_LAYER
|
||||
}
|
||||
|
||||
public object Serializer :
|
||||
TransformSerializer<SingleSelectedRoomOrTopLayer, Set<Int>>(SetSerializer(Int.serializer())) {
|
||||
override fun toData(value: SingleSelectedRoomOrTopLayer): Set<Int> {
|
||||
return value.rooms
|
||||
}
|
||||
|
||||
override fun fromData(data: Set<Int>): SingleSelectedRoomOrTopLayer {
|
||||
return roomsOf(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a collection of selected rooms, not including the top layer.
|
||||
*/
|
||||
@Serializable(SelectedRooms.Serializer::class)
|
||||
public sealed interface SelectedRooms : SelectedRoomsOrTopLayer {
|
||||
public operator fun plus(other: SelectedRooms): SelectedRooms {
|
||||
return of(rooms + other.rooms)
|
||||
}
|
||||
|
||||
private class Impl(override val rooms: Set<Int>) : AbstractSelectedRoomsAndTopLayer(), SelectedRooms {
|
||||
init {
|
||||
requireNotEmpty()
|
||||
requireAllRooms()
|
||||
}
|
||||
}
|
||||
|
||||
public companion object {
|
||||
/**
|
||||
* Creates a new instance of [SelectedRooms].
|
||||
*
|
||||
* @param rooms The set of selected room IDs.
|
||||
* @return A new instance of [SelectedRooms] with the specified room IDs.
|
||||
*/
|
||||
@JvmStatic
|
||||
public fun of(rooms: Set<Int>): SelectedRooms {
|
||||
return Impl(rooms)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of [SelectedRooms] with the specified room IDs.
|
||||
*
|
||||
* @param room The ID of the first selected room.
|
||||
* @param rooms Additional room IDs to include in the selection.
|
||||
* @return A new instance of [SelectedRooms] containing the specified room IDs.
|
||||
*/
|
||||
@JvmStatic
|
||||
public fun of(room: Int, vararg rooms: Int): SelectedRooms {
|
||||
return of(setOf(room) + rooms.toSet())
|
||||
}
|
||||
}
|
||||
|
||||
public object Serializer :
|
||||
TransformSerializer<SelectedRooms, Set<Int>>(SetSerializer(Int.serializer())) {
|
||||
override fun toData(value: SelectedRooms): Set<Int> {
|
||||
return value.rooms
|
||||
}
|
||||
|
||||
override fun fromData(data: Set<Int>): SelectedRooms {
|
||||
return of(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the selected top layer.
|
||||
*/
|
||||
@Serializable(SelectedTopLayer.Serializer::class)
|
||||
public sealed interface SelectedTopLayer : SingleSelectedRoomOrTopLayer {
|
||||
override val room: Int
|
||||
get() = TOP_LAYER
|
||||
|
||||
private object Impl : AbstractSelectedRoomsAndTopLayer(), SelectedTopLayer
|
||||
|
||||
public companion object {
|
||||
/**
|
||||
* Gets the instance of [SelectedTopLayer].
|
||||
*
|
||||
* @return The instance of [SelectedTopLayer].
|
||||
*/
|
||||
@JvmStatic
|
||||
public fun of(): SelectedTopLayer {
|
||||
return Impl
|
||||
}
|
||||
}
|
||||
|
||||
public object Serializer :
|
||||
TransformSerializer<SelectedTopLayer, Set<Int>>(SetSerializer(Int.serializer())) {
|
||||
override fun toData(value: SelectedTopLayer): Set<Int> {
|
||||
return value.rooms
|
||||
}
|
||||
|
||||
override fun fromData(data: Set<Int>): SelectedTopLayer {
|
||||
require(TOP_LAYER in data && data.size == 1) { "SelectedTopLayer must be created with the top layer ID." }
|
||||
return of()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a single selected room, not including the top layer.
|
||||
*/
|
||||
@Serializable(SingleSelectedRoom.Serializer::class)
|
||||
public sealed interface SingleSelectedRoom : SingleSelectedRoomOrTopLayer, SelectedRooms {
|
||||
private class Impl(override val room: Int) : AbstractSelectedRoomsAndTopLayer(), SingleSelectedRoom {
|
||||
init {
|
||||
requireAllRooms()
|
||||
}
|
||||
}
|
||||
|
||||
public companion object {
|
||||
/**
|
||||
* Creates a new instance of [SingleSelectedRoom].
|
||||
*
|
||||
* @param room The ID of the selected room.
|
||||
* @return A new instance of [SingleSelectedRoom] with the specified room ID.
|
||||
*/
|
||||
@JvmStatic
|
||||
public fun of(room: Int): SingleSelectedRoom {
|
||||
return Impl(room)
|
||||
}
|
||||
}
|
||||
|
||||
public object Serializer :
|
||||
TransformSerializer<SingleSelectedRoom, Set<Int>>(SetSerializer(Int.serializer())) {
|
||||
override fun toData(value: SingleSelectedRoom): Set<Int> {
|
||||
return value.rooms
|
||||
}
|
||||
|
||||
override fun fromData(data: Set<Int>): SingleSelectedRoom {
|
||||
require(data.size == 1) { "SingleSelectedRoom must contain exactly one room." }
|
||||
return of(data.first())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the first room.
|
||||
*/
|
||||
public const val ROOM1: Int = 0
|
||||
|
||||
/**
|
||||
* The ID of the second room.
|
||||
*/
|
||||
public const val ROOM2: Int = 1
|
||||
|
||||
/**
|
||||
* The ID of the third room.
|
||||
*/
|
||||
public const val ROOM3: Int = 2
|
||||
|
||||
/**
|
||||
* The ID of the fourth room.
|
||||
*/
|
||||
public const val ROOM4: Int = 3
|
||||
|
||||
/**
|
||||
* The ID of the top layer.
|
||||
*/
|
||||
public const val TOP_LAYER: Int = 4
|
||||
|
||||
/**
|
||||
* Creates an instance of [SelectedRoomsAndTopLayer] based on the provided [KClass] and set of room IDs.
|
||||
*
|
||||
* @param T The type of [SelectedRoomsAndTopLayer] to create.
|
||||
* @param kClass The [KClass] of the type to create.
|
||||
* @param rooms The set of room IDs to include in the selection.
|
||||
* @return An instance of [SelectedRoomsAndTopLayer] of the specified type.
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@RDKTInternalAPI
|
||||
public fun <T : SelectedRoomsAndTopLayer> roomsOf(kClass: KClass<T>, rooms: Set<Int>): T {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (kClass) {
|
||||
SelectedRoomsAndTopLayer::class -> SelectedRoomsAndTopLayer.of(rooms)
|
||||
SelectedRoomsOrTopLayer::class -> {
|
||||
when {
|
||||
TOP_LAYER in rooms && rooms.size > 1 -> error("Cannot have both top layer and other rooms selected.")
|
||||
TOP_LAYER in rooms -> SelectedTopLayer.of()
|
||||
else -> SelectedRooms.of(rooms)
|
||||
}
|
||||
}
|
||||
|
||||
SingleSelectedRoomOrTopLayer::class -> {
|
||||
require(rooms.size == 1) { "SingleSelectedRoomOrTopLayer must contain exactly one room or the top layer." }
|
||||
when {
|
||||
TOP_LAYER in rooms -> SelectedTopLayer.of()
|
||||
else -> SingleSelectedRoom.of(rooms.first())
|
||||
}
|
||||
}
|
||||
|
||||
SelectedRooms::class -> SelectedRooms.of(rooms)
|
||||
SelectedTopLayer::class -> {
|
||||
require(rooms.size == 1 && TOP_LAYER in rooms) { "SelectedTopLayer must contain only the top layer." }
|
||||
SelectedTopLayer.of()
|
||||
}
|
||||
|
||||
SingleSelectedRoom::class -> {
|
||||
require(rooms.size == 1) { "SingleSelectedRoom must contain exactly one room." }
|
||||
SingleSelectedRoom.of(rooms.first())
|
||||
}
|
||||
|
||||
else -> error("Unsupported type: ${kClass.simpleName}")
|
||||
} as T
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of [SelectedRoomsAndTopLayer] based on the provided [KClass] and a single room ID.
|
||||
*
|
||||
* @param T The type of [SelectedRoomsAndTopLayer] to create.
|
||||
* @param kClass The [KClass] of the type to create.
|
||||
* @param room The ID of the room to include in the selection.
|
||||
* @param rooms Additional room IDs to include in the selection.
|
||||
* @return An instance of [SelectedRoomsAndTopLayer] of the specified type.
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@RDKTInternalAPI
|
||||
public fun <T : SelectedRoomsAndTopLayer> roomsOf(kClass: KClass<T>, room: Int, vararg rooms: Int): T {
|
||||
return roomsOf(kClass, setOf(room) + rooms.toSet())
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of [SingleSelectedRoomOrTopLayer] based on the provided [KClass] and a single room ID.
|
||||
*
|
||||
* @param T The type of [SingleSelectedRoomOrTopLayer] to create.
|
||||
* @param kClass The [KClass] of the type to create.
|
||||
* @param room The ID of the room to include in the selection.
|
||||
* @return An instance of [SingleSelectedRoomOrTopLayer] of the specified type.
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@RDKTInternalAPI
|
||||
public fun <T : SingleSelectedRoomOrTopLayer> singleRoomOf(kClass: KClass<T>, room: Int): T {
|
||||
return roomsOf(kClass, room)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of [SelectedRoomsAndTopLayer] based on the provided set of room IDs.
|
||||
*
|
||||
* @param T The type of [SelectedRoomsAndTopLayer] to create.
|
||||
* @param rooms The set of room IDs to include in the selection.
|
||||
* @return An instance of [SelectedRoomsAndTopLayer] of the specified type.
|
||||
*/
|
||||
public inline fun <reified T : SelectedRoomsAndTopLayer> roomsOf(rooms: Set<Int>): T {
|
||||
return roomsOf(T::class, rooms)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of [SelectedRoomsAndTopLayer] based on the provided room ID and additional room IDs.
|
||||
*
|
||||
* @param T The type of [SelectedRoomsAndTopLayer] to create.
|
||||
* @param room The ID of the first selected room.
|
||||
* @param rooms Additional room IDs to include in the selection.
|
||||
* @return An instance of [SelectedRoomsAndTopLayer] of the specified type.
|
||||
*/
|
||||
public inline fun <reified T : SelectedRoomsAndTopLayer> roomsOf(room: Int, vararg rooms: Int): T {
|
||||
return roomsOf(T::class, room, *rooms)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of [SingleSelectedRoomOrTopLayer] based on the provided room ID.
|
||||
*
|
||||
* @param T The type of [SingleSelectedRoomOrTopLayer] to create.
|
||||
* @param room The ID of the selected room.
|
||||
* @return An instance of [SingleSelectedRoomOrTopLayer] of the specified type.
|
||||
*/
|
||||
public inline fun <reified T : SingleSelectedRoomOrTopLayer> singleRoomOf(room: Int): T {
|
||||
return singleRoomOf(T::class, room)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package cn.rdlevel.rdkt.core.events
|
||||
|
||||
public interface Event {
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package cn.rdlevel.rdkt.core.serializers
|
||||
|
||||
import cn.rdlevel.rdkt.core.annotations.RDKTInternalAPI
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
/**
|
||||
* A serializer for subtypes that delegates serialization and deserialization to a [baseSerializer] of a base type.
|
||||
*
|
||||
* The [baseSerializer] is responsible for handling the serialization and deserialization logic,
|
||||
* and returns the deserialized value as the correct subtype of [Base] for possible subtype implementations of this class.
|
||||
*
|
||||
* @param Base The base type that the [baseSerializer] will handle.
|
||||
* @param Sub The subtype that extends [Base] and will be serialized/deserialized.
|
||||
*/
|
||||
@RDKTInternalAPI
|
||||
@SubclassOptInRequired(RDKTInternalAPI::class)
|
||||
public abstract class PolymorphicDelegatedSerializer<Sub : Base, Base>(
|
||||
/**
|
||||
* The base serializer that handles the serialization and deserialization logic.
|
||||
*/
|
||||
protected val baseSerializer: KSerializer<Base>,
|
||||
) : KSerializer<Sub> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = baseSerializer.descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Sub) {
|
||||
encoder.encodeSerializableValue(baseSerializer, value)
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): Sub {
|
||||
val result = decoder.decodeSerializableValue(baseSerializer)
|
||||
runCatching {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return result as Sub
|
||||
}
|
||||
error("Unable to cast deserialized value to specified type. Check your base serializer.")
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
@file:OptIn(RDKTInternalAPI::class)
|
||||
|
||||
package cn.rdlevel.rdkt.core.serializers
|
||||
|
||||
import cn.rdlevel.rdkt.core.annotations.RDKTInternalAPI
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
/**
|
||||
* A serializer for a list of strings that serializes the list as a single string, separated by commas.
|
||||
*/
|
||||
@RDKTInternalAPI
|
||||
public object StringListAsStringSerializer : KSerializer<List<String>> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: List<String>) {
|
||||
encoder.encodeString(value.joinToString(", "))
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): List<String> {
|
||||
return decoder.decodeString()
|
||||
.split(", ")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of strings that is serialized as a single string, separated by commas.
|
||||
*/
|
||||
public typealias StringListSerializedInString = @Serializable(StringListAsStringSerializer::class) List<String>
|
||||
|
||||
/**
|
||||
* A serializer for a mutable list of strings that serializes the list as a single string, separated by commas.
|
||||
*/
|
||||
@RDKTInternalAPI
|
||||
public object MutableStringListAsStringSerializer : KSerializer<MutableList<String>> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: MutableList<String>) {
|
||||
encoder.encodeString(value.joinToString(", "))
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): MutableList<String> {
|
||||
return decoder.decodeString()
|
||||
.split(", ")
|
||||
.toMutableList()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A mutable list of strings that is serialized as a single string, separated by commas.
|
||||
*/
|
||||
public typealias MutableStringListSerializedInString = @Serializable(MutableStringListAsStringSerializer::class) MutableList<String>
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.rdlevel.rdkt.core.serializers
|
||||
|
||||
import cn.rdlevel.rdkt.core.annotations.RDKTInternalAPI
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
/**
|
||||
* A base serializer for types that can be transformed to and from a specific data representation.
|
||||
*
|
||||
* This serializer provides a common implementation for serializing and deserializing types
|
||||
* that can be converted to and from a specific data representation defined by [Data].
|
||||
*
|
||||
* @param T The type to be serialized/deserialized.
|
||||
* @param Data The data representation of the type.
|
||||
*/
|
||||
@RDKTInternalAPI
|
||||
public abstract class TransformSerializer<T, Data>(
|
||||
private val dataSerializer: KSerializer<Data>
|
||||
) : KSerializer<T> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = dataSerializer.descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: T) {
|
||||
val data = toData(value)
|
||||
encoder.encodeSerializableValue(dataSerializer, data)
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): T {
|
||||
val data = decoder.decodeSerializableValue(dataSerializer)
|
||||
return fromData(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given value to its data representation.
|
||||
*
|
||||
* @param value The value to convert.
|
||||
* @return The data representation of the value.
|
||||
*/
|
||||
protected abstract fun toData(value: T): Data
|
||||
|
||||
/**
|
||||
* Converts the given data representation back to the original type.
|
||||
*
|
||||
* @param data The data representation to convert.
|
||||
* @return The original type represented by the data.
|
||||
*/
|
||||
protected abstract fun fromData(data: Data): T
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.rdlevel.rdkt.core.settings
|
||||
|
||||
import cn.rdlevel.rdkt.core.settings.CustomClasses.INJURY
|
||||
|
||||
|
||||
/**
|
||||
* Some available custom classes for custom levels in the game.
|
||||
* Data mainly from [Rhythm Doctor Custom Method Directory](https://docs.google.com/spreadsheets/d/1JAz6iRLqcn08ZeTeBHeeDrpdX6M5K0b1qRVQomua21s).
|
||||
*
|
||||
* Put one of them in [LevelSettings.customClass] to enable it.
|
||||
*/
|
||||
public object CustomClasses {
|
||||
/**
|
||||
* Adds baseballs and animations in Baseball Stadium.
|
||||
* Used in 5-1N.
|
||||
*/
|
||||
public const val INJURY: String = "Injury"
|
||||
|
||||
/**
|
||||
* Simulates part of level 1-2.
|
||||
*/
|
||||
public const val INTIMATE: String = "Intimate"
|
||||
|
||||
/**
|
||||
* Works like [INJURY], but additionally enables scoreboard, score count, and some custom methods.
|
||||
* Used in 5-1.
|
||||
*/
|
||||
public const val LUCKY_BREAK: String = "LuckyBreak"
|
||||
|
||||
/**
|
||||
* Uses a slightly different desert theme.
|
||||
* Used in 4-1N.
|
||||
*/
|
||||
public const val ROLLERDISCO: String = "Rollerdisco"
|
||||
|
||||
/**
|
||||
* Replaces hearts to ones seen in X-WOT.
|
||||
* Requires at least 5 rows in the level to work.
|
||||
*/
|
||||
public const val UNBEATABLE: String = "Unbeatable"
|
||||
|
||||
/**
|
||||
* Forces the S+ rank description to be "ALL CRITICAL".
|
||||
* Enables the "VRankHacky()" custom method.
|
||||
* Used in X-FTS.
|
||||
*/
|
||||
public const val VIVID_STASIS: String = "VividStasis"
|
||||
|
||||
/**
|
||||
* Enables alternative "Spaaaaace!" theme, audio reactive row glows with custom methods.
|
||||
* Used in 2-2N.
|
||||
*/
|
||||
public const val UNREACHABLE: String = "Unreachable"
|
||||
|
||||
/**
|
||||
* Replaces hearts with pumpkins.
|
||||
* Currently, this is broken and does not work.
|
||||
*/
|
||||
@Deprecated("This custom class is currently broken and does not work.")
|
||||
public const val HALLOWEEN: String = "Halloween"
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package cn.rdlevel.rdkt.core.settings
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Represents the special type of the permission on the song used in the level.
|
||||
*/
|
||||
@Serializable
|
||||
public enum class SpecialArtistType {
|
||||
/**
|
||||
* No special type of permission.
|
||||
*/
|
||||
@SerialName("None")
|
||||
NONE,
|
||||
|
||||
/**
|
||||
* The artist is the author of the level.
|
||||
*/
|
||||
@SerialName("AuthorIsArtist")
|
||||
AUTHOR_IS_ARTIST,
|
||||
|
||||
/**
|
||||
* The song is under a public license, such as Creative Commons or Public Domain.
|
||||
*/
|
||||
@SerialName("PublicLicense")
|
||||
PUBLIC_LICENSE,
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the difficulty of a level.
|
||||
*/
|
||||
@Serializable
|
||||
public enum class LevelDifficulty {
|
||||
/**
|
||||
* Easy difficulty level.
|
||||
*/
|
||||
@SerialName("Easy")
|
||||
EASY,
|
||||
|
||||
/**
|
||||
* Medium difficulty level.
|
||||
*/
|
||||
@SerialName("Medium")
|
||||
MEDIUM,
|
||||
|
||||
/**
|
||||
* Tough difficulty level.
|
||||
*/
|
||||
@SerialName("Tough")
|
||||
TOUGH,
|
||||
|
||||
/**
|
||||
* Very tough difficulty level.
|
||||
*/
|
||||
@SerialName("VeryTough")
|
||||
VERY_TOUGH,
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents whether a level can be played in one player, two players or both.
|
||||
*/
|
||||
@Serializable
|
||||
public enum class LevelPlayerMode {
|
||||
/**
|
||||
* The level can only be played in one player mode.
|
||||
*/
|
||||
@SerialName("OnePlayerOnly")
|
||||
ONE_PLAYER_ONLY,
|
||||
|
||||
/**
|
||||
* The level can only be played in two player mode.
|
||||
*/
|
||||
@SerialName("TwoPlayerOnly")
|
||||
TWO_PLAYER_ONLY,
|
||||
|
||||
/**
|
||||
* The level can be played in both one player and two player modes.
|
||||
*/
|
||||
@SerialName("BothModes")
|
||||
BOTH_MODES,
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the execute behavior of the events on bar 1, beat 1, in a level.
|
||||
*/
|
||||
@Serializable
|
||||
public enum class FirstBeatBehavior {
|
||||
/**
|
||||
* The events on bar 1, beat 1 will be executed normally after the level starts.
|
||||
*/
|
||||
@SerialName("RunNormally")
|
||||
RUN_NORMALLY,
|
||||
|
||||
/**
|
||||
* The events on bar 1, beat 1 will be executed before the level starts.
|
||||
*/
|
||||
@SerialName("RunEventsOnPrebar")
|
||||
RUN_EVENTS_ON_PREBAR,
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the appearance of horizontal strips in multiplayer mode.
|
||||
*/
|
||||
@Serializable
|
||||
public enum class MultiplayerAppearance {
|
||||
/**
|
||||
* Horizontal strips will be shown in multiplayer mode.
|
||||
*/
|
||||
@SerialName("HorizontalStrips")
|
||||
HORIZONTAL_STRIPS,
|
||||
|
||||
/**
|
||||
* Horizontal strips will not be shown in multiplayer mode.
|
||||
*/
|
||||
@SerialName("Nothing")
|
||||
NOTHING,
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
@file:JvmName("LevelSettingsUtils")
|
||||
|
||||
package cn.rdlevel.rdkt.core.settings
|
||||
|
||||
import cn.rdlevel.rdkt.core.annotations.RDKTInternalAPI
|
||||
import cn.rdlevel.rdkt.core.serializers.MutableStringListSerializedInString
|
||||
import cn.rdlevel.rdkt.core.settings.LevelSettings.Companion.CURRENT_LEVEL_VERSION
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* Represents the settings of a level.
|
||||
*/
|
||||
@OptIn(RDKTInternalAPI::class)
|
||||
@Serializable
|
||||
public class LevelSettings {
|
||||
/**
|
||||
* The version of the level. Currently, it is set to [61][CURRENT_LEVEL_VERSION].
|
||||
*
|
||||
* This library currently does not support levels with other versions.
|
||||
* If you want to use levels with other versions, please use the level editor to convert them to a supported version.
|
||||
*
|
||||
* Changing this version number to a not supported one will throw an exception.
|
||||
*/
|
||||
public var version: Int = CURRENT_LEVEL_VERSION
|
||||
set(value) {
|
||||
require(value == CURRENT_LEVEL_VERSION) {
|
||||
"""
|
||||
Levels with version $value is not supported.
|
||||
Currently, the supported level version is $CURRENT_LEVEL_VERSION.
|
||||
If you want to use levels with other versions, please use the level editor to convert them to a supported version.
|
||||
""".trimIndent()
|
||||
}
|
||||
field = value
|
||||
}
|
||||
|
||||
/**
|
||||
* The artist of the song used in the level.
|
||||
*/
|
||||
public var artist: String = ""
|
||||
|
||||
/**
|
||||
* The song used in the level.
|
||||
*/
|
||||
public var song: String = ""
|
||||
|
||||
/**
|
||||
* The special artist permission type for the use of the song.
|
||||
*/
|
||||
public var specialArtistType: SpecialArtistType = SpecialArtistType.NONE
|
||||
|
||||
/**
|
||||
* The artist permission, which is usually a file name to the permission file.
|
||||
*/
|
||||
public var artistPermission: String = ""
|
||||
|
||||
/**
|
||||
* The links to the artist's social media or other relevant sites.
|
||||
*/
|
||||
public var artistLinks: MutableStringListSerializedInString = mutableListOf()
|
||||
|
||||
/**
|
||||
* The ones who created or made the level.
|
||||
*/
|
||||
public var author: String = ""
|
||||
|
||||
/**
|
||||
* The level difficulty.
|
||||
*/
|
||||
public var difficulty: LevelDifficulty = LevelDifficulty.EASY
|
||||
|
||||
/**
|
||||
* Whether the level contains intensive visual effects that may cause seizures.
|
||||
*
|
||||
* Usually it can be determined by whether it contains a one-second period that has 3 sudden high contrast changes.
|
||||
*
|
||||
* For more information, see [this article](https://www.w3.org/WAI/WCAG21/Understanding/seizures-and-physical-reactions.html).
|
||||
*/
|
||||
public var seizureWarning: Boolean = false
|
||||
|
||||
/**
|
||||
* The level preview image file name.
|
||||
*/
|
||||
public var previewImage: String = ""
|
||||
|
||||
/**
|
||||
* The level syringe icon file name.
|
||||
*/
|
||||
public var syringeIcon: String = ""
|
||||
|
||||
/**
|
||||
* The level preview song file name.
|
||||
*
|
||||
* This is usually a short clip of the song used in the level.
|
||||
*/
|
||||
public var previewSong: String = ""
|
||||
|
||||
/**
|
||||
* The start time of the preview song in seconds. Must be non-negative.
|
||||
*/
|
||||
public var previewSongStartTime: Double = 0.0
|
||||
set(value) {
|
||||
require(value >= 0.0) { "Preview song start time must be non-negative." }
|
||||
field = value
|
||||
}
|
||||
|
||||
/**
|
||||
* The duration of the preview song in seconds. Must be non-negative.
|
||||
*/
|
||||
public var previewSongDuration: Double = 10.0
|
||||
set(value) {
|
||||
require(value >= 0.0) { "Preview song duration must be non-negative." }
|
||||
field = value
|
||||
}
|
||||
|
||||
/**
|
||||
* The color hue for the syringe strip of the level. Must be between 0.0 and 1.0.
|
||||
*/
|
||||
public var songNameHue: Double = Random.nextDouble()
|
||||
set(value) {
|
||||
require(value in 0.0..1.0) { "Song name hue must be between 0.0 and 1.0." }
|
||||
field = value
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the use grayscale for the syringe strip.
|
||||
*/
|
||||
public var songLabelGrayscale: Boolean = false
|
||||
|
||||
/**
|
||||
* Level description.
|
||||
*/
|
||||
public var description: String = ""
|
||||
|
||||
/**
|
||||
* The level tags. Fill this with tags that are relevant to the level so that it can be searched easily.
|
||||
*/
|
||||
public var tags: MutableStringListSerializedInString = mutableListOf()
|
||||
|
||||
/**
|
||||
* The separate level file name for multiplayer mode.
|
||||
* Leave blank if the level is the same for both one player and two players.
|
||||
*/
|
||||
public var separate2PLevelFilename: String = ""
|
||||
|
||||
/**
|
||||
* Whether the level can be played in one player only, two players only, or can be played in both mode.
|
||||
*/
|
||||
public var canBePlayedOn: LevelPlayerMode = LevelPlayerMode.ONE_PLAYER_ONLY
|
||||
|
||||
/**
|
||||
* Determines how the events on the first beat is executed.
|
||||
*/
|
||||
public var firstBeatBehavior: FirstBeatBehavior = FirstBeatBehavior.RUN_NORMALLY
|
||||
|
||||
/**
|
||||
* Determines how appearances of the multiplayer mode are displayed.
|
||||
*/
|
||||
public var multiplayerAppearance: MultiplayerAppearance = MultiplayerAppearance.HORIZONTAL_STRIPS
|
||||
|
||||
/**
|
||||
* The volume of the level. Must be between 0.0 and 1.0.
|
||||
*/
|
||||
public var levelVolume: Double = 1.0
|
||||
set(value) {
|
||||
require(value in 0.0..1.0) { "Level volume must be between 0.0 and 1.0." }
|
||||
field = value
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum number of mistakes allowed in the level for each rank.
|
||||
*/
|
||||
public var rankMaxMistakes: RankMaxMistakes = RankMaxMistakes()
|
||||
|
||||
/**
|
||||
* The rank descriptions for the level.
|
||||
*/
|
||||
public var rankDescription: RankDescriptions = RankDescriptions()
|
||||
|
||||
/**
|
||||
* The modifications that are enabled for the level.
|
||||
* See [Mods] for available modifications.
|
||||
*/
|
||||
public var mods: MutableList<String> = mutableListOf()
|
||||
|
||||
/**
|
||||
* The custom class name for the level.
|
||||
* See [CustomClasses] for available custom classes.
|
||||
*
|
||||
* This is used to specify a custom class that can be used to handle the level in a special way.
|
||||
* It is not recommended to use this unless you know what you are doing.
|
||||
*/
|
||||
public var customClass: String? = null
|
||||
|
||||
public companion object {
|
||||
/**
|
||||
* The current level version the level editor is using.
|
||||
*/
|
||||
public const val CURRENT_LEVEL_VERSION: Int = 61
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the preview song for the level.
|
||||
*
|
||||
* @param fileName The file name of the preview song.
|
||||
* @param startTime The start time of the preview song in seconds. Defaults to 0.0.
|
||||
* @param duration The duration of the preview song in seconds. Defaults to 10.0.
|
||||
* @return The updated [LevelSettings] instance.
|
||||
*/
|
||||
public fun LevelSettings.previewSong(
|
||||
fileName: String,
|
||||
startTime: Double = 0.0,
|
||||
duration: Double = 10.0
|
||||
): LevelSettings {
|
||||
previewSong = fileName
|
||||
previewSongStartTime = startTime
|
||||
previewSongDuration = duration
|
||||
return this
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.rdlevel.rdkt.core.settings
|
||||
|
||||
import cn.rdlevel.rdkt.core.settings.Mods.OLD_BASS_DROP
|
||||
|
||||
|
||||
/**
|
||||
* Some available modifications for custom levels in the game.
|
||||
* Data mainly from [Rhythm Doctor Custom Method Directory](https://docs.google.com/spreadsheets/d/1JAz6iRLqcn08ZeTeBHeeDrpdX6M5K0b1qRVQomua21s).
|
||||
*
|
||||
* Put them in [LevelSettings.mods] to enable them.
|
||||
*/
|
||||
public object Mods {
|
||||
/**
|
||||
* Enables bomb beats, a type of beat which cause player to take damage if they hit it.
|
||||
*/
|
||||
public const val BOMB_BEATS: String = "bombBeats"
|
||||
|
||||
/**
|
||||
* Makes hit particles stay still and not change size with the row.
|
||||
*/
|
||||
public const val CLASSIC_HIT_PARTICLES: String = "classicHitParticles"
|
||||
|
||||
/**
|
||||
* Make bass drop animation more gentle.
|
||||
* Requires [OLD_BASS_DROP] to work.
|
||||
*/
|
||||
public const val GENTLE_BASS_DROP: String = "gentleBassDrop"
|
||||
|
||||
/**
|
||||
* Use old bass drop animation.
|
||||
* Disables the intensity option in Bass Drop event.
|
||||
*/
|
||||
public const val OLD_BASS_DROP: String = "oldBassDrop"
|
||||
|
||||
/**
|
||||
* Level starts immediately without waiting for the player to press the space bar after loading.
|
||||
*/
|
||||
public const val START_IMMEDIATELY: String = "startImmediately"
|
||||
|
||||
/**
|
||||
* Makes the level skippable via the skip button in the pause menu.
|
||||
* If the player skips the level, the level immediately ends and the player is given an S rank.
|
||||
*/
|
||||
public const val SKIPPABLE: String = "skippable"
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
@file:OptIn(RDKTInternalAPI::class)
|
||||
@file:JvmName("Rankings")
|
||||
|
||||
package cn.rdlevel.rdkt.core.settings
|
||||
|
||||
import cn.rdlevel.rdkt.core.annotations.RDKTInternalAPI
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
/**
|
||||
* Represents the maximum number of mistakes allowed for each rank in a level.
|
||||
*/
|
||||
@Serializable(RankMaxMistakes.Serializer::class)
|
||||
public data class RankMaxMistakes(
|
||||
/**
|
||||
* The maximum number of mistakes allowed for rank A.
|
||||
*/
|
||||
public val rankA: Int = DEFAULT_RANK_A,
|
||||
/**
|
||||
* The maximum number of mistakes allowed for rank B.
|
||||
*/
|
||||
public val rankB: Int = DEFAULT_RANK_B,
|
||||
/**
|
||||
* The maximum number of mistakes allowed for rank C.
|
||||
*/
|
||||
public val rankC: Int = DEFAULT_RANK_C,
|
||||
/**
|
||||
* The maximum number of mistakes allowed for rank D.
|
||||
*/
|
||||
public val rankD: Int = DEFAULT_RANK_D,
|
||||
) {
|
||||
init {
|
||||
require(
|
||||
listOf(
|
||||
DEFAULT_RANK_S <= rankA,
|
||||
rankA <= rankB,
|
||||
rankB <= rankC,
|
||||
rankC <= rankD,
|
||||
rankD <= DEFAULT_RANK_F,
|
||||
).all { it }
|
||||
) {
|
||||
"Invalid rank max mistakes: S <= A <= B <= C <= D <= F must hold true. " +
|
||||
"Got: S=$DEFAULT_RANK_S, A=$rankA, B=$rankB, C=$rankC, D=$rankD"
|
||||
}
|
||||
}
|
||||
|
||||
public companion object {
|
||||
/**
|
||||
* The rank S, which is the highest rank, and always has no mistakes allowed.
|
||||
*/
|
||||
public const val DEFAULT_RANK_S: Int = 0
|
||||
|
||||
/**
|
||||
* The default allowed mistakes for rank A.
|
||||
*/
|
||||
public const val DEFAULT_RANK_A: Int = 5
|
||||
|
||||
/**
|
||||
* The default allowed mistakes for rank B.
|
||||
*/
|
||||
public const val DEFAULT_RANK_B: Int = 10
|
||||
|
||||
/**
|
||||
* The default allowed mistakes for rank C.
|
||||
*/
|
||||
public const val DEFAULT_RANK_C: Int = 15
|
||||
|
||||
/**
|
||||
* The default allowed mistakes for rank D.
|
||||
*/
|
||||
public const val DEFAULT_RANK_D: Int = 20
|
||||
|
||||
/**
|
||||
* The rank F, which is the lowest rank, and always has any number of mistakes allowed.
|
||||
*/
|
||||
public const val DEFAULT_RANK_F: Int = Int.MAX_VALUE
|
||||
}
|
||||
|
||||
public object Serializer : KSerializer<RankMaxMistakes> {
|
||||
private val listSerializer = ListSerializer(Int.Companion.serializer())
|
||||
|
||||
override val descriptor: SerialDescriptor = listSerializer.descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: RankMaxMistakes) {
|
||||
encoder.encodeSerializableValue(
|
||||
listSerializer, listOf(
|
||||
value.rankD,
|
||||
value.rankC,
|
||||
value.rankB,
|
||||
value.rankA,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): RankMaxMistakes {
|
||||
val list = decoder.decodeSerializableValue(listSerializer)
|
||||
return RankMaxMistakes(
|
||||
rankA = list.getOrElse(3) { DEFAULT_RANK_A },
|
||||
rankB = list.getOrElse(2) { DEFAULT_RANK_B },
|
||||
rankC = list.getOrElse(1) { DEFAULT_RANK_C },
|
||||
rankD = list.getOrElse(0) { DEFAULT_RANK_D },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the description for each rank in a level.
|
||||
*/
|
||||
@Serializable
|
||||
public data class RankDescriptions(
|
||||
/**
|
||||
* Rank S description.
|
||||
*/
|
||||
public val rankS: String = DEFAULT_RANK_S,
|
||||
/**
|
||||
* Rank A description.
|
||||
*/
|
||||
public val rankA: String = DEFAULT_RANK_A,
|
||||
/**
|
||||
* Rank B description.
|
||||
*/
|
||||
public val rankB: String = DEFAULT_RANK_B,
|
||||
/**
|
||||
* Rank C description.
|
||||
*/
|
||||
public val rankC: String = DEFAULT_RANK_C,
|
||||
/**
|
||||
* Rank D description.
|
||||
*/
|
||||
public val rankD: String = DEFAULT_RANK_D,
|
||||
/**
|
||||
* Rank F description.
|
||||
*/
|
||||
public val rankF: String = DEFAULT_RANK_F,
|
||||
) {
|
||||
public companion object {
|
||||
/**
|
||||
* The default description for rank S.
|
||||
*/
|
||||
public const val DEFAULT_RANK_S: String = "Wow! That's awesome!!"
|
||||
|
||||
/**
|
||||
* The default description for rank A.
|
||||
*/
|
||||
public const val DEFAULT_RANK_A: String = "You are really good!"
|
||||
|
||||
/**
|
||||
* The default description for rank B.
|
||||
*/
|
||||
public const val DEFAULT_RANK_B: String = "We make a good team!"
|
||||
|
||||
/**
|
||||
* The default description for rank C.
|
||||
*/
|
||||
public const val DEFAULT_RANK_C: String = "Not bad I guess..."
|
||||
|
||||
/**
|
||||
* The default description for rank D.
|
||||
*/
|
||||
public const val DEFAULT_RANK_D: String = "Ugh, you can do better"
|
||||
|
||||
/**
|
||||
* The default description for rank F.
|
||||
*/
|
||||
public const val DEFAULT_RANK_F: String = "Better call 911, now!"
|
||||
}
|
||||
|
||||
public object Serializer : KSerializer<RankDescriptions> {
|
||||
private val listSerializer = ListSerializer(String.serializer())
|
||||
|
||||
override val descriptor: SerialDescriptor = listSerializer.descriptor
|
||||
|
||||
override fun serialize(encoder: Encoder, value: RankDescriptions) {
|
||||
encoder.encodeSerializableValue(
|
||||
listSerializer, listOf(
|
||||
value.rankF,
|
||||
value.rankD,
|
||||
value.rankC,
|
||||
value.rankB,
|
||||
value.rankA,
|
||||
value.rankS,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): RankDescriptions {
|
||||
val list = decoder.decodeSerializableValue(listSerializer)
|
||||
return RankDescriptions(
|
||||
rankS = list.getOrElse(5) { DEFAULT_RANK_S },
|
||||
rankA = list.getOrElse(4) { DEFAULT_RANK_A },
|
||||
rankB = list.getOrElse(3) { DEFAULT_RANK_B },
|
||||
rankC = list.getOrElse(2) { DEFAULT_RANK_C },
|
||||
rankD = list.getOrElse(1) { DEFAULT_RANK_D },
|
||||
rankF = list.getOrElse(0) { DEFAULT_RANK_F },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for creating rank settings in a level.
|
||||
* This is an internal API and instances should not be created directly.
|
||||
*/
|
||||
|
||||
public class RankBuilder @RDKTInternalAPI constructor() {
|
||||
/**
|
||||
* Represents a rank configuration with the number of mistakes allowed and a description.
|
||||
* This interface can only modify the description of the rank.
|
||||
*/
|
||||
public sealed interface Rank {
|
||||
/**
|
||||
* The max number of mistakes allowed for this rank.
|
||||
*/
|
||||
public val mistakes: Int
|
||||
|
||||
/**
|
||||
* The description for this rank.
|
||||
*/
|
||||
public var description: String
|
||||
|
||||
/**
|
||||
* Sets the description for this rank.
|
||||
*
|
||||
* @param description The description for the rank.
|
||||
* @return The current [Rank] instance for chaining.
|
||||
*/
|
||||
public infix fun description(description: String): Rank {
|
||||
this.description = description
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a rank configuration that allows both the number of mistakes and the description to be modified.
|
||||
*/
|
||||
public sealed interface MistakesMutableRank : Rank {
|
||||
override var mistakes: Int
|
||||
|
||||
/**
|
||||
* Sets the number of mistakes allowed for this rank.
|
||||
*
|
||||
* @param mistakes The number of mistakes allowed.
|
||||
* @return The current [Rank] instance for chaining.
|
||||
*/
|
||||
public infix fun mistakes(mistakes: Int): Rank {
|
||||
this.mistakes = mistakes
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
private class RankImpl(
|
||||
override var mistakes: Int = 0,
|
||||
override var description: String = "",
|
||||
) : Rank, MistakesMutableRank
|
||||
|
||||
/**
|
||||
* Rank S configuration.
|
||||
*/
|
||||
public val rankS: Rank = RankImpl(RankMaxMistakes.DEFAULT_RANK_S, RankDescriptions.DEFAULT_RANK_S)
|
||||
|
||||
/**
|
||||
* Rank A configuration.
|
||||
*/
|
||||
public val rankA: MistakesMutableRank = RankImpl(RankMaxMistakes.DEFAULT_RANK_A, RankDescriptions.DEFAULT_RANK_A)
|
||||
|
||||
/**
|
||||
* Rank B configuration.
|
||||
*/
|
||||
public val rankB: MistakesMutableRank = RankImpl(RankMaxMistakes.DEFAULT_RANK_B, RankDescriptions.DEFAULT_RANK_B)
|
||||
|
||||
/**
|
||||
* Rank C configuration.
|
||||
*/
|
||||
public val rankC: MistakesMutableRank = RankImpl(RankMaxMistakes.DEFAULT_RANK_C, RankDescriptions.DEFAULT_RANK_C)
|
||||
|
||||
/**
|
||||
* Rank D configuration.
|
||||
*/
|
||||
public val rankD: MistakesMutableRank = RankImpl(RankMaxMistakes.DEFAULT_RANK_D, RankDescriptions.DEFAULT_RANK_D)
|
||||
|
||||
/**
|
||||
* Rank F configuration.
|
||||
*/
|
||||
public val rankF: Rank = RankImpl(RankMaxMistakes.DEFAULT_RANK_F, RankDescriptions.DEFAULT_RANK_F)
|
||||
|
||||
/**
|
||||
* Applies the rank settings to the provided [LevelSettings].
|
||||
*
|
||||
* @param settings The level settings to apply the rank settings to.
|
||||
*/
|
||||
public fun apply(settings: LevelSettings) {
|
||||
settings.rankMaxMistakes = RankMaxMistakes(
|
||||
rankA = rankA.mistakes,
|
||||
rankB = rankB.mistakes,
|
||||
rankC = rankC.mistakes,
|
||||
rankD = rankD.mistakes,
|
||||
)
|
||||
settings.rankDescription = RankDescriptions(
|
||||
rankS = rankS.description,
|
||||
rankA = rankA.description,
|
||||
rankB = rankB.description,
|
||||
rankC = rankC.description,
|
||||
rankD = rankD.description,
|
||||
rankF = rankF.description,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure ranks in a [LevelSettings] instance.
|
||||
*
|
||||
* @param block The block to configure the ranks.
|
||||
* @return The updated [LevelSettings] instance with the configured ranks.
|
||||
*/
|
||||
public inline fun LevelSettings.ranks(block: RankBuilder.() -> Unit): LevelSettings {
|
||||
val builder = RankBuilder()
|
||||
block(builder)
|
||||
builder.apply(this)
|
||||
return this
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#Gradle
|
||||
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
|
||||
org.gradle.caching=true
|
||||
org.gradle.configuration-cache=true
|
||||
#Kotlin
|
||||
kotlin.code.style=official
|
||||
#MPP
|
||||
kotlin.mpp.enableCInteropCommonization=true
|
||||
#Android
|
||||
android.useAndroidX=true
|
||||
android.nonTransitiveRClass=true
|
||||
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
|
||||
@@ -0,0 +1,13 @@
|
||||
[versions]
|
||||
agp = "8.5.2"
|
||||
kotlin = "2.1.10"
|
||||
android-minSdk = "24"
|
||||
android-compileSdk = "34"
|
||||
|
||||
[libraries]
|
||||
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
|
||||
|
||||
[plugins]
|
||||
androidLibrary = { id = "com.android.library", version.ref = "agp" }
|
||||
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||
vanniktech-mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.29.0" }
|
||||
Vendored
BIN
Binary file not shown.
+6
@@ -0,0 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,244 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,17 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "rdkt"
|
||||
include(":core")
|
||||
Reference in New Issue
Block a user