Skip to content

Commit 89d4329

Browse files
committed
hilt and basic models
1 parent 1067055 commit 89d4329

File tree

14 files changed

+257
-0
lines changed

14 files changed

+257
-0
lines changed

.idea/gradle.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

+6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import org.jetbrains.kotlin.kapt3.base.Kapt.kapt
2+
13
plugins {
24
id("com.android.application")
35
kotlin("android")
46
id("kotlin-parcelize")
7+
kotlin("kapt")
8+
id("dagger.hilt.android.plugin")
59
}
610

711
android {
@@ -42,4 +46,6 @@ dependencies {
4246
testImplementation("junit:junit:4.13.2")
4347
androidTestImplementation("androidx.test.ext:junit:1.1.3")
4448
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
49+
implementation("com.google.dagger:hilt-android:2.38.1")
50+
kapt("com.google.dagger:hilt-android-compiler:2.38.1")
4551
}

app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package="com.peterfarlow">
44

55
<application
6+
android:name=".WingspanApplication"
67
android:allowBackup="false"
78
android:icon="@mipmap/ic_launcher"
89
android:label="@string/app_name"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.peterfarlow
2+
3+
import android.app.Application
4+
5+
class WingspanApplication : Application() {
6+
7+
}

build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ buildscript {
66
dependencies {
77
classpath("com.android.tools.build:gradle:7.0.0")
88
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21")
9+
classpath("com.google.dagger:hilt-android-gradle-plugin:2.38.1")
910
}
1011
}
1112

core/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

core/build.gradle.kts

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
plugins {
2+
id("com.android.library")
3+
kotlin("android")
4+
id("kotlin-parcelize")
5+
}
6+
7+
android {
8+
compileSdk = 30
9+
10+
defaultConfig {
11+
minSdk = 28
12+
targetSdk = 30
13+
consumerProguardFile("consumer-rules.pro")
14+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
15+
}
16+
17+
buildTypes {
18+
getByName("release") {
19+
isMinifyEnabled = false
20+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
21+
}
22+
getByName("debug") {
23+
isMinifyEnabled = false
24+
}
25+
}
26+
compileOptions {
27+
sourceCompatibility(JavaVersion.VERSION_11)
28+
targetCompatibility(JavaVersion.VERSION_11)
29+
}
30+
kotlinOptions {
31+
jvmTarget = "11"
32+
}
33+
}
34+
35+
dependencies {
36+
implementation("androidx.core:core-ktx:1.6.0")
37+
implementation("androidx.appcompat:appcompat:1.3.1")
38+
implementation("com.google.android.material:material:1.4.0")
39+
testImplementation("junit:junit:4.13.2")
40+
androidTestImplementation("androidx.test.ext:junit:1.1.3")
41+
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
42+
}

core/consumer-rules.pro

Whitespace-only changes.

core/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.kts.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.peterfarlow.core
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.peterfarlow.core.test", appContext.packageName)
23+
}
24+
}

core/src/main/AndroidManifest.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.peterfarlow.core">
4+
5+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
@file:Suppress("unused")
2+
3+
package com.peterfarlow.core
4+
5+
enum class TurnAction {
6+
PLAY_BIRD,
7+
GAIN_FOOD,
8+
LAY_EGGS,
9+
DRAW_CARDS
10+
}
11+
12+
data class Bird(
13+
val name: String,
14+
val latinName: String = "",
15+
val points: Points = 0,
16+
val habitat: Set<Habitat>,
17+
val foodCosts: Set<FoodCost>,
18+
val nestType: NestType,
19+
val description: String = "",
20+
val wingspan: Int,
21+
val eggs: Int = 0,
22+
val eggCapacity: Int = 0,
23+
val powerType: PowerType,
24+
val powerText: String,
25+
val tuckedCards: Set<Bird> = emptySet(),
26+
val cachedFood: Set<Food> = emptySet(),
27+
)
28+
29+
typealias Points = Int
30+
31+
enum class PowerType {
32+
BROWN,
33+
WHITE,
34+
PINK,
35+
NONE
36+
}
37+
38+
enum class Habitat {
39+
FOREST,
40+
GRASSLAND,
41+
WETLAND
42+
}
43+
44+
enum class NestType {
45+
PLATFORM,
46+
BOWL,
47+
CAVITY,
48+
GROUND,
49+
STAR,
50+
NONE
51+
}
52+
53+
54+
enum class Food {
55+
WORM,
56+
WHEAT,
57+
MOUSE,
58+
FISH,
59+
CHERRY,
60+
WILD
61+
}
62+
63+
enum class FoodDiceFace {
64+
WORM,
65+
WHEAT,
66+
MOUSE,
67+
FISH,
68+
CHERRY,
69+
WORM_WHEAT
70+
}
71+
72+
typealias FoodCost = Set<Food>
73+
74+
data class PlayerFoodSupply(
75+
val worms: Int = 0,
76+
val wheat: Int = 0,
77+
val mice: Int = 0,
78+
val fish: Int = 0,
79+
val cherries: Int = 0
80+
)
81+
82+
data class BirdFeeder(
83+
val food: Set<FoodDiceFace> = emptySet()
84+
)
85+
86+
data class PlayerState(
87+
val birds: PlayedBirds = PlayedBirds(),
88+
val hand: Set<Bird> = emptySet(),
89+
val foodTokens: PlayerFoodSupply = PlayerFoodSupply(),
90+
val bonusCards: Set<BonusCard> = emptySet()
91+
)
92+
93+
data class PlayedBirds(
94+
val forestBirds: List<Bird> = emptyList(),
95+
val grasslandBirds: List<Bird> = emptyList(),
96+
val wetlandBirds: List<Bird> = emptyList(),
97+
)
98+
99+
data class PlayBirdAction(
100+
val bird: Bird,
101+
val foodCost: FoodCost,
102+
val eggCost: Int,
103+
val habitat: Habitat
104+
)
105+
106+
data class Player(
107+
val id: Int,
108+
val name: String,
109+
val color: Color,
110+
val state: PlayerState,
111+
)
112+
113+
enum class Color {
114+
RED,
115+
BLUE,
116+
PURPLE,
117+
GREEN,
118+
YELLOW
119+
}
120+
121+
data class GameState(
122+
val birdTray: Set<Bird> = emptySet(),
123+
val birdFeeder: BirdFeeder = BirdFeeder()
124+
)
125+
126+
interface BonusCard {
127+
val name: String
128+
val description: String
129+
fun apply(playerState: PlayerState): PlayerState
130+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.peterfarlow.core
2+
3+
import org.junit.Test
4+
5+
import org.junit.Assert.*
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* See [testing documentation](http://d.android.com/tools/testing).
11+
*/
12+
class ExampleUnitTest {
13+
@Test
14+
fun addition_isCorrect() {
15+
assertEquals(4, 2 + 2)
16+
}
17+
}

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ dependencyResolutionManagement {
77
}
88
rootProject.name = "Wingspan"
99
include ':app'
10+
include ':core'

0 commit comments

Comments
 (0)