Adds ability scores to monster card.
This commit is contained in:
@@ -432,4 +432,28 @@ public class Monster {
|
||||
}
|
||||
}
|
||||
|
||||
public String getStrengthDescription() {
|
||||
return String.format(Locale.US, "%d (%+d)", getStrengthScore(), getStrengthModifier());
|
||||
}
|
||||
|
||||
public String getDexterityDescription() {
|
||||
return String.format(Locale.US, "%d (%+d)", getDexterityScore(), getDexterityModifier());
|
||||
}
|
||||
|
||||
public String getConstitutionDescription() {
|
||||
return String.format(Locale.US, "%d (%+d)", getConstitutionScore(), getConstitutionModifier());
|
||||
}
|
||||
|
||||
public String getIntelligenceDescription() {
|
||||
return String.format(Locale.US, "%d (%+d)", getIntelligenceScore(), getIntelligenceModifier());
|
||||
}
|
||||
|
||||
public String getWisdomDescription() {
|
||||
return String.format(Locale.US, "%d (%+d)", getWisdomScore(), getWisdomModifier());
|
||||
}
|
||||
|
||||
public String getCharismaDescription() {
|
||||
return String.format(Locale.US, "%d (%+d)", getCharismaScore(), getCharismaModifier());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,13 @@ public class MonsterFragment extends Fragment {
|
||||
monster.setSwimSpeed("0");
|
||||
monster.setCustomSpeed(false);
|
||||
monster.setSpeedDescription("30 ft., swim 30 ft.");
|
||||
// Ability Scores
|
||||
monster.setStrengthScore(Integer.parseInt("2"));
|
||||
monster.setDexterityScore(Integer.parseInt("20"));
|
||||
monster.setConstitutionScore(Integer.parseInt("8"));
|
||||
monster.setIntelligenceScore(Integer.parseInt("10"));
|
||||
monster.setWisdomScore(Integer.parseInt("14"));
|
||||
monster.setCharismaScore(Integer.parseInt("15"));
|
||||
|
||||
// END remove block
|
||||
monsterViewModel = new ViewModelProvider(this).get(MonsterViewModel.class);
|
||||
@@ -96,6 +103,54 @@ public class MonsterFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
final TextView monsterStrength = root.findViewById(R.id.strength);
|
||||
monsterViewModel.getStrength().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(String strength) {
|
||||
monsterStrength.setText(strength);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView monsterDexterity = root.findViewById(R.id.dexterity);
|
||||
monsterViewModel.getDexterity().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(String dexterity) {
|
||||
monsterDexterity.setText(dexterity);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView monsterConstitution = root.findViewById(R.id.constitution);
|
||||
monsterViewModel.getConstitution().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(String constitution) {
|
||||
monsterConstitution.setText(constitution);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView monsterIntelligence = root.findViewById(R.id.intelligence);
|
||||
monsterViewModel.getIntelligence().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(String intelligence) {
|
||||
monsterIntelligence.setText(intelligence);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView monsterWisdom = root.findViewById(R.id.wisdom);
|
||||
monsterViewModel.getWisdom().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(String wisdom) {
|
||||
monsterWisdom.setText(wisdom);
|
||||
}
|
||||
});
|
||||
|
||||
final TextView monsterCharisma = root.findViewById(R.id.charisma);
|
||||
monsterViewModel.getCharisma().observe(getViewLifecycleOwner(), new Observer<String>() {
|
||||
@Override
|
||||
public void onChanged(String charisma) {
|
||||
monsterCharisma.setText(charisma);
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,18 @@ public class MonsterViewModel extends ViewModel {
|
||||
mHitPoints.setValue("");
|
||||
mSpeed = new MutableLiveData<>();
|
||||
mSpeed.setValue("");
|
||||
mStrength = new MutableLiveData<>();
|
||||
mStrength.setValue("");
|
||||
mDexterity = new MutableLiveData<>();
|
||||
mDexterity.setValue("");
|
||||
mConstitution = new MutableLiveData<>();
|
||||
mConstitution.setValue("");
|
||||
mIntelligence = new MutableLiveData<>();
|
||||
mIntelligence.setValue("");
|
||||
mWisdom = new MutableLiveData<>();
|
||||
mWisdom.setValue("");
|
||||
mCharisma = new MutableLiveData<>();
|
||||
mCharisma.setValue("");
|
||||
}
|
||||
|
||||
private MutableLiveData<String> mName;
|
||||
@@ -42,6 +54,30 @@ public class MonsterViewModel extends ViewModel {
|
||||
public LiveData<String> getSpeed() {
|
||||
return mSpeed;
|
||||
}
|
||||
private MutableLiveData<String> mStrength;
|
||||
public LiveData<String> getStrength() {
|
||||
return mStrength;
|
||||
}
|
||||
private MutableLiveData<String> mDexterity;
|
||||
public LiveData<String> getDexterity() {
|
||||
return mDexterity;
|
||||
}
|
||||
private MutableLiveData<String> mConstitution;
|
||||
public LiveData<String> getConstitution() {
|
||||
return mConstitution;
|
||||
}
|
||||
private MutableLiveData<String> mIntelligence;
|
||||
public LiveData<String> getIntelligence() {
|
||||
return mIntelligence;
|
||||
}
|
||||
private MutableLiveData<String> mWisdom;
|
||||
public LiveData<String> getWisdom() {
|
||||
return mWisdom;
|
||||
}
|
||||
private MutableLiveData<String> mCharisma;
|
||||
public LiveData<String> getCharisma() {
|
||||
return mCharisma;
|
||||
}
|
||||
|
||||
private Monster mMonster;
|
||||
public void setMonster(Monster monster) {
|
||||
@@ -51,5 +87,11 @@ public class MonsterViewModel extends ViewModel {
|
||||
mArmorClass.setValue(mMonster.getArmorClass());
|
||||
mHitPoints.setValue(mMonster.getHitPoints());
|
||||
mSpeed.setValue(mMonster.getSpeedText());
|
||||
mStrength.setValue(monster.getStrengthDescription());
|
||||
mDexterity.setValue(monster.getDexterityDescription());
|
||||
mConstitution.setValue(monster.getConstitutionDescription());
|
||||
mIntelligence.setValue(monster.getIntelligenceDescription());
|
||||
mWisdom.setValue(monster.getWisdomDescription());
|
||||
mCharisma.setValue(monster.getCharismaDescription());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user