Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge for Saving Throws and Money #6

Merged
merged 18 commits into from
Apr 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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