From a70839aadeb552ed1415218d497706592378ddd0 Mon Sep 17 00:00:00 2001 From: Pengoose Date: Fri, 27 Dec 2024 22:10:33 +0900 Subject: [PATCH 1/4] docs: add README-ja.md (#225) --- README-en.md | 2 +- README-ja.md | 213 +++++++++++++++++++++++++++++++++++++++++++++++++ README-zhcn.md | 2 +- README.md | 2 +- 4 files changed, 216 insertions(+), 3 deletions(-) create mode 100644 README-ja.md diff --git a/README-en.md b/README-en.md index a51bd6f..59a9299 100644 --- a/README-en.md +++ b/README-en.md @@ -4,7 +4,7 @@
-**English** | [한국어](README.md) | [简体中文](README-zhcn.md) +**English** | [한국어](README.md) | [简体中文](README-zhcn.md) | [日本語](README-ja.md)
diff --git a/README-ja.md b/README-ja.md new file mode 100644 index 0000000..b7544cb --- /dev/null +++ b/README-ja.md @@ -0,0 +1,213 @@ + + +## + +
+ +[English](README-en.md) | [한국어](README.md) | [简体中文](README-zhcn.md) | **日本語** + + +
+ +
+ + + + +⭐スターを押してください。開発に役立ちます!⭐️
+

スターを押す

+
+ +
+

GitHubの活動でペットを育てましょう!

+

GitHubの活動でペットを獲得し、成長させることができます。 +
コミットを30回すると、1匹のペットを追加で飼うことができます。 +
1つのコントリビューションでランダムなペットのレベルが1上がります。 +
育てたペットは他の人と取引することができます。 +
背景を購入し、変更することができます。 +
+
+50種類以上のペットを選んで育てましょう。 +
+ +[ホームページ](https://gitanimals.org) でペットを取引し、背景を購入して管理することができます。 + +

+
+ + docs/sample.svg + +
+ +## すぐに使う方法 + +以下のリンクをGitHubのREADMEに貼り付けるだけで簡単に適用できます。 + +> [!IMPORTANT] +> {username} は自分のGitHubのニックネーム(例:devxb)に変更してください。 +> このとき、{username} には必ず自分のGitHubの名前が入っている必要があります。 + +### ラインモード + +ラインモードでは、持っているペットの中から1つを指定し、指定した幅と高さの範囲で動かします。 +ラインモードを使用する際、マークダウン方式で画像をリクエストすると、幅と高さを設定できないためペットが見えなくなる場合がありますので、HTML方式を +使用してください。 + +> [!TIP] +> **Imgのwidthとheightを調整して、ペットの移動範囲を制御できます。** +> widthを長くし、heightを小さくすると(width = 1000, height = 120)横に長く動かすことができます。 +> 逆に、widthを小さくし、heightを長くすると(width = 60, height = 1000)縦に長く動かすことができます。 +> もし、ペットが見えない場合は、imgのheightをペットの縦の長さより十分に大きく設定してください。 + + + + + + +```html + + + +``` + +_pet-idに何も入力しないと、最初のペットが取得されます。_ + +変更可能なpet-idは `https://render.gitanimals.org/users/{username}` の {username} を自分のGitHub IDに変更後APIを +リクエストすると確認できます。 +APIのレスポンスの `$.personas.[].id` に対応する値をpet-idに入力してください。 + +linesモードでは、ペットのレベルの上に総コントリビューション数を表示します。表示を望まない場合は、クエリパラメータで `contribution-view=false` を追加してリクエストしてください。 + +### ファームモード + +ファームモードでは、所有しているすべての動物と追加の情報を表示します。 + + + + + +**html** + +```html + + + +``` + +## TIPS + +### ペットを獲得する方法 + +ペットは次の2つの方法で獲得できます。 + +1. **コミットを30回行う** + コミットが30回累積されると新しいペットが登場します。このとき、すべてのペットの登場確率が異なります。 + このとき、最大で30匹のペットを獲得できます。30匹を超えるペットはインベントリに入り、ホームページでいつでも表示されているペットと交換できます。 +2. **ペットを購入する** + 他のユーザーが販売しているペットをコミットポイントで購入できます。 + コミット1回ごとに一定量のポイントが付与されます。または、自分のペットを販売してコミットポイントを得ることもできます。 + +### Total contributions + +Total contributionsは、GitHubに登録後に集計されたコントリビューションの総合です。 +_新しいコントリビューションの反映には最大で1時間かかる場合があります。_ + +### 登場可能なペットたち + +| 名前 | 比率 | 説明 | +|----------------------------------------------------------------------------------------------------------|-----|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| SNOWMAN_MELT
| 0.001 | 🎄2024年クリスマスペット🎄 | +| SNOWMAN
| 0.005 | 🎄2024年クリスマスペット🎄 | +| DESSERT_FOX_RUDOLPH
| 0.005 | 🎄2024年クリスマスペット🎄 | +| RABBIT_BROWN_RUDOLPH
| 0.007 | 🎄2024年クリスマスペット🎄 | +| LITTLE_CHICK_SANTA
| 0.01 | 🎄2024年クリスマスペット🎄 | +| HAMSTER_SANTA
| 0.01 | 🎄2024年クリスマスペット🎄 | +| HAMSTER_JS
| 0.01 | | +| HAMSTER_KOTLIN
| 0.01 | | +| HAMSTER_JAVA
| 0.01 | | +| HAMSTER_SPRING
| 0.01 | | +| HAMSTER
| 0.8 | | +| SCREAM_GHOST
| 0.001 | 😱2024年ハロウィンペット😱 | +| SCREAM
| 0.005 | 😱2024年ハロウィンペット😱 | +| GHOST_KING
| 0.01 | 👻2024年ハロウィンペット👻 | +| GHOST
| 0.05 | 👻2024年ハロウィンペット👻 | +| SLIME_PUMPKIN_1
| 0.08 | 🎃2024年ハロウィンペット🎃 | +| SLIME_PUMPKIN_2
| 0.08 | 🎃2024年ハロウィンペット🎃 | +| TURTLE
| 0.03 | Designed by [@JIWOO CHOI](https://www.behance.net/sopungcjw42af) | +| SLOTH_SUNGLASSES
| 0.06 | | +| SLOTH_KING
| 0.05 | | +| SLOTH
| 0.7 | | +| DESSERT_FOX
| 0.05 | | +| RABBIT
| 0.9 | | +| MOLE
| 0.3 | | +| MOLE_GRASS
| 0.1 | | +| QUOKKA
| 0.3 | | +| QUOKKA_LEAF
| 0.1 | | +| QUOKKA_SUNGLASSES
| 0.05 | | +| FISH_MAN
| 0.001 | | +| FISH_MAN_GLASSES
| 0.001 | | +| flamingo
| 0.08 | | +| TEN_MM
| 0.00 | `10MM`の寄付で作成されたキャラクター
ショップでのみ購入可能
10MM | +| goblin
| 0.06 | | +| goblin-bag
| 0.03 | | +| bibbi
| 0.00 | `BIBBI`の寄付で作成されたキャラクター
ショップでのみ購入可能
BIBBI | +| cat
| 0.1 | | +| cheese-cat
| 0.04 | | +| galchi-cat
| 0.06 | | +| white-cat
| 0.04 | | +| goose
| 1.0 | | +| goose_sunglasses
| 0.05 | | +| goose_kotlin
| 0.01 | | +| goose_java
| 0.01 | | +| goose_js
| 0.01 | | +| goose_node
| 0.01 | | +| goose_swift
| 0.01 | | +| goose_linux
| 0.01 | | +| goose_spring
| 0.01 | | +| little_chick
| 0.9 | | +| little_chick_sunfsuglasses
| 0.4 | | +| little_chick_kotlin
| 0.01 | | +| little_chick_java
| 0.01 | | +| little_chick_js
| 0.01 | | +| little_chick_node
| 0.01 | | +| little_chick_swift
| 0.01 | | +| little_chick_linux
| 0.01 | | +| little_chick_spring
| 0.01 | | +| penguin
| 0.5 | | +| penguin_sunglasses
| 0.2 | | +| penguin_kotlin
| 0.01 | | +| penguin_java
| 0.01 | | +| penguin_js
| 0.01 | | +| penguin_node
| 0.01 | | +| penguin_swift
| 0.01 | | +| penguin_linux
| 0.01 | | +| penguin_spring
| 0.01 | | +| pig
| 0.2 | | +| pig_sunglasses
| 0.08 | | +| pig_kotlin
| 0.01 | | +| pig_java
| 0.01 | | +| pig_js
| 0.01 | | +| pig_node
| 0.01 | | +| pig_swift
| 0.01 | | +| pig_linux
| 0.01 | | +| pig_spring
| 0.01 | | +| slime_red
| 0.1 | | +| slime_red_kotlin
| 0.001 | | +| slime_red_java
| 0.001 | | +| slime_red_js
| 0.001 | | +| slime_red_node
| 0.001 | | +| slime_red_swift
| 0.001 | | +| slime_red_linux
| 0.001 | | +| slime_green
| 0.1 | | +| slime_blue
| 0.1 | | +| cheese_cat_collaborator
| 0.0 | コラボレーター [devxb](https://github.com/devxb) のために作られたペット | +| dessert_fox_collaborator
| 0.0 | コラボレーター [sumi-001](https://github.com/sumi-0011) のために作られたペット | +| pig_collaborator
| 0.0 | コラボレーター [hyesungoh](https://github.com/hyesungoh) のために作られたペット | +| rabbit_collaborator
| 0.0 | コラボレーター [Choi jiwoo](https://www.behance.net/sopungcjw42af) のために作られたペット | + +## + +
+

アイデアや発見したバグがあれば報告してください。 +連絡先 : develxb@gmail.com

+
diff --git a/README-zhcn.md b/README-zhcn.md index a9ffad2..20c1f9b 100644 --- a/README-zhcn.md +++ b/README-zhcn.md @@ -4,7 +4,7 @@
-[English](README-en.md) | [한국어](README.md) | **简体中文** +[English](README-en.md) | [한국어](README.md) | **简体中文** | [日本語](README-ja.md)
diff --git a/README.md b/README.md index 6bf230d..552f9cb 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@
-[English](README-en.md) | **한국어** | [简体中文](README-zhcn.md) +[English](README-en.md) | **한국어** | [简体中文](README-zhcn.md) | [日本語](README-ja.md)
From b7fadc4f44b9bfd13b5f521204b0578b54c100e0 Mon Sep 17 00:00:00 2001 From: devxb Date: Sat, 28 Dec 2024 16:31:37 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20draw=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=EC=9D=84=20core=20=EC=98=81=EC=97=AD=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=98=AE=EA=B8=B4=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{guild => }/core/AggregateRoot.kt | 2 +- .../{render/domain => core}/FieldType.kt | 19 +- .../{guild => }/core/IdGenerator.kt | 2 +- .../{render/domain => core}/Mode.kt | 2 +- .../{render/domain => core}/PersonaType.kt | 1262 ++++++++--------- .../{render/domain => core}/Svgs.kt | 8 +- .../org/gitanimals/{guild => }/core/clock.kt | 2 +- .../gitanimals/guild/app/DrawGuildProxy.kt | 2 +- .../guild/app/event/InboxInputEvent.kt | 2 +- .../guild/app/request/CreateGuildRequest.kt | 4 +- .../guild/controller/GuildController.kt | 5 +- .../response/GuildBackgroundResponse.kt | 4 +- .../org/gitanimals/guild/domain/Guild.kt | 16 +- .../gitanimals/guild/domain/GuildFarmType.kt | 157 -- .../gitanimals/guild/domain/GuildService.kt | 3 +- .../org/gitanimals/guild/domain/Member.kt | 2 +- .../org/gitanimals/guild/domain/Svgs.kt | 57 - .../org/gitanimals/guild/domain/WaitMember.kt | 2 +- .../extension/GuildFieldTypeExtension.kt | 12 + .../domain/request/ChangeGuildRequest.kt | 4 +- .../guild/saga/event/PersonaDeleted.kt | 2 +- .../gitanimals/render/app/AnimationFacade.kt | 2 +- .../gitanimals/render/app/DrawGuildFacade.kt | 12 +- .../org/gitanimals/render/app/UserFacade.kt | 2 +- .../render/app/UserStatisticSchedule.kt | 4 +- .../render/controller/AnimationController.kt | 2 +- .../render/controller/BackgroundController.kt | 2 +- .../render/controller/PersonaController.kt | 4 +- .../controller/response/BackgroundResponse.kt | 2 +- .../response/PersonaEnumResponse.kt | 2 +- .../controller/response/PersonaResponse.kt | 2 +- .../gitanimals/render/core/AggregateRoot.kt | 5 - .../org/gitanimals/render/core/IdGenerator.kt | 10 - .../org/gitanimals/render/core/clock.kt | 14 - .../org/gitanimals/render/domain/Field.kt | 3 +- .../org/gitanimals/render/domain/Persona.kt | 21 +- .../org/gitanimals/render/domain/User.kt | 7 +- .../gitanimals/render/domain/UserService.kt | 3 + .../render/domain/event/PersonaDeleted.kt | 2 +- .../extension/RenderFieldTypeExtension.kt | 12 + .../render/domain/response/PersonaResponse.kt | 2 +- .../guild/app/CreateGuildFacadeTest.kt | 4 +- .../org/gitanimals/guild/domain/Fixture.kt | 4 +- .../guild/domain/GuildServiceTest.kt | 3 +- .../gitanimals/render/domain/UserFixture.kt | 2 +- .../org/gitanimals/render/domain/UserTest.kt | 1 + .../render/saga/UsedCouponSagaHandlerTest.kt | 2 +- 47 files changed, 767 insertions(+), 931 deletions(-) rename src/main/kotlin/org/gitanimals/{guild => }/core/AggregateRoot.kt (75%) rename src/main/kotlin/org/gitanimals/{render/domain => core}/FieldType.kt (98%) rename src/main/kotlin/org/gitanimals/{guild => }/core/IdGenerator.kt (84%) rename src/main/kotlin/org/gitanimals/{render/domain => core}/Mode.kt (71%) rename src/main/kotlin/org/gitanimals/{render/domain => core}/PersonaType.kt (52%) rename src/main/kotlin/org/gitanimals/{render/domain => core}/Svgs.kt (98%) rename src/main/kotlin/org/gitanimals/{guild => }/core/clock.kt (90%) delete mode 100644 src/main/kotlin/org/gitanimals/guild/domain/GuildFarmType.kt delete mode 100644 src/main/kotlin/org/gitanimals/guild/domain/Svgs.kt create mode 100644 src/main/kotlin/org/gitanimals/guild/domain/extension/GuildFieldTypeExtension.kt delete mode 100644 src/main/kotlin/org/gitanimals/render/core/AggregateRoot.kt delete mode 100644 src/main/kotlin/org/gitanimals/render/core/IdGenerator.kt delete mode 100644 src/main/kotlin/org/gitanimals/render/core/clock.kt create mode 100644 src/main/kotlin/org/gitanimals/render/domain/extension/RenderFieldTypeExtension.kt diff --git a/src/main/kotlin/org/gitanimals/guild/core/AggregateRoot.kt b/src/main/kotlin/org/gitanimals/core/AggregateRoot.kt similarity index 75% rename from src/main/kotlin/org/gitanimals/guild/core/AggregateRoot.kt rename to src/main/kotlin/org/gitanimals/core/AggregateRoot.kt index 8a2cb9f..2f83161 100644 --- a/src/main/kotlin/org/gitanimals/guild/core/AggregateRoot.kt +++ b/src/main/kotlin/org/gitanimals/core/AggregateRoot.kt @@ -1,4 +1,4 @@ -package org.gitanimals.guild.core +package org.gitanimals.core @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.RUNTIME) diff --git a/src/main/kotlin/org/gitanimals/render/domain/FieldType.kt b/src/main/kotlin/org/gitanimals/core/FieldType.kt similarity index 98% rename from src/main/kotlin/org/gitanimals/render/domain/FieldType.kt rename to src/main/kotlin/org/gitanimals/core/FieldType.kt index 88449af..0e23651 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/FieldType.kt +++ b/src/main/kotlin/org/gitanimals/core/FieldType.kt @@ -1,4 +1,4 @@ -package org.gitanimals.render.domain +package org.gitanimals.core enum class FieldType { @@ -316,7 +316,7 @@ enum class FieldType { override fun drawBorder(): String { return "" } - }, + }, SNOW_GRASS_FIELD { override fun loadComponent(name: String, commit: Long): String { return snowGrassFieldSvg.replace(NAME_FIX, name.toSvg(0.0, 3.0)) @@ -341,6 +341,21 @@ enum class FieldType { return "" } }, + LOGO_SHOWING { + override fun loadComponent(name: String, commit: Long): String { + return dummyGuildFieldSvg.replace(NAME_FIX, name.toSvg(0.0, 3.0)) + .replace(COMMIT_FIX, commit.toSvg("commit", 260.0, 4.0)) + } + + override fun fillBackground(): String = + """ + + $logoShowingFieldSvg + """ + + override fun drawBorder(): String = + "" + } ; abstract fun loadComponent(name: String, commit: Long): String diff --git a/src/main/kotlin/org/gitanimals/guild/core/IdGenerator.kt b/src/main/kotlin/org/gitanimals/core/IdGenerator.kt similarity index 84% rename from src/main/kotlin/org/gitanimals/guild/core/IdGenerator.kt rename to src/main/kotlin/org/gitanimals/core/IdGenerator.kt index b9389fd..09fc250 100644 --- a/src/main/kotlin/org/gitanimals/guild/core/IdGenerator.kt +++ b/src/main/kotlin/org/gitanimals/core/IdGenerator.kt @@ -1,4 +1,4 @@ -package org.gitanimals.guild.core +package org.gitanimals.core import com.github.f4b6a3.tsid.TsidFactory diff --git a/src/main/kotlin/org/gitanimals/render/domain/Mode.kt b/src/main/kotlin/org/gitanimals/core/Mode.kt similarity index 71% rename from src/main/kotlin/org/gitanimals/render/domain/Mode.kt rename to src/main/kotlin/org/gitanimals/core/Mode.kt index b5b5d2f..2afb292 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/Mode.kt +++ b/src/main/kotlin/org/gitanimals/core/Mode.kt @@ -1,4 +1,4 @@ -package org.gitanimals.render.domain +package org.gitanimals.core enum class Mode { FARM, diff --git a/src/main/kotlin/org/gitanimals/render/domain/PersonaType.kt b/src/main/kotlin/org/gitanimals/core/PersonaType.kt similarity index 52% rename from src/main/kotlin/org/gitanimals/render/domain/PersonaType.kt rename to src/main/kotlin/org/gitanimals/core/PersonaType.kt index 7c2f6fd..c5cd692 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/PersonaType.kt +++ b/src/main/kotlin/org/gitanimals/core/PersonaType.kt @@ -1,4 +1,4 @@ -package org.gitanimals.render.domain +package org.gitanimals.core import java.text.DecimalFormat import kotlin.math.atan2 @@ -8,19 +8,19 @@ import kotlin.random.Random enum class PersonaType(val weight: Double, private var dropRate: String? = null) { GOOSE(1.0) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val goose = gooseSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val goose = gooseSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 * (persona.level.value.toString().length)).toString() + (-1 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (32 + (-3 * user.name.length)).toString() + (32 + (-3 * name.length)).toString() ) return StringBuilder() @@ -34,19 +34,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GOOSE_SUNGLASSES(0.05) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val goose = gooseSunglassesSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val goose = gooseSunglassesSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 * (persona.level.value.toString().length)).toString() + (-1 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (32 + (-3 * user.name.length)).toString() + (32 + (-3 * name.length)).toString() ) return StringBuilder() @@ -60,19 +60,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GOOSE_KOTLIN(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val goose = gooseKotlinSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val goose = gooseKotlinSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 * (persona.level.value.toString().length)).toString() + (-1 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (32 + (-3 * user.name.length)).toString() + (32 + (-3 * name.length)).toString() ) return StringBuilder() @@ -86,19 +86,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GOOSE_JAVA(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val goose = gooseJavaSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val goose = gooseJavaSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 * (persona.level.value.toString().length)).toString() + (-1 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (32 + (-3 * user.name.length)).toString() + (32 + (-3 * name.length)).toString() ) return StringBuilder() @@ -112,19 +112,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GOOSE_JS(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val goose = gooseJsSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val goose = gooseJsSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 * (persona.level.value.toString().length)).toString() + (-1 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (32 + (-3 * user.name.length)).toString() + (32 + (-3 * name.length)).toString() ) return StringBuilder() @@ -138,19 +138,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GOOSE_NODE(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val goose = gooseNodeSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val goose = gooseNodeSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 * (persona.level.value.toString().length)).toString() + (-1 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (32 + (-3 * user.name.length)).toString() + (32 + (-3 * name.length)).toString() ) return StringBuilder() @@ -164,19 +164,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GOOSE_SWIFT(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val goose = gooseSwiftSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val goose = gooseSwiftSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 * (persona.level.value.toString().length)).toString() + (-1 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (32 + (-3 * user.name.length)).toString() + (32 + (-3 * name.length)).toString() ) return StringBuilder() @@ -190,14 +190,14 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GOOSE_LINUX(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val goose = gooseLinuxSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val goose = gooseLinuxSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 * (persona.level.value.toString().length)).toString() + (-1 * (level.toString().length)).toString() ) return StringBuilder() @@ -211,19 +211,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GOOSE_SPRING(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val goose = gooseSpringSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val goose = gooseSpringSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 * (persona.level.value.toString().length)).toString() + (-1 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (32 + (-3 * user.name.length)).toString() + (32 + (-3 * name.length)).toString() ) return StringBuilder() @@ -237,19 +237,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, LITTLE_CHICK(0.9) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val littleChick = littleChickSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val littleChick = littleChickSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) return StringBuilder() @@ -263,19 +263,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, LITTLE_CHICK_SUNGLASSES(0.4) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val littleChick = littleChickSunglassesSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val littleChick = littleChickSunglassesSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) return StringBuilder() @@ -289,19 +289,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, LITTLE_CHICK_KOTLIN(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val littleChick = littleChickKotlinSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val littleChick = littleChickKotlinSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) return StringBuilder() @@ -315,19 +315,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, LITTLE_CHICK_JAVA(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val littleChick = littleChickJavaSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val littleChick = littleChickJavaSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) return StringBuilder() @@ -341,19 +341,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, LITTLE_CHICK_JS(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val littleChick = littleChickJsSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val littleChick = littleChickJsSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) return StringBuilder() @@ -367,19 +367,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, LITTLE_CHICK_NODE(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val littleChick = littleChickNodeSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val littleChick = littleChickNodeSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) return StringBuilder() @@ -393,19 +393,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, LITTLE_CHICK_SWIFT(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val littleChick = littleChickSwiftSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val littleChick = littleChickSwiftSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) return StringBuilder() @@ -419,19 +419,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, LITTLE_CHICK_LINUX(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val littleChick = littleChickLinuxSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val littleChick = littleChickLinuxSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) return StringBuilder() @@ -445,19 +445,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, LITTLE_CHICK_SPRING(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val littleChick = littleChickSpringSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val littleChick = littleChickSpringSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) return StringBuilder() @@ -470,19 +470,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, LITTLE_CHICK_SANTA(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - val littleChick = littleChickSantaSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + val littleChick = littleChickSantaSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) return StringBuilder() @@ -496,19 +496,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PENGUIN(0.5) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return penguinSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return penguinSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-4 + (-1 * (persona.level.value.toString().length))).toString() + (-4 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (20 + (-3 * user.name.length)).toString() + (20 + (-3 * name.length)).toString() ) } @@ -518,19 +518,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PENGUIN_SUNGLASSES(0.2) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return penguinSunglassesSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return penguinSunglassesSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-4 + (-1 * (persona.level.value.toString().length))).toString() + (-4 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (20 + (-3 * user.name.length)).toString() + (20 + (-3 * name.length)).toString() ) } @@ -540,19 +540,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PENGUIN_KOTLIN(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return penguinKotlinSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return penguinKotlinSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-4 + (-1 * (persona.level.value.toString().length))).toString() + (-4 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (20 + (-3 * user.name.length)).toString() + (20 + (-3 * name.length)).toString() ) } @@ -562,19 +562,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PENGUIN_JAVA(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return penguinJavaSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return penguinJavaSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-4 + (-1 * (persona.level.value.toString().length))).toString() + (-4 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (20 + (-3 * user.name.length)).toString() + (20 + (-3 * name.length)).toString() ) } @@ -584,19 +584,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PENGUIN_JS(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return penguinJsSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return penguinJsSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-4 + (-1 * (persona.level.value.toString().length))).toString() + (-4 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (20 + (-3 * user.name.length)).toString() + (20 + (-3 * name.length)).toString() ) } @@ -606,19 +606,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PENGUIN_NODE(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return penguinNodeSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return penguinNodeSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-4 + (-1 * (persona.level.value.toString().length))).toString() + (-4 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (20 + (-3 * user.name.length)).toString() + (20 + (-3 * name.length)).toString() ) } @@ -628,19 +628,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PENGUIN_SWIFT(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return penguinSwiftSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return penguinSwiftSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-4 + (-1 * (persona.level.value.toString().length))).toString() + (-4 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (20 + (-3 * user.name.length)).toString() + (20 + (-3 * name.length)).toString() ) } @@ -650,19 +650,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PENGUIN_LINUX(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return penguinLinuxSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return penguinLinuxSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-4 + (-1 * (persona.level.value.toString().length))).toString() + (-4 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (20 + (-3 * user.name.length)).toString() + (20 + (-3 * name.length)).toString() ) } @@ -672,19 +672,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PENGUIN_SPRING(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return penguinSpringSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return penguinSpringSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-4 + (-1 * (persona.level.value.toString().length))).toString() + (-4 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (20 + (-3 * user.name.length)).toString() + (20 + (-3 * name.length)).toString() ) } @@ -694,19 +694,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PIG(0.2) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return pigSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return pigSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (8 + (-1 * (persona.level.value.toString().length))).toString() + (8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (56 + (-3 * user.name.length)).toString() + (56 + (-3 * name.length)).toString() ) } @@ -716,19 +716,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PIG_SUNGLASSES(0.08) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return pigSunglassesSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return pigSunglassesSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (8 + (-1 * (persona.level.value.toString().length))).toString() + (8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (56 + (-3 * user.name.length)).toString() + (56 + (-3 * name.length)).toString() ) } @@ -738,19 +738,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PIG_KOTLIN(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return pigKotlinSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return pigKotlinSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (8 + (-1 * (persona.level.value.toString().length))).toString() + (8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (56 + (-3 * user.name.length)).toString() + (56 + (-3 * name.length)).toString() ) } @@ -760,19 +760,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PIG_JAVA(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return pigJavaSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return pigJavaSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (8 + (-1 * (persona.level.value.toString().length))).toString() + (8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (56 + (-3 * user.name.length)).toString() + (56 + (-3 * name.length)).toString() ) } @@ -782,19 +782,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PIG_JS(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return pigJsSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return pigJsSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (8 + (-1 * (persona.level.value.toString().length))).toString() + (8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (56 + (-3 * user.name.length)).toString() + (56 + (-3 * name.length)).toString() ) } @@ -804,19 +804,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PIG_NODE(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return pigNodeSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return pigNodeSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (8 + (-1 * (persona.level.value.toString().length))).toString() + (8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (56 + (-3 * user.name.length)).toString() + (56 + (-3 * name.length)).toString() ) } @@ -826,19 +826,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PIG_SWIFT(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return pigSwiftSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return pigSwiftSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (8 + (-1 * (persona.level.value.toString().length))).toString() + (8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (56 + (-3 * user.name.length)).toString() + (56 + (-3 * name.length)).toString() ) } @@ -848,19 +848,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PIG_LINUX(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return pigLinuxSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return pigLinuxSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (8 + (-1 * (persona.level.value.toString().length))).toString() + (8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (56 + (-3 * user.name.length)).toString() + (56 + (-3 * name.length)).toString() ) } @@ -870,19 +870,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PIG_SPRING(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return pigSpringSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return pigSpringSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (8 + (-1 * (persona.level.value.toString().length))).toString() + (8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (56 + (-3 * user.name.length)).toString() + (56 + (-3 * name.length)).toString() ) } @@ -892,19 +892,19 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, PIG_COLLABORATOR(0.0) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return pigCollaboratorSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return pigCollaboratorSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) .replace("*{leg-iteration-count}", "360") - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (8 + (-1 * (persona.level.value.toString().length))).toString() + (8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (56 + (-3 * user.name.length)).toString() + (56 + (-3 * name.length)).toString() ) } @@ -914,18 +914,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, SLIME_RED(0.1) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimeRedSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimeRedSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -935,18 +935,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, SLIME_RED_KOTLIN(0.001) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimeRedKotlinSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimeRedKotlinSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -956,18 +956,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, SLIME_RED_JAVA(0.001) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimeRedJavaSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimeRedJavaSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -977,18 +977,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, SLIME_RED_JS(0.001) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimeRedJsSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimeRedJsSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -998,18 +998,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, SLIME_RED_NODE(0.001) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimeRedNodeSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimeRedNodeSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1019,18 +1019,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, SLIME_RED_SWIFT(0.001) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimeRedSwiftSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimeRedSwiftSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1040,18 +1040,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, SLIME_RED_LINUX(0.001) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimeRedLinuxSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimeRedLinuxSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1061,23 +1061,23 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, SLIME_BLUE(0.1) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimeBlueSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimeBlueSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1087,18 +1087,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, SLIME_GREEN(0.1) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimeGreenSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimeGreenSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1108,18 +1108,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, FLAMINGO(0.05) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return flamingoSvg.replace("*{position}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return flamingoSvg.replace("*{position}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 * (persona.level.value.toString().length)).toString() + (-1 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (32 + (-3 * user.name.length)).toString() + (32 + (-3 * name.length)).toString() ) } @@ -1132,18 +1132,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, TEN_MM(0.000) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return tenmmSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return tenmmSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-2 + (-1 * (persona.level.value.toString().length))).toString() + (-2 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (26 + (-3 * user.name.length)).toString() + (26 + (-3 * name.length)).toString() ) } @@ -1153,18 +1153,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GOBLIN(0.06) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return goblinSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return goblinSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6.5 + (-1 * (persona.level.value.toString().length))).toString() + (-6.5 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (13 + (-3 * user.name.length)).toString() + (13 + (-3 * name.length)).toString() ) } @@ -1174,18 +1174,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GOBLIN_BAG(0.03) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return goblinBagSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return goblinBagSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6.5 + (-1 * (persona.level.value.toString().length))).toString() + (-6.5 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (13 + (-3 * user.name.length)).toString() + (13 + (-3 * name.length)).toString() ) } @@ -1195,18 +1195,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, BBIBBI(0.000) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return bbibbiSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return bbibbiSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1.5 + (-1 * (persona.level.value.toString().length))).toString() + (-1.5 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (27 + (-3 * user.name.length)).toString() + (27 + (-3 * name.length)).toString() ) } @@ -1216,18 +1216,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, CAT(0.1) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return catSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return catSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1237,18 +1237,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, CHEESE_CAT(0.04) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return cheeseCatSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return cheeseCatSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1258,18 +1258,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, CHEESE_CAT_COLLABORATOR(0.0) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return cheeseCatCollaboratorSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return cheeseCatCollaboratorSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1279,18 +1279,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, GALCHI_CAT(0.06) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return galchiCatSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return galchiCatSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1300,18 +1300,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, WHITE_CAT(0.04) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return whiteCatSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return whiteCatSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1321,18 +1321,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, WHITE_CAT_COLLABORATOR(0.00) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return whiteCatCollaboratorSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return whiteCatCollaboratorSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1342,18 +1342,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) }, FISH_MAN(0.002) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return fishManSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return fishManSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1362,18 +1362,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, FISH_MAN_GLASSES(0.001) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return fishManGlassesSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return fishManGlassesSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1382,18 +1382,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, QUOKKA(0.3) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return quokkaSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return quokkaSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-9 + (-1 * (persona.level.value.toString().length))).toString() + (-9 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (6 + (-3 * user.name.length)).toString() + (6 + (-3 * name.length)).toString() ) } @@ -1402,18 +1402,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, QUOKKA_LEAF(0.1) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return quokkaLeafSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return quokkaLeafSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-9 + (-1 * (persona.level.value.toString().length))).toString() + (-9 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (6 + (-3 * user.name.length)).toString() + (6 + (-3 * name.length)).toString() ) } @@ -1422,18 +1422,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, QUOKKA_SUNGLASSES(0.05) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return quokkaSunglassesSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return quokkaSunglassesSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-9 + (-1 * (persona.level.value.toString().length))).toString() + (-9 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (6 + (-3 * user.name.length)).toString() + (6 + (-3 * name.length)).toString() ) } @@ -1442,18 +1442,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, MOLE(0.3) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return moleSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return moleSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-8 + (-1 * (persona.level.value.toString().length))).toString() + (-8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (8.5 + (-3 * user.name.length)).toString() + (8.5 + (-3 * name.length)).toString() ) } @@ -1462,18 +1462,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, MOLE_GRASS(0.1) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return moleGrassSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return moleGrassSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-8 + (-1 * (persona.level.value.toString().length))).toString() + (-8 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (8.5 + (-3 * user.name.length)).toString() + (8.5 + (-3 * name.length)).toString() ) } @@ -1482,18 +1482,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, RABBIT(0.9) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return rabbitSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return rabbitSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-9 + (-1 * (persona.level.value.toString().length))).toString() + (-9 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (6 + (-3 * user.name.length)).toString() + (6 + (-3 * name.length)).toString() ) } @@ -1502,18 +1502,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, RABBIT_BROWN_RUDOLPH(0.007) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return rabbitBrownRudolphSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return rabbitBrownRudolphSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-9 + (-1 * (persona.level.value.toString().length))).toString() + (-9 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (6 + (-3 * user.name.length)).toString() + (6 + (-3 * name.length)).toString() ) } @@ -1522,18 +1522,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, RABBIT_COLLABORATOR(0.0) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return rabbitCollaboratorSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return rabbitCollaboratorSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-9 + (-1 * (persona.level.value.toString().length))).toString() + (-9 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (6 + (-3 * user.name.length)).toString() + (6 + (-3 * name.length)).toString() ) } @@ -1542,18 +1542,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, DESSERT_FOX(0.05) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return dessertFoxSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return dessertFoxSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-3 + (-1 * (persona.level.value.toString().length))).toString() + (-3 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (23 + (-3 * user.name.length)).toString() + (23 + (-3 * name.length)).toString() ) } @@ -1562,18 +1562,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, DESSERT_FOX_COLLABORATOR(0.0) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return dessertFoxCollaboratorSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return dessertFoxCollaboratorSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-3 + (-1 * (persona.level.value.toString().length))).toString() + (-3 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (23 + (-3 * user.name.length)).toString() + (23 + (-3 * name.length)).toString() ) } @@ -1582,18 +1582,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, DESSERT_FOX_RUDOLPH(0.005) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return dessertFoxRudolphSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return dessertFoxRudolphSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-3 + (-1 * (persona.level.value.toString().length))).toString() + (-3 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (23 + (-3 * user.name.length)).toString() + (23 + (-3 * name.length)).toString() ) } @@ -1602,18 +1602,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, SLOTH(0.7) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slothSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slothSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1622,18 +1622,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, SLOTH_KING(0.05) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slothKingSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slothKingSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1642,18 +1642,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, SLOTH_SUNGLASSES(0.06) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slothSunglassesSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slothSunglassesSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1662,18 +1662,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, TURTLE(0.03) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return turtleSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return turtleSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1 + (-1 * (persona.level.value.toString().length))).toString() + (-1 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (29 + (-3 * user.name.length)).toString() + (29 + (-3 * name.length)).toString() ) } @@ -1682,18 +1682,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, GHOST(0.05) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return ghostSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return ghostSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1.8 * (persona.level.value.toString().length)).toString() + (-1.8 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (23 + (-3 * user.name.length)).toString() + (23 + (-3 * name.length)).toString() ) } @@ -1702,18 +1702,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, GHOST_KING(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return ghostKingSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return ghostKingSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-1.8 * (persona.level.value.toString().length)).toString() + (-1.8 * (level.toString().length)).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (23 + (-3 * user.name.length)).toString() + (23 + (-3 * name.length)).toString() ) } @@ -1722,18 +1722,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, SCREAM(0.005) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return screamSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return screamSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1742,18 +1742,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, SCREAM_GHOST(0.001) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return screamGhostSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return screamGhostSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1762,18 +1762,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, SLIME_PUMPKIN_1(0.08) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimePumpkin1Svg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimePumpkin1Svg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1782,18 +1782,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, SLIME_PUMPKIN_2(0.08) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return slimePumpkin2Svg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return slimePumpkin2Svg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1802,18 +1802,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, HAMSTER(0.8) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return hamsterSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return hamsterSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-5 + (-1 * (persona.level.value.toString().length))).toString() + (-5 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (17 + (-3 * user.name.length)).toString() + (17 + (-3 * name.length)).toString() ) } @@ -1822,18 +1822,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, HAMSTER_SPRING(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return hamsterSpringSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return hamsterSpringSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-5 + (-1 * (persona.level.value.toString().length))).toString() + (-5 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (17 + (-3 * user.name.length)).toString() + (17 + (-3 * name.length)).toString() ) } @@ -1842,18 +1842,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, HAMSTER_JAVA(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return hamsterJavaSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return hamsterJavaSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-5 + (-1 * (persona.level.value.toString().length))).toString() + (-5 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (17 + (-3 * user.name.length)).toString() + (17 + (-3 * name.length)).toString() ) } @@ -1862,18 +1862,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, HAMSTER_KOTLIN(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return hamsterKotlinSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return hamsterKotlinSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-5 + (-1 * (persona.level.value.toString().length))).toString() + (-5 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (17 + (-3 * user.name.length)).toString() + (17 + (-3 * name.length)).toString() ) } @@ -1882,18 +1882,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, HAMSTER_JS(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return hamsterJsSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return hamsterJsSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-5 + (-1 * (persona.level.value.toString().length))).toString() + (-5 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (17 + (-3 * user.name.length)).toString() + (17 + (-3 * name.length)).toString() ) } @@ -1902,18 +1902,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, HAMSTER_SANTA(0.01) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return hamsterSantaSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return hamsterSantaSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-5 + (-1 * (persona.level.value.toString().length))).toString() + (-5 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (17 + (-3 * user.name.length)).toString() + (17 + (-3 * name.length)).toString() ) } @@ -1922,18 +1922,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, SNOWMAN(0.005) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return snowmanSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return snowmanSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-6 + (-1 * (persona.level.value.toString().length))).toString() + (-6 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (15 + (-3 * user.name.length)).toString() + (15 + (-3 * name.length)).toString() ) } @@ -1942,18 +1942,18 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .toString() }, SNOWMAN_MELT(0.001) { - override fun loadSvg(user: User, persona: Persona, mode: Mode): String { - return snowmanMeltSvg.replace("*{act}", act(persona.id)) - .replace("*{id}", persona.id.toString()) - .replace("*{level}", persona.level.value.toSvg(14.0, 2.0)) + override fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String { + return snowmanMeltSvg.replace("*{act}", act(animationId)) + .replace("*{id}", animationId.toString()) + .replace("*{level}", level.toSvg(14.0, 2.0)) .replace( "*{levelx}", - (-5 + (-1 * (persona.level.value.toString().length))).toString() + (-5 + (-1 * (level.toString().length))).toString() ) - .replace("*{username}", user.name.toSvg(14.0, 25.0)) + .replace("*{username}", name.toSvg(14.0, 25.0)) .replace( "*{usernamex}", - (17 + (-3 * user.name.length)).toString() + (17 + (-3 * name.length)).toString() ) } @@ -1985,17 +1985,17 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) return dropRate!! } - fun load(user: User, persona: Persona, mode: Mode): String = - loadSvg(user, persona, mode) - .drawContribution(mode, user) + fun load(name: String, contributionCount: Long, animationId: Long, level: Long, mode: Mode): String = + loadSvg(name, animationId, level, mode) + .drawContribution(mode, contributionCount) - abstract fun loadSvg(user: User, persona: Persona, mode: Mode): String + abstract fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String protected abstract fun act(id: Long, flippedWidth: Double = 0.0): String protected fun String.drawContribution( mode: Mode, - user: User + contributionCount: Long, ): String { return when (mode) { Mode.LINE -> { @@ -2003,11 +2003,11 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) .replace("*{username-display}", "none") .replace( "*{contributionx}", - (12.8 + (-1 * (user.contributionCount().toString().length))).toString() + (12.8 + (-1 * (contributionCount.toString().length))).toString() ) .replace( "*{contribution}", - user.contributionCount().toSvg(0.0, 2.0) + contributionCount.toSvg(0.0, 2.0) ).replace("*{contribution-display}", "default") .replace("*{level-tag-display}", "default") } diff --git a/src/main/kotlin/org/gitanimals/render/domain/Svgs.kt b/src/main/kotlin/org/gitanimals/core/Svgs.kt similarity index 98% rename from src/main/kotlin/org/gitanimals/render/domain/Svgs.kt rename to src/main/kotlin/org/gitanimals/core/Svgs.kt index f111fe2..5614f3f 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/Svgs.kt +++ b/src/main/kotlin/org/gitanimals/core/Svgs.kt @@ -1,4 +1,4 @@ -package org.gitanimals.render.domain +package org.gitanimals.core import org.springframework.core.io.ClassPathResource import java.nio.charset.Charset @@ -38,6 +38,12 @@ val grassChristmasTreeBackgroundSvg: String = ClassPathResource("persona/field/grass-christmastree-background.svg") .getContentAsString(Charset.defaultCharset()) +val dummyGuildFieldSvg: String = ClassPathResource("persona/field/white-field.svg") + .getContentAsString(Charset.defaultCharset()) + +val logoShowingFieldSvg: String = ClassPathResource("persona/field/logo-showing.svg") + .getContentAsString(Charset.defaultCharset()) + val gooseSvg: String = ClassPathResource("persona/animal/goose.svg") .getContentAsString(Charset.defaultCharset()) diff --git a/src/main/kotlin/org/gitanimals/guild/core/clock.kt b/src/main/kotlin/org/gitanimals/core/clock.kt similarity index 90% rename from src/main/kotlin/org/gitanimals/guild/core/clock.kt rename to src/main/kotlin/org/gitanimals/core/clock.kt index 40f89c7..b58e690 100644 --- a/src/main/kotlin/org/gitanimals/guild/core/clock.kt +++ b/src/main/kotlin/org/gitanimals/core/clock.kt @@ -1,4 +1,4 @@ -package org.gitanimals.guild.core +package org.gitanimals.core import java.time.Clock import java.time.Instant diff --git a/src/main/kotlin/org/gitanimals/guild/app/DrawGuildProxy.kt b/src/main/kotlin/org/gitanimals/guild/app/DrawGuildProxy.kt index c38c224..947f46b 100644 --- a/src/main/kotlin/org/gitanimals/guild/app/DrawGuildProxy.kt +++ b/src/main/kotlin/org/gitanimals/guild/app/DrawGuildProxy.kt @@ -17,7 +17,7 @@ class DrawGuildProxy( return renderDrawGuildFacade.drawGuild( title = guild.getTitle(), totalContributions = guild.getTotalContributions(), - guildFarmType = guild.getGuildFarmType(), + fieldType = guild.getGuildFarmType(), userIds = guild.getMembers().map { it.userId } + guild.getLeaderUserId(), personaIds = guild.getMembers().map { it.personaId } + guild.getLeaderPersonaId(), ) diff --git a/src/main/kotlin/org/gitanimals/guild/app/event/InboxInputEvent.kt b/src/main/kotlin/org/gitanimals/guild/app/event/InboxInputEvent.kt index bf69ca0..1bb6fdc 100644 --- a/src/main/kotlin/org/gitanimals/guild/app/event/InboxInputEvent.kt +++ b/src/main/kotlin/org/gitanimals/guild/app/event/InboxInputEvent.kt @@ -1,6 +1,6 @@ package org.gitanimals.guild.app.event -import org.gitanimals.guild.core.clock +import org.gitanimals.core.clock import java.time.Instant data class InboxInputEvent( diff --git a/src/main/kotlin/org/gitanimals/guild/app/request/CreateGuildRequest.kt b/src/main/kotlin/org/gitanimals/guild/app/request/CreateGuildRequest.kt index 33cc584..4914f2f 100644 --- a/src/main/kotlin/org/gitanimals/guild/app/request/CreateGuildRequest.kt +++ b/src/main/kotlin/org/gitanimals/guild/app/request/CreateGuildRequest.kt @@ -1,12 +1,12 @@ package org.gitanimals.guild.app.request -import org.gitanimals.guild.domain.GuildFarmType +import org.gitanimals.core.FieldType data class CreateGuildRequest( val title: String, val body: String, val guildIcon: String, val autoJoin: Boolean, - val farmType: GuildFarmType, + val farmType: FieldType, val personaId: String, ) diff --git a/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt b/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt index fc4cb8a..37f7581 100644 --- a/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt +++ b/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt @@ -1,13 +1,14 @@ package org.gitanimals.guild.controller +import org.gitanimals.core.FieldType import org.gitanimals.guild.app.* import org.gitanimals.guild.app.request.CreateGuildRequest import org.gitanimals.guild.controller.request.JoinGuildRequest import org.gitanimals.guild.controller.response.* -import org.gitanimals.guild.domain.GuildFarmType import org.gitanimals.guild.domain.GuildIcons import org.gitanimals.guild.domain.GuildService import org.gitanimals.guild.domain.SearchFilter +import org.gitanimals.guild.domain.extension.GuildFieldTypeExtension.isGuildField import org.gitanimals.guild.domain.request.ChangeGuildRequest import org.springframework.http.HttpHeaders import org.springframework.http.HttpStatus @@ -121,7 +122,7 @@ class GuildController( @GetMapping("/guilds/backgrounds") @ResponseStatus(HttpStatus.OK) fun findAllGuildBackgrounds(): GuildBackgroundResponse { - return GuildBackgroundResponse(GuildFarmType.entries) + return GuildBackgroundResponse(FieldType.entries.filter { it.isGuildField() }) } @PostMapping("/guilds/{guildId}/personas") diff --git a/src/main/kotlin/org/gitanimals/guild/controller/response/GuildBackgroundResponse.kt b/src/main/kotlin/org/gitanimals/guild/controller/response/GuildBackgroundResponse.kt index 4eef035..5a9ea39 100644 --- a/src/main/kotlin/org/gitanimals/guild/controller/response/GuildBackgroundResponse.kt +++ b/src/main/kotlin/org/gitanimals/guild/controller/response/GuildBackgroundResponse.kt @@ -1,7 +1,7 @@ package org.gitanimals.guild.controller.response -import org.gitanimals.guild.domain.GuildFarmType +import org.gitanimals.core.FieldType data class GuildBackgroundResponse( - val backgrounds: List + val backgrounds: List ) diff --git a/src/main/kotlin/org/gitanimals/guild/domain/Guild.kt b/src/main/kotlin/org/gitanimals/guild/domain/Guild.kt index 3ee647c..b7e28a5 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/Guild.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/Guild.kt @@ -1,8 +1,10 @@ package org.gitanimals.guild.domain import jakarta.persistence.* -import org.gitanimals.guild.core.AggregateRoot -import org.gitanimals.guild.core.IdGenerator +import org.gitanimals.core.AggregateRoot +import org.gitanimals.core.FieldType +import org.gitanimals.core.IdGenerator +import org.gitanimals.guild.domain.extension.GuildFieldTypeExtension.isGuildField import org.gitanimals.guild.domain.request.ChangeGuildRequest import org.hibernate.annotations.BatchSize @@ -33,7 +35,7 @@ class Guild( @Enumerated(EnumType.STRING) @Column(name = "farm_type", nullable = false, columnDefinition = "TEXT") - private var farmType: GuildFarmType, + private var farmType: FieldType, @Column(name = "auto_join", nullable = false) private var autoJoin: Boolean, @@ -136,7 +138,7 @@ class Guild( fun getContributions(): Long = leader.contributions - fun getGuildFarmType(): GuildFarmType = farmType + fun getGuildFarmType(): FieldType = farmType fun getTotalContributions(): Long { return leader.contributions + members.sumOf { it.getContributions() } @@ -218,9 +220,13 @@ class Guild( body: String, leader: Leader, members: MutableSet = mutableSetOf(), - farmType: GuildFarmType, + farmType: FieldType, autoJoin: Boolean, ): Guild { + require(farmType.isGuildField()) { + "Cannot create guild cause \"$farmType\" is not guild field." + } + GuildIcons.requireExistImagePath(guildIcon) return Guild( diff --git a/src/main/kotlin/org/gitanimals/guild/domain/GuildFarmType.kt b/src/main/kotlin/org/gitanimals/guild/domain/GuildFarmType.kt deleted file mode 100644 index 53284ea..0000000 --- a/src/main/kotlin/org/gitanimals/guild/domain/GuildFarmType.kt +++ /dev/null @@ -1,157 +0,0 @@ -package org.gitanimals.guild.domain - -enum class GuildFarmType { - - DUMMY { - override fun loadComponent(name: String, commit: Long): String { - return dummyGuildFieldSvg.replace(NAME_FIX, name.toSvg(0.0, 3.0)) - .replace(COMMIT_FIX, commit.toSvg("commit", 260.0, 4.0)) - } - - override fun fillBackground(): String = - "" - - override fun drawBorder(): String = - "" - }, - LOGO_SHOWING { - override fun loadComponent(name: String, commit: Long): String { - return dummyGuildFieldSvg.replace(NAME_FIX, name.toSvg(0.0, 3.0)) - .replace(COMMIT_FIX, commit.toSvg("commit", 260.0, 4.0)) - } - - override fun fillBackground(): String = - """ - - $logoShowingFieldSvg - """ - - override fun drawBorder(): String = - "" - } - ; - - abstract fun loadComponent(name: String, commit: Long): String - - abstract fun fillBackground(): String - - abstract fun drawBorder(): String - - private companion object { - private const val NAME_FIX = "*{username}" - private const val COMMIT_FIX = "*{commit-count}" - private const val VISIT_FIX = "*{visit-count}" - - private val largeTextWidth = mapOf( - "A" to 20.0, - "B" to 20.0, - "C" to 20.0, - "D" to 20.0, - "E" to 20.0, - "F" to 20.0, - "G" to 20.0, - "H" to 20.0, - "I" to 14.0, - "J" to 20.0, - "K" to 20.0, - "L" to 20.0, - "M" to 23.0, - "N" to 23.0, - "O" to 20.0, - "P" to 20.0, - "Q" to 20.0, - "R" to 20.0, - "S" to 20.0, - "T" to 20.0, - "U" to 20.0, - "V" to 20.0, - "W" to 23.0, - "X" to 20.0, - "Y" to 20.0, - "Z" to 20.0, - "-" to 20.0, - "a" to 20.0, - "b" to 20.0, - "c" to 20.0, - "d" to 20.0, - "e" to 20.0, - "f" to 20.0, - "g" to 20.0, - "h" to 20.0, - "i" to 20.0, - "j" to 17.0, - "k" to 20.0, - "l" to 20.0, - "m" to 23.0, - "n" to 20.0, - "o" to 20.0, - "p" to 20.0, - "q" to 20.0, - "r" to 20.0, - "s" to 20.0, - "t" to 20.0, - "u" to 20.0, - "v" to 20.0, - "w" to 23.0, - "x" to 20.0, - "y" to 23.0, - "z" to 20.0, - "0" to 20.0, - "1" to 17.0, - "2" to 20.0, - "3" to 20.0, - "4" to 23.0, - "5" to 20.0, - "6" to 20.0, - "7" to 20.0, - "8" to 20.0, - "9" to 20.0, - ) - - private val mediumNumberWidth = listOf( - 11.0, - 9.0, - 11.0, - 11.0, - 12.0, - 11.0, - 11.0, - 11.0, - 11.0, - 11.0, - ) - - private fun String.toSvg(startX: Double, xIncrease: Double): String { - val builder = StringBuilder() - var currentX = startX - this.forEach { char -> - val largeTextSvg = largeTextSvgs[char.toString()] - val index = char - 'A' - - val charWidth = largeTextWidth[char.toString()] - ?: throw IllegalArgumentException("Cannot find matched charWidth by \"$char\"") - - builder.append("") - .append(largeTextSvg) - .append("") - - currentX += xIncrease + charWidth - } - return builder.toString() - } - - private fun Long.toSvg(id: String, startX: Double, xIncrease: Double): String { - val builder = StringBuilder() - var currentX = startX - this.toString().forEach { char -> - val index = char.digitToInt() - val mediumNumberSvg = mediumNumberSvgs[index] - builder.append("") - .append(mediumNumberSvg) - .append("") - currentX += xIncrease + mediumNumberWidth[index] - } - return builder.toString() - } - } -} diff --git a/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt b/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt index e0485bc..a9320e7 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt @@ -1,5 +1,6 @@ package org.gitanimals.guild.domain +import org.gitanimals.core.FieldType import org.gitanimals.guild.domain.request.ChangeGuildRequest import org.gitanimals.guild.domain.request.CreateLeaderRequest import org.hibernate.Hibernate @@ -22,7 +23,7 @@ class GuildService( guildIcon: String, title: String, body: String, - farmType: GuildFarmType, + farmType: FieldType, autoJoin: Boolean, createLeaderRequest: CreateLeaderRequest, ) { diff --git a/src/main/kotlin/org/gitanimals/guild/domain/Member.kt b/src/main/kotlin/org/gitanimals/guild/domain/Member.kt index 6aeec67..d4089e5 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/Member.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/Member.kt @@ -1,7 +1,7 @@ package org.gitanimals.guild.domain import jakarta.persistence.* -import org.gitanimals.guild.core.IdGenerator +import org.gitanimals.core.IdGenerator @Entity @Table(name = "member") diff --git a/src/main/kotlin/org/gitanimals/guild/domain/Svgs.kt b/src/main/kotlin/org/gitanimals/guild/domain/Svgs.kt deleted file mode 100644 index 8e3876f..0000000 --- a/src/main/kotlin/org/gitanimals/guild/domain/Svgs.kt +++ /dev/null @@ -1,57 +0,0 @@ -package org.gitanimals.guild.domain - -import org.springframework.core.io.ClassPathResource -import java.nio.charset.Charset - -val dummyGuildFieldSvg: String = ClassPathResource("persona/field/white-field.svg") - .getContentAsString(Charset.defaultCharset()) - -val logoShowingFieldSvg: String = ClassPathResource("persona/field/logo-showing.svg") - .getContentAsString(Charset.defaultCharset()) - -val largeTextSvgs = lazy { - val map = mutableMapOf() - for (i in 'A'..'Z') { - val path = "persona/text/large/$i.svg" - map[i.toString()] = ClassPathResource(path) - .getContentAsString(Charset.defaultCharset()) - } - for (i in 'a'..'z') { - val path = "persona/text/large/_$i.svg" - map[i.toString()] = ClassPathResource(path) - .getContentAsString(Charset.defaultCharset()) - } - for (i in 0..9) { - val path = "persona/text/large/$i.svg" - map[i.toString()] = ClassPathResource(path) - .getContentAsString(Charset.defaultCharset()) - } - map["-"] = ClassPathResource("persona/text/large/hyphens.svg") - .getContentAsString(Charset.defaultCharset()) - map -}.value - -val mediumNumberSvgs = lazy { - val list = mutableListOf() - for (i in 0..9) { - val path = "persona/text/medium/$i.svg" - list.add( - ClassPathResource(path) - .getContentAsString(Charset.defaultCharset()) - ) - } - list -}.value - -val numberSvgs = lazy { - val list = mutableListOf() - for (i in 0..9) { - val path = "persona/text/small/$i.svg" - list.add( - ClassPathResource(path) - .getContentAsString(Charset.defaultCharset()) - ) - } - list -}.value - diff --git a/src/main/kotlin/org/gitanimals/guild/domain/WaitMember.kt b/src/main/kotlin/org/gitanimals/guild/domain/WaitMember.kt index a50ee1e..1c5c606 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/WaitMember.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/WaitMember.kt @@ -1,7 +1,7 @@ package org.gitanimals.guild.domain import jakarta.persistence.* -import org.gitanimals.guild.core.IdGenerator +import org.gitanimals.core.IdGenerator @Entity @Table( diff --git a/src/main/kotlin/org/gitanimals/guild/domain/extension/GuildFieldTypeExtension.kt b/src/main/kotlin/org/gitanimals/guild/domain/extension/GuildFieldTypeExtension.kt new file mode 100644 index 0000000..95e43e0 --- /dev/null +++ b/src/main/kotlin/org/gitanimals/guild/domain/extension/GuildFieldTypeExtension.kt @@ -0,0 +1,12 @@ +package org.gitanimals.guild.domain.extension + +import org.gitanimals.core.FieldType + +object GuildFieldTypeExtension { + + fun FieldType.isGuildField(): Boolean { + return this in guildFields + } + + private val guildFields = listOf(FieldType.LOGO_SHOWING) +} diff --git a/src/main/kotlin/org/gitanimals/guild/domain/request/ChangeGuildRequest.kt b/src/main/kotlin/org/gitanimals/guild/domain/request/ChangeGuildRequest.kt index 7a92bc3..1513ff9 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/request/ChangeGuildRequest.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/request/ChangeGuildRequest.kt @@ -1,11 +1,11 @@ package org.gitanimals.guild.domain.request -import org.gitanimals.guild.domain.GuildFarmType +import org.gitanimals.core.FieldType data class ChangeGuildRequest( val title: String, val body: String, - val farmType: GuildFarmType, + val farmType: FieldType, val guildIcon: String, val autoJoin: Boolean, ) diff --git a/src/main/kotlin/org/gitanimals/guild/saga/event/PersonaDeleted.kt b/src/main/kotlin/org/gitanimals/guild/saga/event/PersonaDeleted.kt index 0c5f665..6daee02 100644 --- a/src/main/kotlin/org/gitanimals/guild/saga/event/PersonaDeleted.kt +++ b/src/main/kotlin/org/gitanimals/guild/saga/event/PersonaDeleted.kt @@ -1,6 +1,6 @@ package org.gitanimals.guild.saga.event -import org.gitanimals.render.core.clock +import org.gitanimals.core.clock import java.time.Instant data class PersonaDeleted( diff --git a/src/main/kotlin/org/gitanimals/render/app/AnimationFacade.kt b/src/main/kotlin/org/gitanimals/render/app/AnimationFacade.kt index 69a8cea..f738595 100644 --- a/src/main/kotlin/org/gitanimals/render/app/AnimationFacade.kt +++ b/src/main/kotlin/org/gitanimals/render/app/AnimationFacade.kt @@ -1,6 +1,6 @@ package org.gitanimals.render.app -import org.gitanimals.render.domain.Mode +import org.gitanimals.core.Mode import org.gitanimals.render.domain.User import org.gitanimals.render.domain.UserService import org.gitanimals.render.domain.event.NewUserCreated diff --git a/src/main/kotlin/org/gitanimals/render/app/DrawGuildFacade.kt b/src/main/kotlin/org/gitanimals/render/app/DrawGuildFacade.kt index aad896b..8be7afc 100644 --- a/src/main/kotlin/org/gitanimals/render/app/DrawGuildFacade.kt +++ b/src/main/kotlin/org/gitanimals/render/app/DrawGuildFacade.kt @@ -1,7 +1,7 @@ package org.gitanimals.render.app -import org.gitanimals.guild.domain.GuildFarmType -import org.gitanimals.render.domain.Mode +import org.gitanimals.core.FieldType +import org.gitanimals.core.Mode import org.gitanimals.render.domain.UserService import org.springframework.stereotype.Service @@ -13,14 +13,14 @@ class DrawGuildFacade( fun drawGuild( title: String, totalContributions: Long, - guildFarmType: GuildFarmType, + fieldType: FieldType, userIds: List, personaIds: List, ): String { val users = userService.findAllUsersByIdWithContributions(userIds.toSet()) val svgBuilder = StringBuilder().openGuild() - .append(guildFarmType.fillBackground()) + .append(fieldType.fillBackground()) val personaSvgs = users.flatMap { user -> user.personas.filter { persona -> @@ -32,8 +32,8 @@ class DrawGuildFacade( personaSvgs.forEach { svgBuilder.append(it) } - return svgBuilder.append(guildFarmType.loadComponent(title, totalContributions)) - .append(guildFarmType.drawBorder()) + return svgBuilder.append(fieldType.loadComponent(title, totalContributions)) + .append(fieldType.drawBorder()) .closeGuild() } diff --git a/src/main/kotlin/org/gitanimals/render/app/UserFacade.kt b/src/main/kotlin/org/gitanimals/render/app/UserFacade.kt index e567b2c..a033427 100644 --- a/src/main/kotlin/org/gitanimals/render/app/UserFacade.kt +++ b/src/main/kotlin/org/gitanimals/render/app/UserFacade.kt @@ -1,7 +1,7 @@ package org.gitanimals.render.app import org.gitanimals.render.app.request.MergePersonaRequest -import org.gitanimals.render.domain.FieldType +import org.gitanimals.core.FieldType import org.gitanimals.render.domain.UserService import org.gitanimals.render.domain.request.PersonaChangeRequest import org.gitanimals.render.domain.response.PersonaResponse diff --git a/src/main/kotlin/org/gitanimals/render/app/UserStatisticSchedule.kt b/src/main/kotlin/org/gitanimals/render/app/UserStatisticSchedule.kt index 73e73b9..098edf0 100644 --- a/src/main/kotlin/org/gitanimals/render/app/UserStatisticSchedule.kt +++ b/src/main/kotlin/org/gitanimals/render/app/UserStatisticSchedule.kt @@ -1,7 +1,7 @@ package org.gitanimals.render.app -import org.gitanimals.render.core.instant -import org.gitanimals.render.core.toKr +import org.gitanimals.core.instant +import org.gitanimals.core.toKr import org.gitanimals.render.domain.UserStatisticService import org.gitanimals.render.domain.event.UserYesterdayReport import org.rooftop.netx.api.SagaManager diff --git a/src/main/kotlin/org/gitanimals/render/controller/AnimationController.kt b/src/main/kotlin/org/gitanimals/render/controller/AnimationController.kt index 4b3cd59..540a192 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/AnimationController.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/AnimationController.kt @@ -2,7 +2,7 @@ package org.gitanimals.render.controller import jakarta.servlet.http.HttpServletResponse import org.gitanimals.render.app.AnimationFacade -import org.gitanimals.render.domain.Mode +import org.gitanimals.core.Mode import org.springframework.http.HttpHeaders import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable diff --git a/src/main/kotlin/org/gitanimals/render/controller/BackgroundController.kt b/src/main/kotlin/org/gitanimals/render/controller/BackgroundController.kt index 71a40fa..d3157e2 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/BackgroundController.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/BackgroundController.kt @@ -4,7 +4,7 @@ import org.gitanimals.render.app.UserFacade import org.gitanimals.render.controller.request.ChangeFieldRequest import org.gitanimals.render.controller.response.BackgroundResponse import org.gitanimals.render.controller.response.ErrorResponse -import org.gitanimals.render.domain.FieldType +import org.gitanimals.core.FieldType import org.gitanimals.render.domain.UserService import org.gitanimals.render.domain.UserService.Companion.loadField import org.springframework.http.HttpHeaders diff --git a/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt b/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt index b62b33e..e516130 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt @@ -9,8 +9,8 @@ import org.gitanimals.render.controller.response.ErrorResponse import org.gitanimals.render.controller.response.PersonaEnumResponse import org.gitanimals.render.controller.response.PersonaResponse import org.gitanimals.render.controller.response.UserResponse -import org.gitanimals.render.core.IdGenerator -import org.gitanimals.render.domain.PersonaType +import org.gitanimals.core.IdGenerator +import org.gitanimals.core.PersonaType import org.gitanimals.render.domain.UserService import org.gitanimals.render.domain.request.PersonaChangeRequest import org.springframework.http.HttpHeaders diff --git a/src/main/kotlin/org/gitanimals/render/controller/response/BackgroundResponse.kt b/src/main/kotlin/org/gitanimals/render/controller/response/BackgroundResponse.kt index 77035c0..ae42e78 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/response/BackgroundResponse.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/response/BackgroundResponse.kt @@ -1,6 +1,6 @@ package org.gitanimals.render.controller.response -import org.gitanimals.render.domain.FieldType +import org.gitanimals.core.FieldType import org.gitanimals.render.domain.User data class BackgroundResponse( diff --git a/src/main/kotlin/org/gitanimals/render/controller/response/PersonaEnumResponse.kt b/src/main/kotlin/org/gitanimals/render/controller/response/PersonaEnumResponse.kt index 8d5fc6b..ed2144b 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/response/PersonaEnumResponse.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/response/PersonaEnumResponse.kt @@ -1,6 +1,6 @@ package org.gitanimals.render.controller.response -import org.gitanimals.render.domain.PersonaType +import org.gitanimals.core.PersonaType data class PersonaEnumResponse( val type: PersonaType, diff --git a/src/main/kotlin/org/gitanimals/render/controller/response/PersonaResponse.kt b/src/main/kotlin/org/gitanimals/render/controller/response/PersonaResponse.kt index 51fbf24..a125e02 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/response/PersonaResponse.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/response/PersonaResponse.kt @@ -1,6 +1,6 @@ package org.gitanimals.render.controller.response -import org.gitanimals.render.domain.PersonaType +import org.gitanimals.core.PersonaType data class PersonaResponse( val id: String, diff --git a/src/main/kotlin/org/gitanimals/render/core/AggregateRoot.kt b/src/main/kotlin/org/gitanimals/render/core/AggregateRoot.kt deleted file mode 100644 index 8d3ee5e..0000000 --- a/src/main/kotlin/org/gitanimals/render/core/AggregateRoot.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.gitanimals.render.core - -@Target(AnnotationTarget.CLASS) -@Retention(AnnotationRetention.RUNTIME) -annotation class AggregateRoot diff --git a/src/main/kotlin/org/gitanimals/render/core/IdGenerator.kt b/src/main/kotlin/org/gitanimals/render/core/IdGenerator.kt deleted file mode 100644 index 2b2942f..0000000 --- a/src/main/kotlin/org/gitanimals/render/core/IdGenerator.kt +++ /dev/null @@ -1,10 +0,0 @@ -package org.gitanimals.render.core - -import com.github.f4b6a3.tsid.TsidFactory - -object IdGenerator { - - private val tsidFactory = TsidFactory.newInstance256() - - fun generate(): Long = tsidFactory.create().toLong() -} diff --git a/src/main/kotlin/org/gitanimals/render/core/clock.kt b/src/main/kotlin/org/gitanimals/render/core/clock.kt deleted file mode 100644 index ba4a659..0000000 --- a/src/main/kotlin/org/gitanimals/render/core/clock.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.gitanimals.render.core - -import java.time.Clock -import java.time.Instant -import java.time.ZoneId -import java.time.ZonedDateTime - -var clock: Clock = Clock.systemUTC() - -fun instant() = Instant.now(clock) - -fun Instant.toZonedDateTime() = ZonedDateTime.ofInstant(this, clock.zone) - -fun Instant.toKr() = ZonedDateTime.ofInstant(this, ZoneId.of("Asia/Seoul")) diff --git a/src/main/kotlin/org/gitanimals/render/domain/Field.kt b/src/main/kotlin/org/gitanimals/render/domain/Field.kt index 2ffc24f..a9a45a2 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/Field.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/Field.kt @@ -2,7 +2,8 @@ package org.gitanimals.render.domain import com.fasterxml.jackson.annotation.JsonIgnore import jakarta.persistence.* -import org.gitanimals.render.core.IdGenerator +import org.gitanimals.core.FieldType +import org.gitanimals.core.IdGenerator @Entity @Table(name = "field") diff --git a/src/main/kotlin/org/gitanimals/render/domain/Persona.kt b/src/main/kotlin/org/gitanimals/render/domain/Persona.kt index da8f6a1..13ea438 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/Persona.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/Persona.kt @@ -2,7 +2,9 @@ package org.gitanimals.render.domain import com.fasterxml.jackson.annotation.JsonIgnore import jakarta.persistence.* -import org.gitanimals.render.core.IdGenerator +import org.gitanimals.core.IdGenerator +import org.gitanimals.core.Mode +import org.gitanimals.core.PersonaType import org.gitanimals.render.domain.value.Level @Table(name = "persona") @@ -52,13 +54,26 @@ class Persona( ) - fun toSvgForce(mode: Mode): String = type.load(user!!, this, mode) + fun toSvgForce(mode: Mode): String = type.load( + name = user!!.name, + contributionCount = user!!.contributionCount(), + animationId = this.id, + level = this.level(), + mode = mode, + ) fun toSvg(mode: Mode): String { if (!visible) { return "" } - return type.load(user!!, this, mode) + + return type.load( + name = user!!.name, + contributionCount = user!!.contributionCount(), + animationId = this.id, + level = this.level(), + mode = mode, + ) } fun level(): Long = level.value diff --git a/src/main/kotlin/org/gitanimals/render/domain/User.kt b/src/main/kotlin/org/gitanimals/render/domain/User.kt index 94e83af..3b073ac 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/User.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/User.kt @@ -2,9 +2,9 @@ package org.gitanimals.render.domain import com.fasterxml.jackson.annotation.JsonIgnore import jakarta.persistence.* -import org.gitanimals.render.core.AggregateRoot -import org.gitanimals.render.core.IdGenerator +import org.gitanimals.core.* import org.gitanimals.render.domain.event.PersonaDeleted +import org.gitanimals.render.domain.extension.RenderFieldTypeExtension.isRenderField import org.gitanimals.render.domain.listeners.DomainEventPublisher import org.gitanimals.render.domain.response.PersonaResponse import org.gitanimals.render.domain.value.Contribution @@ -233,6 +233,9 @@ class User( } fun addField(fieldType: FieldType) { + require(fieldType.isRenderField()) { + "Cannot add field cause \"$fieldType\" is not render field." + } require(fields.any { it.fieldType == fieldType }.not()) { "Duplicated add field request." } diff --git a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt index 614309c..c8b20ce 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt @@ -1,5 +1,8 @@ package org.gitanimals.render.domain +import org.gitanimals.core.FieldType +import org.gitanimals.core.Mode +import org.gitanimals.core.PersonaType import org.gitanimals.render.domain.request.PersonaChangeRequest import org.gitanimals.render.domain.response.PersonaResponse import org.hibernate.Hibernate diff --git a/src/main/kotlin/org/gitanimals/render/domain/event/PersonaDeleted.kt b/src/main/kotlin/org/gitanimals/render/domain/event/PersonaDeleted.kt index 4913b2e..ae45d28 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/event/PersonaDeleted.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/event/PersonaDeleted.kt @@ -1,6 +1,6 @@ package org.gitanimals.render.domain.event -import org.gitanimals.render.core.clock +import org.gitanimals.core.clock import java.time.Instant data class PersonaDeleted( diff --git a/src/main/kotlin/org/gitanimals/render/domain/extension/RenderFieldTypeExtension.kt b/src/main/kotlin/org/gitanimals/render/domain/extension/RenderFieldTypeExtension.kt new file mode 100644 index 0000000..e2ff864 --- /dev/null +++ b/src/main/kotlin/org/gitanimals/render/domain/extension/RenderFieldTypeExtension.kt @@ -0,0 +1,12 @@ +package org.gitanimals.render.domain.extension + +import org.gitanimals.core.FieldType + +object RenderFieldTypeExtension { + + fun FieldType.isRenderField(): Boolean { + return this in renderFields + } + + private val renderFields = FieldType.entries.filter { it != FieldType.LOGO_SHOWING } +} diff --git a/src/main/kotlin/org/gitanimals/render/domain/response/PersonaResponse.kt b/src/main/kotlin/org/gitanimals/render/domain/response/PersonaResponse.kt index 519b7a8..db29fa6 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/response/PersonaResponse.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/response/PersonaResponse.kt @@ -1,7 +1,7 @@ package org.gitanimals.render.domain.response import org.gitanimals.render.domain.Persona -import org.gitanimals.render.domain.PersonaType +import org.gitanimals.core.PersonaType data class PersonaResponse( val id: String, diff --git a/src/test/kotlin/org/gitanimals/guild/app/CreateGuildFacadeTest.kt b/src/test/kotlin/org/gitanimals/guild/app/CreateGuildFacadeTest.kt index d8374ef..adca606 100644 --- a/src/test/kotlin/org/gitanimals/guild/app/CreateGuildFacadeTest.kt +++ b/src/test/kotlin/org/gitanimals/guild/app/CreateGuildFacadeTest.kt @@ -7,8 +7,8 @@ import io.kotest.assertions.throwables.shouldThrowExactly import io.kotest.core.annotation.DisplayName import io.kotest.core.spec.style.DescribeSpec import io.mockk.every +import org.gitanimals.core.FieldType import org.gitanimals.guild.app.request.CreateGuildRequest -import org.gitanimals.guild.domain.GuildFarmType import org.gitanimals.guild.domain.GuildIcons import org.gitanimals.guild.domain.GuildRepository import org.gitanimals.guild.domain.GuildService @@ -111,7 +111,7 @@ internal class CreateGuildFacadeTest( body = "We are gitanimals", guildIcon = GuildIcons.CAT.getImagePath(), autoJoin = true, - farmType = GuildFarmType.LOGO_SHOWING, + farmType = FieldType.LOGO_SHOWING, personaId = "3", ) diff --git a/src/test/kotlin/org/gitanimals/guild/domain/Fixture.kt b/src/test/kotlin/org/gitanimals/guild/domain/Fixture.kt index 412b2d9..576f215 100644 --- a/src/test/kotlin/org/gitanimals/guild/domain/Fixture.kt +++ b/src/test/kotlin/org/gitanimals/guild/domain/Fixture.kt @@ -1,5 +1,7 @@ package org.gitanimals.guild.domain +import org.gitanimals.core.FieldType + fun guild( id: Long = 1L, guildIcon: String = "default_icon.png", @@ -8,7 +10,7 @@ fun guild( leader: Leader = leader(), members: MutableSet = mutableSetOf(), waitMembers: MutableSet = mutableSetOf(), - farmType: GuildFarmType = GuildFarmType.LOGO_SHOWING, + farmType: FieldType = FieldType.LOGO_SHOWING, autoJoin: Boolean = true, ): Guild { return Guild( diff --git a/src/test/kotlin/org/gitanimals/guild/domain/GuildServiceTest.kt b/src/test/kotlin/org/gitanimals/guild/domain/GuildServiceTest.kt index 1a1fbf1..36605fd 100644 --- a/src/test/kotlin/org/gitanimals/guild/domain/GuildServiceTest.kt +++ b/src/test/kotlin/org/gitanimals/guild/domain/GuildServiceTest.kt @@ -5,6 +5,7 @@ import io.kotest.assertions.throwables.shouldThrowExactly import io.kotest.core.annotation.DisplayName import io.kotest.core.spec.style.DescribeSpec import io.kotest.matchers.shouldBe +import org.gitanimals.core.FieldType import org.gitanimals.guild.domain.GuildService.Companion.loadMembers import org.gitanimals.guild.domain.GuildService.Companion.loadWaitMembers import org.gitanimals.guild.domain.request.CreateLeaderRequest @@ -32,7 +33,7 @@ internal class GuildServiceTest( val guildIcon = GuildIcons.CAT.getImagePath() val title = "guildTitle" val body = "guildBody" - val farmType = GuildFarmType.LOGO_SHOWING + val farmType = FieldType.LOGO_SHOWING val leaderRequest = CreateLeaderRequest( userId = 1L, name = "devxb", diff --git a/src/test/kotlin/org/gitanimals/render/domain/UserFixture.kt b/src/test/kotlin/org/gitanimals/render/domain/UserFixture.kt index e3e719b..1a66d13 100644 --- a/src/test/kotlin/org/gitanimals/render/domain/UserFixture.kt +++ b/src/test/kotlin/org/gitanimals/render/domain/UserFixture.kt @@ -1,6 +1,6 @@ package org.gitanimals.render.domain -import org.gitanimals.render.core.IdGenerator +import org.gitanimals.core.IdGenerator import org.gitanimals.render.domain.value.Contribution fun user( diff --git a/src/test/kotlin/org/gitanimals/render/domain/UserTest.kt b/src/test/kotlin/org/gitanimals/render/domain/UserTest.kt index 2eb0273..79a4a9f 100644 --- a/src/test/kotlin/org/gitanimals/render/domain/UserTest.kt +++ b/src/test/kotlin/org/gitanimals/render/domain/UserTest.kt @@ -6,6 +6,7 @@ import io.kotest.core.annotation.DisplayName import io.kotest.core.spec.style.DescribeSpec import io.kotest.matchers.equals.shouldBeEqual import io.kotest.matchers.nulls.shouldNotBeNull +import org.gitanimals.core.PersonaType import org.gitanimals.render.domain.event.PersonaDeleted import org.gitanimals.render.domain.listeners.DomainEventPublisher import org.gitanimals.render.domain.value.Contribution diff --git a/src/test/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlerTest.kt b/src/test/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlerTest.kt index 2f946c3..78d8707 100644 --- a/src/test/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlerTest.kt +++ b/src/test/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlerTest.kt @@ -6,7 +6,7 @@ import io.kotest.core.spec.style.DescribeSpec import io.kotest.matchers.collections.shouldHaveSize import io.kotest.matchers.equals.shouldBeEqual import io.kotest.matchers.should -import org.gitanimals.render.domain.PersonaType +import org.gitanimals.core.PersonaType import org.gitanimals.render.domain.UserRepository import org.gitanimals.render.domain.UserService import org.gitanimals.render.domain.user From bd0d3502c4545da89f1431eb31426dc2c2ba9454 Mon Sep 17 00:00:00 2001 From: devxb Date: Sat, 28 Dec 2024 17:28:29 +0900 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20guild=20farm=20=EC=9D=84=20?= =?UTF-8?q?=EA=B7=B8=EB=A6=AC=EB=8A=94=20=EC=B1=85=EC=9E=84=EC=9D=84=20gui?= =?UTF-8?q?ld=20=EB=8F=84=EB=A9=94=EC=9D=B8=EC=9C=BC=EB=A1=9C=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B4=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/org/gitanimals/core/PersonaType.kt | 2 +- .../interceptor/InterceptorConfigurer.kt | 2 +- .../interceptor/InternalApiInterceptor.kt | 2 +- .../gitanimals/guild/app/DrawGuildFacade.kt | 70 +++++++++++ .../gitanimals/guild/app/DrawGuildProxy.kt | 25 ---- .../org/gitanimals/guild/app/RenderApi.kt | 22 +++- .../guild/controller/GuildController.kt | 4 +- .../controller/response/GuildResponse.kt | 7 +- .../org/gitanimals/guild/domain/Guild.kt | 9 +- .../gitanimals/guild/domain/GuildService.kt | 7 +- .../org/gitanimals/guild/domain/Leader.kt | 8 +- .../org/gitanimals/guild/domain/Member.kt | 8 +- .../org/gitanimals/guild/domain/WaitMember.kt | 8 +- .../domain/request/CreateLeaderRequest.kt | 3 +- .../guild/infra/HttpClientConfigurer.kt | 29 +++++ .../gitanimals/render/app/DrawGuildFacade.kt | 49 -------- .../controller/InternalPersonaController.kt | 110 ++++++++++++++++++ .../render/controller/PersonaController.kt | 68 +---------- .../request/UserIdAndPersonaIdRequest.kt | 6 + .../controller/response/UserResponse.kt | 19 +++ .../org/gitanimals/guild/domain/Fixture.kt | 5 +- .../guild/domain/GuildServiceTest.kt | 11 +- .../saga/PersonaDeletedSagaHandlerTest.kt | 7 +- .../guild/supports/MockApiConfiguration.kt | 5 +- 24 files changed, 307 insertions(+), 179 deletions(-) rename src/main/kotlin/org/gitanimals/{render/controller => core}/interceptor/InterceptorConfigurer.kt (93%) rename src/main/kotlin/org/gitanimals/{render/controller => core}/interceptor/InternalApiInterceptor.kt (92%) create mode 100644 src/main/kotlin/org/gitanimals/guild/app/DrawGuildFacade.kt delete mode 100644 src/main/kotlin/org/gitanimals/guild/app/DrawGuildProxy.kt delete mode 100644 src/main/kotlin/org/gitanimals/render/app/DrawGuildFacade.kt create mode 100644 src/main/kotlin/org/gitanimals/render/controller/InternalPersonaController.kt create mode 100644 src/main/kotlin/org/gitanimals/render/controller/request/UserIdAndPersonaIdRequest.kt diff --git a/src/main/kotlin/org/gitanimals/core/PersonaType.kt b/src/main/kotlin/org/gitanimals/core/PersonaType.kt index c5cd692..f1fceb0 100644 --- a/src/main/kotlin/org/gitanimals/core/PersonaType.kt +++ b/src/main/kotlin/org/gitanimals/core/PersonaType.kt @@ -1989,7 +1989,7 @@ enum class PersonaType(val weight: Double, private var dropRate: String? = null) loadSvg(name, animationId, level, mode) .drawContribution(mode, contributionCount) - abstract fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String + protected abstract fun loadSvg(name: String, animationId: Long, level: Long, mode: Mode): String protected abstract fun act(id: Long, flippedWidth: Double = 0.0): String diff --git a/src/main/kotlin/org/gitanimals/render/controller/interceptor/InterceptorConfigurer.kt b/src/main/kotlin/org/gitanimals/core/interceptor/InterceptorConfigurer.kt similarity index 93% rename from src/main/kotlin/org/gitanimals/render/controller/interceptor/InterceptorConfigurer.kt rename to src/main/kotlin/org/gitanimals/core/interceptor/InterceptorConfigurer.kt index afc089a..36dd4b2 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/interceptor/InterceptorConfigurer.kt +++ b/src/main/kotlin/org/gitanimals/core/interceptor/InterceptorConfigurer.kt @@ -1,4 +1,4 @@ -package org.gitanimals.render.controller.interceptor +package org.gitanimals.core.interceptor import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Bean diff --git a/src/main/kotlin/org/gitanimals/render/controller/interceptor/InternalApiInterceptor.kt b/src/main/kotlin/org/gitanimals/core/interceptor/InternalApiInterceptor.kt similarity index 92% rename from src/main/kotlin/org/gitanimals/render/controller/interceptor/InternalApiInterceptor.kt rename to src/main/kotlin/org/gitanimals/core/interceptor/InternalApiInterceptor.kt index 5d6b157..ffed41b 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/interceptor/InternalApiInterceptor.kt +++ b/src/main/kotlin/org/gitanimals/core/interceptor/InternalApiInterceptor.kt @@ -1,4 +1,4 @@ -package org.gitanimals.render.controller.interceptor +package org.gitanimals.core.interceptor import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletResponse diff --git a/src/main/kotlin/org/gitanimals/guild/app/DrawGuildFacade.kt b/src/main/kotlin/org/gitanimals/guild/app/DrawGuildFacade.kt new file mode 100644 index 0000000..5f3cc41 --- /dev/null +++ b/src/main/kotlin/org/gitanimals/guild/app/DrawGuildFacade.kt @@ -0,0 +1,70 @@ +package org.gitanimals.guild.app + +import org.gitanimals.core.Mode +import org.gitanimals.guild.domain.Guild +import org.gitanimals.guild.domain.GuildService +import org.gitanimals.guild.domain.GuildService.Companion.loadMembers +import org.springframework.beans.factory.annotation.Value +import org.springframework.stereotype.Service + +@Service +class DrawGuildFacade( + private val renderApi: RenderApi, + private val guildService: GuildService, + @Value("\${internal.secret}") private val internalSecret: String, +) { + + fun drawGuild(id: Long): String { + val guild = guildService.getGuildById(id, loadMembers) + val renderUsers = getRenderUsers(guild) + + val svgBuilder = StringBuilder().openGuild() + .append(guild.getGuildFarmType().fillBackground()) + + val personaSvgs = renderUsers.map { user -> + val persona = user.personas.firstOrNull() + ?: throw IllegalArgumentException("Cannot draw guild cause user does not have any persona. user: \"$user\"") + + persona.type.load( + name = user.name, + contributionCount = user.totalContributions.toLong(), + animationId = persona.id.toLong(), + level = persona.level.toLong(), + mode = Mode.NAME_WITH_LEVEL, + ) + } + + personaSvgs.forEach { svgBuilder.append(it) } + + return svgBuilder.append( + guild.getGuildFarmType().loadComponent(guild.getTitle(), guild.getTotalContributions()) + ).append(guild.getGuildFarmType().drawBorder()) + .closeGuild() + } + + private fun getRenderUsers(guild: Guild): List { + val userIdAndPersonaIdRequests = guild.getMembers().map { + RenderApi.UserIdAndPersonaIdRequest( + personaId = it.personaId, + userId = it.userId, + ) + } + RenderApi.UserIdAndPersonaIdRequest( + personaId = guild.getLeaderPersonaId(), + userId = guild.getLeaderUserId(), + ) + + return renderApi.getAllPersonasByUserIdsAndPersonaIds( + internalSecret = internalSecret, + userIdAndPersonaIdRequests = userIdAndPersonaIdRequests, + ) + } + + + private fun StringBuilder.openGuild(): StringBuilder = + this.append("") + + private fun StringBuilder.closeGuild(): String = this + .append("") + .toString() + +} diff --git a/src/main/kotlin/org/gitanimals/guild/app/DrawGuildProxy.kt b/src/main/kotlin/org/gitanimals/guild/app/DrawGuildProxy.kt deleted file mode 100644 index 947f46b..0000000 --- a/src/main/kotlin/org/gitanimals/guild/app/DrawGuildProxy.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.gitanimals.guild.app - -import org.gitanimals.guild.domain.GuildService -import org.gitanimals.guild.domain.GuildService.Companion.loadMembers -import org.gitanimals.render.app.DrawGuildFacade -import org.springframework.stereotype.Service - -@Service -class DrawGuildProxy( - private val guildService: GuildService, - private val renderDrawGuildFacade: DrawGuildFacade, -) { - - fun drawGuild(id: Long): String { - val guild = guildService.getGuildById(id, loadMembers) - - return renderDrawGuildFacade.drawGuild( - title = guild.getTitle(), - totalContributions = guild.getTotalContributions(), - fieldType = guild.getGuildFarmType(), - userIds = guild.getMembers().map { it.userId } + guild.getLeaderUserId(), - personaIds = guild.getMembers().map { it.personaId } + guild.getLeaderPersonaId(), - ) - } -} diff --git a/src/main/kotlin/org/gitanimals/guild/app/RenderApi.kt b/src/main/kotlin/org/gitanimals/guild/app/RenderApi.kt index 9052785..739a18b 100644 --- a/src/main/kotlin/org/gitanimals/guild/app/RenderApi.kt +++ b/src/main/kotlin/org/gitanimals/guild/app/RenderApi.kt @@ -1,13 +1,22 @@ package org.gitanimals.guild.app +import org.gitanimals.core.PersonaType import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestHeader import org.springframework.web.service.annotation.GetExchange -fun interface RenderApi { +interface RenderApi { @GetExchange("/users/{username}") fun getUserByName(@PathVariable("username") username: String): UserResponse + @GetExchange("/internals/personas/all") + fun getAllPersonasByUserIdsAndPersonaIds( + @RequestHeader(INTERNAL_SECRET_KEY) internalSecret: String, + @RequestBody userIdAndPersonaIdRequests: List, + ): List + data class UserResponse( val id: String, val name: String, @@ -18,7 +27,16 @@ fun interface RenderApi { data class PersonaResponse( val id: String, val level: String, - val type: String, + val type: PersonaType, ) } + + data class UserIdAndPersonaIdRequest( + val userId: Long, + val personaId: Long, + ) + + private companion object { + private const val INTERNAL_SECRET_KEY = "Internal-Secret" + } } diff --git a/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt b/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt index 37f7581..74721b6 100644 --- a/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt +++ b/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt @@ -26,7 +26,7 @@ class GuildController( private val searchGuildFacade: SearchGuildFacade, private val changeMainPersonaFacade: ChangeMainPersonaFacade, private val leaveGuildFacade: LeaveGuildFacade, - private val drawGuildProxy: DrawGuildProxy, + private val drawGuildFacade: DrawGuildFacade, ) { @ResponseStatus(HttpStatus.OK) @@ -145,5 +145,5 @@ class GuildController( @GetMapping("/guilds/{guildId}/draw") fun draw( @PathVariable("guildId") guildId: Long, - ) = drawGuildProxy.drawGuild(guildId) + ) = drawGuildFacade.drawGuild(guildId) } diff --git a/src/main/kotlin/org/gitanimals/guild/controller/response/GuildResponse.kt b/src/main/kotlin/org/gitanimals/guild/controller/response/GuildResponse.kt index d0b8282..347f431 100644 --- a/src/main/kotlin/org/gitanimals/guild/controller/response/GuildResponse.kt +++ b/src/main/kotlin/org/gitanimals/guild/controller/response/GuildResponse.kt @@ -1,6 +1,7 @@ package org.gitanimals.guild.controller.response import com.fasterxml.jackson.annotation.JsonFormat +import org.gitanimals.core.PersonaType import org.gitanimals.guild.domain.Guild import java.time.Instant @@ -26,7 +27,7 @@ data class GuildResponse( val name: String, val contributions: String, val personaId: String, - val personaType: String, + val personaType: PersonaType, ) data class Member( @@ -35,7 +36,7 @@ data class GuildResponse( val name: String, val contributions: String, val personaId: String, - val personaType: String, + val personaType: PersonaType, ) data class WaitMember( @@ -44,7 +45,7 @@ data class GuildResponse( val name: String, val contributions: String, val personaId: String, - val personaType: String, + val personaType: PersonaType, ) companion object { diff --git a/src/main/kotlin/org/gitanimals/guild/domain/Guild.kt b/src/main/kotlin/org/gitanimals/guild/domain/Guild.kt index b7e28a5..c9f9adf 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/Guild.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/Guild.kt @@ -4,6 +4,7 @@ import jakarta.persistence.* import org.gitanimals.core.AggregateRoot import org.gitanimals.core.FieldType import org.gitanimals.core.IdGenerator +import org.gitanimals.core.PersonaType import org.gitanimals.guild.domain.extension.GuildFieldTypeExtension.isGuildField import org.gitanimals.guild.domain.request.ChangeGuildRequest import org.hibernate.annotations.BatchSize @@ -73,7 +74,7 @@ class Guild( memberName: String, memberPersonaId: Long, memberContributions: Long, - memberPersonaType: String, + memberPersonaType: PersonaType, ) { require(leader.userId != memberUserId) { "Leader cannot join their own guild leaderId: \"${leader.userId}\", memberUserId: \"$memberUserId\"" @@ -156,7 +157,7 @@ class Guild( userId: Long, deletedPersonaId: Long, changePersonaId: Long, - changePersonaType: String, + changePersonaType: PersonaType, ) { if (leader.userId == userId) { if (leader.personaId == deletedPersonaId) { @@ -185,11 +186,11 @@ class Guild( return leader.personaId } - fun getLeaderPersonaType(): String { + fun getLeaderPersonaType(): PersonaType { return leader.personaType } - fun changeMainPersona(userId: Long, personaId: Long, personaType: String) { + fun changeMainPersona(userId: Long, personaId: Long, personaType: PersonaType) { if (leader.userId == userId) { leader.personaId = personaId leader.personaType = personaType diff --git a/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt b/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt index a9320e7..cfb83e0 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt @@ -1,6 +1,7 @@ package org.gitanimals.guild.domain import org.gitanimals.core.FieldType +import org.gitanimals.core.PersonaType import org.gitanimals.guild.domain.request.ChangeGuildRequest import org.gitanimals.guild.domain.request.CreateLeaderRequest import org.hibernate.Hibernate @@ -52,7 +53,7 @@ class GuildService( memberUserId: Long, memberName: String, memberPersonaId: Long, - memberPersonaType: String, + memberPersonaType: PersonaType, memberContributions: Long, ) { val guild = getGuildById(guildId) @@ -104,7 +105,7 @@ class GuildService( @Transactional @Retryable(ObjectOptimisticLockingFailureException::class) - fun changeMainPersona(guildId: Long, userId: Long, personaId: Long, personaType: String) { + fun changeMainPersona(guildId: Long, userId: Long, personaId: Long, personaType: PersonaType) { val guild = getGuildById(guildId) guild.changeMainPersona(userId, personaId, personaType) @@ -164,7 +165,7 @@ class GuildService( userId: Long, deletedPersonaId: Long, changePersonaId: Long, - changePersonaType: String, + changePersonaType: PersonaType, ) { val guilds = guildRepository.findAllGuildByUserIdWithMembers(userId) diff --git a/src/main/kotlin/org/gitanimals/guild/domain/Leader.kt b/src/main/kotlin/org/gitanimals/guild/domain/Leader.kt index d27d0ff..752e83b 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/Leader.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/Leader.kt @@ -2,6 +2,9 @@ package org.gitanimals.guild.domain import jakarta.persistence.Column import jakarta.persistence.Embeddable +import jakarta.persistence.EnumType +import jakarta.persistence.Enumerated +import org.gitanimals.core.PersonaType @Embeddable data class Leader( @@ -14,8 +17,9 @@ data class Leader( @Column(name = "persona_id", nullable = false) var personaId: Long, - @Column(name = "persona_type", nullable = false) - var personaType: String, + @Enumerated(EnumType.STRING) + @Column(name = "persona_type", nullable = false, columnDefinition = "VARCHAR(255)") + var personaType: PersonaType, @Column(name = "contributions", nullable = false) var contributions: Long, diff --git a/src/main/kotlin/org/gitanimals/guild/domain/Member.kt b/src/main/kotlin/org/gitanimals/guild/domain/Member.kt index d4089e5..dffb3d6 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/Member.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/Member.kt @@ -2,6 +2,7 @@ package org.gitanimals.guild.domain import jakarta.persistence.* import org.gitanimals.core.IdGenerator +import org.gitanimals.core.PersonaType @Entity @Table(name = "member") @@ -19,8 +20,9 @@ class Member( @Column(name = "persona_id", nullable = false) var personaId: Long, - @Column(name = "persona_type", nullable = false) - var personaType: String, + @Enumerated(EnumType.STRING) + @Column(name = "persona_type", nullable = false, columnDefinition = "VARCHAR(255)") + var personaType: PersonaType, @Column(name = "contributions", nullable = false) private var contributions: Long, @@ -54,7 +56,7 @@ class Member( userId: Long, name: String, personaId: Long, - personaType: String, + personaType: PersonaType, contributions: Long, ): Member { return Member( diff --git a/src/main/kotlin/org/gitanimals/guild/domain/WaitMember.kt b/src/main/kotlin/org/gitanimals/guild/domain/WaitMember.kt index 1c5c606..8843e75 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/WaitMember.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/WaitMember.kt @@ -2,6 +2,7 @@ package org.gitanimals.guild.domain import jakarta.persistence.* import org.gitanimals.core.IdGenerator +import org.gitanimals.core.PersonaType @Entity @Table( @@ -27,8 +28,9 @@ class WaitMember( @Column(name = "persona_id", nullable = false) var personaId: Long, - @Column(name = "persona_type", nullable = false) - var personaType: String, + @Enumerated(EnumType.STRING) + @Column(name = "persona_type", nullable = false, columnDefinition = "VARCHAR(255)") + var personaType: PersonaType, @Column(name = "contributions", nullable = false) private var contributions: Long, @@ -66,7 +68,7 @@ class WaitMember( userId: Long, name: String, personaId: Long, - personaType: String, + personaType: PersonaType, contributions: Long, ): WaitMember { return WaitMember( diff --git a/src/main/kotlin/org/gitanimals/guild/domain/request/CreateLeaderRequest.kt b/src/main/kotlin/org/gitanimals/guild/domain/request/CreateLeaderRequest.kt index a2d4199..ced57fe 100644 --- a/src/main/kotlin/org/gitanimals/guild/domain/request/CreateLeaderRequest.kt +++ b/src/main/kotlin/org/gitanimals/guild/domain/request/CreateLeaderRequest.kt @@ -1,5 +1,6 @@ package org.gitanimals.guild.domain.request +import org.gitanimals.core.PersonaType import org.gitanimals.guild.domain.Leader data class CreateLeaderRequest( @@ -7,7 +8,7 @@ data class CreateLeaderRequest( val name: String, val personaId: Long, val contributions: Long, - val personaType: String, + val personaType: PersonaType, ) { fun toDomain(): Leader { diff --git a/src/main/kotlin/org/gitanimals/guild/infra/HttpClientConfigurer.kt b/src/main/kotlin/org/gitanimals/guild/infra/HttpClientConfigurer.kt index 4e5daeb..8a04a17 100644 --- a/src/main/kotlin/org/gitanimals/guild/infra/HttpClientConfigurer.kt +++ b/src/main/kotlin/org/gitanimals/guild/infra/HttpClientConfigurer.kt @@ -4,11 +4,13 @@ import org.gitanimals.guild.app.IdentityApi import org.gitanimals.guild.app.RenderApi import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Profile import org.springframework.web.client.RestClient import org.springframework.web.client.support.RestClientAdapter import org.springframework.web.service.invoker.HttpServiceProxyFactory @Configuration +@Profile("!test") class HttpClientConfigurer { @Bean @@ -33,3 +35,30 @@ class HttpClientConfigurer { return httpServiceProxyFactory.createClient(RenderApi::class.java) } } + +@Configuration +@Profile("test") +class TestHttpClientConfigurer { + + @Bean + fun identityApiHttpClient(): IdentityApi { + val restClient = RestClient.create("http://localhost:8080") + + val httpServiceProxyFactory = HttpServiceProxyFactory + .builderFor(RestClientAdapter.create(restClient)) + .build() + + return httpServiceProxyFactory.createClient(IdentityApi::class.java) + } + + @Bean + fun renderApiHttpClient(): RenderApi { + val restClient = RestClient.create("http://localhost:8080") + + val httpServiceProxyFactory = HttpServiceProxyFactory + .builderFor(RestClientAdapter.create(restClient)) + .build() + + return httpServiceProxyFactory.createClient(RenderApi::class.java) + } +} diff --git a/src/main/kotlin/org/gitanimals/render/app/DrawGuildFacade.kt b/src/main/kotlin/org/gitanimals/render/app/DrawGuildFacade.kt deleted file mode 100644 index 8be7afc..0000000 --- a/src/main/kotlin/org/gitanimals/render/app/DrawGuildFacade.kt +++ /dev/null @@ -1,49 +0,0 @@ -package org.gitanimals.render.app - -import org.gitanimals.core.FieldType -import org.gitanimals.core.Mode -import org.gitanimals.render.domain.UserService -import org.springframework.stereotype.Service - -@Service -class DrawGuildFacade( - private val userService: UserService, -) { - - fun drawGuild( - title: String, - totalContributions: Long, - fieldType: FieldType, - userIds: List, - personaIds: List, - ): String { - val users = userService.findAllUsersByIdWithContributions(userIds.toSet()) - - val svgBuilder = StringBuilder().openGuild() - .append(fieldType.fillBackground()) - - val personaSvgs = users.flatMap { user -> - user.personas.filter { persona -> - persona.id in personaIds - }.map { persona -> - persona.toSvgForce(Mode.NAME_WITH_LEVEL) - } - } - - personaSvgs.forEach { svgBuilder.append(it) } - - return svgBuilder.append(fieldType.loadComponent(title, totalContributions)) - .append(fieldType.drawBorder()) - .closeGuild() - } - - private fun StringBuilder.openGuild(): StringBuilder = - this.append("") - - private fun StringBuilder.closeGuild(): String = this - .append("") - .toString() - -} - - diff --git a/src/main/kotlin/org/gitanimals/render/controller/InternalPersonaController.kt b/src/main/kotlin/org/gitanimals/render/controller/InternalPersonaController.kt new file mode 100644 index 0000000..0a63c83 --- /dev/null +++ b/src/main/kotlin/org/gitanimals/render/controller/InternalPersonaController.kt @@ -0,0 +1,110 @@ +package org.gitanimals.render.controller + +import org.gitanimals.core.IdGenerator +import org.gitanimals.render.app.AuthorizationException +import org.gitanimals.render.app.UserFacade +import org.gitanimals.render.controller.request.AddMultiplyPersonaRequest +import org.gitanimals.render.controller.request.AddPersonaRequest +import org.gitanimals.render.controller.request.UserIdAndPersonaIdRequest +import org.gitanimals.render.controller.response.ErrorResponse +import org.gitanimals.render.controller.response.PersonaResponse +import org.gitanimals.render.controller.response.UserResponse +import org.gitanimals.render.domain.UserService +import org.springframework.http.HttpHeaders +import org.springframework.http.HttpStatus +import org.springframework.web.bind.annotation.* + +@RestController +class InternalPersonaController( + private val userFacade: UserFacade, + private val userService: UserService, +) { + + @PostMapping("/internals/personas") + fun addPersona( + @RequestHeader(HttpHeaders.AUTHORIZATION) token: String, + @RequestParam("idempotency-key") idempotencyKey: String, + @RequestBody addPersonaRequest: AddPersonaRequest, + ): PersonaResponse { + val persona = userFacade.addPersona( + token, + idempotencyKey, + addPersonaRequest.id, + addPersonaRequest.name, + addPersonaRequest.level, + ) + + return PersonaResponse( + persona.id, + persona.type, + persona.level, + persona.visible, + persona.dropRate, + ) + } + + @PostMapping("/internals/personas/multiply") + fun addPersonaMultiple( + @RequestHeader(HttpHeaders.AUTHORIZATION) token: String, + @RequestBody addPersonaRequests: List, + ): List { + return addPersonaRequests.map { + val persona = userFacade.addPersona( + token, + it.idempotencyKey, + IdGenerator.generate(), + it.personaName, + 0, + ) + + PersonaResponse( + persona.id, + persona.type, + persona.level, + persona.visible, + persona.dropRate, + ) + } + } + + @DeleteMapping("/internals/personas") + fun deletePersona( + @RequestHeader(HttpHeaders.AUTHORIZATION) token: String, + @RequestParam("persona-id") personaId: Long, + ): PersonaResponse { + val persona = userFacade.deletePersona(token, personaId) + + return PersonaResponse( + persona.id, + persona.type, + persona.level, + persona.visible, + persona.dropRate, + ) + } + + @GetMapping("/internals/personas/all") + @ResponseStatus(HttpStatus.OK) + fun getAllPersonasByUserIdsAndPersonaIds( + @RequestBody userIdAndPersonaIdRequests: List + ): List { + val users = userService.findAllUsersByIdWithContributions( + userIdAndPersonaIdRequests.map { it.userId }.toSet() + ) + + return users.map { user -> + val personaId = userIdAndPersonaIdRequests.first { it.userId == user.id }.personaId + UserResponse.fromWithSpecificPersona(user, listOf(personaId)) + } + } + + @ExceptionHandler(IllegalArgumentException::class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + fun handleIllegalArgumentException(exception: IllegalArgumentException): ErrorResponse = + ErrorResponse.from(exception) + + @ExceptionHandler(AuthorizationException::class) + @ResponseStatus(HttpStatus.UNAUTHORIZED) + fun handleAuthorizationException(exception: AuthorizationException): ErrorResponse = + ErrorResponse.from(exception) +} diff --git a/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt b/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt index e516130..5429161 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/PersonaController.kt @@ -1,16 +1,13 @@ package org.gitanimals.render.controller +import org.gitanimals.core.PersonaType import org.gitanimals.render.app.AuthorizationException import org.gitanimals.render.app.UserFacade import org.gitanimals.render.app.request.MergePersonaRequest -import org.gitanimals.render.controller.request.AddMultiplyPersonaRequest -import org.gitanimals.render.controller.request.AddPersonaRequest import org.gitanimals.render.controller.response.ErrorResponse import org.gitanimals.render.controller.response.PersonaEnumResponse import org.gitanimals.render.controller.response.PersonaResponse import org.gitanimals.render.controller.response.UserResponse -import org.gitanimals.core.IdGenerator -import org.gitanimals.core.PersonaType import org.gitanimals.render.domain.UserService import org.gitanimals.render.domain.request.PersonaChangeRequest import org.springframework.http.HttpHeaders @@ -85,69 +82,6 @@ class PersonaController( fun handleIllegalArgumentException(exception: IllegalArgumentException): ErrorResponse = ErrorResponse.from(exception) - @PostMapping("/internals/personas") - fun addPersona( - @RequestHeader(HttpHeaders.AUTHORIZATION) token: String, - @RequestParam("idempotency-key") idempotencyKey: String, - @RequestBody addPersonaRequest: AddPersonaRequest, - ): PersonaResponse { - val persona = userFacade.addPersona( - token, - idempotencyKey, - addPersonaRequest.id, - addPersonaRequest.name, - addPersonaRequest.level, - ) - - return PersonaResponse( - persona.id, - persona.type, - persona.level, - persona.visible, - persona.dropRate, - ) - } - - @PostMapping("/internals/personas/multiply") - fun addPersonaMultiple( - @RequestHeader(HttpHeaders.AUTHORIZATION) token: String, - @RequestBody addPersonaRequests: List, - ): List { - return addPersonaRequests.map { - val persona = userFacade.addPersona( - token, - it.idempotencyKey, - IdGenerator.generate(), - it.personaName, - 0, - ) - - PersonaResponse( - persona.id, - persona.type, - persona.level, - persona.visible, - persona.dropRate, - ) - } - } - - @DeleteMapping("/internals/personas") - fun deletePersona( - @RequestHeader(HttpHeaders.AUTHORIZATION) token: String, - @RequestParam("persona-id") personaId: Long, - ): PersonaResponse { - val persona = userFacade.deletePersona(token, personaId) - - return PersonaResponse( - persona.id, - persona.type, - persona.level, - persona.visible, - persona.dropRate, - ) - } - @ExceptionHandler(AuthorizationException::class) @ResponseStatus(HttpStatus.UNAUTHORIZED) fun handleAuthorizationException(exception: AuthorizationException): ErrorResponse = diff --git a/src/main/kotlin/org/gitanimals/render/controller/request/UserIdAndPersonaIdRequest.kt b/src/main/kotlin/org/gitanimals/render/controller/request/UserIdAndPersonaIdRequest.kt new file mode 100644 index 0000000..1395a7f --- /dev/null +++ b/src/main/kotlin/org/gitanimals/render/controller/request/UserIdAndPersonaIdRequest.kt @@ -0,0 +1,6 @@ +package org.gitanimals.render.controller.request + +data class UserIdAndPersonaIdRequest( + val userId: Long, + val personaId: Long, +) diff --git a/src/main/kotlin/org/gitanimals/render/controller/response/UserResponse.kt b/src/main/kotlin/org/gitanimals/render/controller/response/UserResponse.kt index 7af2d0c..5497b56 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/response/UserResponse.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/response/UserResponse.kt @@ -26,5 +26,24 @@ data class UserResponse( }.toList() ) } + + fun fromWithSpecificPersona(user: User, personaId: List): UserResponse { + return UserResponse( + user.id.toString(), + user.name, + user.contributionCount().toString(), + user.personas.filter { + it.id in personaId + }.map { + PersonaResponse( + it.id.toString(), + it.type, + it.level().toString(), + it.visible, + it.type.getDropRate() + ) + }.toList() + ) + } } } diff --git a/src/test/kotlin/org/gitanimals/guild/domain/Fixture.kt b/src/test/kotlin/org/gitanimals/guild/domain/Fixture.kt index 576f215..e013c31 100644 --- a/src/test/kotlin/org/gitanimals/guild/domain/Fixture.kt +++ b/src/test/kotlin/org/gitanimals/guild/domain/Fixture.kt @@ -1,6 +1,7 @@ package org.gitanimals.guild.domain import org.gitanimals.core.FieldType +import org.gitanimals.core.PersonaType fun guild( id: Long = 1L, @@ -31,7 +32,7 @@ fun leader( name: String = "Default Leader", personaId: Long = 1L, contributions: Long = 0L, - personaType: String = "GOOSE", + personaType: PersonaType = PersonaType.GOOSE, ): Leader { return Leader( userId = userId, @@ -48,7 +49,7 @@ fun member( name: String = "DefaultName", personaId: Long = 200L, contributions: Long = 500L, - personaType: String = "GOOSE", + personaType: PersonaType = PersonaType.GOOSE, ): Member { return Member.create( guild = guild, diff --git a/src/test/kotlin/org/gitanimals/guild/domain/GuildServiceTest.kt b/src/test/kotlin/org/gitanimals/guild/domain/GuildServiceTest.kt index 36605fd..efb9034 100644 --- a/src/test/kotlin/org/gitanimals/guild/domain/GuildServiceTest.kt +++ b/src/test/kotlin/org/gitanimals/guild/domain/GuildServiceTest.kt @@ -6,6 +6,7 @@ import io.kotest.core.annotation.DisplayName import io.kotest.core.spec.style.DescribeSpec import io.kotest.matchers.shouldBe import org.gitanimals.core.FieldType +import org.gitanimals.core.PersonaType import org.gitanimals.guild.domain.GuildService.Companion.loadMembers import org.gitanimals.guild.domain.GuildService.Companion.loadWaitMembers import org.gitanimals.guild.domain.request.CreateLeaderRequest @@ -39,7 +40,7 @@ internal class GuildServiceTest( name = "devxb", personaId = 2L, contributions = 3L, - personaType = "GOOSE", + personaType = PersonaType.GOOSE, ) it("중복된 길드가 아니라면 길드를 생성한다.") { @@ -96,7 +97,7 @@ internal class GuildServiceTest( memberName = memberName, memberPersonaId = memberPersonaId, memberContributions = memberContributions, - memberPersonaType = "GOOSE", + memberPersonaType = PersonaType.GOOSE, ) guildService.getGuildById(guild.id, loadMembers).getMembers().size shouldBe 1 @@ -118,7 +119,7 @@ internal class GuildServiceTest( memberName = memberName, memberPersonaId = memberPersonaId, memberContributions = memberContributions, - memberPersonaType = "GOOSE", + memberPersonaType = PersonaType.GOOSE, ) guildService.getGuildById(guild.id, loadWaitMembers) @@ -141,7 +142,7 @@ internal class GuildServiceTest( memberName = memberName, memberPersonaId = memberPersonaId, memberContributions = memberContributions, - memberPersonaType = "GOOSE", + memberPersonaType = PersonaType.GOOSE, ) } } @@ -162,7 +163,7 @@ internal class GuildServiceTest( memberName = memberName, memberPersonaId = memberPersonaId, memberContributions = memberContributions, - memberPersonaType = "GOOSE", + memberPersonaType = PersonaType.GOOSE, ) it("멤버를 가입시킨다.") { diff --git a/src/test/kotlin/org/gitanimals/guild/saga/PersonaDeletedSagaHandlerTest.kt b/src/test/kotlin/org/gitanimals/guild/saga/PersonaDeletedSagaHandlerTest.kt index e246d26..6954917 100644 --- a/src/test/kotlin/org/gitanimals/guild/saga/PersonaDeletedSagaHandlerTest.kt +++ b/src/test/kotlin/org/gitanimals/guild/saga/PersonaDeletedSagaHandlerTest.kt @@ -5,6 +5,7 @@ import io.kotest.core.annotation.DisplayName import io.kotest.core.spec.style.DescribeSpec import io.kotest.matchers.shouldBe import io.mockk.every +import org.gitanimals.core.PersonaType import org.gitanimals.guild.app.RenderApi import org.gitanimals.guild.domain.* import org.gitanimals.guild.saga.event.PersonaDeleted @@ -60,7 +61,7 @@ internal class PersonaDeletedSagaHandlerTest( memberName = memberName, memberPersonaId = memberPersonaId, memberContributions = 100L, - memberPersonaType = "GOOSE", + memberPersonaType = PersonaType.GOOSE, ) guild = guildRepository.save(guild) @@ -85,7 +86,7 @@ internal class PersonaDeletedSagaHandlerTest( RenderApi.UserResponse.PersonaResponse( changePersonaId.toString(), "10", - "GOOSE", + PersonaType.GOOSE, ) ) ) @@ -98,7 +99,7 @@ internal class PersonaDeletedSagaHandlerTest( RenderApi.UserResponse.PersonaResponse( changePersonaId.toString(), "10", - "GOOSE", + PersonaType.GOOSE, ) ) ) diff --git a/src/test/kotlin/org/gitanimals/guild/supports/MockApiConfiguration.kt b/src/test/kotlin/org/gitanimals/guild/supports/MockApiConfiguration.kt index 2814dcc..a5c1d8a 100644 --- a/src/test/kotlin/org/gitanimals/guild/supports/MockApiConfiguration.kt +++ b/src/test/kotlin/org/gitanimals/guild/supports/MockApiConfiguration.kt @@ -4,6 +4,7 @@ import io.mockk.Runs import io.mockk.every import io.mockk.just import io.mockk.mockk +import org.gitanimals.core.PersonaType import org.gitanimals.guild.app.IdentityApi import org.gitanimals.guild.app.RenderApi import org.springframework.boot.test.context.TestConfiguration @@ -42,12 +43,12 @@ class MockApiConfiguration { RenderApi.UserResponse.PersonaResponse( id = "3", level = "99", - type = "GOOSE", + type = PersonaType.GOOSE, ), RenderApi.UserResponse.PersonaResponse( id = "4", level = "98", - type = "GOOSE", + type = PersonaType.GOOSE, ), ) ) From ef1768a084343df7c33e94bb7688ef1a91df8bcd Mon Sep 17 00:00:00 2001 From: devxb Date: Mon, 30 Dec 2024 17:21:14 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20create=20guild=20=ED=83=80=EC=9E=84?= =?UTF-8?q?=EC=95=84=EC=9B=83=EC=9D=84=201=EB=B6=84=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=8A=98=EB=A6=B0=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.kt | 4 +++- .../kotlin/org/gitanimals/guild/controller/GuildController.kt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.kt b/src/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.kt index d802527..d29d831 100644 --- a/src/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.kt +++ b/src/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.kt @@ -8,6 +8,7 @@ import org.rooftop.netx.api.OrchestratorFactory import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Service import java.util.* +import kotlin.time.Duration.Companion.minutes @Service class CreateGuildFacade( @@ -25,8 +26,9 @@ class CreateGuildFacade( createGuildRequest: CreateGuildRequest, ) { createGuildOrchestrator.sagaSync( - createGuildRequest, + request = createGuildRequest, context = mapOf("token" to token, IDEMPOTENCY_KEY to UUID.randomUUID().toString()), + timeoutMillis = 1.minutes.inWholeMilliseconds, ).decodeResultOrThrow(Unit::class) } diff --git a/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt b/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt index 74721b6..85d2c74 100644 --- a/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt +++ b/src/main/kotlin/org/gitanimals/guild/controller/GuildController.kt @@ -73,7 +73,7 @@ class GuildController( @ResponseStatus(HttpStatus.OK) @GetMapping("/guilds/{guildId}") - fun getGuildById(guildId: Long): GuildResponse { + fun getGuildById(@PathVariable("guildId") guildId: Long): GuildResponse { val guild = guildService.getGuildById( guildId, GuildService.loadMembers,