Skip to content

Commit

Permalink
[AN-HACK] 상성 기능 구현 (#26)
Browse files Browse the repository at this point in the history
* ci: an/hack/develop 추가

* ui: theme 설정 및 컬러 적용

* refactor: type UI 모델 재정의

- 색상도 포함하도록 수정

* chore: 타입 데이터 추가 및 파일 위치 변경

* chore: 불필요한 파일 제거

* feat: 타입 결과 반환하는 로직 구현

* feat: 타입 선택 바텀 시트 데이터 및 이벤트 핸들러 연결

* feat: 상성 결과 화면 데이터 연결 및 이벤트 처리

* refresh, 눌렀을 때 바텀시트 dismiss

* ktlintformat

---------

Co-authored-by: murjune <[email protected]>
  • Loading branch information
JoYehyun99 and murjune committed Jul 17, 2024
1 parent 0739658 commit 50001e8
Show file tree
Hide file tree
Showing 58 changed files with 1,266 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Android_PR_Builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Android PR Builder

on:
pull_request:
branches: [ an/develop, an/hack/develop ]
branches: [ an/develop ]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/ic_poke_icon"
android:supportsRtl="true"
android:theme="@style/Theme.PokeRogueHelper"
tools:targetApi="31">
Expand Down
Binary file added android/app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package poke.rogue.helper.data.datasource

import poke.rogue.helper.data.model.TypeMatchedResult
import poke.rogue.helper.local.DummyTypeData

class LocalTypeDataSource(private val typeData: DummyTypeData = DummyTypeData) {
fun findAllTypesAgainstAttackingType(attackingTypeId: Int): List<TypeMatchedResult> {
val allResult = typeData.typeMatchedTable[attackingTypeId]
val resultMap = allResult.withIndex().groupBy({ it.value }, { typeData.allTypes[it.index] })
val result =
resultMap.entries.map {
(matchedResult, types) ->
TypeMatchedResult(matchedResult, types)
}
return result
}

fun findAllTypesAgainstDefendingType(defendingTypeId: Int): List<TypeMatchedResult> {
val allResult = typeData.typeMatchedTable.map { it[defendingTypeId] }
val resultMap = allResult.withIndex().groupBy({ it.value }, { typeData.allTypes[it.index] })
val result =
resultMap.entries.map {
(matchedResult, types) ->
TypeMatchedResult(matchedResult, types)
}
return result
}

fun findMatchedTypeResult(
attackingTypeId: Int,
defendingTypeId: Int,
): TypeMatchedResult {
return TypeMatchedResult(
typeData.typeMatchedTable[attackingTypeId][defendingTypeId],
listOf(typeData.allTypes.get(defendingTypeId)),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package poke.rogue.helper.data.model

data class TypeMatchedResult(val matchedResult: MatchedResult, val types: List<TypeInfo>)
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package poke.rogue.helper.data.repository

import poke.rogue.helper.data.datasource.LocalTypeDataSource
import poke.rogue.helper.data.model.MatchedResult
import poke.rogue.helper.data.model.TypeMatchedResult

class TypeRepository(private val localTypeDataSource: LocalTypeDataSource) {
fun findResultAgainstMyType(myTypeId: Int): List<TypeMatchedResult> {
return localTypeDataSource.findAllTypesAgainstAttackingType(myTypeId)
.filter { it.matchedResult != MatchedResult.NORMAL }
}

fun findResultAgainstOpponent(opponentTypeId: Int): List<TypeMatchedResult> {
return localTypeDataSource.findAllTypesAgainstDefendingType(opponentTypeId)
.filter { it.matchedResult != MatchedResult.NORMAL }
}

fun findMatchedResult(
myTypeId: Int,
opponentTypeIds: List<Int>,
): List<TypeMatchedResult> {
return opponentTypeIds.map {
localTypeDataSource.findMatchedTypeResult(myTypeId, it)
}.filter { it.matchedResult != MatchedResult.NORMAL }
}
}
Loading

0 comments on commit 50001e8

Please sign in to comment.