Skip to content

Commit

Permalink
Merge for Saving Throws and Money (#6)
Browse files Browse the repository at this point in the history
* Started to add the character class into the Game.

* + Added references in game_references.xml for
    - Genders
    - Classes
    - Levels
+ Finalized Warrior Type Classes along with Base Classes
+ Created Barbarian Class
+ Created Util Class to provide helper functions and values
+ Removed CharClass
+ Renamed Core to Score to better explain usage.

* Actually pushed the files

* Started to add the character class into the Game.

* + Added references in game_references.xml for
    - Genders
    - Classes
    - Levels
+ Finalized Warrior Type Classes along with Base Classes
+ Created Barbarian Class
+ Created Util Class to provide helper functions and values
+ Removed CharClass
+ Renamed Core to Score to better explain usage.

* Actually pushed the files

* + Changed the code to use AttributeScores rather than just raw Integers.
+ Created a basic form of Amazon
+ Swapped the ResId in Barbarian for the ResId defined in the Enum.

* + Added Money enum
+ Added Money property to Character
+ Improved the functionality of Barbarian
    - Added LevelUp
    - Added LevelDown
    - Added property to track user choices of leveling up
+ Added Money strings to game_references.xml

+ Created Magician abstract class
+ Created mEffectiveLevel property in base class to ease the burden of leveling up and down.

* + Changed Character class to PlayerCharacter

* + Changed getCoreStatScore to getScore

* + Modified LevelUp and LevelDown to restore the proper scores rather than calculated scores.
---WARNING---
Changes made in a sleepy state, they may not be implemented properly or effectively.

* Removed the EffectiveLevel property from BaseClass
Removed the updateLevel method
Added an example of getting modifier to CharacterSheet

* + Added methods for saving throws in PlayerCharacter.java
    +getAthleticProwess
    +getDangerEvasion
    +getMysticFortitude
    +getPhysicalVigor
    +getCharisma
  • Loading branch information
Justin Smith authored and Thorin Schmidt committed Apr 16, 2017
1 parent e715e18 commit 265a7a8
Show file tree
Hide file tree
Showing 8 changed files with 358 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.example.cis.mazeminotaurs.character;

import com.example.cis.mazeminotaurs.R;

/**
* Created by jusmith on 4/5/17.
*/

public enum Money {
COPPER(R.string.copper),
SILVER(R.string.silver),
GOLD(R.string.gold);

private int resId;

Money(int resId) {
setResId(resId);
}

public int getResId() {
return resId;
}

public void setResId(int resId) {
this.resId = resId;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.example.cis.mazeminotaurs.character;

import android.util.Log;

import com.example.cis.mazeminotaurs.Armor;
import com.example.cis.mazeminotaurs.AttributeScore;
import com.example.cis.mazeminotaurs.AttributeScoreGenerator;
import com.example.cis.mazeminotaurs.R;
import com.example.cis.mazeminotaurs.character.classes.Amazon;
import com.example.cis.mazeminotaurs.character.classes.Barbarian;
import com.example.cis.mazeminotaurs.character.classes.BaseClass;
import com.example.cis.mazeminotaurs.character.stats.Score;
Expand All @@ -17,48 +16,51 @@
*/

public class PlayerCharacter {
private final String TAG = "PlayerCharacter Class";

private HashMap<Score, AttributeScore> mCoreStats = new HashMap<>();
private HashMap<Score, AttributeScore> mScores = new HashMap<>();
private BaseClass mCharClass;
private Gender mGender;
private HashMap<Money, Integer> mMoney = new HashMap<>();
private int mAge;
private String mName;
private Armor mHelmet;
private Armor mBreastplate;
private Armor mShield;

public PlayerCharacter() {
Log.i(TAG, "Creating PlayerCharacter");
initalizeMoneyMap();

setAge(0);
setCharClass(new Barbarian(this, R.string.barb_axe, R.string.bow));
setName("Thorin");


getMoney().put(Money.SILVER, getCharClass().getStartGold());

AttributeScore[] scores = new AttributeScoreGenerator().nextValidSet();
for (int i = 0; i < scores.length; i++) {
mCoreStats.put(Score.values()[i], scores[i]);
mScores.put(Score.values()[i], scores[i]);
}
}

public int getMeleeMod() {
return getCoreStatScore(Score.MIGHT).getModifier() +
getCoreStatScore(Score.GRACE).getModifier() +
getCoreStatScore(Score.LUCK).getModifier();
return getScore(Score.MIGHT).getModifier() +
getScore(Score.GRACE).getModifier() +
getScore(Score.LUCK).getModifier();
}

public int getMissleMod() {
return getCoreStatScore(Score.SKILL).getModifier() +
getCoreStatScore(Score.WITS).getModifier() +
getCoreStatScore(Score.LUCK).getModifier();
return getScore(Score.SKILL).getModifier() +
getScore(Score.WITS).getModifier() +
getScore(Score.LUCK).getModifier();
}

public int getInititive() {
return 10 + getCoreStatScore(Score.SKILL).getModifier() +
getCoreStatScore(Score.WITS).getModifier();
return 10 + getScore(Score.SKILL).getModifier() +
getScore(Score.WITS).getModifier();
}

public int getDC() {
return 12 + getCoreStatScore(Score.LUCK).getModifier();
return 12 + getScore(Score.LUCK).getModifier();
}

public int getEDC() {
Expand All @@ -76,27 +78,143 @@ public int getEDC() {
return getDC() + armorBonus;
}

public int getHitTotal(){
public int getHitTotal() {
//return mCharClass.getHits() + getMod(Score.MIGHT);
return 0;
}

public int getCharisma(){
return getCoreStatScore(Score.WILL).getModifier() +
getCoreStatScore(Score.GRACE).getModifier() +
getCoreStatScore(Score.LUCK).getModifier();
public int getAthleticProwess(){
return getScore(Score.MIGHT).getModifier() +
getScore(Score.SKILL).getModifier() +
getScore(Score.LUCK).getModifier();
}

public int getDangerEvasion(){
return getScore(Score.WITS).getModifier() +
getScore(Score.SKILL).getModifier() +
getScore(Score.LUCK).getModifier();
}

public int getMysticForitude(){
return getScore(Score.WITS).getModifier() +
getScore(Score.WILL).getModifier() +
getScore(Score.LUCK).getModifier();
}

public int getPhysicalVigor(){
return getScore(Score.MIGHT).getModifier() +
getScore(Score.WILL).getModifier() +
getScore(Score.LUCK).getModifier();
}

public int getCharisma() {
return getScore(Score.WILL).getModifier() +
getScore(Score.GRACE).getModifier() +
getScore(Score.LUCK).getModifier();
}

public Gender getGender() {
return mGender;
}

public void setGender(Gender gender) {
mGender = gender;
}

public void addMoney(Money money, int amount) {
getMoney().put(money, getMoney().get(money) + amount);
validateMoney();
}

public HashMap<Money, Integer> getMoney() {
return mMoney;
}

public void setMoney(HashMap<Money, Integer> money) {
mMoney = money;
}

private void initalizeMoneyMap() {
mMoney.put(Money.COPPER, 0);
mMoney.put(Money.SILVER, 0);
mMoney.put(Money.GOLD, 0);
}

public void validateMoney() {
HashMap<Money, Integer> cash = getMoney();

int tradedUpSilver = cash.get(Money.COPPER) / 100;
int tradedUpGold = cash.get(Money.SILVER) / 100;

cash.put(Money.COPPER, cash.get(Money.COPPER) % 100);
cash.put(Money.SILVER, (cash.get(Money.SILVER) % 100) + tradedUpSilver);
cash.put(Money.GOLD, cash.get(Money.GOLD) + tradedUpGold);
}

public Armor getHelmet() {
return mHelmet;
}

public void setHelmet(Armor helmet) {
mHelmet = helmet;
}

public Armor getBreastplate() {
return mBreastplate;
}

public void setBreastplate(Armor breastplate) {
mBreastplate = breastplate;
}

public Armor getShield() {
return mShield;
}

public void setShield(Armor shield) {
mShield = shield;
}

public AttributeScore getCoreStatScore(Score scoreStat) {
return mCoreStats.get(scoreStat);
public boolean canAddToScore(Score score) {
boolean isPrimary = getCharClass().getPrimaryAttributes().contains(score);
int scoreValue = getScore(score).getScore();

if (isPrimary) {
return scoreValue < 21;
} else {
return scoreValue < 20;
}
}

public HashMap<Score, AttributeScore> getCoreStats() {
return mCoreStats;
public void validateScores() {
for (Score score: Score.values()) {
boolean isPrimary = getCharClass().getPrimaryAttributes().contains(score);
int scoreValue = getScore(score).getScore();

if (isPrimary && scoreValue > 21) {
getScore(score).setScore(21);
} else if (!isPrimary && scoreValue > 20) {
getScore(score).setScore(20);
}
}
}

public void setCoreStats(HashMap<Score, AttributeScore> coreStats) {
mCoreStats = coreStats;
protected void debugPrintScores() {
for (Score score : getScores().keySet()) {
System.out.println(score.toString() + ":" + String.valueOf(getScore(score).getScore()));
}
}

public AttributeScore getScore(Score scoreStat) {
return mScores.get(scoreStat);
}

public HashMap<Score, AttributeScore> getScores() {
return mScores;
}

public void setScores(HashMap<Score, AttributeScore> scores) {
mScores = scores;
}

public BaseClass getCharClass() {
Expand All @@ -122,4 +240,5 @@ public String getName() {
public void setName(String name) {
mName = name;
}

}
Original file line number Diff line number Diff line change
@@ -1,41 +1,8 @@
package com.example.cis.mazeminotaurs.character.classes;

import com.example.cis.mazeminotaurs.R;
import com.example.cis.mazeminotaurs.character.PlayerCharacter;
import com.example.cis.mazeminotaurs.character.Gender;
import com.example.cis.mazeminotaurs.character.stats.Score;
import com.example.cis.mazeminotaurs.util.Util;

/**
* Created by jusmith on 4/4/17.
* Created by jusmith on 4/13/17.
*/

public class Amazon extends Warrior{
public Amazon(PlayerCharacter playerCharacter) {
Score[] primAttributes = {Score.SKILL, Score.GRACE};

int rolledGold = 0;
for (int i = 0; i < 3; i++) {
rolledGold += Util.roll(6);
}

setAddedHits(0);
setBasicHits(12);
setPlayerCharacter(playerCharacter);
setExperience(0);
setLevel(1);
setPrimaryAttributes(primAttributes);
setRequiredGender(Gender.FEMALE);
setResId(Classes.AMAZON.getResId());
setStartGold(rolledGold);
setWeaponOfChoice(R.string.bow);
}

public int getDeadlyShotBonus(){
return getPlayerCharacter().getCoreStatScore(Score.SKILL).getModifier();
}

public int getBattleGraceBonus(){
return getPlayerCharacter().getCoreStatScore(Score.GRACE).getModifier();
}
public class Amazon extends Warrior implements Level {
}
Loading

0 comments on commit 265a7a8

Please sign in to comment.