Adds senses to monster cards.
This commit is contained in:
		| @@ -690,4 +690,84 @@ public class Monster { | |||||||
|         return StringHelper.oxfordJoin(", ", ", and ", " and ", immunities); |         return StringHelper.oxfordJoin(", ", ", and ", " and ", immunities); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     private String mBlindsight; | ||||||
|  |     public String getBlindsight() { | ||||||
|  |         return mBlindsight; | ||||||
|  |     } | ||||||
|  |     public void setBlindsight(String value) { | ||||||
|  |         mBlindsight = value; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private boolean mIsBlind; | ||||||
|  |     public boolean getIsBlind() { | ||||||
|  |         return mIsBlind; | ||||||
|  |     } | ||||||
|  |     public void setIsBlind(boolean value) { | ||||||
|  |         mIsBlind = value; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private String mDarkvision; | ||||||
|  |     public String getDarkvision() { | ||||||
|  |         return mDarkvision; | ||||||
|  |     } | ||||||
|  |     public void setDarkvision(String value) { | ||||||
|  |         mDarkvision = value; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private String mTremorsense; | ||||||
|  |     public String getTremorsense() { | ||||||
|  |         return mTremorsense; | ||||||
|  |     } | ||||||
|  |     public void setTremorsense(String value) { | ||||||
|  |         mTremorsense = value; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private String mTruesight; | ||||||
|  |     public String getTruesight() { | ||||||
|  |         return mTruesight; | ||||||
|  |     } | ||||||
|  |     public void setTruesight(String value) { | ||||||
|  |         mTruesight = value; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private int mTelepathy; | ||||||
|  |     public int getTelepathy() { | ||||||
|  |         return mTelepathy; | ||||||
|  |     } | ||||||
|  |     public void setTelepathy(int value) { | ||||||
|  |         mTelepathy = value; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private String mUnderstandsBut; | ||||||
|  |     public String getUnderstandsBut() { | ||||||
|  |         return mUnderstandsBut; | ||||||
|  |     } | ||||||
|  |     public void setUnderstandsBut(String value) { | ||||||
|  |         mUnderstandsBut = value; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public String getSensesDescription() { | ||||||
|  |         ArrayList<String> parts = new ArrayList<>(); | ||||||
|  |  | ||||||
|  |         String blindsight = getBlindsight(); | ||||||
|  |         if (!StringHelper.isNullOrEmpty(blindsight) && !"0".equals(blindsight)) { | ||||||
|  |             parts.add(String.format(Locale.US, "blindsight %s ft.%s", blindsight, getIsBlind() ? " (blind beyond this radius)" : "")); | ||||||
|  |         } | ||||||
|  |         String darkvision = getDarkvision(); | ||||||
|  |         if (!StringHelper.isNullOrEmpty(darkvision) && !"0".equals(darkvision)) { | ||||||
|  |             parts.add(String.format(Locale.US, "darkvision %s ft.", darkvision)); | ||||||
|  |         } | ||||||
|  |         String tremorsense = getTremorsense(); | ||||||
|  |         if (!StringHelper.isNullOrEmpty(tremorsense) && !"0".equals(tremorsense)) { | ||||||
|  |             parts.add(String.format(Locale.US, "tremorsense %s ft.", tremorsense)); | ||||||
|  |         } | ||||||
|  |         String truesight = getTruesight(); | ||||||
|  |         if (!StringHelper.isNullOrEmpty(truesight) && !"0".equals(truesight)) { | ||||||
|  |             parts.add(String.format(Locale.US, "truesight %s ft.", truesight)); | ||||||
|  |         } | ||||||
|  |         parts.add(String.format(Locale.US, "passive Perception %d", 10 + getWisdomModifier())); | ||||||
|  |  | ||||||
|  |         return StringHelper.join(", ", parts); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -83,6 +83,14 @@ public class MonsterFragment extends Fragment { | |||||||
|         monster.addDamageType(new DamageType("poison", " (Immune)", "i")); |         monster.addDamageType(new DamageType("poison", " (Immune)", "i")); | ||||||
|         // Condition Immunities |         // Condition Immunities | ||||||
|         monster.addConditionImmunity("blinded"); |         monster.addConditionImmunity("blinded"); | ||||||
|  |         // Senses | ||||||
|  |         monster.setBlindsight("10"); | ||||||
|  |         monster.setIsBlind(true); | ||||||
|  |         monster.setDarkvision("20"); | ||||||
|  |         monster.setTremorsense("30"); | ||||||
|  |         monster.setTruesight("40"); | ||||||
|  |         monster.setTelepathy(20); | ||||||
|  |         monster.setUnderstandsBut("doesn't care"); | ||||||
|  |  | ||||||
|         // Challenge Rating |         // Challenge Rating | ||||||
|         monster.setChallengeRating("*"); |         monster.setChallengeRating("*"); | ||||||
| @@ -259,6 +267,20 @@ public class MonsterFragment extends Fragment { | |||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |         final TextView monsterSenses = root.findViewById(R.id.senses); | ||||||
|  |         monsterViewModel.getSenses().observe(getViewLifecycleOwner(), new Observer<String>() { | ||||||
|  |             @Override | ||||||
|  |             public void onChanged(String senses) { | ||||||
|  |             if (StringHelper.isNullOrEmpty(senses)) { | ||||||
|  |                 monsterSenses.setVisibility(View.GONE); | ||||||
|  |             } else { | ||||||
|  |                 monsterSenses.setVisibility(View.VISIBLE); | ||||||
|  |             } | ||||||
|  |             monsterSenses.setText(Html.fromHtml("<b>Senses</b> " + senses)); | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |  | ||||||
|         return root; |         return root; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -44,6 +44,8 @@ public class MonsterViewModel extends ViewModel { | |||||||
|         mDamageImmunities.setValue(""); |         mDamageImmunities.setValue(""); | ||||||
|         mConditionImmunities = new MutableLiveData<>(); |         mConditionImmunities = new MutableLiveData<>(); | ||||||
|         mConditionImmunities.setValue(""); |         mConditionImmunities.setValue(""); | ||||||
|  |         mSenses = new MutableLiveData<>(); | ||||||
|  |         mSenses.setValue(""); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private MutableLiveData<String> mName; |     private MutableLiveData<String> mName; | ||||||
| @@ -114,6 +116,10 @@ public class MonsterViewModel extends ViewModel { | |||||||
|     public LiveData<String> getConditionImmunities() { |     public LiveData<String> getConditionImmunities() { | ||||||
|         return mConditionImmunities; |         return mConditionImmunities; | ||||||
|     } |     } | ||||||
|  |     private MutableLiveData<String> mSenses; | ||||||
|  |     public LiveData<String> getSenses() { | ||||||
|  |         return mSenses; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     private Monster mMonster; |     private Monster mMonster; | ||||||
|     public void setMonster(Monster monster) { |     public void setMonster(Monster monster) { | ||||||
| @@ -135,5 +141,6 @@ public class MonsterViewModel extends ViewModel { | |||||||
|         mDamageResistances.setValue(mMonster.getDamageResistancesDescription()); |         mDamageResistances.setValue(mMonster.getDamageResistancesDescription()); | ||||||
|         mDamageImmunities.setValue(mMonster.getDamageImmunitiesDescription()); |         mDamageImmunities.setValue(mMonster.getDamageImmunitiesDescription()); | ||||||
|         mConditionImmunities.setValue(mMonster.getConditionImmunitiesDescription()); |         mConditionImmunities.setValue(mMonster.getConditionImmunitiesDescription()); | ||||||
|  |         mSenses.setValue(monster.getSensesDescription()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -383,5 +383,18 @@ | |||||||
|             app:layout_constraintTop_toBottomOf="@+id/damage_immunities" |             app:layout_constraintTop_toBottomOf="@+id/damage_immunities" | ||||||
|             tools:text="Condition Immunities" /> |             tools:text="Condition Immunities" /> | ||||||
|  |  | ||||||
|  |         <TextView | ||||||
|  |             android:id="@+id/senses" | ||||||
|  |             android:layout_width="0dp" | ||||||
|  |             android:layout_height="wrap_content" | ||||||
|  |             android:layout_marginStart="8dp" | ||||||
|  |             android:layout_marginTop="8dp" | ||||||
|  |             android:layout_marginEnd="8dp" | ||||||
|  |             android:layout_marginBottom="8dp" | ||||||
|  |             app:layout_constraintEnd_toEndOf="parent" | ||||||
|  |             app:layout_constraintStart_toStartOf="parent" | ||||||
|  |             app:layout_constraintTop_toBottomOf="@+id/condition_immunities" | ||||||
|  |             tools:text="Senses" /> | ||||||
|  |  | ||||||
|     </androidx.constraintlayout.widget.ConstraintLayout> |     </androidx.constraintlayout.widget.ConstraintLayout> | ||||||
| </ScrollView> | </ScrollView> | ||||||
		Reference in New Issue
	
	Block a user