Adds hit points to monster card.

This commit is contained in:
2020-09-01 20:55:58 -07:00
committed by Tom Hicks
parent 5fca394f0e
commit 212358e41d
5 changed files with 89 additions and 1 deletions

View File

@@ -38,6 +38,11 @@ public class MonsterFragment extends Fragment {
monster.setShieldBonus(0);
monster.setNaturalArmorBonus(7);
monster.setOtherArmorDescription("14");
// Hit Points
monster.setHitDice(1);
monster.setCustomHP(false);
monster.setHPText("11 (2d8 + 2)");
// END remove block
monsterViewModel = new ViewModelProvider(this).get(MonsterViewModel.class);
View root = inflater.inflate(R.layout.fragment_monster, container, false);
@@ -67,6 +72,14 @@ public class MonsterFragment extends Fragment {
}
});
final TextView monsterHitPoints = root.findViewById(R.id.hit_points);
monsterViewModel.getHitPoints().observe(getViewLifecycleOwner(), new Observer<String>() {
@Override
public void onChanged(String hitPoints) {
monsterHitPoints.setText(Html.fromHtml("<b>Hit Points</b> " + hitPoints));
}
});
return root;
}
}

View File

@@ -16,7 +16,8 @@ public class MonsterViewModel extends ViewModel {
mMeta.setValue("");
mArmorClass = new MutableLiveData<>();
mArmorClass.setValue("");
mHitPoints = new MutableLiveData<>();
mHitPoints.setValue("");
}
private MutableLiveData<String> mName;
@@ -31,6 +32,10 @@ public class MonsterViewModel extends ViewModel {
public LiveData<String> getArmorClass() {
return mArmorClass;
}
private MutableLiveData<String> mHitPoints;
public LiveData<String> getHitPoints() {
return mHitPoints;
}
private Monster mMonster;
public void setMonster(Monster monster) {
@@ -38,5 +43,6 @@ public class MonsterViewModel extends ViewModel {
mName.setValue(mMonster.getName());
mMeta.setValue(mMonster.getMeta());
mArmorClass.setValue(mMonster.getArmorClass());
mHitPoints.setValue(mMonster.getHitPoints());
}
}