Skip to content

Commit cd1a78a

Browse files
committed
Merge branch 'feat/note' into 'master'
Přidána vlastní poznámka u postavy See merge request fmasa/pv239-project!76
2 parents c9fde25 + ca1df82 commit cd1a78a

File tree

15 files changed

+68
-17
lines changed

15 files changed

+68
-17
lines changed

app/src/main/java/cz/muni/fi/rpg/model/domain/character/Character.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ data class Character(
1616
private var maxStats: Stats,
1717
private var points: Points,
1818
private var ambitions: Ambitions = Ambitions("", ""),
19-
private var mutation: String = ""
19+
private var mutation: String = "",
20+
private var note: String = ""
2021
) {
2122
companion object {
2223
const val NAME_MAX_LENGTH = 50
@@ -25,6 +26,7 @@ data class Character(
2526
const val PSYCHOLOGY_MAX_LENGTH = 200
2627
const val MOTIVATION_MAX_LENGTH = 200
2728
const val MUTATION_MAX_LENGTH = 200
29+
const val NOTE_MAX_LENGTH = 400
2830
}
2931

3032
private var money: Money = Money.zero()
@@ -37,6 +39,7 @@ data class Character(
3739
require(psychology.length <= PSYCHOLOGY_MAX_LENGTH) { "Psychology is too long" }
3840
require(motivation.length <= MOTIVATION_MAX_LENGTH) { "Motivation is too long" }
3941
require(mutation.length <= MUTATION_MAX_LENGTH) { "Mutation is too long" }
42+
require(note.length <= NOTE_MAX_LENGTH) { "Note is too long" }
4043
}
4144

4245
fun update(
@@ -48,7 +51,8 @@ data class Character(
4851
maxStats: Stats,
4952
points: Points,
5053
psychology: String,
51-
motivation: String
54+
motivation: String,
55+
note: String
5256
) {
5357
require(listOf(name, career).all { it.isNotBlank() })
5458
require(name.length <= NAME_MAX_LENGTH) { "Character name is too long" }
@@ -57,6 +61,7 @@ data class Character(
5761
require(stats.allLowerOrEqualTo(maxStats)) { "Stats cannot be larger than max stats" }
5862
require(psychology.length <= PSYCHOLOGY_MAX_LENGTH) { "Psychology is too long" }
5963
require(motivation.length <= MOTIVATION_MAX_LENGTH) { "Motivation is too long" }
64+
require(note.length <= NOTE_MAX_LENGTH) { "Note is too long" }
6065

6166
this.name = name
6267
this.career = career
@@ -67,6 +72,7 @@ data class Character(
6772
this.points = points
6873
this.psychology = psychology
6974
this.motivation = motivation
75+
this.note = note
7076
}
7177

7278
fun addMoney(amount: Money) {
@@ -113,5 +119,7 @@ data class Character(
113119

114120
fun getMotivation() = motivation
115121

122+
fun getNote() = note
123+
116124
fun getMutation() = mutation
117125
}

app/src/main/java/cz/muni/fi/rpg/ui/character/CharacterMiscFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ internal class CharacterMiscFragment : Fragment(R.layout.fragment_character_misc
6666
socialClassValue.text = character.getSocialClass()
6767
psychologyValue.text = character.getPsychology()
6868
motivationValue.text = character.getMotivation()
69+
noteValue.text = character.getNote()
6970

7071
xpPoints.text = getString(R.string.xp_points, character.getPoints().experience)
7172
xpPoints.setOnClickListener {

app/src/main/java/cz/muni/fi/rpg/ui/character/edit/CharacterEditFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ class CharacterEditFragment(
112112
statsData.maxStats,
113113
points.updateMaxWounds(maxWounds),
114114
info.psychology,
115-
info.motivation
115+
info.motivation,
116+
info.note
116117
)
117118

118119
characters.save(args.characterId.partyId, character)

app/src/main/java/cz/muni/fi/rpg/ui/characterCreation/CharacterCreationFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ class CharacterCreationFragment(
147147
maxStats = statsData.maxStats,
148148
points = points,
149149
psychology = info.psychology,
150-
motivation = info.motivation
150+
motivation = info.motivation,
151+
note = info.note
151152
)
152153
)
153154
toast("Your character has been created")

app/src/main/java/cz/muni/fi/rpg/ui/characterCreation/CharacterInfoFormFragment.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CharacterInfoFormFragment :
1717
private const val STATE_SOCIAL_CLASS = "infoClass"
1818
private const val STATE_PSYCHOLOGY = "infoPsychology"
1919
private const val STATE_MOTIVATION = "infoMotivation"
20+
private const val STATE_NOTE = "infoNote"
2021
}
2122

2223
var character: Character? = null
@@ -27,7 +28,8 @@ class CharacterInfoFormFragment :
2728
val career: String,
2829
val socialClass: String,
2930
val psychology: String,
30-
val motivation: String
31+
val motivation: String,
32+
val note: String
3133
)
3234

3335
private lateinit var form: Form
@@ -39,6 +41,7 @@ class CharacterInfoFormFragment :
3941
outState.putString(STATE_SOCIAL_CLASS, socialClassInput.getValue())
4042
outState.putString(STATE_PSYCHOLOGY, psychologyInput.getValue())
4143
outState.putString(STATE_MOTIVATION, motivationInput.getValue())
44+
outState.putString(STATE_NOTE, noteInput.getValue())
4245

4346
super.onSaveInstanceState(outState)
4447
}
@@ -69,6 +72,10 @@ class CharacterInfoFormFragment :
6972
addTextInput(motivationInput).apply {
7073
setMaxLength(Character.MOTIVATION_MAX_LENGTH, showCounter = false)
7174
}
75+
76+
addTextInput(noteInput).apply {
77+
setMaxLength(Character.NOTE_MAX_LENGTH, showCounter = false)
78+
}
7279
}
7380

7481
setDefaultValues()
@@ -78,6 +85,7 @@ class CharacterInfoFormFragment :
7885
it.getInt(STATE_RACE).let(radioGroup::check)
7986
it.getString(STATE_CAREER)?.let(careerInput::setDefaultValue)
8087
it.getString(STATE_SOCIAL_CLASS)?.let(socialClassInput::setDefaultValue)
88+
it.getString(STATE_NOTE)?.let(noteInput::setDefaultValue)
8189
}
8290
}
8391

@@ -102,6 +110,7 @@ class CharacterInfoFormFragment :
102110
socialClassInput.setDefaultValue(character.getSocialClass())
103111
psychologyInput.setDefaultValue(character.getPsychology())
104112
motivationInput.setDefaultValue(character.getMotivation())
113+
noteInput.setDefaultValue(character.getNote())
105114

106115
when (character.getRace()) {
107116
Race.HUMAN -> radioButtonRaceHuman.isChecked = true
@@ -132,7 +141,8 @@ class CharacterInfoFormFragment :
132141
career = career,
133142
socialClass = socialClass,
134143
psychology = psychologyInput.getValue(),
135-
motivation = motivationInput.getValue()
144+
motivation = motivationInput.getValue(),
145+
note = noteInput.getValue()
136146
)
137147
}
138148
}

