Skip to content

Commit

Permalink
Handle cabbage/radish and water/milk
Browse files Browse the repository at this point in the history
closes #49
  • Loading branch information
joshfriend committed Sep 26, 2018
1 parent 0f436f8 commit 51fd8b4
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 22 deletions.
@@ -1,5 +1,6 @@
package com.fueledbycaffeine.bunnypedia.database.model

import androidx.room.Embedded
import androidx.room.Entity
import androidx.room.PrimaryKey

Expand All @@ -20,10 +21,11 @@ data class Card(
val symbols: List<Symbol>,
val pawn: Pawn?,
val weaponLevel: String?,
val cabbage: Int,
val water: Int,
val psi: Psi?,
val specialSeries: SpecialSeries?
val specialSeries: SpecialSeries?,

@Embedded
val ftb: FeedTheBunny
) {
companion object {
const val FTB_RANDOM = -1
Expand All @@ -34,6 +36,4 @@ data class Card(
// var rules: List<Rule> = emptyList()

val imageURI: String get() = "file:///android_asset/card_thumbnails/${String.format("%04d.jpg", canonicalId ?: id)}"

val isFtb: Boolean get() = cabbage != 0 && water != 0
}
@@ -0,0 +1,19 @@
package com.fueledbycaffeine.bunnypedia.database.model

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize

@Parcelize
data class FeedTheBunny(
val cabbage: Int,
val radish: Int,
val water: Int,
val milk: Int
): Parcelable {
val applicable get() = cabbage != 0 || radish != 0 || water != 0 || milk != 0

val cabbageAndWater get() = cabbage > 0 && water > 0
val radishAndMilk get() = radish > 0 && milk > 0
val cabbageOrRadish get() = cabbage > 0 && radish > 0
val waterOrMilk get() = water > 0 && milk > 0
}
Expand Up @@ -169,8 +169,8 @@ class CardDetailFragment: DaggerFragment() {
requiresBunny.text = getString(card.bunnyRequirement.description)
}

if (card.isFtb) {
setupFtbInfo(card.cabbage, card.water)
if (card.ftb.applicable) {
setupFtbInfo(card.ftb)
}

if (card.rank != null) {
Expand Down Expand Up @@ -217,15 +217,22 @@ class CardDetailFragment: DaggerFragment() {
pawnName.text = getString(pawn.pawnName)
}

private fun setupFtbInfo(cabbage: Int, water: Int) {
private fun setupFtbInfo(ftb: FeedTheBunny) {
val (cabbage, radish, water, milk) = ftb
containerFtb.visibility = View.VISIBLE
if (cabbage > 0 && water > 0) {
if (ftb.cabbageAndWater) {
ftbRequirement.text = getString(R.string.ftb_cabbage_water, cabbage, water)
} else if (ftb.radishAndMilk) {
ftbRequirement.text = getString(R.string.ftb_radish_milk, radish, milk)
} else if (ftb.cabbageOrRadish) {
ftbRequirement.text = getString(R.string.ftb_cabbage_radish, cabbage)
} else if (ftb.waterOrMilk) {
ftbRequirement.text = getString(R.string.ftb_water_milk, water)
} else if (cabbage > 0) {
ftbRequirement.text = getString(R.string.ftb_cabbage, cabbage)
} else if (water > 0) {
ftbRequirement.text = getString(R.string.ftb_water, water)
} else if (cabbage == Card.FTB_RANDOM) {
} else if (cabbage == Card.FTB_RANDOM || radish == Card.FTB_RANDOM) {
ftbRequirement.text = getString(R.string.ftb_random)
} else if (cabbage == Card.FTB_DATED) {
ftbRequirement.text = getString(R.string.ftb_dated_cabbage)
Expand Down
5 changes: 4 additions & 1 deletion bunnies/src/main/res/values/strings.xml
Expand Up @@ -37,8 +37,11 @@
<string name="deck_creature_feature_booster">Creature Feature Booster</string>
<string name="card_type_kaballa_dolla">Kaballa Dolla</string>
<string name="card_type_rank">Rank</string>
<string name="section_ftb_requirements">Cabbage/Water Required</string>
<string name="section_ftb_requirements">Food Units Required</string>
<string name="ftb_cabbage_water" tool:ignore="PluralsCandidate">%1$d Cabbage &amp; %2$d Water</string>
<string name="ftb_radish_milk" tool:ignore="PluralsCandidate">%1$d Radish &amp; %2$d Milk</string>
<string name="ftb_cabbage_radish" tool:ignore="PluralsCandidate">%1$d Cabbage or %1$d Radish</string>
<string name="ftb_water_milk" tool:ignore="PluralsCandidate">%1$d Water or %1$d Milk</string>
<string name="ftb_cabbage" tool:ignore="PluralsCandidate">%1$d Cabbage</string>
<string name="ftb_water" tool:ignore="PluralsCandidate">%1$d Water</string>
<string name="ftb_random">Roll for amounts</string>
Expand Down
9 changes: 6 additions & 3 deletions database/dbseed.py
Expand Up @@ -15,7 +15,8 @@ class Card:
title TEXT NOT NULL, deck TEXT NOT NULL, type TEXT NOT NULL, rank TEXT,
zodiacType TEXT, zodiacAnimal TEXT, bunnyRequirement TEXT NOT NULL, dice TEXT NOT NULL,
symbols TEXT NOT NULL, pawn TEXT, weaponLevel TEXT,
cabbage INTEGER NOT NULL, water INTEGER NOT NULL, psi TEXT,
cabbage INTEGER NOT NULL, radish INTEGER NOT NULL,
water INTEGER NOT NULL, milk INTEGER NOT NULL, psi TEXT,
specialSeries TEXT
);
""",
Expand All @@ -24,11 +25,11 @@ class Card:
INSERT_STMT = """
INSERT INTO Card (
id, canonicalId, title, deck, type, rank, zodiacType, zodiacAnimal, bunnyRequirement,
dice, symbols, pawn, weaponLevel, cabbage, water, psi, specialSeries
dice, symbols, pawn, weaponLevel, cabbage, radish, water, milk, psi, specialSeries
) VALUES (
:id, :canonicalId, :title, :deck, :type, :rank, :zodiacType,
:zodiacAnimal, :bunnyRequirement, :dice, :symbols, :pawn, :weaponLevel,
:cabbage, :water, :psi, :specialSeries
:cabbage, :radish, :water, :milk, :psi, :specialSeries
);
"""

Expand All @@ -55,7 +56,9 @@ def __init__(self, **kwargs):
self.pawn = kwargs.get('pawn')
self.weaponLevel = kwargs.get('weaponLevel')
self.cabbage = kwargs.get('cabbage', 0)
self.radish = kwargs.get('radish', 0)
self.water = kwargs.get('water', 0)
self.milk = kwargs.get('milk', 0)
self.psi = kwargs.get('psi')
self.specialSeries = kwargs.get('specialSeries')

Expand Down
4 changes: 2 additions & 2 deletions database/deck_caramel_swirl.json
Expand Up @@ -78,7 +78,7 @@
"type": "RUN",
"bunnyRequirement": "PLAY",
"cabbage": 2,
"water": 0,
"radish": 2,
"rules": [
{"title": "Card Text", "text": "May be placed on any bunny which must feed the amounts shown by the end of its next turn or die."}
]
Expand All @@ -89,7 +89,7 @@
"deck": "CARAMEL_SWIRL",
"type": "RUN",
"bunnyRequirement": "PLAY",
"cabbage": 0,
"milk": 1,
"water": 1,
"rules": [
{"title": "Card Text", "text": "May be placed on any bunny which must feed the amounts shown by the end of its next turn or die."}
Expand Down
8 changes: 4 additions & 4 deletions database/deck_creature_feature.json
Expand Up @@ -95,24 +95,24 @@
},
{
"id": "1165",
"title": "Feed The Bunny",
"title": "Feed The Bunny 3/0",
"type": "RUN",
"bunnyRequirement": "PLAY",
"deck": "CREATURE_FEATURE",
"water": 0,
"cabbage": 3,
"radish": 3,
"rules": [
{"title": "Card Text", "text": "May be placed on any bunny which must feed the amounts shown by the end of its next turn or die."}
]
},
{
"id": "1166",
"title": "Feed The Bunny",
"title": "Feed The Bunny 0/3",
"type": "RUN",
"bunnyRequirement": "PLAY",
"deck": "CREATURE_FEATURE",
"water": 3,
"cabbage": 0,
"milk": 3,
"rules": [
{"title": "Card Text", "text": "May be placed on any bunny which must feed the amounts shown by the end of its next turn or die."}
]
Expand Down
6 changes: 4 additions & 2 deletions database/deck_fantastic.json
Expand Up @@ -393,22 +393,24 @@
},
{
"id": 1080,
"title": "Feed The Bunny - 1 Cabbage Or Radish",
"title": "Feed The Bunny 1/0",
"deck": "FANTASTIC",
"type": "RUN",
"bunnyRequirement": "PLAY",
"cabbage": 1,
"radish": 1,
"rules": [
{"title": "Card Text", "text": "May be placed on any bunny which must feed the amounts shown by the end of its next turn or die."}
]
},
{
"id": 1081,
"title": "Feed The Bunny - 2 Water or Milk",
"title": "Feed The Bunny 0/2",
"deck": "FANTASTIC",
"type": "RUN",
"bunnyRequirement": "PLAY",
"water": 2,
"milk": 2,
"rules": [
{"title": "Card Text", "text": "May be placed on any bunny which must feed the amounts shown by the end of its next turn or die."}
]
Expand Down

0 comments on commit 51fd8b4

Please sign in to comment.