Adds hit points to monster card.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user