app/src/main/res/layout/fragment_character_info_form.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,11 @@
9696
app:inputLabel="@string/label_motivation_input"
9797
android:layout_width="match_parent"
9898
android:layout_height="wrap_content"/>
99+
100+
<cz.muni.fi.rpg.ui.views.TextInput
101+
android:id="@+id/noteInput"
102+
android:layout_marginTop="12dp"
103+
app:inputLabel="@string/label_character_note_input"
104+
android:layout_width="match_parent"
105+
android:layout_height="wrap_content"/>
99106
</LinearLayout>

app/src/main/res/layout/fragment_character_misc.xml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
psychologyLabel,
4444
psychologyValue,
4545
motivationLabel,
46-
motivationValue"
46+
motivationValue,
47+
noteLabel,
48+
noteValue"
4749
app:flow_horizontalBias="0"
4850
app:flow_horizontalGap="14dp"
4951
app:flow_horizontalStyle="spread"
@@ -159,13 +161,26 @@
159161
android:paddingBottom="6dp"
160162
android:layout_width="match_parent"
161163
android:layout_height="wrap_content" />
164+
165+
<TextView
166+
android:id="@+id/noteLabel"
167+
android:text="@string/label_character_note"
168+
android:layout_width="match_parent"
169+
android:layout_height="wrap_content" />
170+
171+
<TextView
172+
android:id="@+id/noteValue"
173+
style="@style/TextAppearance.AppCompat.Medium"
174+
android:textColor="@color/colorText"
175+
android:paddingBottom="6dp"
176+
android:layout_width="match_parent"
177+
android:layout_height="wrap_content" />
162178
</androidx.constraintlayout.widget.ConstraintLayout>
163179
</androidx.cardview.widget.CardView>
164180

165181
<cz.muni.fi.rpg.ui.views.AmbitionsCard
166182
android:id="@+id/characterAmbitionsCard"
167183
style="@style/CardContainer"
168-
android:layout_marginTop="20dp"
169184
android:clickable="true"
170185
android:focusable="true"
171186
android:foreground="?attr/selectableItemBackground"
@@ -176,7 +191,6 @@
176191
<cz.muni.fi.rpg.ui.views.AmbitionsCard
177192
android:id="@+id/partyAmbitionsCard"
178193
style="@style/CardContainer"
179-
android:layout_marginTop="20dp"
180194
android:layout_width="match_parent"
181195
android:layout_height="wrap_content"
182196
app:title="@string/title_party_ambitions"

app/src/main/res/layout/fragment_character_stats.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
app:constraint_referenced_ids="woundsCard,pointsContainer,statsCard"
2929
app:flow_maxElementsWrap="1"
3030
app:flow_verticalBias="0"
31-
app:flow_verticalGap="48dp"
31+
app:flow_verticalGap="40dp"
3232
app:flow_wrapMode="aligned"
3333
app:layout_constraintEnd_toEndOf="parent"
3434
app:layout_constraintStart_toStartOf="parent"
@@ -81,7 +81,7 @@
8181
android:layout_width="match_parent"
8282
android:layout_height="wrap_content"
8383
app:constraint_referenced_ids="fateCard,pointsCard"
84-
app:flow_horizontalGap="16dp" />
84+
app:flow_horizontalGap="10dp" />
8585

8686
<androidx.cardview.widget.CardView
8787
android:id="@+id/fateCard"

app/src/main/res/layout/fragment_game_master.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
android:layout_width="match_parent"
1212
android:layout_height="wrap_content"
1313
android:orientation="vertical"
14+
android:clipToPadding="false"
1415
android:paddingBottom="@dimen/long_ui_bottom_padding">
1516

1617
<androidx.cardview.widget.CardView
@@ -74,7 +75,6 @@
7475
android:clickable="true"
7576
android:focusable="true"
7677
android:foreground="?attr/selectableItemBackground"
77-
android:layout_marginTop="20dp"
7878
app:title="@string/title_party_ambitions" />
7979
</LinearLayout>
8080
</ScrollView>

app/src/main/res/layout/fragment_inventory.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
tools:context=".ui.character.InventoryFragment">
99

1010
<LinearLayout
11+
android:clipToPadding="false"
1112
android:orientation="vertical"
1213
android:paddingBottom="@dimen/long_ui_bottom_padding"
1314
android:layout_width="match_parent"

0 commit comments

Comments
 (0)