From 812c53d063fa1250e33654b53b21c654ac2041d5 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Thu, 30 Mar 2017 13:39:44 -0500 Subject: [PATCH 01/18] Started to add the character class into the Game. --- .idea/workspace.xml | 45 ++++++---- MazesAndMinotaurs/.idea/encodings.xml | 6 -- MazesAndMinotaurs/.idea/vcs.xml | 6 -- .../mazeminotaurs/character/CharClass.java | 10 +++ .../mazeminotaurs/character/Character.java | 88 +++++++++++++++++++ .../cis/mazeminotaurs/character/Patron.java | 10 +++ .../mazeminotaurs/character/stats/Core.java | 9 ++ 7 files changed, 146 insertions(+), 28 deletions(-) delete mode 100644 MazesAndMinotaurs/.idea/encodings.xml delete mode 100644 MazesAndMinotaurs/.idea/vcs.xml create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Patron.java create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 00c7f6c..5b69ef0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,15 @@ - + + + + + + + + + - @@ -58,7 +66,7 @@ - + @@ -66,17 +74,22 @@ - - + + - + + @@ -181,25 +194,25 @@ - + - + - + - + - + - - + + @@ -208,10 +221,10 @@ - - + + diff --git a/MazesAndMinotaurs/.idea/encodings.xml b/MazesAndMinotaurs/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/MazesAndMinotaurs/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/MazesAndMinotaurs/.idea/vcs.xml b/MazesAndMinotaurs/.idea/vcs.xml deleted file mode 100644 index 6c0b863..0000000 --- a/MazesAndMinotaurs/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java new file mode 100644 index 0000000..1769979 --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java @@ -0,0 +1,10 @@ +package com.example.cis.mazeminotaurs.character; + +/** + * Created by jusmith on 3/30/17. + */ + +public enum CharClass { + AMAZON, AMAZON_B, ARCHER, BARBARIAN, BEASTMASTER, CAVALRYMAN, CENTAUR, ELEMENTALIST, HUNTER, + LYRIST, NOBLE, NYMPH, PRIEST, SHAPESHIFTER, SORCEROR, SPEARMAN, THIEF; +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java new file mode 100644 index 0000000..ee09e8b --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java @@ -0,0 +1,88 @@ +package com.example.cis.mazeminotaurs.character; + +import com.example.cis.mazeminotaurs.character.stats.Core; + +import java.util.HashMap; + +/** + * Created by jusmith on 3/30/17. + */ + +public class Character { + private HashMap mCoreStats; + private CharClass mClass; + private int mAge; + private String mName; + + public Character() { + mAge = 0; + mClass = CharClass.AMAZON; + for (Core coreStat: Core.values()) { + mCoreStats.put(coreStat, 0); + } + mName = "Thorin"; + } + + public int getMod(Core coreStat) { + int statValue = mCoreStats.get(coreStat); + if (statValue <= 2) { + return -4; + } else if (statValue <= 4) { + return -3; + } else if (statValue <= 6) { + return -2; + } else if (statValue <= 8) { + return -1; + } else if (statValue <= 12) { + return 0; + } else if (statValue <= 14) { + return 1; + } else if (statValue <= 16) { + return 2; + } else if (statValue <= 18) { + return 3; + } else { + return 4; + } + } + + public int getMeleeMod() { + return getMod(Core) + } + + public Integer getCoreStatScore(Core coreStat) { + return mCoreStats.get(coreStat); + } + + public HashMap getCoreStats() { + return mCoreStats; + } + + public void setCoreStats(HashMap coreStats) { + mCoreStats = coreStats; + } + + public CharClass getCharClass() { + return mClass; + } + + public void setCharClass(CharClass aClass) { + mClass = aClass; + } + + public int getAge() { + return mAge; + } + + public void setAge(int age) { + mAge = age; + } + + public String getName() { + return mName; + } + + public void setName(String name) { + mName = name; + } +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Patron.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Patron.java new file mode 100644 index 0000000..7ede667 --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Patron.java @@ -0,0 +1,10 @@ +package com.example.cis.mazeminotaurs.character; + +/** + * Created by jusmith on 3/30/17. + */ + +public enum Patron { + APHRODITE, APOLLO, ARES, ARTEMIS, ATHENA, DEMETER, HEPHAESTUS, HERA, HERMES, HESTIA, POSEIDON, + ZEUS; +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java new file mode 100644 index 0000000..468ebdc --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java @@ -0,0 +1,9 @@ +package com.example.cis.mazeminotaurs.character.stats; + +/** + * Created by jusmith on 3/30/17. + */ + +public enum Core { + MIGHT, GRACE, SKILL, WILL, WITS, LUCK; +} From d77d2500c2a6050a5a9ffb1710afdf81b8b75f20 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Fri, 31 Mar 2017 13:19:49 -0500 Subject: [PATCH 02/18] + 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. --- .../example/cis/mazeminotaurs/character/CharClass.java | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java deleted file mode 100644 index 1769979..0000000 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.example.cis.mazeminotaurs.character; - -/** - * Created by jusmith on 3/30/17. - */ - -public enum CharClass { - AMAZON, AMAZON_B, ARCHER, BARBARIAN, BEASTMASTER, CAVALRYMAN, CENTAUR, ELEMENTALIST, HUNTER, - LYRIST, NOBLE, NYMPH, PRIEST, SHAPESHIFTER, SORCEROR, SPEARMAN, THIEF; -} From 24335df898a1beaf4af0efcc0d33e0e151ed20d0 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Fri, 31 Mar 2017 13:35:47 -0500 Subject: [PATCH 03/18] Actually pushed the files --- .../mazeminotaurs/character/Character.java | 79 ++++++++--- .../cis/mazeminotaurs/character/Gender.java | 27 ++++ .../character/classes/Barbarian.java | 57 ++++++++ .../character/classes/BaseClass.java | 130 ++++++++++++++++++ .../character/classes/Classes.java | 55 ++++++++ .../character/classes/Specialist.java | 17 +++ .../character/classes/Warrior.java | 29 ++++ .../character/stats/{Core.java => Score.java} | 9 +- .../example/cis/mazeminotaurs/util/Util.java | 25 ++++ .../src/main/res/values/game_references.xml | 30 ++++ 10 files changed, 439 insertions(+), 19 deletions(-) create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Gender.java create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Classes.java create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Warrior.java rename MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/{Core.java => Score.java} (54%) create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/util/Util.java diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java index ee09e8b..deab602 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java @@ -1,6 +1,11 @@ package com.example.cis.mazeminotaurs.character; -import com.example.cis.mazeminotaurs.character.stats.Core; +import com.example.cis.mazeminotaurs.Armor; +import com.example.cis.mazeminotaurs.AttributeScoreGenerator; +import com.example.cis.mazeminotaurs.R; +import com.example.cis.mazeminotaurs.character.classes.Barbarian; +import com.example.cis.mazeminotaurs.character.classes.BaseClass; +import com.example.cis.mazeminotaurs.character.stats.Score; import java.util.HashMap; @@ -9,22 +14,26 @@ */ public class Character { - private HashMap mCoreStats; - private CharClass mClass; + private HashMap mCoreStats; + private BaseClass mCharClass; + private Gender mGender; private int mAge; private String mName; + private Armor mHelmet; + private Armor mBreastplate; + private Armor mShield; public Character() { mAge = 0; - mClass = CharClass.AMAZON; - for (Core coreStat: Core.values()) { - mCoreStats.put(coreStat, 0); + setCharClass(new Barbarian(this, R.string.barb_axe, R.string.bow)); + for (Score scoreStat : Score.values()) { + mCoreStats.put(scoreStat, 0); } mName = "Thorin"; } - public int getMod(Core coreStat) { - int statValue = mCoreStats.get(coreStat); + public int getMod(Score scoreStat) { + int statValue = mCoreStats.get(scoreStat); if (statValue <= 2) { return -4; } else if (statValue <= 4) { @@ -47,27 +56,63 @@ public int getMod(Core coreStat) { } public int getMeleeMod() { - return getMod(Core) + return getMod(Score.MIGHT) + getMod(Score.GRACE) + getMod(Score.LUCK); } - public Integer getCoreStatScore(Core coreStat) { - return mCoreStats.get(coreStat); + public int getMissleMod() { + return getMod(Score.SKILL) + getMod(Score.WITS) + getMod(Score.LUCK); } - public HashMap getCoreStats() { + public int getInititive() { + return 10 + getMod(Score.SKILL) + getMod(Score.WITS); + } + + public int getDC() { + return 12 + getMod(Score.LUCK); + } + + public int getEDC() { + int armorBonus = 0; + if (mHelmet != null) { + armorBonus += 2; + } + if (mBreastplate != null) { + armorBonus += 2; + } + if (mShield != null) { + armorBonus += 2; + } + + return getDC() + armorBonus; + } + + public int getHitTotal(){ + //return mCharClass.getHits() + getMod(Score.MIGHT); + return 0; + } + + public int getCharisma(){ + return getMod(Score.WILL) + getMod(Score.GRACE) + getMod(Score.LUCK); + } + + public int getCoreStatScore(Score scoreStat) { + return mCoreStats.get(scoreStat); + } + + public HashMap getCoreStats() { return mCoreStats; } - public void setCoreStats(HashMap coreStats) { + public void setCoreStats(HashMap coreStats) { mCoreStats = coreStats; } - public CharClass getCharClass() { - return mClass; + public BaseClass getCharClass() { + return mCharClass; } - public void setCharClass(CharClass aClass) { - mClass = aClass; + public void setCharClass(BaseClass aClass) { + mCharClass = aClass; } public int getAge() { diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Gender.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Gender.java new file mode 100644 index 0000000..a9e6011 --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Gender.java @@ -0,0 +1,27 @@ +package com.example.cis.mazeminotaurs.character; + +import com.example.cis.mazeminotaurs.R; + +/** + * Created by jusmith on 3/31/17. + */ + +public enum Gender { + MALE(R.string.male), + FEMALE(R.string.female), + EITHER(R.string.either_gender); + + private int mResId; + + Gender(int resId) { + mResId = resId; + } + + public int getResId() { + return mResId; + } + + public void setResId(int resId) { + mResId = resId; + } +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java new file mode 100644 index 0000000..0d882e6 --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java @@ -0,0 +1,57 @@ +package com.example.cis.mazeminotaurs.character.classes; + +import com.example.cis.mazeminotaurs.R; +import com.example.cis.mazeminotaurs.character.Character; +import com.example.cis.mazeminotaurs.character.Gender; +import com.example.cis.mazeminotaurs.character.stats.Score; +import com.example.cis.mazeminotaurs.util.Util; + +import java.util.ArrayList; + +/** + * Created by jusmith on 3/31/17. + */ + +public class Barbarian extends Warrior { + + public Barbarian(Character character, int choiceWeapon, int startingMissleWeapon) { + Score[] primAttributes = {Score.MIGHT, Score.WILL}; + ArrayList wepsOfChoice = new ArrayList<>(); + wepsOfChoice.add(R.string.barb_axe); + wepsOfChoice.add(R.string.barb_club); + wepsOfChoice.add(R.string.barb_mace); + wepsOfChoice.add(R.string.barb_sword); + + int rolledGold = 0; + for (int i =0; i < 3; i++) { + rolledGold += Util.roll(6); + } + + setAddedHits(0); + setBasicHits(12); + setCharacter(character); + setExperience(0); + setLevel(1); + setPrimaryAttributes(primAttributes); + setRequiredGender(Gender.MALE); + setResId(R.string.barbarian); + // Cannot set up without Equipment made + // setStartGear(); + setStartGold(rolledGold * 5); + + // If choice weapon isn't valid, just select a random valid choice + if (wepsOfChoice.contains(choiceWeapon)) { + setWeaponOfChoice(choiceWeapon); + } else { + setWeaponOfChoice(wepsOfChoice.get(Util.roll(wepsOfChoice.size()) - 1)); + } + } + + public int getBattleMightBonus(){ + return getCharacter().getMod(Score.MIGHT); + } + + public int getBattleFuryBonus(){ + return getCharacter().getMod(Score.WILL); + } +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java new file mode 100644 index 0000000..e474ddb --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java @@ -0,0 +1,130 @@ +package com.example.cis.mazeminotaurs.character.classes; + +import com.example.cis.mazeminotaurs.Equipment; +import com.example.cis.mazeminotaurs.character.Character; +import com.example.cis.mazeminotaurs.character.Gender; +import com.example.cis.mazeminotaurs.character.stats.Score; + +import java.util.ArrayList; + +/** + * Created by jusmith on 3/31/17. + */ + +public abstract class BaseClass { + private int mAddedHits; + private int mBasicHits; + private Character mCharacter; + private int mExperience; + private int mLevel; + private Score[] mPrimaryAttributes; + private Gender mRequiredGender; + private int mResId; + private ArrayList mStartGear; + private int mStartGold; + + public void updateLevel(){ + if (getExperience() < 1000) { + setLevel(1); + } + if (getExperience() < 2000) { + setLevel(2); + } + if (getExperience() < 4000) { + setLevel(3); + } + if (getExperience() < 7000) { + setLevel(4); + } + if (getExperience() < 10000) { + setLevel(5); + } + if (getExperience() > 9999) { + setLevel(6); + } + } + + public int getAddedHits() { + return mAddedHits; + } + + public void setAddedHits(int addedHits) { + mAddedHits = addedHits; + } + + public int getBasicHits() { + return mBasicHits; + } + + public void setBasicHits(int basicHits) { + mBasicHits = basicHits; + } + + public Character getCharacter() { + return mCharacter; + } + + public void setCharacter(Character character) { + mCharacter = character; + } + + public Score[] getPrimaryAttributes() { + return mPrimaryAttributes; + } + + public void setPrimaryAttributes(Score[] primaryAttributes) { + mPrimaryAttributes = primaryAttributes; + } + + public Gender getRequiredGender() { + return mRequiredGender; + } + + public void setRequiredGender(Gender requiredGender) { + mRequiredGender = requiredGender; + } + + public int getResId() { + return mResId; + } + + public void setResId(int resId) { + mResId = resId; + } + + public ArrayList getStartGear() { + return mStartGear; + } + + public void setStartGear(ArrayList startGear) { + mStartGear = startGear; + } + + public int getStartGold() { + return mStartGold; + } + + public void setStartGold(int startGold) { + mStartGold = startGold; + } + + public int getExperience() { + return mExperience; + } + + public void setExperience(int experience) { + mExperience = experience; + } + + public int getLevel() { + return mLevel; + } + + public void setLevel(int level) { + mLevel = level; + } + + public int getLevelDescription() { + return -12321; + } +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Classes.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Classes.java new file mode 100644 index 0000000..b679769 --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Classes.java @@ -0,0 +1,55 @@ +package com.example.cis.mazeminotaurs.character.classes; + +import com.example.cis.mazeminotaurs.R; + +/** + * Created by jusmith on 3/30/17. + */ + +public enum Classes { + AMAZON, + AMAZON_B, + ARCHER, + BARBARIAN(R.string.barbarian, Barbarian.class), + BEASTMASTER, + CAVALRYMAN, + CENTAUR, + ELEMENTALIST, + HUNTER, + LYRIST, + NOBLE, + NYMPH, + PRIEST, + SHAPESHIFTER, + SORCEROR, + SPEARMAN, + THIEF; + + int mResId; + Class mJavaClass; + + Classes() { + + } + + Classes(int resId, Class javaClass) { + mResId = resId; + mJavaClass = javaClass; + } + + public int getResId() { + return mResId; + } + + public void setResId(int resId) { + mResId = resId; + } + + public Class getJavaClass() { + return mJavaClass; + } + + public void setJavaClass(Class javaClass) { + mJavaClass = javaClass; + } +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java new file mode 100644 index 0000000..6792c9f --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java @@ -0,0 +1,17 @@ +package com.example.cis.mazeminotaurs.character.classes; + +/** + * Created by jusmith on 3/31/17. + */ + +public abstract class Specialist extends BaseClass { + private int mSpecialScoreId; + + public int getSpecialScoreId() { + return mSpecialScoreId; + } + + public void setSpecialScoreId(int specialScoreId) { + mSpecialScoreId = specialScoreId; + } +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Warrior.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Warrior.java new file mode 100644 index 0000000..63d0506 --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Warrior.java @@ -0,0 +1,29 @@ +package com.example.cis.mazeminotaurs.character.classes; + +import com.example.cis.mazeminotaurs.R; + + +/** + * Created by jusmith on 3/31/17. + */ + +public abstract class Warrior extends BaseClass { + private int mWeaponOfChoice; + private static final int[] mLevelDescriptions = {R.string.warrior_one, R.string.warrior_two, + R.string.warrior_three, R.string.warrior_four, + R.string.warrior_five, R.string.warrior_six}; + + public int getWeaponOfChoice() { + return mWeaponOfChoice; + } + + public void setWeaponOfChoice(int weaponOfChoice) { + mWeaponOfChoice = weaponOfChoice; + } + + @Override + public int getLevelDescription() { + updateLevel(); + return mLevelDescriptions[getLevel() - 1]; + } +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Score.java similarity index 54% rename from MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java rename to MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Score.java index 468ebdc..42f41cc 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Score.java @@ -4,6 +4,11 @@ * Created by jusmith on 3/30/17. */ -public enum Core { - MIGHT, GRACE, SKILL, WILL, WITS, LUCK; +public enum Score { + MIGHT, + GRACE, + SKILL, + WILL, + WITS, + LUCK; } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/util/Util.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/util/Util.java new file mode 100644 index 0000000..669fac8 --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/util/Util.java @@ -0,0 +1,25 @@ +package com.example.cis.mazeminotaurs.util; + +import com.example.cis.mazeminotaurs.R; + +import java.util.Random; + +/** + * Created by jusmith on 3/31/17. + */ + +public class Util { + public static final int[] sBarbWeapons = {R.string.barb_axe, R.string.barb_club, R.string.barb_mace, R.string.barb_sword}; + public static final int[] sMissleWeapons = {R.string.bow, R.string.javelin, R.string.sling, R.string.arrow, R.string.slingshot}; + public static final int[] sMeleeWeapons = {R.string.dagger, R.string.mace, R.string.axe, R.string.spear, R.string.sword}; + + private static Random sRandom; + + public static int roll(int sides) { + if (sRandom == null) { + sRandom = new Random(); + } + + return sRandom.nextInt(sides) + 1; + } +} diff --git a/MazesAndMinotaurs/app/src/main/res/values/game_references.xml b/MazesAndMinotaurs/app/src/main/res/values/game_references.xml index cbad990..89cf935 100644 --- a/MazesAndMinotaurs/app/src/main/res/values/game_references.xml +++ b/MazesAndMinotaurs/app/src/main/res/values/game_references.xml @@ -51,4 +51,34 @@ Water Light Dark + + + Male + Female + Either + + + + Local Hero + Favored Hero + Celebrated Hero + Famous Hero + Illustrious Hero + Legendary Hero + + + Amateur + Competent + Superior + Expert + Master + Extraordinaire + + + Novice Adept + Initiate Adept + Wise Adept + Sage Adept + Venerable Adept + Supreme Adept \ No newline at end of file From 43fdacccdd36c0b16d01c07f38db32364ed79061 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Thu, 30 Mar 2017 13:39:44 -0500 Subject: [PATCH 04/18] Started to add the character class into the Game. --- MazesAndMinotaurs/.gitignore | 1 + .../example/cis/mazeminotaurs/character/CharClass.java | 10 ++++++++++ .../cis/mazeminotaurs/character/stats/Core.java | 9 +++++++++ 3 files changed, 20 insertions(+) create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java diff --git a/MazesAndMinotaurs/.gitignore b/MazesAndMinotaurs/.gitignore index 39fb081..f9931bf 100644 --- a/MazesAndMinotaurs/.gitignore +++ b/MazesAndMinotaurs/.gitignore @@ -1,6 +1,7 @@ *.iml .gradle /local.properties +.idea/ /.idea/workspace.xml /.idea/libraries .DS_Store diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java new file mode 100644 index 0000000..1769979 --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java @@ -0,0 +1,10 @@ +package com.example.cis.mazeminotaurs.character; + +/** + * Created by jusmith on 3/30/17. + */ + +public enum CharClass { + AMAZON, AMAZON_B, ARCHER, BARBARIAN, BEASTMASTER, CAVALRYMAN, CENTAUR, ELEMENTALIST, HUNTER, + LYRIST, NOBLE, NYMPH, PRIEST, SHAPESHIFTER, SORCEROR, SPEARMAN, THIEF; +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java new file mode 100644 index 0000000..468ebdc --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java @@ -0,0 +1,9 @@ +package com.example.cis.mazeminotaurs.character.stats; + +/** + * Created by jusmith on 3/30/17. + */ + +public enum Core { + MIGHT, GRACE, SKILL, WILL, WITS, LUCK; +} From bc8c450fd3fdc88eb0113ff67045336b11687043 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Fri, 31 Mar 2017 13:19:49 -0500 Subject: [PATCH 05/18] + 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. --- .../example/cis/mazeminotaurs/character/CharClass.java | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java deleted file mode 100644 index 1769979..0000000 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/CharClass.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.example.cis.mazeminotaurs.character; - -/** - * Created by jusmith on 3/30/17. - */ - -public enum CharClass { - AMAZON, AMAZON_B, ARCHER, BARBARIAN, BEASTMASTER, CAVALRYMAN, CENTAUR, ELEMENTALIST, HUNTER, - LYRIST, NOBLE, NYMPH, PRIEST, SHAPESHIFTER, SORCEROR, SPEARMAN, THIEF; -} From 1c12e9cc065a7dc8f20bd1f9fdba0fe050a7b214 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Fri, 31 Mar 2017 13:35:47 -0500 Subject: [PATCH 06/18] Actually pushed the files --- .../example/cis/mazeminotaurs/character/stats/Core.java | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java deleted file mode 100644 index 468ebdc..0000000 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/stats/Core.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.example.cis.mazeminotaurs.character.stats; - -/** - * Created by jusmith on 3/30/17. - */ - -public enum Core { - MIGHT, GRACE, SKILL, WILL, WITS, LUCK; -} From 9a6dee99b0211d349405393ad6bb18b3dac71b9b Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Tue, 4 Apr 2017 11:52:52 -0500 Subject: [PATCH 07/18] + 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. --- .../mazeminotaurs/character/Character.java | 59 ++++++++----------- .../character/classes/Amazon.java | 41 +++++++++++++ .../character/classes/Barbarian.java | 6 +- .../character/classes/BaseClass.java | 2 + .../character/classes/Specialist.java | 4 +- 5 files changed, 70 insertions(+), 42 deletions(-) create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java index deab602..c934edd 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java @@ -1,6 +1,7 @@ package com.example.cis.mazeminotaurs.character; 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.Barbarian; @@ -14,7 +15,7 @@ */ public class Character { - private HashMap mCoreStats; + private HashMap mCoreStats = new HashMap<>(); private BaseClass mCharClass; private Gender mGender; private int mAge; @@ -24,51 +25,35 @@ public class Character { private Armor mShield; public Character() { - mAge = 0; + setAge(0); setCharClass(new Barbarian(this, R.string.barb_axe, R.string.bow)); - for (Score scoreStat : Score.values()) { - mCoreStats.put(scoreStat, 0); - } - mName = "Thorin"; - } - - public int getMod(Score scoreStat) { - int statValue = mCoreStats.get(scoreStat); - if (statValue <= 2) { - return -4; - } else if (statValue <= 4) { - return -3; - } else if (statValue <= 6) { - return -2; - } else if (statValue <= 8) { - return -1; - } else if (statValue <= 12) { - return 0; - } else if (statValue <= 14) { - return 1; - } else if (statValue <= 16) { - return 2; - } else if (statValue <= 18) { - return 3; - } else { - return 4; + setName("Thorin"); + + AttributeScore[] scores = new AttributeScoreGenerator().nextValidSet(); + for (int i = 0; i < scores.length; i++) { + mCoreStats.put(Score.values()[i], scores[i]); } } public int getMeleeMod() { - return getMod(Score.MIGHT) + getMod(Score.GRACE) + getMod(Score.LUCK); + return getCoreStatScore(Score.MIGHT).getModifier() + + getCoreStatScore(Score.GRACE).getModifier() + + getCoreStatScore(Score.LUCK).getModifier(); } public int getMissleMod() { - return getMod(Score.SKILL) + getMod(Score.WITS) + getMod(Score.LUCK); + return getCoreStatScore(Score.SKILL).getModifier() + + getCoreStatScore(Score.WITS).getModifier() + + getCoreStatScore(Score.LUCK).getModifier(); } public int getInititive() { - return 10 + getMod(Score.SKILL) + getMod(Score.WITS); + return 10 + getCoreStatScore(Score.SKILL).getModifier() + + getCoreStatScore(Score.WITS).getModifier(); } public int getDC() { - return 12 + getMod(Score.LUCK); + return 12 + getCoreStatScore(Score.LUCK).getModifier(); } public int getEDC() { @@ -92,18 +77,20 @@ public int getHitTotal(){ } public int getCharisma(){ - return getMod(Score.WILL) + getMod(Score.GRACE) + getMod(Score.LUCK); + return getCoreStatScore(Score.WILL).getModifier() + + getCoreStatScore(Score.GRACE).getModifier() + + getCoreStatScore(Score.LUCK).getModifier(); } - public int getCoreStatScore(Score scoreStat) { + public AttributeScore getCoreStatScore(Score scoreStat) { return mCoreStats.get(scoreStat); } - public HashMap getCoreStats() { + public HashMap getCoreStats() { return mCoreStats; } - public void setCoreStats(HashMap coreStats) { + public void setCoreStats(HashMap coreStats) { mCoreStats = coreStats; } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java new file mode 100644 index 0000000..deaf817 --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java @@ -0,0 +1,41 @@ +package com.example.cis.mazeminotaurs.character.classes; + +import com.example.cis.mazeminotaurs.R; +import com.example.cis.mazeminotaurs.character.Character; +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. + */ + +public class Amazon extends Warrior{ + public Amazon(Character character) { + Score[] primAttributes = {Score.SKILL, Score.GRACE}; + + int rolledGold = 0; + for (int i = 0; i < 3; i++) { + rolledGold += Util.roll(6); + } + + setAddedHits(0); + setBasicHits(12); + setCharacter(character); + setExperience(0); + setLevel(1); + setPrimaryAttributes(primAttributes); + setRequiredGender(Gender.FEMALE); + setResId(Classes.AMAZON.getResId()); + setStartGold(rolledGold); + setWeaponOfChoice(R.string.bow); + } + + public int getDeadlyShotBonus(){ + return getCharacter().getCoreStatScore(Score.SKILL).getModifier(); + } + + public int getBattleGraceBonus(){ + return getCharacter().getCoreStatScore(Score.GRACE).getModifier(); + } +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java index 0d882e6..b21f407 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java @@ -34,7 +34,7 @@ public Barbarian(Character character, int choiceWeapon, int startingMissleWeapon setLevel(1); setPrimaryAttributes(primAttributes); setRequiredGender(Gender.MALE); - setResId(R.string.barbarian); + setResId(Classes.BARBARIAN.getResId()); // Cannot set up without Equipment made // setStartGear(); setStartGold(rolledGold * 5); @@ -48,10 +48,10 @@ public Barbarian(Character character, int choiceWeapon, int startingMissleWeapon } public int getBattleMightBonus(){ - return getCharacter().getMod(Score.MIGHT); + return getCharacter().getCoreStatScore(Score.MIGHT).getModifier(); } public int getBattleFuryBonus(){ - return getCharacter().getMod(Score.WILL); + return getCharacter().getCoreStatScore(Score.WILL).getModifier(); } } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java index e474ddb..81a279d 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java @@ -124,6 +124,8 @@ public void setLevel(int level) { mLevel = level; } + // Dummy Method + // Returns the ResId of the level descriptions public int getLevelDescription() { return -12321; } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java index 6792c9f..4303c01 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java @@ -7,9 +7,7 @@ public abstract class Specialist extends BaseClass { private int mSpecialScoreId; - public int getSpecialScoreId() { - return mSpecialScoreId; - } + public int getSpecialScoreId() { return mSpecialScoreId; } public void setSpecialScoreId(int specialScoreId) { mSpecialScoreId = specialScoreId; From 03c44fd59f46dacfbfca5a622d3dc7c8ecec6903 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Wed, 5 Apr 2017 13:38:34 -0500 Subject: [PATCH 08/18] + 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. --- MazesAndMinotaurs/.idea/misc.xml | 2 +- .../mazeminotaurs/character/Character.java | 67 +++++++++++++++++++ .../cis/mazeminotaurs/character/Money.java | 27 ++++++++ .../character/classes/Barbarian.java | 56 +++++++++++++++- .../character/classes/BaseClass.java | 48 ++++++++++--- .../character/classes/Magician.java | 23 +++++++ .../src/main/res/values/game_references.xml | 5 ++ 7 files changed, 215 insertions(+), 13 deletions(-) create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Money.java create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Magician.java diff --git a/MazesAndMinotaurs/.idea/misc.xml b/MazesAndMinotaurs/.idea/misc.xml index 5d19981..fbb6828 100644 --- a/MazesAndMinotaurs/.idea/misc.xml +++ b/MazesAndMinotaurs/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java index c934edd..ab09e1e 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java @@ -18,6 +18,7 @@ public class Character { private HashMap mCoreStats = new HashMap<>(); private BaseClass mCharClass; private Gender mGender; + private HashMap mMoney = new HashMap<>(); private int mAge; private String mName; private Armor mHelmet; @@ -25,9 +26,13 @@ public class Character { private Armor mShield; public Character() { + 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++) { @@ -82,6 +87,68 @@ public int getCharisma(){ getCoreStatScore(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 getMoney() { + return mMoney; + } + + private void initalizeMoneyMap() { + mMoney.put(Money.COPPER, 0); + mMoney.put(Money.SILVER, 0); + mMoney.put(Money.GOLD, 0); + } + + public void setMoney(HashMap money) { + mMoney = money; + } + + public void validateMoney() { + HashMap 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); } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Money.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Money.java new file mode 100644 index 0000000..96a0968 --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Money.java @@ -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; + } +} diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java index b21f407..45d76b1 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java @@ -1,5 +1,6 @@ package com.example.cis.mazeminotaurs.character.classes; +import com.example.cis.mazeminotaurs.AttributeScore; import com.example.cis.mazeminotaurs.R; import com.example.cis.mazeminotaurs.character.Character; import com.example.cis.mazeminotaurs.character.Gender; @@ -7,6 +8,7 @@ import com.example.cis.mazeminotaurs.util.Util; import java.util.ArrayList; +import java.util.Arrays; /** * Created by jusmith on 3/31/17. @@ -14,6 +16,8 @@ public class Barbarian extends Warrior { + private ArrayList mScoreLevelChoice = new ArrayList<>(); + public Barbarian(Character character, int choiceWeapon, int startingMissleWeapon) { Score[] primAttributes = {Score.MIGHT, Score.WILL}; ArrayList wepsOfChoice = new ArrayList<>(); @@ -27,11 +31,8 @@ public Barbarian(Character character, int choiceWeapon, int startingMissleWeapon rolledGold += Util.roll(6); } - setAddedHits(0); setBasicHits(12); setCharacter(character); - setExperience(0); - setLevel(1); setPrimaryAttributes(primAttributes); setRequiredGender(Gender.MALE); setResId(Classes.BARBARIAN.getResId()); @@ -47,6 +48,55 @@ public Barbarian(Character character, int choiceWeapon, int startingMissleWeapon } } + @Override + public void doLevelUp(){ + Score[] possibleScores = {Score.SKILL, Score.WILL, Score.MIGHT}; + doLevelUp(possibleScores[Util.roll(3) - 1]); + } + + public void doLevelUp(Score score) { + if (getLevel() < getEffectiveLevel()){ + + Score[] possibleScores = {Score.SKILL, Score.WILL, Score.MIGHT}; + Score selectedScore; + if (Arrays.asList(possibleScores).contains(score)) { + selectedScore = score; + } else { + selectedScore = possibleScores[Util.roll(3) - 1]; + } + + AttributeScore selectedAttrScore = getCharacter().getCoreStatScore(selectedScore); + AttributeScore luck = getCharacter().getCoreStatScore(Score.LUCK); + + luck.setScore(luck.getScore() + 1); + selectedAttrScore.setScore(selectedAttrScore.getScore() + 2); + setAddedHits(getAddedHits() + 4); + + setLevel(getLevel() + 1); + getScoreLevelChoice().add(selectedScore); + } + } + + @Override + public void doLevelDown(){ + if (getLevel() > 1) { + AttributeScore luck = getCharacter().getCoreStatScore(Score.LUCK); + AttributeScore lastScoreLeveled = getCharacter().getCoreStatScore(getScoreLevelChoice().get(getScoreLevelChoice().size() - 1)); + + setAddedHits(getAddedHits() - 4); + luck.setScore(luck.getScore() - 1); + lastScoreLeveled.setScore(lastScoreLeveled.getScore() - 2); + } + } + + public ArrayList getScoreLevelChoice() { + return mScoreLevelChoice; + } + + public void setScoreLevelChoice(ArrayList scoreLevelChoice) { + mScoreLevelChoice = scoreLevelChoice; + } + public int getBattleMightBonus(){ return getCharacter().getCoreStatScore(Score.MIGHT).getModifier(); } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java index 81a279d..f0c939b 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java @@ -9,14 +9,32 @@ /** * Created by jusmith on 3/31/17. + * + * Level is the actual of a character + * EffectiveLevel is what level the character will be after handling leveling up + * + * Example of Usage: + * Assume: + * mLevel = 1; + * mExperience = 2000; + * mEffectiveLevel = 3; + * After calling doLevelUp + * mLevel = 2; + * mExperience = 2000; + * mEffectiveLevel = 3; + * After calling doLevelUp + * mLevel = 3; + * mExperience = 2000; + * mEffectiveLevel = 3; */ public abstract class BaseClass { - private int mAddedHits; + private int mAddedHits = 0; private int mBasicHits; private Character mCharacter; - private int mExperience; - private int mLevel; + private int mExperience = 0; + private int mLevel = 1; + private int mEffectiveLevel = 1; private Score[] mPrimaryAttributes; private Gender mRequiredGender; private int mResId; @@ -25,22 +43,22 @@ public abstract class BaseClass { public void updateLevel(){ if (getExperience() < 1000) { - setLevel(1); + setEffectiveLevel(1); } if (getExperience() < 2000) { - setLevel(2); + setEffectiveLevel(2); } if (getExperience() < 4000) { - setLevel(3); + setEffectiveLevel(3); } if (getExperience() < 7000) { - setLevel(4); + setEffectiveLevel(4); } if (getExperience() < 10000) { - setLevel(5); + setEffectiveLevel(5); } if (getExperience() > 9999) { - setLevel(6); + setEffectiveLevel(6); } } @@ -124,9 +142,21 @@ public void setLevel(int level) { mLevel = level; } + public int getEffectiveLevel() { + return mEffectiveLevel; + } + + public void setEffectiveLevel(int effectiveLevel) { + mEffectiveLevel = effectiveLevel; + } + // Dummy Method // Returns the ResId of the level descriptions public int getLevelDescription() { return -12321; } + + // Dummy Methods + public void doLevelUp() {} + public void doLevelDown() {} } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Magician.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Magician.java new file mode 100644 index 0000000..bd5434e --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Magician.java @@ -0,0 +1,23 @@ +package com.example.cis.mazeminotaurs.character.classes; + +import com.example.cis.mazeminotaurs.character.stats.Score; + +/** + * Created by jusmith on 4/5/17. + */ + +public abstract class Magician extends BaseClass { + private int mSpecialTalentResId; + + public int getSpecialTalent(){ + int total = 0; + for (Score score: getPrimaryAttributes()) { + total += getCharacter().getCoreStatScore(score).getModifier(); + } + return total; + } + + public int getMysticalStrength(){ + return 12 + getSpecialTalent(); + } +} \ No newline at end of file diff --git a/MazesAndMinotaurs/app/src/main/res/values/game_references.xml b/MazesAndMinotaurs/app/src/main/res/values/game_references.xml index 89cf935..e5c27db 100644 --- a/MazesAndMinotaurs/app/src/main/res/values/game_references.xml +++ b/MazesAndMinotaurs/app/src/main/res/values/game_references.xml @@ -57,6 +57,11 @@ Female Either + + Copper + Silver + Gold + Local Hero From 59b3722322a08e85fc1ae69b7e124d9fed8ced56 Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Wed, 5 Apr 2017 16:42:51 -0500 Subject: [PATCH 09/18] + Changed Character class to PlayerCharacter --- MazesAndMinotaurs/.idea/misc.xml | 2 +- .../{Character.java => PlayerCharacter.java} | 18 +----------------- .../character/classes/Amazon.java | 6 +++--- .../character/classes/Barbarian.java | 6 +++--- .../character/classes/BaseClass.java | 12 ++++++------ 5 files changed, 14 insertions(+), 30 deletions(-) rename MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/{Character.java => PlayerCharacter.java} (82%) diff --git a/MazesAndMinotaurs/.idea/misc.xml b/MazesAndMinotaurs/.idea/misc.xml index fbb6828..5d19981 100644 --- a/MazesAndMinotaurs/.idea/misc.xml +++ b/MazesAndMinotaurs/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java similarity index 82% rename from MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java rename to MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java index c151aef..61bbc2f 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java @@ -16,13 +16,8 @@ * Created by jusmith on 3/30/17. */ -<<<<<<< HEAD:MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java -public class Character { -======= public class PlayerCharacter { - private final String TAG = "PlayerCharacter Class"; ->>>>>>> 2f6980a2a86150f8f810ee0775cc1434a98701a2:MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java private HashMap mCoreStats = new HashMap<>(); private BaseClass mCharClass; private Gender mGender; @@ -33,8 +28,7 @@ public class PlayerCharacter { private Armor mBreastplate; private Armor mShield; -<<<<<<< HEAD:MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java - public Character() { + public PlayerCharacter() { initalizeMoneyMap(); setAge(0); @@ -42,13 +36,6 @@ public Character() { setName("Thorin"); getMoney().put(Money.SILVER, getCharClass().getStartGold()); -======= - public PlayerCharacter() { - Log.i(TAG, "Creating PlayerCharacter"); - setAge(0); - setCharClass(new Barbarian(this, R.string.barb_axe, R.string.bow)); - setName("Thorin"); ->>>>>>> 2f6980a2a86150f8f810ee0775cc1434a98701a2:MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java AttributeScore[] scores = new AttributeScoreGenerator().nextValidSet(); for (int i = 0; i < scores.length; i++) { @@ -101,7 +88,6 @@ public int getCharisma(){ return getCoreStatScore(Score.WILL).getModifier() + getCoreStatScore(Score.GRACE).getModifier() + getCoreStatScore(Score.LUCK).getModifier(); -<<<<<<< HEAD:MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/Character.java } public Gender getGender() { @@ -164,8 +150,6 @@ public Armor getShield() { public void setShield(Armor shield) { mShield = shield; -======= ->>>>>>> 2f6980a2a86150f8f810ee0775cc1434a98701a2:MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java } public AttributeScore getCoreStatScore(Score scoreStat) { diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java index deaf817..754a446 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java @@ -1,7 +1,7 @@ package com.example.cis.mazeminotaurs.character.classes; import com.example.cis.mazeminotaurs.R; -import com.example.cis.mazeminotaurs.character.Character; +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; @@ -11,7 +11,7 @@ */ public class Amazon extends Warrior{ - public Amazon(Character character) { + public Amazon(PlayerCharacter playerCharacter) { Score[] primAttributes = {Score.SKILL, Score.GRACE}; int rolledGold = 0; @@ -21,7 +21,7 @@ public Amazon(Character character) { setAddedHits(0); setBasicHits(12); - setCharacter(character); + setCharacter(playerCharacter); setExperience(0); setLevel(1); setPrimaryAttributes(primAttributes); diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java index 769484a..ffe935c 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java @@ -2,7 +2,7 @@ import com.example.cis.mazeminotaurs.AttributeScore; import com.example.cis.mazeminotaurs.R; -import com.example.cis.mazeminotaurs.character.Character; +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; @@ -17,7 +17,7 @@ public class Barbarian extends Warrior { private ArrayList mScoreLevelChoice = new ArrayList<>(); - public Barbarian(Character character, int choiceWeapon, int startingMissleWeapon) { + public Barbarian(PlayerCharacter playerCharacter, int choiceWeapon, int startingMissleWeapon) { Score[] primAttributes = {Score.MIGHT, Score.WILL}; ArrayList wepsOfChoice = new ArrayList<>(); wepsOfChoice.add(R.string.barb_axe); @@ -31,7 +31,7 @@ public Barbarian(Character character, int choiceWeapon, int startingMissleWeapon } setBasicHits(12); - setCharacter(character); + setCharacter(playerCharacter); setPrimaryAttributes(primAttributes); setRequiredGender(Gender.MALE); setResId(Classes.BARBARIAN.getResId()); diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java index 5f4a5f7..193be48 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java @@ -1,7 +1,7 @@ package com.example.cis.mazeminotaurs.character.classes; import com.example.cis.mazeminotaurs.Equipment; -import com.example.cis.mazeminotaurs.character.Character; +import com.example.cis.mazeminotaurs.character.PlayerCharacter; import com.example.cis.mazeminotaurs.character.Gender; import com.example.cis.mazeminotaurs.character.stats.Score; @@ -31,7 +31,7 @@ public abstract class BaseClass { private int mAddedHits = 0; private int mBasicHits; - private Character mCharacter; + private PlayerCharacter mPlayerCharacter; private int mExperience = 0; private int mLevel = 1; private int mEffectiveLevel = 1; @@ -78,12 +78,12 @@ public void setBasicHits(int basicHits) { mBasicHits = basicHits; } - public Character getCharacter() { - return mCharacter; + public PlayerCharacter getCharacter() { + return mPlayerCharacter; } - public void setCharacter(Character playerCharacter) { - mCharacter = playerCharacter; + public void setCharacter(PlayerCharacter playerCharacter) { + mPlayerCharacter = playerCharacter; } public Score[] getPrimaryAttributes() { From 4a3abbc4ffdc6c683388dad57b66a99c9cddb24d Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Fri, 7 Apr 2017 12:46:55 -0500 Subject: [PATCH 10/18] + Changed getCoreStatScore to getScore --- .../character/PlayerCharacter.java | 48 ++++++++++--------- .../character/classes/Amazon.java | 4 +- .../character/classes/Barbarian.java | 41 ++++++++++------ .../character/classes/Magician.java | 2 +- 4 files changed, 56 insertions(+), 39 deletions(-) diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java index 61bbc2f..52b74b4 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java @@ -1,7 +1,5 @@ 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; @@ -18,7 +16,7 @@ public class PlayerCharacter { - private HashMap mCoreStats = new HashMap<>(); + private HashMap mScores = new HashMap<>(); private BaseClass mCharClass; private Gender mGender; private HashMap mMoney = new HashMap<>(); @@ -39,29 +37,29 @@ public PlayerCharacter() { 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() { @@ -85,9 +83,9 @@ public int getHitTotal(){ } public int getCharisma(){ - return getCoreStatScore(Score.WILL).getModifier() + - getCoreStatScore(Score.GRACE).getModifier() + - getCoreStatScore(Score.LUCK).getModifier(); + return getScore(Score.WILL).getModifier() + + getScore(Score.GRACE).getModifier() + + getScore(Score.LUCK).getModifier(); } public Gender getGender() { @@ -152,16 +150,16 @@ public void setShield(Armor shield) { mShield = shield; } - public AttributeScore getCoreStatScore(Score scoreStat) { - return mCoreStats.get(scoreStat); + public AttributeScore getScore(Score scoreStat) { + return mScores.get(scoreStat); } - public HashMap getCoreStats() { - return mCoreStats; + public HashMap getScores() { + return mScores; } - public void setCoreStats(HashMap coreStats) { - mCoreStats = coreStats; + public void setScores(HashMap scores) { + mScores = scores; } public BaseClass getCharClass() { @@ -187,4 +185,10 @@ public String getName() { public void setName(String name) { mName = name; } + + protected void printScores() { + for (Score score: getScores().keySet()) { + System.out.println(score.toString() + ":" + String.valueOf(getScore(score).getScore())); + } + } } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java index 754a446..8cf26e4 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java @@ -32,10 +32,10 @@ public Amazon(PlayerCharacter playerCharacter) { } public int getDeadlyShotBonus(){ - return getCharacter().getCoreStatScore(Score.SKILL).getModifier(); + return getCharacter().getScore(Score.SKILL).getModifier(); } public int getBattleGraceBonus(){ - return getCharacter().getCoreStatScore(Score.GRACE).getModifier(); + return getCharacter().getScore(Score.GRACE).getModifier(); } } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java index ffe935c..18dc0a4 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java @@ -1,7 +1,6 @@ package com.example.cis.mazeminotaurs.character.classes; import com.example.cis.mazeminotaurs.AttributeScore; -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; @@ -20,10 +19,9 @@ public class Barbarian extends Warrior { public Barbarian(PlayerCharacter playerCharacter, int choiceWeapon, int startingMissleWeapon) { Score[] primAttributes = {Score.MIGHT, Score.WILL}; ArrayList wepsOfChoice = new ArrayList<>(); - wepsOfChoice.add(R.string.barb_axe); - wepsOfChoice.add(R.string.barb_club); - wepsOfChoice.add(R.string.barb_mace); - wepsOfChoice.add(R.string.barb_sword); + for (int weaponResId: Util.sBarbWeapons) { + wepsOfChoice.add(weaponResId); + } int rolledGold = 0; for (int i =0; i < 3; i++) { @@ -56,16 +54,31 @@ public void doLevelUp(){ public void doLevelUp(Score score) { if (getLevel() < getEffectiveLevel()){ - Score[] possibleScores = {Score.SKILL, Score.WILL, Score.MIGHT}; + Score[] selectableScores = {Score.SKILL, Score.WILL, Score.MIGHT}; + ArrayList possibleScores = new ArrayList<>(); + for (Score selectScore: selectableScores) { + if(!(getCharacter().getScore(selectScore).getScore() >= 20) || + !(getCharacter().getScore(selectScore).getScore() >= 21 && + Arrays.asList(getPrimaryAttributes()).contains(selectScore))) { + possibleScores.add(selectScore); + } + } + Score selectedScore; - if (Arrays.asList(possibleScores).contains(score)) { + if (possibleScores.contains(score)) { selectedScore = score; } else { - selectedScore = possibleScores[Util.roll(3) - 1]; + selectedScore = possibleScores.get(Util.roll(3) - 1); + } + + while (getCharacter().getScore(selectedScore).getScore() >= 20 || + (getCharacter().getScore(selectedScore).getScore() >= 21 && + Arrays.asList(getPrimaryAttributes()).contains(selectedScore))) { + selectedScore = possibleScores.get((possibleScores.indexOf(selectedScore) + 1) % possibleScores.size()); } - AttributeScore selectedAttrScore = getCharacter().getCoreStatScore(selectedScore); - AttributeScore luck = getCharacter().getCoreStatScore(Score.LUCK); + AttributeScore selectedAttrScore = getCharacter().getScore(selectedScore); + AttributeScore luck = getCharacter().getScore(Score.LUCK); luck.setScore(luck.getScore() + 1); selectedAttrScore.setScore(selectedAttrScore.getScore() + 2); @@ -79,8 +92,8 @@ public void doLevelUp(Score score) { @Override public void doLevelDown(){ if (getLevel() > 1) { - AttributeScore luck = getCharacter().getCoreStatScore(Score.LUCK); - AttributeScore lastScoreLeveled = getCharacter().getCoreStatScore(getScoreLevelChoice().get(getScoreLevelChoice().size() - 1)); + AttributeScore luck = getCharacter().getScore(Score.LUCK); + AttributeScore lastScoreLeveled = getCharacter().getScore(getScoreLevelChoice().get(getScoreLevelChoice().size() - 1)); setAddedHits(getAddedHits() - 4); luck.setScore(luck.getScore() - 1); @@ -97,10 +110,10 @@ public void setScoreLevelChoice(ArrayList scoreLevelChoice) { } public int getBattleMightBonus(){ - return getCharacter().getCoreStatScore(Score.MIGHT).getModifier(); + return getCharacter().getScore(Score.MIGHT).getModifier(); } public int getBattleFuryBonus(){ - return getCharacter().getCoreStatScore(Score.WILL).getModifier(); + return getCharacter().getScore(Score.WILL).getModifier(); } } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Magician.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Magician.java index bd5434e..44d5314 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Magician.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Magician.java @@ -12,7 +12,7 @@ public abstract class Magician extends BaseClass { public int getSpecialTalent(){ int total = 0; for (Score score: getPrimaryAttributes()) { - total += getCharacter().getCoreStatScore(score).getModifier(); + total += getCharacter().getScore(score).getModifier(); } return total; } From 83957e36c53eff8bc88b76b2fa75f2795480697d Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Mon, 10 Apr 2017 12:34:43 -0500 Subject: [PATCH 11/18] + 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. --- .../character/PlayerCharacter.java | 50 +++++++++---- .../character/classes/Amazon.java | 7 +- .../character/classes/Barbarian.java | 71 ++++++++++++------- .../character/classes/BaseClass.java | 6 +- .../character/classes/Level.java | 13 ++++ 5 files changed, 107 insertions(+), 40 deletions(-) create mode 100644 MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Level.java diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java index 52b74b4..7d44c71 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java @@ -4,6 +4,7 @@ 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; @@ -34,7 +35,7 @@ public PlayerCharacter() { setName("Thorin"); getMoney().put(Money.SILVER, getCharClass().getStartGold()); - + AttributeScore[] scores = new AttributeScoreGenerator().nextValidSet(); for (int i = 0; i < scores.length; i++) { mScores.put(Score.values()[i], scores[i]); @@ -77,12 +78,12 @@ public int getEDC() { return getDC() + armorBonus; } - public int getHitTotal(){ + public int getHitTotal() { //return mCharClass.getHits() + getMod(Score.MIGHT); return 0; } - public int getCharisma(){ + public int getCharisma() { return getScore(Score.WILL).getModifier() + getScore(Score.GRACE).getModifier() + getScore(Score.LUCK).getModifier(); @@ -105,16 +106,16 @@ public HashMap getMoney() { return mMoney; } + public void setMoney(HashMap money) { + mMoney = money; + } + private void initalizeMoneyMap() { mMoney.put(Money.COPPER, 0); mMoney.put(Money.SILVER, 0); mMoney.put(Money.GOLD, 0); } - public void setMoney(HashMap money) { - mMoney = money; - } - public void validateMoney() { HashMap cash = getMoney(); @@ -150,6 +151,36 @@ public void setShield(Armor shield) { mShield = shield; } + 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 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); + } + } + } + + 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); } @@ -186,9 +217,4 @@ public void setName(String name) { mName = name; } - protected void printScores() { - for (Score score: getScores().keySet()) { - System.out.println(score.toString() + ":" + String.valueOf(getScore(score).getScore())); - } - } } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java index 8cf26e4..ea384ae 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java @@ -6,13 +6,18 @@ import com.example.cis.mazeminotaurs.character.stats.Score; import com.example.cis.mazeminotaurs.util.Util; +import java.util.ArrayList; +import java.util.Collections; + /** * Created by jusmith on 4/4/17. */ public class Amazon extends Warrior{ public Amazon(PlayerCharacter playerCharacter) { - Score[] primAttributes = {Score.SKILL, Score.GRACE}; + Score[] primAttrs = {Score.SKILL, Score.GRACE}; + ArrayList primAttributes = new ArrayList<>(); + Collections.addAll(primAttributes, primAttrs); int rolledGold = 0; for (int i = 0; i < 3; i++) { diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java index 18dc0a4..d0bec6a 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java @@ -7,17 +7,21 @@ import com.example.cis.mazeminotaurs.util.Util; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; /** * Created by jusmith on 3/31/17. */ -public class Barbarian extends Warrior { - private ArrayList mScoreLevelChoice = new ArrayList<>(); +public class Barbarian extends Warrior implements Level{ + private ArrayList> mScoreLevelChoice = new ArrayList<>(); public Barbarian(PlayerCharacter playerCharacter, int choiceWeapon, int startingMissleWeapon) { - Score[] primAttributes = {Score.MIGHT, Score.WILL}; + Score[] primAttrs = {Score.MIGHT, Score.WILL}; + ArrayList primAttributes = new ArrayList<>(); + Collections.addAll(primAttributes, primAttrs); + ArrayList wepsOfChoice = new ArrayList<>(); for (int weaponResId: Util.sBarbWeapons) { wepsOfChoice.add(weaponResId); @@ -45,7 +49,6 @@ public Barbarian(PlayerCharacter playerCharacter, int choiceWeapon, int starting } } - @Override public void doLevelUp(){ Score[] possibleScores = {Score.SKILL, Score.WILL, Score.MIGHT}; doLevelUp(possibleScores[Util.roll(3) - 1]); @@ -54,12 +57,10 @@ public void doLevelUp(){ public void doLevelUp(Score score) { if (getLevel() < getEffectiveLevel()){ - Score[] selectableScores = {Score.SKILL, Score.WILL, Score.MIGHT}; + Score[] choices = {Score.SKILL, Score.WILL, Score.MIGHT}; ArrayList possibleScores = new ArrayList<>(); - for (Score selectScore: selectableScores) { - if(!(getCharacter().getScore(selectScore).getScore() >= 20) || - !(getCharacter().getScore(selectScore).getScore() >= 21 && - Arrays.asList(getPrimaryAttributes()).contains(selectScore))) { + for (Score selectScore: choices) { + if(getCharacter().canAddToScore(selectScore)) { possibleScores.add(selectScore); } } @@ -68,44 +69,66 @@ public void doLevelUp(Score score) { if (possibleScores.contains(score)) { selectedScore = score; } else { - selectedScore = possibleScores.get(Util.roll(3) - 1); + selectedScore = possibleScores.get(Util.roll(possibleScores.size()) - 1); + } + + if (possibleScores.size() > 0) { + while (!getCharacter().canAddToScore(selectedScore)) { + selectedScore = possibleScores.get((possibleScores.indexOf(selectedScore) + 1) % possibleScores.size()); + } } - while (getCharacter().getScore(selectedScore).getScore() >= 20 || - (getCharacter().getScore(selectedScore).getScore() >= 21 && - Arrays.asList(getPrimaryAttributes()).contains(selectedScore))) { - selectedScore = possibleScores.get((possibleScores.indexOf(selectedScore) + 1) % possibleScores.size()); + // Contains information about changed scores + HashMap levelData = new HashMap<>(); + + if (getCharacter().canAddToScore(Score.LUCK)) { + AttributeScore luck = getCharacter().getScore(Score.LUCK); + levelData.put(Score.LUCK, luck.getScore()); + luck.setScore(luck.getScore() + 1); + } else { + levelData.put(Score.LUCK, 20); } AttributeScore selectedAttrScore = getCharacter().getScore(selectedScore); - AttributeScore luck = getCharacter().getScore(Score.LUCK); - luck.setScore(luck.getScore() + 1); + levelData.put(selectedScore, selectedAttrScore.getScore()); + getScoreLevelChoice().add(levelData); + selectedAttrScore.setScore(selectedAttrScore.getScore() + 2); setAddedHits(getAddedHits() + 4); setLevel(getLevel() + 1); - getScoreLevelChoice().add(selectedScore); + getCharacter().validateScores(); } } - @Override public void doLevelDown(){ if (getLevel() > 1) { + HashMap levelData = getScoreLevelChoice().remove(getScoreLevelChoice().size() - 1); + Score lastSelectedScore = null; + for (Object rawScore: levelData.keySet().toArray()) { + Score score = (Score) rawScore; + if (score != Score.LUCK) { + lastSelectedScore = score; + break; + } + } + AttributeScore luck = getCharacter().getScore(Score.LUCK); - AttributeScore lastScoreLeveled = getCharacter().getScore(getScoreLevelChoice().get(getScoreLevelChoice().size() - 1)); + AttributeScore lastScoreLeveled = getCharacter().getScore(lastSelectedScore); setAddedHits(getAddedHits() - 4); - luck.setScore(luck.getScore() - 1); - lastScoreLeveled.setScore(lastScoreLeveled.getScore() - 2); + luck.setScore(levelData.get(Score.LUCK)); + lastScoreLeveled.setScore(levelData.get(lastSelectedScore)); + setLevel(getLevel() - 1); } } - public ArrayList getScoreLevelChoice() { + public ArrayList> getScoreLevelChoice() { return mScoreLevelChoice; } - public void setScoreLevelChoice(ArrayList scoreLevelChoice) { + public void setScoreLevelChoice(ArrayList> scoreLevelChoice) { mScoreLevelChoice = scoreLevelChoice; } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java index 193be48..2e07a15 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java @@ -35,7 +35,7 @@ public abstract class BaseClass { private int mExperience = 0; private int mLevel = 1; private int mEffectiveLevel = 1; - private Score[] mPrimaryAttributes; + private ArrayList mPrimaryAttributes; private Gender mRequiredGender; private int mResId; private ArrayList mStartGear; @@ -86,11 +86,11 @@ public void setCharacter(PlayerCharacter playerCharacter) { mPlayerCharacter = playerCharacter; } - public Score[] getPrimaryAttributes() { + public ArrayList getPrimaryAttributes() { return mPrimaryAttributes; } - public void setPrimaryAttributes(Score[] primaryAttributes) { + public void setPrimaryAttributes(ArrayList primaryAttributes) { mPrimaryAttributes = primaryAttributes; } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Level.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Level.java new file mode 100644 index 0000000..2dc9adb --- /dev/null +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Level.java @@ -0,0 +1,13 @@ +package com.example.cis.mazeminotaurs.character.classes; + +import com.example.cis.mazeminotaurs.character.stats.Score; + +/** + * Created by jusmith on 4/10/17. + */ + +public interface Level { + void doLevelUp(); + void doLevelUp(Score score); + void doLevelDown(); +} From 0d2bde812461045e3057ad0cfe24845e51fefff8 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Thu, 13 Apr 2017 13:39:07 -0500 Subject: [PATCH 12/18] Removed the EffectiveLevel property from BaseClass Removed the updateLevel method Added an example of getting modifier to CharacterSheet --- .../character/classes/Amazon.java | 42 +------------------ 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java index ea384ae..22c24df 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Amazon.java @@ -1,46 +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; - -import java.util.ArrayList; -import java.util.Collections; - /** - * Created by jusmith on 4/4/17. + * Created by jusmith on 4/13/17. */ -public class Amazon extends Warrior{ - public Amazon(PlayerCharacter playerCharacter) { - Score[] primAttrs = {Score.SKILL, Score.GRACE}; - ArrayList primAttributes = new ArrayList<>(); - Collections.addAll(primAttributes, primAttrs); - - int rolledGold = 0; - for (int i = 0; i < 3; i++) { - rolledGold += Util.roll(6); - } - - setAddedHits(0); - setBasicHits(12); - setCharacter(playerCharacter); - setExperience(0); - setLevel(1); - setPrimaryAttributes(primAttributes); - setRequiredGender(Gender.FEMALE); - setResId(Classes.AMAZON.getResId()); - setStartGold(rolledGold); - setWeaponOfChoice(R.string.bow); - } - - public int getDeadlyShotBonus(){ - return getCharacter().getScore(Score.SKILL).getModifier(); - } - - public int getBattleGraceBonus(){ - return getCharacter().getScore(Score.GRACE).getModifier(); - } +public class Amazon extends Warrior implements Level { } From 250c314a1737de40175743c8566b542d610091fe Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Sun, 16 Apr 2017 03:36:42 -0500 Subject: [PATCH 13/18] + Added methods for saving throws in PlayerCharacter.java +getAthleticProwess +getDangerEvasion +getMysticFortitude +getPhysicalVigor +getCharisma --- .../character/PlayerCharacter.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java index 7d44c71..6e719a6 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java @@ -83,6 +83,30 @@ public int getHitTotal() { return 0; } + 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() + From 86f56e69fef7e789affa2f4cc814f03ad2661c95 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Thu, 20 Apr 2017 11:47:59 -0500 Subject: [PATCH 14/18] + Added the Equipment functionality to Barbarian + Changed some int arguments to use Weapon instead + Added some documentation to PlayerCharacter + Also fixed some typos in method names in PlayerCharacter. --- MazesAndMinotaurs/.idea/misc.xml | 2 +- .../mazeminotaurs/CharacterSheetFragment.java | 4 +- .../character/PlayerCharacter.java | 156 ++++++++++++++++-- .../character/classes/Barbarian.java | 48 ++++-- .../character/classes/Warrior.java | 7 +- .../example/cis/mazeminotaurs/util/Util.java | 1 + 6 files changed, 188 insertions(+), 30 deletions(-) diff --git a/MazesAndMinotaurs/.idea/misc.xml b/MazesAndMinotaurs/.idea/misc.xml index 5d19981..fbb6828 100644 --- a/MazesAndMinotaurs/.idea/misc.xml +++ b/MazesAndMinotaurs/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java index f520e27..729ad18 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java @@ -127,7 +127,7 @@ public void onClick(View v){ }); mMissileButton = (Button) rootView.findViewById(R.id.missile_modifier_button); - mMissileButton.setText(Integer.toString(mSheetPlayerCharacter.getMissleMod())); + mMissileButton.setText(Integer.toString(mSheetPlayerCharacter.getMissileMod())); mMissileButton.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ @@ -136,7 +136,7 @@ public void onClick(View v){ }); mInitiativeButton = (Button) rootView.findViewById(R.id.initiative_modifier_button); - mInitiativeButton.setText(Integer.toString(mSheetPlayerCharacter.getInititive())); + mInitiativeButton.setText(Integer.toString(mSheetPlayerCharacter.getInitiative())); diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java index 6e719a6..e658248 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java @@ -3,66 +3,145 @@ import com.example.cis.mazeminotaurs.Armor; import com.example.cis.mazeminotaurs.AttributeScore; import com.example.cis.mazeminotaurs.AttributeScoreGenerator; +import com.example.cis.mazeminotaurs.Equipment; +import com.example.cis.mazeminotaurs.EquipmentDB; 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; +import java.util.ArrayList; import java.util.HashMap; +// TODO: Make the equipment equipped +// TODO: Create the method that checks if the weapon equipped is the weapon of choice + /** - * Created by jusmith on 3/30/17. + * Used to hold the data of a player's character. + * @author Justin Smith */ public class PlayerCharacter { - + /** + * The character's attribute scores. + */ private HashMap mScores = new HashMap<>(); + + /** + * The character class's i.e. Barbarian + */ private BaseClass mCharClass; + + /** + * The character's gender(MALE or FEMALE) + */ private Gender mGender; + + /** + * The character's money. + */ private HashMap mMoney = new HashMap<>(); + + /** + * The character's age. + */ private int mAge; + + /** + * The character's name. + */ private String mName; + + /** + * All of the items that the character is holding. + */ + private ArrayList mInventory = new ArrayList<>(); + + /** + * The character's equipped weapon. + */ + private Equipment mWeapon; + + /** + * The helmet that the character is currently wearing. + */ private Armor mHelmet; + + /** + * The breastplate that the character is currently wearing. + */ private Armor mBreastplate; + + /** + * The shield that the character is currently wearing. + */ private Armor mShield; + /** + * Blank character constructor. + */ public PlayerCharacter() { - initalizeMoneyMap(); + initializeMoneyMap(); + + EquipmentDB equipmentDB = EquipmentDB.getInstance(); setAge(0); - setCharClass(new Barbarian(this, R.string.barb_axe, R.string.bow)); + // Purposely inputting improper argument + setCharClass(new Barbarian(this, equipmentDB.getWeapon(R.string.barb_axe), + equipmentDB.getWeapon(R.string.barb_axe))); setName("Thorin"); getMoney().put(Money.SILVER, getCharClass().getStartGold()); + getInventory().addAll(getCharClass().getStartGear()); + AttributeScore[] scores = new AttributeScoreGenerator().nextValidSet(); for (int i = 0; i < scores.length; i++) { mScores.put(Score.values()[i], scores[i]); } } + /** + * Gets the modifier for melee attacks. + * @return int, the melee modifier + */ public int getMeleeMod() { return getScore(Score.MIGHT).getModifier() + getScore(Score.GRACE).getModifier() + getScore(Score.LUCK).getModifier(); } - public int getMissleMod() { + /** + * Gets the modifier for missile attacks. + * @return int, the missile modifier + */ + public int getMissileMod() { return getScore(Score.SKILL).getModifier() + getScore(Score.WITS).getModifier() + getScore(Score.LUCK).getModifier(); } - public int getInititive() { + /** + * Gets initiative of the character. + * @return int, initiative. + */ + public int getInitiative() { return 10 + getScore(Score.SKILL).getModifier() + getScore(Score.WITS).getModifier(); } + /** + * Gets the defense class of the character. + * @return int, defense class + */ public int getDC() { return 12 + getScore(Score.LUCK).getModifier(); } + /** + * Gets the effective defense class of the character. + * @return int, effective defense class + */ public int getEDC() { int armorBonus = 0; if (mHelmet != null) { @@ -78,35 +157,59 @@ public int getEDC() { return getDC() + armorBonus; } + /** + * Gets the total hits of the character + * @return int, total hits. + */ public int getHitTotal() { //return mCharClass.getHits() + getMod(Score.MIGHT); return 0; } + /** + * Gets the athletic prowess save score of the character. + * @return int, athletic prowess score + */ public int getAthleticProwess(){ return getScore(Score.MIGHT).getModifier() + getScore(Score.SKILL).getModifier() + getScore(Score.LUCK).getModifier(); } + /** + * Gets the danger evasion save score of the character. + * @return int, danger evasion score + */ public int getDangerEvasion(){ return getScore(Score.WITS).getModifier() + getScore(Score.SKILL).getModifier() + getScore(Score.LUCK).getModifier(); } - public int getMysticForitude(){ + /** + * Gets the mystic fortitude save score of the character. + * @return int, mystic fortitude score + */ + public int getMysticFortitude(){ return getScore(Score.WITS).getModifier() + getScore(Score.WILL).getModifier() + getScore(Score.LUCK).getModifier(); } + /** + * Gets the physical vigor save score of the character. + * @return int, physical vigor score + */ public int getPhysicalVigor(){ return getScore(Score.MIGHT).getModifier() + getScore(Score.WILL).getModifier() + getScore(Score.LUCK).getModifier(); } + /** + * Gets the charisma score of the character. + * @return int, charisma score + */ public int getCharisma() { return getScore(Score.WILL).getModifier() + getScore(Score.GRACE).getModifier() + @@ -121,6 +224,11 @@ public void setGender(Gender gender) { mGender = gender; } + /** + * Helper method to add money easier to the character and automatically validate. + * @param money The key of the money map to add to. + * @param amount The amount of money to add the value. + */ public void addMoney(Money money, int amount) { getMoney().put(money, getMoney().get(money) + amount); validateMoney(); @@ -133,13 +241,17 @@ public HashMap getMoney() { public void setMoney(HashMap money) { mMoney = money; } - - private void initalizeMoneyMap() { + /** + * Places the correct keys and values inside of the character's mMoney attribute. + */ + private void initializeMoneyMap() { mMoney.put(Money.COPPER, 0); mMoney.put(Money.SILVER, 0); mMoney.put(Money.GOLD, 0); } - + /** + * Automatically converts the cash that a player character is holding + */ public void validateMoney() { HashMap cash = getMoney(); @@ -175,6 +287,11 @@ public void setShield(Armor shield) { mShield = shield; } + /** + * Checks if a score is maxed out + * @param score The score to check + * @return true if score is not maxed out else false + */ public boolean canAddToScore(Score score) { boolean isPrimary = getCharClass().getPrimaryAttributes().contains(score); int scoreValue = getScore(score).getScore(); @@ -186,6 +303,9 @@ public boolean canAddToScore(Score score) { } } + /** + * Checks if any score contained in the mScores attribute is over the max value. + */ public void validateScores() { for (Score score: Score.values()) { boolean isPrimary = getCharClass().getPrimaryAttributes().contains(score); @@ -199,6 +319,9 @@ public void validateScores() { } } + /** + * Prints the value of every score contained in the mScores attribute + */ protected void debugPrintScores() { for (Score score : getScores().keySet()) { System.out.println(score.toString() + ":" + String.valueOf(getScore(score).getScore())); @@ -218,6 +341,10 @@ public void setScores(HashMap scores) { } public BaseClass getCharClass() { + if (mCharClass == null) { + setCharClass(new Barbarian(this, EquipmentDB.getInstance().getWeapon(R.string.barb_axe), + EquipmentDB.getInstance().getWeapon(R.string.barb_axe))); + } return mCharClass; } @@ -241,4 +368,11 @@ public void setName(String name) { mName = name; } + public ArrayList getInventory() { + return mInventory; + } + + public void setInventory(ArrayList inventory) { + mInventory = inventory; + } } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java index d0bec6a..b2ea368 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java @@ -1,12 +1,17 @@ package com.example.cis.mazeminotaurs.character.classes; import com.example.cis.mazeminotaurs.AttributeScore; +import com.example.cis.mazeminotaurs.Equipment; +import com.example.cis.mazeminotaurs.EquipmentDB; +import com.example.cis.mazeminotaurs.R; +import com.example.cis.mazeminotaurs.Weapon; 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; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -17,14 +22,37 @@ public class Barbarian extends Warrior implements Level{ private ArrayList> mScoreLevelChoice = new ArrayList<>(); - public Barbarian(PlayerCharacter playerCharacter, int choiceWeapon, int startingMissleWeapon) { + public Barbarian(PlayerCharacter playerCharacter, Weapon weaponOfChoice, Weapon rangedChoice) { Score[] primAttrs = {Score.MIGHT, Score.WILL}; ArrayList primAttributes = new ArrayList<>(); Collections.addAll(primAttributes, primAttrs); - ArrayList wepsOfChoice = new ArrayList<>(); - for (int weaponResId: Util.sBarbWeapons) { - wepsOfChoice.add(weaponResId); + EquipmentDB equipDB = EquipmentDB.getInstance(); + Weapon[] possibleWepsOfChoice = {equipDB.getWeapon(R.string.barb_axe)}; + Weapon[] possibleRanged = {equipDB.getWeapon(R.string.bow)}; + ArrayList startingEquipment = new ArrayList<>(); + + if (Arrays.asList(possibleWepsOfChoice).contains(weaponOfChoice)) { + setWeaponOfChoice(weaponOfChoice); + } else { + setWeaponOfChoice(possibleWepsOfChoice[0]); + } + startingEquipment.add(weaponOfChoice); + + if (Arrays.asList(possibleRanged).contains(rangedChoice)){ + switch (rangedChoice.getResId()) { + case R.string.bow: + startingEquipment.add(equipDB.getWeapon(R.string.bow)); + startingEquipment.add(equipDB.getWeapon(R.string.arrows)); + break; + default: + //PANIC + System.out.println("PANIC in Barbarian Ranged Weapon Case"); + break; + } + } else { + startingEquipment.add(equipDB.getWeapon(R.string.bow)); + startingEquipment.add(equipDB.getWeapon(R.string.arrows)); } int rolledGold = 0; @@ -32,21 +60,15 @@ public Barbarian(PlayerCharacter playerCharacter, int choiceWeapon, int starting rolledGold += Util.roll(6); } + setBasicHits(12); setCharacter(playerCharacter); setPrimaryAttributes(primAttributes); setRequiredGender(Gender.MALE); setResId(Classes.BARBARIAN.getResId()); - // Cannot set up without Equipment made - // setStartGear(); setStartGold(rolledGold * 5); - - // If choice weapon isn't valid, just select a random valid choice - if (wepsOfChoice.contains(choiceWeapon)) { - setWeaponOfChoice(choiceWeapon); - } else { - setWeaponOfChoice(wepsOfChoice.get(Util.roll(wepsOfChoice.size()) - 1)); - } + setStartGear(startingEquipment); + setWeaponOfChoice(EquipmentDB.getInstance().getWeapon(R.string.barb_axe)); } public void doLevelUp(){ diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Warrior.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Warrior.java index 63d0506..f5e6cc0 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Warrior.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Warrior.java @@ -1,6 +1,7 @@ package com.example.cis.mazeminotaurs.character.classes; import com.example.cis.mazeminotaurs.R; +import com.example.cis.mazeminotaurs.Weapon; /** @@ -8,16 +9,16 @@ */ public abstract class Warrior extends BaseClass { - private int mWeaponOfChoice; + private Weapon mWeaponOfChoice; private static final int[] mLevelDescriptions = {R.string.warrior_one, R.string.warrior_two, R.string.warrior_three, R.string.warrior_four, R.string.warrior_five, R.string.warrior_six}; - public int getWeaponOfChoice() { + public Weapon getWeaponOfChoice() { return mWeaponOfChoice; } - public void setWeaponOfChoice(int weaponOfChoice) { + public void setWeaponOfChoice(Weapon weaponOfChoice) { mWeaponOfChoice = weaponOfChoice; } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/util/Util.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/util/Util.java index 03e7d09..913f71f 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/util/Util.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/util/Util.java @@ -2,6 +2,7 @@ import com.example.cis.mazeminotaurs.R; +import java.util.ArrayList; import java.util.Random; /** From a2ec89b4b41de6bafa4f587f858ed545d8941b2c Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Thu, 20 Apr 2017 12:09:53 -0500 Subject: [PATCH 15/18] + Added the equipment functionality to the PlayerCharacter - Weapon Attribute - Weapon of Choice checking + Added weapon of choice to specialist --- .../character/PlayerCharacter.java | 39 ++++++++++++++++--- .../character/classes/Specialist.java | 11 ++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java index e658248..22bb92e 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java @@ -6,8 +6,12 @@ import com.example.cis.mazeminotaurs.Equipment; import com.example.cis.mazeminotaurs.EquipmentDB; import com.example.cis.mazeminotaurs.R; +import com.example.cis.mazeminotaurs.Weapon; import com.example.cis.mazeminotaurs.character.classes.Barbarian; import com.example.cis.mazeminotaurs.character.classes.BaseClass; +import com.example.cis.mazeminotaurs.character.classes.Magician; +import com.example.cis.mazeminotaurs.character.classes.Specialist; +import com.example.cis.mazeminotaurs.character.classes.Warrior; import com.example.cis.mazeminotaurs.character.stats.Score; import java.util.ArrayList; @@ -103,7 +107,7 @@ public PlayerCharacter() { /** * Gets the modifier for melee attacks. - * @return int, the melee modifier + * @return the melee modifier */ public int getMeleeMod() { return getScore(Score.MIGHT).getModifier() + @@ -113,7 +117,7 @@ public int getMeleeMod() { /** * Gets the modifier for missile attacks. - * @return int, the missile modifier + * @return the missile modifier */ public int getMissileMod() { return getScore(Score.SKILL).getModifier() + @@ -123,7 +127,7 @@ public int getMissileMod() { /** * Gets initiative of the character. - * @return int, initiative. + * @return initiative. */ public int getInitiative() { return 10 + getScore(Score.SKILL).getModifier() + @@ -132,7 +136,7 @@ public int getInitiative() { /** * Gets the defense class of the character. - * @return int, defense class + * @return defense class */ public int getDC() { return 12 + getScore(Score.LUCK).getModifier(); @@ -140,7 +144,7 @@ public int getDC() { /** * Gets the effective defense class of the character. - * @return int, effective defense class + * @return effective defense class */ public int getEDC() { int armorBonus = 0; @@ -287,6 +291,31 @@ public void setShield(Armor shield) { mShield = shield; } + public Equipment getWeapon() { + return mWeapon; + } + + public void setWeapon(Equipment weapon) { + mWeapon = weapon; + } + + /** + * Checks if the current weapon in mWeapon is a weapon of choice. + * @return true if the weapon is the same as the CharClass's weapon of choice else false + */ + public boolean isWeaponOfChoiceEquipped(){ + if (!(getCharClass() instanceof Magician)) { + if (getCharClass() instanceof Warrior) { + Warrior warrior = (Warrior) getCharClass(); + return warrior.getWeaponOfChoice().getResId() == getWeapon().getResId(); + } else { + Specialist specialist = (Specialist) getCharClass(); + return specialist.getWeaponOfChoice().getResId() == getWeapon().getResId(); + } + } + return false; + } + /** * Checks if a score is maxed out * @param score The score to check diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java index 4303c01..a2d0f88 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Specialist.java @@ -1,11 +1,22 @@ package com.example.cis.mazeminotaurs.character.classes; +import com.example.cis.mazeminotaurs.Weapon; + /** * Created by jusmith on 3/31/17. */ public abstract class Specialist extends BaseClass { private int mSpecialScoreId; + private Weapon mWeaponOfChoice; + + public Weapon getWeaponOfChoice() { + return mWeaponOfChoice; + } + + public void setWeaponOfChoice(Weapon weaponOfChoice) { + mWeaponOfChoice = weaponOfChoice; + } public int getSpecialScoreId() { return mSpecialScoreId; } From 66835638c82f187da432fc837b21de56fb4d7ea0 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Thu, 20 Apr 2017 13:03:17 -0500 Subject: [PATCH 16/18] + Fixed more typos + Added the initializeClass method to ease the burden of switching classes at first. --- .../character/PlayerCharacter.java | 65 ++++++++++++------- .../character/classes/BaseClass.java | 6 +- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java index 22bb92e..64d43e0 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java @@ -17,11 +17,26 @@ import java.util.ArrayList; import java.util.HashMap; -// TODO: Make the equipment equipped -// TODO: Create the method that checks if the weapon equipped is the weapon of choice - /** * Used to hold the data of a player's character. + * + *

Steps to use a player character

+ *
    + *
  • 1: Create a new PlayerCharacter instance
  • + *
  • 2: Create a new subclass of BaseClass instance using the PlayerCharacter instance i.e. Barbarian
  • + *
  • 3: Assign the class to the PlayerCharacter using setCharClass
  • + *
  • 4: Call the PlayerCharacter's initializeClass method
  • + *
  • 5: Your PlayerCharacter is now working!
  • + *
+ * + *

Example:

+ *
    + *
  • PlayerCharacter character = new PlayerCharacter();
  • + *
  • Barbarian barb = new Barbarian(character, [weapon of choice], [ranged weapon]);
  • + *
  • character.setCharClass(character);
  • + *
  • character.initializeClass();
  • + *
+ * * @author Justin Smith */ @@ -64,7 +79,7 @@ public class PlayerCharacter { /** * The character's equipped weapon. */ - private Equipment mWeapon; + private Weapon mWeapon; /** * The helmet that the character is currently wearing. @@ -91,13 +106,12 @@ public PlayerCharacter() { setAge(0); // Purposely inputting improper argument - setCharClass(new Barbarian(this, equipmentDB.getWeapon(R.string.barb_axe), - equipmentDB.getWeapon(R.string.barb_axe))); - setName("Thorin"); - getMoney().put(Money.SILVER, getCharClass().getStartGold()); + setName("Thorin"); - getInventory().addAll(getCharClass().getStartGear()); + setCharClass(new Barbarian(this, equipmentDB.getWeapon(R.string.barb_axe), + equipmentDB.getWeapon(R.string.barb_axe))); + initializeClass(); AttributeScore[] scores = new AttributeScoreGenerator().nextValidSet(); for (int i = 0; i < scores.length; i++) { @@ -163,7 +177,7 @@ public int getEDC() { /** * Gets the total hits of the character - * @return int, total hits. + * @return total hits. */ public int getHitTotal() { //return mCharClass.getHits() + getMod(Score.MIGHT); @@ -172,7 +186,7 @@ public int getHitTotal() { /** * Gets the athletic prowess save score of the character. - * @return int, athletic prowess score + * @return athletic prowess score */ public int getAthleticProwess(){ return getScore(Score.MIGHT).getModifier() + @@ -182,7 +196,7 @@ public int getAthleticProwess(){ /** * Gets the danger evasion save score of the character. - * @return int, danger evasion score + * @return danger evasion score */ public int getDangerEvasion(){ return getScore(Score.WITS).getModifier() + @@ -192,7 +206,7 @@ public int getDangerEvasion(){ /** * Gets the mystic fortitude save score of the character. - * @return int, mystic fortitude score + * @return mystic fortitude score */ public int getMysticFortitude(){ return getScore(Score.WITS).getModifier() + @@ -202,7 +216,7 @@ public int getMysticFortitude(){ /** * Gets the physical vigor save score of the character. - * @return int, physical vigor score + * @return physical vigor score */ public int getPhysicalVigor(){ return getScore(Score.MIGHT).getModifier() + @@ -212,7 +226,7 @@ public int getPhysicalVigor(){ /** * Gets the charisma score of the character. - * @return int, charisma score + * @return charisma score */ public int getCharisma() { return getScore(Score.WILL).getModifier() + @@ -247,6 +261,7 @@ public void setMoney(HashMap money) { } /** * Places the correct keys and values inside of the character's mMoney attribute. + * Will erase any values found in the keys in the map. */ private void initializeMoneyMap() { mMoney.put(Money.COPPER, 0); @@ -260,10 +275,10 @@ public void validateMoney() { HashMap 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); + + int tradedUpGold = cash.get(Money.SILVER) / 100; cash.put(Money.GOLD, cash.get(Money.GOLD) + tradedUpGold); } @@ -291,11 +306,11 @@ public void setShield(Armor shield) { mShield = shield; } - public Equipment getWeapon() { + public Weapon getWeapon() { return mWeapon; } - public void setWeapon(Equipment weapon) { + public void setWeapon(Weapon weapon) { mWeapon = weapon; } @@ -370,10 +385,6 @@ public void setScores(HashMap scores) { } public BaseClass getCharClass() { - if (mCharClass == null) { - setCharClass(new Barbarian(this, EquipmentDB.getInstance().getWeapon(R.string.barb_axe), - EquipmentDB.getInstance().getWeapon(R.string.barb_axe))); - } return mCharClass; } @@ -381,6 +392,14 @@ public void setCharClass(BaseClass aClass) { mCharClass = aClass; } + /** + * A helper method to get the starting gear and starting money of a class added to the character + */ + public void initializeClass(){ + getMoney().put(Money.SILVER, getCharClass().getStartMoney()); + getInventory().addAll(getCharClass().getStartGear()); + } + public int getAge() { return mAge; } diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java index 2e07a15..3b32c13 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/BaseClass.java @@ -10,8 +10,8 @@ /** * Created by jusmith on 3/31/17. * - * Level is the actual of a character - * EffectiveLevel is what level the character will be after handling leveling up + * Level is the actual level of a character + * EffectiveLevel is what level the character should be * * Example of Usage: * Assume: @@ -118,7 +118,7 @@ public void setStartGear(ArrayList startGear) { mStartGear = startGear; } - public int getStartGold() { + public int getStartMoney() { return mStartGold; } From 28fde6c4619be2dd8189e7100cd61d19f4e708ed Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Thu, 20 Apr 2017 13:14:09 -0500 Subject: [PATCH 17/18] + Changed Portfolio to work with the new method of Character Creation --- .../java/com/example/cis/mazeminotaurs/Portfolio.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/Portfolio.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/Portfolio.java index de7d967..24c93b2 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/Portfolio.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/Portfolio.java @@ -1,6 +1,7 @@ package com.example.cis.mazeminotaurs; import com.example.cis.mazeminotaurs.character.PlayerCharacter; +import com.example.cis.mazeminotaurs.character.classes.Barbarian; import java.util.ArrayList; @@ -16,7 +17,13 @@ public class Portfolio { private Portfolio(){ portfolio = new ArrayList<>(); //For Testing Only - portfolio.add(new PlayerCharacter()); + PlayerCharacter playerCharacter = new PlayerCharacter(); + Barbarian barbarian = new Barbarian(playerCharacter, EquipmentDB.getInstance().getWeapon(R.string.barb_axe), + EquipmentDB.getInstance().getWeapon(R.string.barb_axe)); + playerCharacter.setCharClass(barbarian); + playerCharacter.initializeClass(); + + portfolio.add(playerCharacter); } public static Portfolio get(){ From dcf49f40a0eda876f8c72272d7e581fa24f92353 Mon Sep 17 00:00:00 2001 From: JayTSmith Date: Mon, 24 Apr 2017 11:26:36 -0500 Subject: [PATCH 18/18] + Changed mWeapon to mCurrentWeapon + Added getWeapons method to PlayerCharacter + Fixed issue where PlayerCharacter wouldn't have a weapon equipped. --- .../mazeminotaurs/AttackResultFragment.java | 6 ++-- .../mazeminotaurs/CharacterSheetFragment.java | 8 ++--- .../character/PlayerCharacter.java | 33 ++++++++++++------- .../character/classes/Barbarian.java | 14 -------- 4 files changed, 28 insertions(+), 33 deletions(-) diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/AttackResultFragment.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/AttackResultFragment.java index 4d56203..71f6f97 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/AttackResultFragment.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/AttackResultFragment.java @@ -50,16 +50,16 @@ public void onCreate(Bundle savedInstanceState){ mPortfolio = Portfolio.get(); mCurrentCharacter = mPortfolio.getPlayerCharacter(mCurrentCharacterIndex); - if(mCurrentCharacter.getWeapon().getWeaponType() == R.string.melee){ + if(mCurrentCharacter.getCurrentWeapon().getWeaponType() == R.string.melee){ mMod = mCurrentCharacter.getMeleeMod(); } - else if(mCurrentCharacter.getWeapon().getWeaponType() == R.string.missile){ + else if(mCurrentCharacter.getCurrentWeapon().getWeaponType() == R.string.missile){ mMod = mCurrentCharacter.getMissileMod(); } else {//this should never happen mMod = -10; } - mAttackType = getString(mCurrentCharacter.getWeapon().getWeaponType()); + mAttackType = getString(mCurrentCharacter.getCurrentWeapon().getWeaponType()); mAttackRoll1 = Util.roll(20); mAttackRoll2 = Util.roll(20); mDamage1 = Util.roll(6); diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java index 2dbd555..ef56f78 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java @@ -127,10 +127,10 @@ public void onClick(View v){ }); mAttackType = (TextView) rootView.findViewById(R.id.attack_title_view); - mAttackType.setText(mSheetPlayerCharacter.getWeapon().getWeaponType()); + mAttackType.setText(mSheetPlayerCharacter.getCurrentWeapon().getWeaponType()); mAttackButton = (Button) rootView.findViewById(R.id.attack_button); - if(mSheetPlayerCharacter.getWeapon().getWeaponType() == R.string.melee) { + if(mSheetPlayerCharacter.getCurrentWeapon().getWeaponType() == R.string.melee) { mAttackButton.setText(Integer.toString(mSheetPlayerCharacter.getMeleeMod())); } else{ @@ -140,7 +140,7 @@ public void onClick(View v){ @Override public void onClick(View v){ //just for testing, replace these with calls to character methods - int weaponType = mSheetPlayerCharacter.getWeapon().getWeaponType(); + int weaponType = mSheetPlayerCharacter.getCurrentWeapon().getWeaponType(); boolean woc = true; onAttackClick(weaponType, woc); } @@ -149,7 +149,7 @@ public void onClick(View v){ mEquippedWeaponButton = (Button) rootView.findViewById(R.id.equipped_weapon_button); //Get equipped weapon from character Class //int equippedWeaponID = R.string.barb_axe; - Weapon equippedWeapon = mSheetPlayerCharacter.getWeapon(); + Weapon equippedWeapon = mSheetPlayerCharacter.getCurrentWeapon(); Log.i(TAG, equippedWeapon.toString()); int equippedWeaponID = equippedWeapon.getResId(); mEquippedWeaponButton.setText(equippedWeaponID); diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java index 538bdf1..8e6bdea 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/PlayerCharacter.java @@ -33,11 +33,7 @@ *
    *
  • PlayerCharacter character = new PlayerCharacter();
  • *
  • Barbarian barb = new Barbarian(character, [weapon of choice], [ranged weapon]);
  • -<<<<<<< HEAD - *
  • character.setCharClass(character);
  • -======= *
  • character.setCharClass(barb);
  • ->>>>>>> 392d6a61fd8487bc403e2396b6cfcc5173c0f16d *
  • character.initializeClass();
  • *
* @@ -83,7 +79,7 @@ public class PlayerCharacter { /** * The character's equipped weapon. */ - private Weapon mWeapon; + private Weapon mCurrentWeapon; /** * The helmet that the character is currently wearing. @@ -310,26 +306,26 @@ public void setShield(Armor shield) { mShield = shield; } - public Weapon getWeapon() { - return mWeapon; + public Weapon getCurrentWeapon() { + return mCurrentWeapon; } - public void setWeapon(Weapon weapon) { - mWeapon = weapon; + public void setCurrentWeapon(Weapon currentWeapon) { + mCurrentWeapon = currentWeapon; } /** - * Checks if the current weapon in mWeapon is a weapon of choice. + * Checks if the current weapon in mCurrentWeapon is a weapon of choice. * @return true if the weapon is the same as the CharClass's weapon of choice else false */ public boolean isWeaponOfChoiceEquipped(){ if (!(getCharClass() instanceof Magician)) { if (getCharClass() instanceof Warrior) { Warrior warrior = (Warrior) getCharClass(); - return warrior.getWeaponOfChoice().getResId() == getWeapon().getResId(); + return warrior.getWeaponOfChoice().getResId() == getCurrentWeapon().getResId(); } else { Specialist specialist = (Specialist) getCharClass(); - return specialist.getWeaponOfChoice().getResId() == getWeapon().getResId(); + return specialist.getWeaponOfChoice().getResId() == getCurrentWeapon().getResId(); } } return false; @@ -402,6 +398,19 @@ public void setCharClass(BaseClass aClass) { public void initializeClass(){ getMoney().put(Money.SILVER, getCharClass().getStartMoney()); getInventory().addAll(getCharClass().getStartGear()); + setCurrentWeapon(getWeapons().get(0)); + } + + public ArrayList getWeapons(){ + ArrayList weaponsFound = new ArrayList<>(); + + for (Equipment equipment: getInventory()) { + if (equipment instanceof Weapon) { + weaponsFound.add((Weapon) equipment); + } + } + + return weaponsFound; } public int getAge() { diff --git a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java index b400abf..79268b6 100644 --- a/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java +++ b/MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/character/classes/Barbarian.java @@ -39,11 +39,6 @@ public Barbarian(PlayerCharacter playerCharacter, Weapon weaponOfChoice, Weapon } startingEquipment.add(weaponOfChoice); -<<<<<<< HEAD -======= - - ->>>>>>> 392d6a61fd8487bc403e2396b6cfcc5173c0f16d if (Arrays.asList(possibleRanged).contains(rangedChoice)){ switch (rangedChoice.getResId()) { case R.string.bow: @@ -65,16 +60,11 @@ public Barbarian(PlayerCharacter playerCharacter, Weapon weaponOfChoice, Weapon rolledGold += Util.roll(6); } -<<<<<<< HEAD -======= //Add the rest of starting equipment startingEquipment.add(equipDB.getWeapon(R.string.dagger)); startingEquipment.add(equipDB.getArmor(R.string.shield)); ->>>>>>> 392d6a61fd8487bc403e2396b6cfcc5173c0f16d - setBasicHits(12); - playerCharacter.setWeapon(weaponOfChoice); setCharacter(playerCharacter); setPrimaryAttributes(primAttributes); setRequiredGender(Gender.MALE); @@ -82,10 +72,6 @@ public Barbarian(PlayerCharacter playerCharacter, Weapon weaponOfChoice, Weapon setStartGold(rolledGold * 5); setStartGear(startingEquipment); setWeaponOfChoice(EquipmentDB.getInstance().getWeapon(R.string.barb_axe)); -<<<<<<< HEAD -======= - ->>>>>>> 392d6a61fd8487bc403e2396b6cfcc5173c0f16d } public void doLevelUp(){