From 0907b0978d58179b92e5b55706cb848c26e86342 Mon Sep 17 00:00:00 2001 From: life Date: Wed, 4 Jan 2017 01:29:46 +0200 Subject: [PATCH 01/32] Skills, Inventory, and Shops now have the Sort & Category options in the UI. --- .../res/layout-land/heroinfo_inventory.xml | 30 ++ AndorsTrail/res/layout/heroinfo_inventory.xml | 33 +++ .../res/layout/heroinfo_skill_list.xml | 68 ++++- AndorsTrail/res/layout/shoplist.xml | 44 ++- AndorsTrail/res/menu/inventoryitem.xml | 2 +- AndorsTrail/res/values/arrays.xml | 51 ++++ AndorsTrail/res/values/strings.xml | 40 +++ .../fragment/HeroinfoActivity_Skills.java | 98 ++++++- .../fragment/ShopActivityFragment.java | 30 ++ .../rpg/AndorsTrail/model/InterfaceData.java | 8 + .../model/ability/SkillCollection.java | 260 +++++++++--------- .../AndorsTrail/model/ability/SkillInfo.java | 11 +- .../rpg/AndorsTrail/model/item/Inventory.java | 109 ++++++-- .../AndorsTrail/model/item/ItemContainer.java | 114 ++++++++ .../view/ItemContainerAdapter.java | 45 +++ .../view/ShopItemContainerAdapter.java | 4 + .../AndorsTrail/view/SkillListAdapter.java | 76 ++++- 17 files changed, 829 insertions(+), 194 deletions(-) diff --git a/AndorsTrail/res/layout-land/heroinfo_inventory.xml b/AndorsTrail/res/layout-land/heroinfo_inventory.xml index c48730d39..c6304089a 100644 --- a/AndorsTrail/res/layout-land/heroinfo_inventory.xml +++ b/AndorsTrail/res/layout-land/heroinfo_inventory.xml @@ -13,6 +13,36 @@ android:gravity="left" > + + + + + + + + + + + + + - + + + android:layout_marginBottom="5dp" + android:layout_marginTop="10dp" + android:gravity="right" + android:orientation="horizontal"> + + + + + + + + + + + + android:layout_width="match_parent" + android:layout_height="wrap_content" /> - + \ No newline at end of file diff --git a/AndorsTrail/res/layout/shoplist.xml b/AndorsTrail/res/layout/shoplist.xml index 2b871b54f..13e880ad7 100644 --- a/AndorsTrail/res/layout/shoplist.xml +++ b/AndorsTrail/res/layout/shoplist.xml @@ -1,26 +1,42 @@ - + android:orientation="vertical"> - + android:layout_marginBottom="5dp" + android:layout_marginTop="10dp" + android:gravity="right" + android:orientation="horizontal" + android:layout_alignParentRight="true"> + + + + + + android:layout_height="wrap_content" /> diff --git a/AndorsTrail/res/menu/inventoryitem.xml b/AndorsTrail/res/menu/inventoryitem.xml index 2b03c4eb0..a4b1ef89a 100644 --- a/AndorsTrail/res/menu/inventoryitem.xml +++ b/AndorsTrail/res/menu/inventoryitem.xml @@ -16,4 +16,4 @@ - + \ No newline at end of file diff --git a/AndorsTrail/res/values/arrays.xml b/AndorsTrail/res/values/arrays.xml index da1fd0406..fd5367d8e 100644 --- a/AndorsTrail/res/values/arrays.xml +++ b/AndorsTrail/res/values/arrays.xml @@ -8,6 +8,57 @@ @string/questlog_includecompleted_onlycompleted + + + @string/inventory_category_all + @string/inventory_category_favorites + @string/inventory_category_weapons + @string/inventory_category_armor + @string/inventory_category_usable + @string/inventory_category_quest + @string/inventory_category_other + + + + + @string/inventory_sort_custom + @string/inventory_sort_name + @string/inventory_sort_price + @string/inventory_sort_quantity + @string/inventory_sort_rarity + @string/inventory_sort_type + + + + + @string/skill_category_all + @string/skill_category_offense + @string/skill_category_defense + @string/skill_category_criticals + @string/skill_category_immunity + @string/skill_category_utility + @string/skill_category_speciality + @string/skill_category_proficiency + + + + + @string/skill_sort_unsorted + @string/skill_sort_name + @string/skill_sort_points + @string/skill_sort_unlocked + + + + + @string/shoplist_sort_custom + @string/shoplist_sort_name + @string/shoplist_sort_price + @string/shoplist_sort_quantity + @string/shoplist_sort_rarity + @string/shoplist_sort_type + + @string/preferences_display_loot_dialog @string/preferences_display_loot_dialog_on_items diff --git a/AndorsTrail/res/values/strings.xml b/AndorsTrail/res/values/strings.xml index b19ccd1ce..751416edf 100644 --- a/AndorsTrail/res/values/strings.xml +++ b/AndorsTrail/res/values/strings.xml @@ -33,11 +33,15 @@ Overview Items Skills + Category + Sort Level up Level Total experience Worn equipment Inventory + Category + Sort By Gold: %1$d Action points (AP): Quests @@ -142,6 +146,7 @@ Your gold: %1$d %1$s bought. %1$s sold. + Sort Level up Welcome to level %1$d! @@ -630,4 +635,39 @@ Every skill level increases the attack chance of weapons with %1$d %% of their o Use translation of interface and content, where available. (requires restart) Changing locale requires restart. Andor\'s Trail has been closed. + All + Favorites + Weapon + Armor + Consumable + Quest Item + Other + + Unsorted + Name + Price + Quantity + Rarity + Type + + Unsorted + Name + Price + Quantity + Rarity + Type + + All + Offense + Defense + Criticals + Immunity + Utility + Speciality + Proficiency + + Unsorted + Name + Points + Unlocked diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java index 6bd30e740..219d65539 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java @@ -9,7 +9,9 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; import android.widget.ListView; +import android.widget.Spinner; import android.widget.TextView; import com.gpl.rpg.AndorsTrail.AndorsTrailApplication; import com.gpl.rpg.AndorsTrail.Dialogs; @@ -20,6 +22,9 @@ import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection; import com.gpl.rpg.AndorsTrail.model.actor.Player; import com.gpl.rpg.AndorsTrail.view.SkillListAdapter; +import java.util.ArrayList; + + public final class HeroinfoActivity_Skills extends Fragment { private static final int INTENTREQUEST_SKILLINFO = 12; @@ -28,7 +33,10 @@ public final class HeroinfoActivity_Skills extends Fragment { private ControllerContext controllers; private Player player; - private SkillListAdapter skillListAdapter; + ListView skillList; + private ArrayList skillListCategoryViewsAdapters = new ArrayList(); + private Spinner skillList_categories; + private Spinner skillList_sort; private TextView listskills_number_of_increases; @Override @@ -46,13 +54,62 @@ public final class HeroinfoActivity_Skills extends Fragment { View v = inflater.inflate(R.layout.heroinfo_skill_list, container, false); final Activity ctx = getActivity(); - skillListAdapter = new SkillListAdapter(ctx, world.skills.getAllSkills(), player); - ListView skillList = (ListView) v.findViewById(R.id.heroinfo_listskills_list); - skillList.setAdapter(skillListAdapter); + + //Initiating drop-down list for category filters + skillList_categories = (Spinner) v.findViewById(R.id.skillList_category_filters); + ArrayAdapter skillCategoryFilterAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.skill_category_filters, android.R.layout.simple_spinner_item); + skillCategoryFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + skillList_categories.setAdapter(skillCategoryFilterAdapter); + skillList_categories.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) { + world.model.uiSelections.selectedSkillCategory = skillList_categories.getSelectedItemPosition(); + reloadShownCategory(); + } + + @Override + public void onNothingSelected(AdapterView arg0) { + world.model.uiSelections.selectedSkillCategory = 0; + } + }); + skillList_categories.setSelection(world.model.uiSelections.selectedSkillCategory); + + for(int i = 0; i< SkillCollection.SkillCategory.values().length; i++){ + // Creates a list of adapters for each category. + // The adapter at position 0 has all items. + // length + 1 in order to create an extra position for "all" + skillListCategoryViewsAdapters.add( + new SkillListAdapter(ctx, world.skills.getAllSkills(), player, i)); + } + + + //Initiating drop-down list for sort filters + skillList_sort = (Spinner) v.findViewById(R.id.skillList_sort_filters); + ArrayAdapter skillSortFilterAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.skill_sort_filters, android.R.layout.simple_spinner_item); + skillSortFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + skillList_sort.setAdapter(skillSortFilterAdapter); + skillList_sort.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) { + world.model.uiSelections.selectedSkillSort = skillList_sort.getSelectedItemPosition(); + reloadShownSort(); //Yet to be implemented + } + + @Override + public void onNothingSelected(AdapterView arg0) { + world.model.uiSelections.selectedSkillSort = 0; + } + }); + skillList_sort.setSelection(world.model.uiSelections.selectedSkillSort); + + + skillList = (ListView) v.findViewById(R.id.heroinfo_listskills_list); + skillList.setAdapter(getCurrentCategoryAdapter()); skillList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View v, int position, long id) { - Intent intent = Dialogs.getIntentForSkillInfo(ctx, skillListAdapter.getItem(position).id); + Intent intent = Dialogs.getIntentForSkillInfo(ctx, + getCurrentCategoryAdapter().getItem(position).id); startActivityForResult(intent, INTENTREQUEST_SKILLINFO); } }); @@ -60,6 +117,25 @@ public final class HeroinfoActivity_Skills extends Fragment { return v; } + private void reloadShownSort() { + int v = world.model.uiSelections.selectedSkillSort; + if(v ==0); + if(v==1) getCurrentCategoryAdapter().sortByName(); + if(v==2) getCurrentCategoryAdapter().sortByPoints(); + if(v==3) getCurrentCategoryAdapter().sortByUnlocked(); + + updateSkillList(); + } + + private void reloadShownCategory() { + skillList.setAdapter(getCurrentCategoryAdapter()); + updateSkillList(); + } + private SkillListAdapter getCurrentCategoryAdapter(){ + return skillListCategoryViewsAdapters.get( + world.model.uiSelections.selectedSkillCategory); + } + @Override public void onStart() { super.onStart(); @@ -70,12 +146,12 @@ public final class HeroinfoActivity_Skills extends Fragment { public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { - case INTENTREQUEST_SKILLINFO: - if (resultCode != Activity.RESULT_OK) break; + case INTENTREQUEST_SKILLINFO: + if (resultCode != Activity.RESULT_OK) break; - SkillCollection.SkillID skillID = SkillCollection.SkillID.valueOf(data.getExtras().getString("skillID")); - controllers.skillController.levelUpSkillManually(player, world.skills.getSkill(skillID)); - break; + SkillCollection.SkillID skillID = SkillCollection.SkillID.valueOf(data.getExtras().getString("skillID")); + controllers.skillController.levelUpSkillManually(player, world.skills.getSkill(skillID)); + break; } update(); } @@ -96,6 +172,6 @@ public final class HeroinfoActivity_Skills extends Fragment { } else { listskills_number_of_increases.setVisibility(View.GONE); } - skillListAdapter.notifyDataSetInvalidated(); + getCurrentCategoryAdapter().notifyDataSetInvalidated(); } } \ No newline at end of file diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/ShopActivityFragment.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/ShopActivityFragment.java index 2cc0ba64e..1aa5476f3 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/ShopActivityFragment.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/ShopActivityFragment.java @@ -6,7 +6,10 @@ import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.ListView; +import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; import com.gpl.rpg.AndorsTrail.AndorsTrailApplication; @@ -17,6 +20,7 @@ import com.gpl.rpg.AndorsTrail.model.actor.Monster; import com.gpl.rpg.AndorsTrail.model.actor.Player; import com.gpl.rpg.AndorsTrail.model.item.ItemContainer; import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection; +import com.gpl.rpg.AndorsTrail.view.ItemContainerAdapter; import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter; import com.gpl.rpg.AndorsTrail.view.ShopItemContainerAdapter.OnContainerItemClickedListener; @@ -33,6 +37,7 @@ public abstract class ShopActivityFragment extends Fragment implements OnContain protected ItemContainer shopInventory; private TextView shop_gc; private ShopItemContainerAdapter listAdapter; + private Spinner shoplist_sort; protected abstract boolean isSellingInterface(); @@ -66,9 +71,34 @@ public abstract class ShopActivityFragment extends Fragment implements OnContain final boolean isSelling = isSellingInterface(); listAdapter = new ShopItemContainerAdapter(getActivity(), tiles, world.tileManager, player, isSelling ? player.inventory : shopInventory, this, isSelling); shoplist.setAdapter(listAdapter); + + //Initiating drop-down list for category filters + shoplist_sort = (Spinner) v.findViewById(R.id.shoplist_sort_filters); + ArrayAdapter sortFilterAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.shoplist_sort_filters, android.R.layout.simple_spinner_item); + sortFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + shoplist_sort.setAdapter(sortFilterAdapter); + shoplist_sort.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) { + world.model.uiSelections.selectedShopSort = shoplist_sort.getSelectedItemPosition(); + reloadShownSort(isSelling ? player.inventory : shopInventory); + } + + @Override + public void onNothingSelected(AdapterView arg0) { + world.model.uiSelections.selectedShopSort = 0; + } + }); + shoplist_sort.setSelection(world.model.uiSelections.selectedShopSort); + return v; } + private void reloadShownSort(ItemContainer itemContainer) { + listAdapter.reloadShownSort(world.model.uiSelections.selectedShopSort, itemContainer, player); + listAdapter.notifyDataSetChanged(); + } + @Override public void onStart() { super.onStart(); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/InterfaceData.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/InterfaceData.java index 532544b39..3d368fc47 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/InterfaceData.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/InterfaceData.java @@ -1,6 +1,7 @@ package com.gpl.rpg.AndorsTrail.model; import com.gpl.rpg.AndorsTrail.model.actor.Monster; +import com.gpl.rpg.AndorsTrail.model.item.Inventory; import com.gpl.rpg.AndorsTrail.util.Coord; import java.io.DataInputStream; @@ -16,6 +17,13 @@ public final class InterfaceData { public String selectedTabHeroInfo = ""; public int selectedQuestFilter = 0; // Should not be parceled + public int selectedInventoryCategory = 0; //All + public int selectedInventorySort = 0; //Unsorted + public int oldSortSelection = 0; // Later will be used for reversing ascending/descending order + public int selectedSkillCategory = 0; //All + public int selectedSkillSort = 0; //Unsorted + public int selectedShopSort = 0; //Unsorted + public InterfaceData() { } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java index 7a3f75e1e..5112aa19e 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java @@ -11,49 +11,63 @@ import java.util.Collection; public final class SkillCollection { public static enum SkillID { weaponChance - ,weaponDmg - ,barter - ,dodge - ,barkSkin - ,moreCriticals - ,betterCriticals - ,speed // Raises max ap - ,coinfinder - ,moreExp - ,cleave // +10ap on kill - ,eater // +1hp per kill - ,fortitude // +N hp per levelup - ,evasion // increase successful flee chance & reduce chance of monster attack - ,regeneration // +N hp per round - ,lowerExploss - ,magicfinder - ,resistanceMental // lowers chance to get negative active conditions by monsters (Mental like Dazed) - ,resistancePhysical // lowers chance to get negative active conditions by monsters (Physical Capacity like Minor fatigue) - ,resistanceBlood // lowers chance to get negative active conditions by monsters (Blood Disorder like Weak Poison) - ,shadowBless - ,crit1 // lowers atk ability - ,crit2 // lowers def ability ,rejuvenation // Reduces magnitudes of conditions - ,rejuvenation // Reduces magnitudes of conditions - ,taunt // Causes AP loss of attackers that miss - ,concussion // AC loss for monsters with (AC-BC)>N - ,weaponProficiencyDagger - ,weaponProficiency1hsword - ,weaponProficiency2hsword - ,weaponProficiencyAxe - ,weaponProficiencyBlunt - ,weaponProficiencyUnarmed - ,armorProficiencyShield - ,armorProficiencyUnarmored - ,armorProficiencyLight - ,armorProficiencyHeavy - ,fightstyleDualWield - ,fightstyle2hand - ,fightstyleWeaponShield - ,specializationDualWield - ,specialization2hand - ,specializationWeaponShield + ,weaponDmg + ,barter + ,dodge + ,barkSkin + ,moreCriticals + ,betterCriticals + ,speed // Raises max ap + ,coinfinder + ,moreExp + ,cleave // +10ap on kill + ,eater // +1hp per kill + ,fortitude // +N hp per levelup + ,evasion // increase successful flee chance & reduce chance of monster attack + ,regeneration // +N hp per round + ,lowerExploss + ,magicfinder + ,resistanceMental // lowers chance to get negative active conditions by monsters (Mental like Dazed) + ,resistancePhysical // lowers chance to get negative active conditions by monsters (Physical Capacity like Minor fatigue) + ,resistanceBlood // lowers chance to get negative active conditions by monsters (Blood Disorder like Weak Poison) + ,shadowBless + ,crit1 // lowers atk ability + ,crit2 // lowers def ability ,rejuvenation // Reduces magnitudes of conditions + ,rejuvenation // Reduces magnitudes of conditions + ,taunt // Causes AP loss of attackers that miss + ,concussion // AC loss for monsters with (AC-BC)>N + ,weaponProficiencyDagger + ,weaponProficiency1hsword + ,weaponProficiency2hsword + ,weaponProficiencyAxe + ,weaponProficiencyBlunt + ,weaponProficiencyUnarmed + ,armorProficiencyShield + ,armorProficiencyUnarmored + ,armorProficiencyLight + ,armorProficiencyHeavy + ,fightstyleDualWield + ,fightstyle2hand + ,fightstyleWeaponShield + ,specializationDualWield + ,specialization2hand + ,specializationWeaponShield } + // should be in the same number &U order as in arrays.xml + public static enum SkillCategory { + all, // filler value -- don't use + offense, + defense, + criticals, + immunity, //fortitude? + utility, // efficiency? + specialty, + proficiency + } + + + public static final int PER_SKILLPOINT_INCREASE_WEAPON_CHANCE = 12; public static final int PER_SKILLPOINT_INCREASE_WEAPON_DAMAGE_MAX = 2; public static final int PER_SKILLPOINT_INCREASE_WEAPON_DAMAGE_MIN = 0; @@ -115,7 +129,7 @@ public final class SkillCollection { private static final int MAX_LEVEL_EVASION = Math.max( Constants.FLEE_FAIL_CHANCE_PERCENT / PER_SKILLPOINT_INCREASE_EVASION_FLEE_CHANCE_PERCENTAGE ,Constants.MONSTER_AGGRESSION_CHANCE_PERCENT / PER_SKILLPOINT_INCREASE_EVASION_MONSTER_ATTACK_CHANCE_PERCENTAGE - ); + ); public static final int MAX_LEVEL_LOWER_EXPLOSS = 100 / PER_SKILLPOINT_INCREASE_EXPLOSS_PERCENT; public static final int MAX_LEVEL_RESISTANCE = 70 / PER_SKILLPOINT_INCREASE_RESISTANCE_CHANCE_PERCENT; @@ -124,98 +138,98 @@ public final class SkillCollection { skills.put(skill.id.ordinal(), skill); } public void initialize() { - initializeSkill(new SkillInfo(SkillID.weaponChance, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.weaponDmg, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.barter, MAX_LEVEL_BARTER, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.dodge, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.barkSkin, MAX_LEVEL_BARKSKIN, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requireExperienceLevels(10, 0) - ,SkillLevelRequirement.requirePlayerStats(Player.StatID.blockChance, 15, 0) + initializeSkill(new SkillInfo(SkillID.weaponChance, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, null)); + initializeSkill(new SkillInfo(SkillID.weaponDmg, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, null)); + initializeSkill(new SkillInfo(SkillID.barter, MAX_LEVEL_BARTER, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null)); + initializeSkill(new SkillInfo(SkillID.dodge, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, null)); + initializeSkill(new SkillInfo(SkillID.barkSkin, MAX_LEVEL_BARKSKIN, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, new SkillLevelRequirement[] { + SkillLevelRequirement.requireExperienceLevels(10, 0) + ,SkillLevelRequirement.requirePlayerStats(Player.StatID.blockChance, 15, 0) })); - initializeSkill(new SkillInfo(SkillID.moreCriticals, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.betterCriticals, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 1) + initializeSkill(new SkillInfo(SkillID.moreCriticals, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, null)); + initializeSkill(new SkillInfo(SkillID.betterCriticals, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] { + SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 1) })); - initializeSkill(new SkillInfo(SkillID.speed, MAX_LEVEL_SPEED, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requireExperienceLevels(15, 0) - })); - initializeSkill(new SkillInfo(SkillID.coinfinder, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.moreExp, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.cleave, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.weaponChance, 1) - ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponDmg, 1) - })); - initializeSkill(new SkillInfo(SkillID.eater, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requirePlayerStats(Player.StatID.maxHP, 20, 20) - })); - initializeSkill(new SkillInfo(SkillID.fortitude, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requireExperienceLevels(15, -10) - })); - initializeSkill(new SkillInfo(SkillID.evasion, MAX_LEVEL_EVASION, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.regeneration, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requirePlayerStats(Player.StatID.maxHP, 30, 0) - ,SkillLevelRequirement.requireOtherSkill(SkillID.fortitude, 1) - })); - initializeSkill(new SkillInfo(SkillID.lowerExploss, MAX_LEVEL_LOWER_EXPLOSS, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.magicfinder, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.resistanceMental, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.resistancePhysical, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.resistanceBlood, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, null)); - initializeSkill(new SkillInfo(SkillID.shadowBless, 1, SkillInfo.LevelUpType.onlyByQuests, null)); - initializeSkill(new SkillInfo(SkillID.crit1, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 3) - ,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 3) - })); - initializeSkill(new SkillInfo(SkillID.crit2, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 6) - ,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 6) - ,SkillLevelRequirement.requireOtherSkill(SkillID.crit1, 1) - })); - initializeSkill(new SkillInfo(SkillID.rejuvenation, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.resistanceBlood, 3) - ,SkillLevelRequirement.requireOtherSkill(SkillID.resistanceMental, 3) - ,SkillLevelRequirement.requireOtherSkill(SkillID.resistancePhysical, 3) - })); - initializeSkill(new SkillInfo(SkillID.taunt, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.evasion, 2) - ,SkillLevelRequirement.requireOtherSkill(SkillID.dodge, 4) - })); - initializeSkill(new SkillInfo(SkillID.concussion, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.speed, 2) - ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponChance, 3) - ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponDmg, 5) - })); - initializeSkill(new SkillInfo(SkillID.weaponProficiencyDagger, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null)); - initializeSkill(new SkillInfo(SkillID.weaponProficiency1hsword, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null)); - initializeSkill(new SkillInfo(SkillID.weaponProficiency2hsword, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null)); - initializeSkill(new SkillInfo(SkillID.weaponProficiencyAxe, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null)); - initializeSkill(new SkillInfo(SkillID.weaponProficiencyBlunt, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null)); - initializeSkill(new SkillInfo(SkillID.weaponProficiencyUnarmed, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null)); - initializeSkill(new SkillInfo(SkillID.armorProficiencyShield, 2, SkillInfo.LevelUpType.firstLevelRequiresQuest, null)); - initializeSkill(new SkillInfo(SkillID.armorProficiencyUnarmored, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null)); - initializeSkill(new SkillInfo(SkillID.armorProficiencyLight, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, null)); - initializeSkill(new SkillInfo(SkillID.armorProficiencyHeavy, 4, SkillInfo.LevelUpType.firstLevelRequiresQuest, null)); - initializeSkill(new SkillInfo(SkillID.fightstyleDualWield, 2, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { + initializeSkill(new SkillInfo(SkillID.speed, MAX_LEVEL_SPEED, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(15, 0) - })); - initializeSkill(new SkillInfo(SkillID.fightstyle2hand, 2, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { + })); + initializeSkill(new SkillInfo(SkillID.coinfinder, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null)); + initializeSkill(new SkillInfo(SkillID.moreExp, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null)); + initializeSkill(new SkillInfo(SkillID.cleave, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, new SkillLevelRequirement[] { + SkillLevelRequirement.requireOtherSkill(SkillID.weaponChance, 1) + ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponDmg, 1) + })); + initializeSkill(new SkillInfo(SkillID.eater, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] { + SkillLevelRequirement.requirePlayerStats(Player.StatID.maxHP, 20, 20) + })); + initializeSkill(new SkillInfo(SkillID.fortitude, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] { + SkillLevelRequirement.requireExperienceLevels(15, -10) + })); + initializeSkill(new SkillInfo(SkillID.evasion, MAX_LEVEL_EVASION, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, null)); + initializeSkill(new SkillInfo(SkillID.regeneration, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] { + SkillLevelRequirement.requirePlayerStats(Player.StatID.maxHP, 30, 0) + ,SkillLevelRequirement.requireOtherSkill(SkillID.fortitude, 1) + })); + initializeSkill(new SkillInfo(SkillID.lowerExploss, MAX_LEVEL_LOWER_EXPLOSS, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null)); + initializeSkill(new SkillInfo(SkillID.magicfinder, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null)); + initializeSkill(new SkillInfo(SkillID.resistanceMental, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, null)); + initializeSkill(new SkillInfo(SkillID.resistancePhysical, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, null)); + initializeSkill(new SkillInfo(SkillID.resistanceBlood, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, null)); + initializeSkill(new SkillInfo(SkillID.shadowBless, 1, SkillInfo.LevelUpType.onlyByQuests, SkillCategory.immunity, null)); + initializeSkill(new SkillInfo(SkillID.crit1, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] { + SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 3) + ,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 3) + })); + initializeSkill(new SkillInfo(SkillID.crit2, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] { + SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 6) + ,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 6) + ,SkillLevelRequirement.requireOtherSkill(SkillID.crit1, 1) + })); + initializeSkill(new SkillInfo(SkillID.rejuvenation, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] { + SkillLevelRequirement.requireOtherSkill(SkillID.resistanceBlood, 3) + ,SkillLevelRequirement.requireOtherSkill(SkillID.resistanceMental, 3) + ,SkillLevelRequirement.requireOtherSkill(SkillID.resistancePhysical, 3) + })); + initializeSkill(new SkillInfo(SkillID.taunt, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, new SkillLevelRequirement[] { + SkillLevelRequirement.requireOtherSkill(SkillID.evasion, 2) + ,SkillLevelRequirement.requireOtherSkill(SkillID.dodge, 4) + })); + initializeSkill(new SkillInfo(SkillID.concussion, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, new SkillLevelRequirement[] { + SkillLevelRequirement.requireOtherSkill(SkillID.speed, 2) + ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponChance, 3) + ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponDmg, 5) + })); + initializeSkill(new SkillInfo(SkillID.weaponProficiencyDagger, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); + initializeSkill(new SkillInfo(SkillID.weaponProficiency1hsword, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); + initializeSkill(new SkillInfo(SkillID.weaponProficiency2hsword, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); + initializeSkill(new SkillInfo(SkillID.weaponProficiencyAxe, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); + initializeSkill(new SkillInfo(SkillID.weaponProficiencyBlunt, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); + initializeSkill(new SkillInfo(SkillID.weaponProficiencyUnarmed, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); + initializeSkill(new SkillInfo(SkillID.armorProficiencyShield, 2, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); + initializeSkill(new SkillInfo(SkillID.armorProficiencyUnarmored, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); + initializeSkill(new SkillInfo(SkillID.armorProficiencyLight, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); + initializeSkill(new SkillInfo(SkillID.armorProficiencyHeavy, 4, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); + initializeSkill(new SkillInfo(SkillID.fightstyleDualWield, 2, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(15, 0) - })); - initializeSkill(new SkillInfo(SkillID.fightstyleWeaponShield, 2, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { + })); + initializeSkill(new SkillInfo(SkillID.fightstyle2hand, 2, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(15, 0) - })); - initializeSkill(new SkillInfo(SkillID.specializationDualWield, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { + })); + initializeSkill(new SkillInfo(SkillID.fightstyleWeaponShield, 2, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { + SkillLevelRequirement.requireExperienceLevels(15, 0) + })); + initializeSkill(new SkillInfo(SkillID.specializationDualWield, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(45, 0) ,SkillLevelRequirement.requireOtherSkill(SkillID.fightstyleDualWield, 2) - })); - initializeSkill(new SkillInfo(SkillID.specialization2hand, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { + })); + initializeSkill(new SkillInfo(SkillID.specialization2hand, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(45, 0) ,SkillLevelRequirement.requireOtherSkill(SkillID.fightstyle2hand, 2) - })); - initializeSkill(new SkillInfo(SkillID.specializationWeaponShield, 1, SkillInfo.LevelUpType.alwaysShown, new SkillLevelRequirement[] { + })); + initializeSkill(new SkillInfo(SkillID.specializationWeaponShield, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(45, 0) ,SkillLevelRequirement.requireOtherSkill(SkillID.fightstyleWeaponShield, 2) - })); + })); } public SkillInfo getSkill(SkillID skillID) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java index 2df7e0cfd..dcdbc40b5 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java @@ -14,16 +14,19 @@ public final class SkillInfo { public final int maxLevel; public final LevelUpType levelupVisibility; public final SkillLevelRequirement[] levelupRequirements; + public final SkillCollection.SkillCategory categoryType; public SkillInfo( SkillCollection.SkillID id , int maxLevel , LevelUpType levelupVisibility + , SkillCollection.SkillCategory categoryType , SkillLevelRequirement[] levelupRequirements ) { this.id = id; this.maxLevel = maxLevel; this.levelupVisibility = levelupVisibility; this.levelupRequirements = levelupRequirements; + this.categoryType = categoryType; } public boolean hasMaxLevel() { @@ -85,10 +88,10 @@ public final class SkillInfo { private int getRequirementActualValue(Player player) { switch (requirementType) { - case skillLevel: return player.getSkillLevel(SkillCollection.SkillID.valueOf(skillOrStatID)); - case experienceLevel: return player.getLevel(); - case playerStat: return player.getStatValue(Player.StatID.valueOf(skillOrStatID)); - default: return 0; + case skillLevel: return player.getSkillLevel(SkillCollection.SkillID.valueOf(skillOrStatID)); + case experienceLevel: return player.getLevel(); + case playerStat: return player.getStatValue(Player.StatID.valueOf(skillOrStatID)); + default: return 0; } } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java index a901d750d..2f8e350ab 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java @@ -1,29 +1,31 @@ package com.gpl.rpg.AndorsTrail.model.item; +import android.content.ClipData; + import com.gpl.rpg.AndorsTrail.context.WorldContext; +import com.gpl.rpg.AndorsTrail.model.actor.Player; import com.gpl.rpg.AndorsTrail.savegames.LegacySavegameFormatReaderForItemContainer; +import com.gpl.rpg.AndorsTrail.savegames.Savegames; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; public final class Inventory extends ItemContainer { public static enum WearSlot { - weapon - ,shield - ,head - ,body - ,hand - ,feet - ,neck - ,leftring - ,rightring; - public static WearSlot fromString(String s, WearSlot default_) { - if (s == null) return default_; - return valueOf(s); - } + weapon, shield, head, body, hand, feet, neck, leftring, rightring; + + public static WearSlot fromString(String s, WearSlot default_) { + if (s == null) return default_; + return valueOf(s); } +} public int gold = 0; private static final int NUM_WORN_SLOTS = WearSlot.values().length; @@ -31,11 +33,12 @@ public final class Inventory extends ItemContainer { private final ItemType[] wear = new ItemType[NUM_WORN_SLOTS]; public final ItemType[] quickitem = new ItemType[NUM_QUICK_SLOTS]; - public Inventory() { } + public Inventory() { + } public void clear() { - for(int i = 0; i < NUM_WORN_SLOTS; ++i) wear[i] = null; - for(int i = 0; i < NUM_QUICK_SLOTS; ++i) quickitem[i] = null; + for (int i = 0; i < NUM_WORN_SLOTS; ++i) wear[i] = null; + for (int i = 0; i < NUM_QUICK_SLOTS; ++i) quickitem[i] = null; gold = 0; items.clear(); } @@ -52,12 +55,13 @@ public final class Inventory extends ItemContainer { public ItemType getItemTypeInWearSlot(WearSlot slot) { return wear[slot.ordinal()]; } + public void setItemTypeInWearSlot(WearSlot slot, ItemType type) { - wear[slot.ordinal()] = type; + setItemTypeInWearSlot(slot, type, wear); } public boolean isWearing(String itemTypeID) { - for(int i = 0; i < NUM_WORN_SLOTS; ++i) { + for (int i = 0; i < NUM_WORN_SLOTS; ++i) { if (wear[i] == null) continue; if (wear[i].id.equals(itemTypeID)) return true; } @@ -66,7 +70,7 @@ public final class Inventory extends ItemContainer { public boolean isWearing(String itemTypeID, int minNumber) { if (minNumber == 0) return isWearing(itemTypeID); - for(int i = 0; i < NUM_WORN_SLOTS; ++i) { + for (int i = 0; i < NUM_WORN_SLOTS; ++i) { if (wear[i] == null) continue; if (wear[i].id.equals(itemTypeID)) minNumber--; } @@ -87,6 +91,58 @@ public final class Inventory extends ItemContainer { } + // Move to item container? + public Inventory buildQuestItems() { + Inventory questItems = new Inventory(); + for (ItemEntry i : this.items) { + if (i == null) break; + if (i.itemType.isQuestItem()) + questItems.items.add(i); + } + return questItems; + } + // Move to item container? + public Inventory buildUsableItems() { + Inventory usableItems = new Inventory(); + for (ItemEntry i : this.items) { + if (i == null) break; + if (i.itemType.isUsable()) + usableItems.items.add(i); + } + return usableItems; + } + // Move to item container? + public Inventory buildWeaponItems() { + Inventory weaponItems = new Inventory(); + for (ItemEntry i : this.items) { + if (i == null) break; + if (i.itemType.isWeapon()) + weaponItems.items.add(i); + } + return weaponItems; + } + // Move to item container? + public Inventory buildArmorItems() { + Inventory armorItems = new Inventory(); + for (ItemEntry i : this.items) { + if (i == null) break; + if (i.itemType.isEquippable() && !i.itemType.isWeapon()) + armorItems.items.add(i); + } + return armorItems; + } + // Move to item container? + public Inventory buildOtherItems() { + Inventory otherItems = new Inventory(); + for (ItemEntry i : this.items) { + if (i == null) break; + if (i.itemType.isEquippable() || i.itemType.isUsable() || i.itemType.isQuestItem()) + continue; + otherItems.items.add(i); + } + return otherItems; + } + // ====== PARCELABLE =================================================================== public Inventory(DataInputStream src, WorldContext world, int fileversion) throws IOException { @@ -100,21 +156,21 @@ public final class Inventory extends ItemContainer { if (fileversion < 23) LegacySavegameFormatReaderForItemContainer.refundUpgradedItems(this); - for(int i = 0; i < NUM_WORN_SLOTS; ++i) { + for (int i = 0; i < NUM_WORN_SLOTS; ++i) { wear[i] = null; } final int numWornSlots = src.readInt(); - for(int i = 0; i < numWornSlots; ++i) { + for (int i = 0; i < numWornSlots; ++i) { if (src.readBoolean()) { wear[i] = world.itemTypes.getItemType(src.readUTF()); } } - for(int i = 0; i < NUM_QUICK_SLOTS; ++i) { + for (int i = 0; i < NUM_QUICK_SLOTS; ++i) { quickitem[i] = null; } if (fileversion >= 19) { final int quickSlots = src.readInt(); - for(int i = 0; i < quickSlots; ++i) { + for (int i = 0; i < quickSlots; ++i) { if (src.readBoolean()) { quickitem[i] = world.itemTypes.getItemType(src.readUTF()); } @@ -127,7 +183,7 @@ public final class Inventory extends ItemContainer { super.writeToParcel(dest); dest.writeInt(gold); dest.writeInt(NUM_WORN_SLOTS); - for(int i = 0; i < NUM_WORN_SLOTS; ++i) { + for (int i = 0; i < NUM_WORN_SLOTS; ++i) { if (wear[i] != null) { dest.writeBoolean(true); dest.writeUTF(wear[i].id); @@ -136,13 +192,12 @@ public final class Inventory extends ItemContainer { } } dest.writeInt(NUM_QUICK_SLOTS); - for(int i = 0; i < NUM_QUICK_SLOTS; ++i) { + for (int i = 0; i < NUM_QUICK_SLOTS; ++i) { if (quickitem[i] != null) { dest.writeBoolean(true); dest.writeUTF(quickitem[i].id); - } else { + } else dest.writeBoolean(false); - } } } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java index 0ade2120c..56911b341 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java @@ -1,11 +1,14 @@ package com.gpl.rpg.AndorsTrail.model.item; import com.gpl.rpg.AndorsTrail.context.WorldContext; +import com.gpl.rpg.AndorsTrail.model.actor.Player; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; public class ItemContainer { public final ArrayList items = new ArrayList(); @@ -117,6 +120,117 @@ public class ItemContainer { } + public void sortByName(Player p) { + final Player q = p; + Comparator comparatorName = new Comparator() { + @Override + public int compare(ItemEntry item1, ItemEntry item2) { + return item1.itemType.getName(q).compareTo(item2.itemType.getName(q)); + } + }; + Collections.sort(this.items, comparatorName); + + } + + + public void sortByPrice(Player p) { + final Player q = p; + Comparator comparatorPrice = new Comparator() { + @Override + public int compare(ItemEntry item1, ItemEntry item2) { + // More expensive items go to top + if (item1.itemType.baseMarketCost < item2.itemType.baseMarketCost) { + return 1; + } else if (item1.itemType.baseMarketCost > item2.itemType.baseMarketCost) { + return -1; + } else { // compares the names if rarity is the same + return item1.itemType.getName(q).compareTo(item2.itemType.getName(q)); + } + } + }; + Collections.sort(this.items, comparatorPrice); + + } + + public void sortByQuantity(Player p) { + final Player q = p; + Comparator comparatorQuantity = new Comparator() { + @Override + public int compare(ItemEntry item1, ItemEntry item2) { + // Bigger quantity is put first + if (item1.quantity > item2.quantity) { + return -1; + } else if (item1.quantity < item2.quantity) { + return 1; + } else { // compares the names if quantity is the same + return item1.itemType.getName(q).compareTo(item2.itemType.getName(q)); + } + } + }; + Collections.sort(this.items, comparatorQuantity); + + } + + + public void sortByRarity(Player p) { + final Player q = p; + Comparator comparatorRarity = new Comparator() { + @Override + public int compare(ItemEntry item1, ItemEntry item2) { + // More rare items go to top + if (item1.itemType.displayType.compareTo(item2.itemType.displayType) != 0 ) { + return (-1) * item1.itemType.displayType.compareTo(item2.itemType.displayType); + // ^ More rare goes on top + } else { // compares the names if rarity is the same + return item1.itemType.getName(q).compareTo(item2.itemType.getName(q)); + } + } + }; + Collections.sort(this.items, comparatorRarity); + + } + + + public void sortByType(Player p) { + final Player q = p; + Comparator comparatorType = new Comparator() { + @Override + public int compare(ItemEntry item1, ItemEntry item2) { + if (determineType(item1) > determineType(item2)) { + return 1; + } else if (determineType(item1) < determineType(item2)) { + return -666; + } else { // compares the names if type is the same + return item1.itemType.getName(q).compareTo(item2.itemType.getName(q)); + } + } + }; + Collections.sort(this.items, comparatorType); + + } + + public int determineType(ItemEntry item) { + if (item.itemType.isWeapon()) { + if(item.itemType.isTwohandWeapon()) + return 1; + if(item.itemType.isRangedWeapon()) + return 2; + return 3; + } // Weapons + else if (item.itemType.isShield()) { return 4; } // Shields + else if (item.itemType.isArmor()) { return 5; } // Armor, gloves, hats, boots + else if (item.itemType.isEquippable()) { return 6; } // Jewelry + else if (item.itemType.isUsable()) { return 7; } // Items with use, for example food + else if (item.itemType.isQuestItem()) { return 8; } // Quest items + else { return 9; } // others + } + + public void sortByReverse() { + Collections.reverse(this.items); + } + + + // ====== PARCELABLE =================================================================== public static ItemContainer newFromParcel(DataInputStream src, WorldContext world, int fileversion) throws IOException { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ItemContainerAdapter.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ItemContainerAdapter.java index 392e036b7..2f758ccd4 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ItemContainerAdapter.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ItemContainerAdapter.java @@ -47,4 +47,49 @@ public final class ItemContainerAdapter extends ArrayAdapter { public long getItemId(int position) { return getItem(position).itemType.id.hashCode(); } + + /*public void reloadShownCategory(int category){ // Overwrites player.inventory instead of cloning it + this.clear(); + ArrayList< + for(ItemEntry i: (ItemEntry) this.player.inventory.items.clone()){ + if(category == 0) + this.add(i); + else if(i.itemType.isWeapon()) + if(category ==1) + this.add(i); + else if(i.itemType.isEquippable() && ! i.itemType.isWeapon()) + if(category==2) + this.add(i); + else if(i.itemType.isUsable()) + if(category ==3) + this.add(i); + else if(i.itemType.isQuestItem()) + if(category ==4) + this.add(i); + else if(category == 5) //other items + this.add(i); + } + }*/ + + public static void reloadShownSort(int selected, int oldSortSelection, ItemContainer container, Player p) { + //Not sure which is worse, hardcoding the names or the position. + + if(selected == oldSortSelection); + //inv.sortByReverse(); + else if (selected ==1) + container.sortByName(p); + else if (selected == 2) + container.sortByPrice(p); + else if (selected == 3) + container.sortByQuantity(p); + else if (selected == 4) + container.sortByRarity(p); + else if (selected == 5) + container.sortByType(p); + else if (selected == 0); //Unsorted + } + + public static void reloadShownSort(int selected, ItemContainer container, Player p){ + reloadShownSort(selected, -1, container, p); + } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ShopItemContainerAdapter.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ShopItemContainerAdapter.java index a99212911..0d2c7f36a 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ShopItemContainerAdapter.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ShopItemContainerAdapter.java @@ -82,4 +82,8 @@ public final class ShopItemContainerAdapter extends ArrayAdapter { void onItemActionClicked(int position, ItemType itemType); void onItemInfoClicked(int position, ItemType itemType); } + + public void reloadShownSort(int selection, ItemContainer container, Player p){ + ItemContainerAdapter.reloadShownSort(selection, container, player); + } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java index 7c30bf2a8..0412f7ca3 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java @@ -26,6 +26,12 @@ public final class SkillListAdapter extends ArrayAdapter { this.player = player; } + public SkillListAdapter(Context context, Collection skills, Player player, int category) { + super(context, 0, filterNondisplayedSkills(skills, player, category-1)); + this.r = context.getResources(); + this.player = player; + } + private static List filterNondisplayedSkills(Collection skills, Player player) { final ArrayList result = new ArrayList(); for (SkillInfo skill : skills) { @@ -39,7 +45,24 @@ public final class SkillListAdapter extends ArrayAdapter { }); return result; } - + private static List filterNondisplayedSkills(Collection skills, Player player, int category) { + final ArrayList result = new ArrayList(); + for (SkillInfo skill : skills) { + if (shouldDisplaySkill(skill, player)){ + if(category <0) + result.add(skill); + else if(skill.categoryType.equals(SkillCollection.SkillCategory.values()[category+1])) + result.add(skill); + } + } + Collections.sort(result, new Comparator() { + @Override + public int compare(SkillInfo a, SkillInfo b) { + return a.id.ordinal() - b.id.ordinal(); + } + }); + return result; + } private static boolean shouldDisplaySkill(SkillInfo skill, Player player) { if (player.hasSkill(skill.id)) return true; if (skill.levelupVisibility == SkillInfo.LevelUpType.alwaysShown) return true; @@ -134,4 +157,55 @@ public final class SkillListAdapter extends ArrayAdapter { return -1; } } + + public void sortByName(){ + Comparator comparatorName = new Comparator() { + @Override + public int compare(SkillInfo item1, SkillInfo item2) { + return r.getString( SkillInfoActivity.getSkillTitleResourceID(item1.id)).compareTo( + r.getString( SkillInfoActivity.getSkillTitleResourceID(item2.id))); + } + }; + this.sort(comparatorName); + } + + public void sortByPoints(){ + Comparator comparatorPoints = new Comparator() { + @Override + public int compare(SkillInfo item1, SkillInfo item2) { + if(player.getSkillLevel(item1.id) > player.getSkillLevel(item2.id)) + return -1; + else if(player.getSkillLevel(item1.id) < player.getSkillLevel(item2.id)) + return 1; + else + return r.getString( SkillInfoActivity.getSkillTitleResourceID(item1.id)).compareTo( + r.getString( SkillInfoActivity.getSkillTitleResourceID(item2.id))); + } + }; + this.sort(comparatorPoints); + } + + public void sortByUnlocked(){ + Comparator comparatorUnlocked = new Comparator() { + @Override + public int compare(SkillInfo item1, SkillInfo item2) { + // First compare by whether requirements are met + if(item1.canLevelUpSkillTo(player, player.getSkillLevel(item1.id) + 1) + && !(item2.canLevelUpSkillTo(player, player.getSkillLevel(item2.id) +1))) + return -1; + else if(!(item1.canLevelUpSkillTo(player, player.getSkillLevel(item1.id) +1)) + && item2.canLevelUpSkillTo(player, player.getSkillLevel(item2.id) +1)) + return 1; + else { // Then compare by number of requirements (complexity) + if(item1.levelupRequirements.length< item2.levelupRequirements.length) + return -1; + else if(item1.levelupRequirements.length > item2.levelupRequirements.length) + return 1; + return r.getString(SkillInfoActivity.getSkillTitleResourceID(item1.id)).compareTo( + r.getString(SkillInfoActivity.getSkillTitleResourceID(item2.id))); + } + } + }; + this.sort(comparatorUnlocked); + } } From 3e6921d101f69828077cf30398f600e016d9249c Mon Sep 17 00:00:00 2001 From: HummusSamurai Date: Wed, 4 Jan 2017 11:27:31 +0200 Subject: [PATCH 02/32] Inventory sort/category is implemented (only buttons were there before) and favorites no longer show in UI --- AndorsTrail/AndorsTrail.iml | 26 +-- AndorsTrail/res/values/arrays.xml | 1 - .../fragment/HeroinfoActivity_Inventory.java | 152 +++++++++++++++++- .../rpg/AndorsTrail/model/item/Inventory.java | 2 +- .../AndorsTrail/model/item/ItemContainer.java | 2 +- 5 files changed, 154 insertions(+), 29 deletions(-) diff --git a/AndorsTrail/AndorsTrail.iml b/AndorsTrail/AndorsTrail.iml index d428b7c7a..02330429b 100644 --- a/AndorsTrail/AndorsTrail.iml +++ b/AndorsTrail/AndorsTrail.iml @@ -1,36 +1,18 @@ - - - - - - - - - - + - + - - - - - - - - - + - - + \ No newline at end of file diff --git a/AndorsTrail/res/values/arrays.xml b/AndorsTrail/res/values/arrays.xml index fd5367d8e..6a7c65b3f 100644 --- a/AndorsTrail/res/values/arrays.xml +++ b/AndorsTrail/res/values/arrays.xml @@ -11,7 +11,6 @@ @string/inventory_category_all - @string/inventory_category_favorites @string/inventory_category_weapons @string/inventory_category_armor @string/inventory_category_usable diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java index 679bcaaed..a306c0c19 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java @@ -10,9 +10,14 @@ import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; +import android.widget.Button; import android.widget.ImageView; import android.widget.ListView; +import android.widget.Spinner; import android.widget.TextView; +import android.widget.Toast; + import com.gpl.rpg.AndorsTrail.AndorsTrailApplication; import com.gpl.rpg.AndorsTrail.Dialogs; import com.gpl.rpg.AndorsTrail.R; @@ -31,13 +36,31 @@ public final class HeroinfoActivity_Inventory extends Fragment { private static final int INTENTREQUEST_ITEMINFO = 3; private static final int INTENTREQUEST_BULKSELECT_DROP = 11; + public static final int INTENTREQUEST_PRESETLOAD = 12; + public static final int INTENTREQUEST_PRESETSAVE = 13; + public static final int INTENTREQUEST_PRESETDELETE = 14; private WorldContext world; private ControllerContext controllers; private TileCollection wornTiles; private Player player; + private ListView inventoryList; + private Spinner inventorylist_categories; + private Spinner inventorylist_sort; private ItemContainerAdapter inventoryListAdapter; + private ItemContainerAdapter inventoryWeaponsListAdapter; + private ItemContainerAdapter inventoryArmorListAdapter; + private ItemContainerAdapter inventoryUsableListAdapter; + private ItemContainerAdapter inventoryQuestListAdapter; + private ItemContainerAdapter inventoryOtherListAdapter; + + private Button inventory_preset_button; + + private TextView preset_quickswitch_save; + private TextView preset_quickswitch_load; + private TextView preset_quickswitch_delete; + private TextView heroinfo_stats_gold; private TextView heroinfo_stats_attack; @@ -60,17 +83,21 @@ public final class HeroinfoActivity_Inventory extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.heroinfo_inventory, container, false); + final View v = inflater.inflate(R.layout.heroinfo_inventory, container, false); - ListView inventoryList = (ListView) v.findViewById(R.id.inventorylist_root); + initialiseInventorySpinners(v); + + inventoryList = (ListView) v.findViewById(R.id.inventorylist_root); registerForContextMenu(inventoryList); inventoryList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View v, int position, long id) { - ItemType itemType = inventoryListAdapter.getItem(position).itemType; + // Move this code to separate function? -- Done + ItemType itemType = getSelectedItemType(position); showInventoryItemInfo(itemType.id); } }); + ItemContainer inv = player.inventory; wornTiles = world.tileManager.loadTilesFor(player.inventory, getResources()); inventoryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, inv, player, wornTiles); @@ -93,6 +120,52 @@ public final class HeroinfoActivity_Inventory extends Fragment { return v; } + private void initialiseInventorySpinners(View v) { + inventorylist_categories = (Spinner) v.findViewById(R.id.inventorylist_category_filters); + ArrayAdapter categoryFilterAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.inventorylist_category_filters, android.R.layout.simple_spinner_item); + categoryFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + inventorylist_categories.setAdapter(categoryFilterAdapter); + inventorylist_categories.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) { + world.model.uiSelections.selectedInventoryCategory = inventorylist_categories.getSelectedItemPosition(); + reloadShownCategory(world.model.uiSelections.selectedInventoryCategory); + } + + @Override + public void onNothingSelected(AdapterView arg0) { + world.model.uiSelections.selectedInventoryCategory = 0; + } + }); + inventorylist_categories.setSelection(world.model.uiSelections.selectedInventoryCategory); + + + inventorylist_sort = (Spinner) v.findViewById(R.id.inventorylist_sort_filters); + ArrayAdapter sortFilterAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.inventorylist_sort_filters, android.R.layout.simple_spinner_item); + sortFilterAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + inventorylist_sort.setAdapter(sortFilterAdapter); + inventorylist_sort.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + world.model.uiSelections.selectedInventorySort = inventorylist_sort.getSelectedItemPosition(); + reloadShownSort(player.inventory); + } + + @Override + public void onNothingSelected(AdapterView parent) { + // Reset to "Custom" position + world.model.uiSelections.selectedInventorySort = 0; + } + }); + inventorylist_sort.setSelection(world.model.uiSelections.selectedInventorySort); + } + + private void setHeroStatsVisiblity(int visibility) { + heroinfo_stats_gold.setVisibility(visibility); + heroinfo_stats_attack.setVisibility(visibility); + heroinfo_stats_defense.setVisibility(visibility); + } + @Override public void onStart() { super.onStart(); @@ -201,7 +274,11 @@ public final class HeroinfoActivity_Inventory extends Fragment { } private void updateItemList() { - inventoryListAdapter.notifyDataSetChanged(); + int currentScreen = world.model.uiSelections.selectedInventoryCategory; + if (currentScreen == 0) + inventoryListAdapter.notifyDataSetChanged(); + else + reloadShownCategory(world.model.uiSelections.selectedInventoryCategory); } @Override @@ -226,6 +303,29 @@ public final class HeroinfoActivity_Inventory extends Fragment { lastSelectedItem = null; } + private ItemType getSelectedItemType(int position) { + int v = world.model.uiSelections.selectedInventoryCategory; + + if (v == 0) { //All items + return inventoryListAdapter.getItem(position).itemType; + }else if (v == 1) { //Weapon items + return inventoryWeaponsListAdapter.getItem(position).itemType; + } else if (v == 2) { //Armor items + return inventoryArmorListAdapter.getItem(position).itemType; + } else if (v == 3) { //Usable items + return inventoryUsableListAdapter.getItem(position).itemType; + } else if (v == 4) { //Quest items + return inventoryQuestListAdapter.getItem(position).itemType; + } else if (v == 5) { //Other items + return inventoryOtherListAdapter.getItem(position).itemType; + } + + // Better than crashing... + return inventoryListAdapter.getItem(position).itemType; + + } + + private ItemType getSelectedItemType(AdapterContextMenuInfo info) { return inventoryListAdapter.getItem(info.position).itemType; } @@ -340,4 +440,48 @@ public final class HeroinfoActivity_Inventory extends Fragment { Intent intent = Dialogs.getIntentForItemInfo(getActivity(), itemType.id, action, text, enabled, null); startActivityForResult(intent, INTENTREQUEST_ITEMINFO); } + + private void reloadShownCategory(int v) { // Apologies about the code duplication, + // just didn't seem to make sense as an array, although I did create a nice array for skill category adapters. + + // Decide which category to show + if (v == 0) { //All items + inventoryList.setAdapter(inventoryListAdapter); + inventoryListAdapter.notifyDataSetChanged(); + } else if (v == 1) { //Weapon items + inventoryWeaponsListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildWeaponItems(), player, wornTiles); + inventoryList.setAdapter(inventoryWeaponsListAdapter); + inventoryWeaponsListAdapter.notifyDataSetChanged(); + } else if (v == 2) { //Armor items + inventoryArmorListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildArmorItems(), player, wornTiles); + inventoryList.setAdapter(inventoryArmorListAdapter); + inventoryArmorListAdapter.notifyDataSetChanged(); + } else if (v == 3) { //Usable items + inventoryUsableListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildUsableItems(), player, wornTiles); + inventoryList.setAdapter(inventoryUsableListAdapter); + inventoryUsableListAdapter.notifyDataSetChanged(); + } else if (v == 4) { //Quest items + inventoryQuestListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildQuestItems(), player, wornTiles); + inventoryList.setAdapter(inventoryQuestListAdapter); + inventoryQuestListAdapter.notifyDataSetChanged(); + } else if (v == 5) { //Other items + inventoryOtherListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildOtherItems(), player, wornTiles); + inventoryList.setAdapter(inventoryOtherListAdapter); + inventoryOtherListAdapter.notifyDataSetChanged(); + } + //updateItemList(); + } + + private void reloadShownSort(Inventory inv) { + int selected = world.model.uiSelections.selectedInventorySort; + + inventoryListAdapter.reloadShownSort(selected, world.model.uiSelections.oldSortSelection, player.inventory, player); + + // Currently not functional, perhaps because selection only updates when changed. + if (world.model.uiSelections.oldSortSelection == selected) + world.model.uiSelections.oldSortSelection = 0; + else world.model.uiSelections.oldSortSelection = selected; + updateItemList(); + } + } \ No newline at end of file diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java index 2f8e350ab..5a73b7b02 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java @@ -57,7 +57,7 @@ public final class Inventory extends ItemContainer { } public void setItemTypeInWearSlot(WearSlot slot, ItemType type) { - setItemTypeInWearSlot(slot, type, wear); + wear[slot.ordinal()] = type; } public boolean isWearing(String itemTypeID) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java index 56911b341..048dc9f70 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemContainer.java @@ -213,7 +213,7 @@ public class ItemContainer { if (item.itemType.isWeapon()) { if(item.itemType.isTwohandWeapon()) return 1; - if(item.itemType.isRangedWeapon()) + if(false)//item.itemType.isRangedWeapon()) return 2; return 3; } // Weapons From fd9bad2ca5eaff50929b7b25b62b3a83961fe102 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 18:25:54 +0200 Subject: [PATCH 03/32] lazy undo --- AndorsTrail/AndorsTrail.iml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/AndorsTrail/AndorsTrail.iml b/AndorsTrail/AndorsTrail.iml index 02330429b..e8d6091e8 100644 --- a/AndorsTrail/AndorsTrail.iml +++ b/AndorsTrail/AndorsTrail.iml @@ -1,18 +1,35 @@ + + + + + + + + - + + - + - + + + + + + + + + - \ No newline at end of file + From b66a4b336079f5b719318285923ab367dc68f976 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 18:26:18 +0200 Subject: [PATCH 04/32] + new line --- AndorsTrail/AndorsTrail.iml | 1 + 1 file changed, 1 insertion(+) diff --git a/AndorsTrail/AndorsTrail.iml b/AndorsTrail/AndorsTrail.iml index e8d6091e8..d428b7c7a 100644 --- a/AndorsTrail/AndorsTrail.iml +++ b/AndorsTrail/AndorsTrail.iml @@ -33,3 +33,4 @@ + From ee24226c8efe14f9a1222af975b2849da5ecc3fa Mon Sep 17 00:00:00 2001 From: HummusSamurai Date: Wed, 4 Jan 2017 18:32:39 +0200 Subject: [PATCH 05/32] git ignore --- AndorsTrail/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/AndorsTrail/.gitignore b/AndorsTrail/.gitignore index 258f986d4..2455aa658 100644 --- a/AndorsTrail/.gitignore +++ b/AndorsTrail/.gitignore @@ -14,3 +14,4 @@ out/test/ # Other .metadata .svn/ +AndorsTrail.iml From 8627d3f87059a06bdc642866747da3dbe0a55d14 Mon Sep 17 00:00:00 2001 From: HummusSamurai Date: Wed, 4 Jan 2017 19:00:50 +0200 Subject: [PATCH 06/32] reverted style changes in Inventory.java --- .../rpg/AndorsTrail/model/item/Inventory.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java index 5a73b7b02..e47c7459a 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java @@ -33,12 +33,11 @@ public final class Inventory extends ItemContainer { private final ItemType[] wear = new ItemType[NUM_WORN_SLOTS]; public final ItemType[] quickitem = new ItemType[NUM_QUICK_SLOTS]; - public Inventory() { - } + public Inventory() { } public void clear() { - for (int i = 0; i < NUM_WORN_SLOTS; ++i) wear[i] = null; - for (int i = 0; i < NUM_QUICK_SLOTS; ++i) quickitem[i] = null; + for(int i = 0; i < NUM_WORN_SLOTS; ++i) wear[i] = null; + for(int i = 0; i < NUM_QUICK_SLOTS; ++i) quickitem[i] = null; gold = 0; items.clear(); } @@ -47,7 +46,6 @@ public final class Inventory extends ItemContainer { this.gold += loot.gold; this.add(loot.items); } - public boolean isEmptySlot(WearSlot slot) { return wear[slot.ordinal()] == null; } @@ -61,7 +59,7 @@ public final class Inventory extends ItemContainer { } public boolean isWearing(String itemTypeID) { - for (int i = 0; i < NUM_WORN_SLOTS; ++i) { + for(int i = 0; i < NUM_WORN_SLOTS; ++i) { if (wear[i] == null) continue; if (wear[i].id.equals(itemTypeID)) return true; } @@ -70,7 +68,7 @@ public final class Inventory extends ItemContainer { public boolean isWearing(String itemTypeID, int minNumber) { if (minNumber == 0) return isWearing(itemTypeID); - for (int i = 0; i < NUM_WORN_SLOTS; ++i) { + for(int i = 0; i < NUM_WORN_SLOTS; ++i) { if (wear[i] == null) continue; if (wear[i].id.equals(itemTypeID)) minNumber--; } @@ -156,21 +154,21 @@ public final class Inventory extends ItemContainer { if (fileversion < 23) LegacySavegameFormatReaderForItemContainer.refundUpgradedItems(this); - for (int i = 0; i < NUM_WORN_SLOTS; ++i) { + for(int i = 0; i < NUM_WORN_SLOTS; ++i) { wear[i] = null; } final int numWornSlots = src.readInt(); - for (int i = 0; i < numWornSlots; ++i) { + for(int i = 0; i < numWornSlots; ++i) { if (src.readBoolean()) { wear[i] = world.itemTypes.getItemType(src.readUTF()); } } - for (int i = 0; i < NUM_QUICK_SLOTS; ++i) { + for(int i = 0; i < NUM_QUICK_SLOTS; ++i) { quickitem[i] = null; } if (fileversion >= 19) { final int quickSlots = src.readInt(); - for (int i = 0; i < quickSlots; ++i) { + for(int i = 0; i < quickSlots; ++i) { if (src.readBoolean()) { quickitem[i] = world.itemTypes.getItemType(src.readUTF()); } @@ -183,7 +181,7 @@ public final class Inventory extends ItemContainer { super.writeToParcel(dest); dest.writeInt(gold); dest.writeInt(NUM_WORN_SLOTS); - for (int i = 0; i < NUM_WORN_SLOTS; ++i) { + for(int i = 0; i < NUM_WORN_SLOTS; ++i) { if (wear[i] != null) { dest.writeBoolean(true); dest.writeUTF(wear[i].id); @@ -192,7 +190,7 @@ public final class Inventory extends ItemContainer { } } dest.writeInt(NUM_QUICK_SLOTS); - for (int i = 0; i < NUM_QUICK_SLOTS; ++i) { + for(int i = 0; i < NUM_QUICK_SLOTS; ++i) { if (quickitem[i] != null) { dest.writeBoolean(true); dest.writeUTF(quickitem[i].id); From 1b69561667f18b22df141660f785d769d7bc0a36 Mon Sep 17 00:00:00 2001 From: HummusSamurai Date: Wed, 4 Jan 2017 19:02:58 +0200 Subject: [PATCH 07/32] git integration in Android Studio is ugly --- AndorsTrail/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/AndorsTrail/.gitignore b/AndorsTrail/.gitignore index 2455aa658..258f986d4 100644 --- a/AndorsTrail/.gitignore +++ b/AndorsTrail/.gitignore @@ -14,4 +14,3 @@ out/test/ # Other .metadata .svn/ -AndorsTrail.iml From 66898885fa8fecc973de7c9b51fcf298d66307a0 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 19:06:21 +0200 Subject: [PATCH 08/32] reverting style --- .../com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java index dcdbc40b5..3493c86f8 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java @@ -88,9 +88,9 @@ public final class SkillInfo { private int getRequirementActualValue(Player player) { switch (requirementType) { - case skillLevel: return player.getSkillLevel(SkillCollection.SkillID.valueOf(skillOrStatID)); - case experienceLevel: return player.getLevel(); - case playerStat: return player.getStatValue(Player.StatID.valueOf(skillOrStatID)); + case skillLevel: return player.getSkillLevel(SkillCollection.SkillID.valueOf(skillOrStatID)); + case experienceLevel: return player.getLevel(); + case playerStat: return player.getStatValue(Player.StatID.valueOf(skillOrStatID)); default: return 0; } } From c27567c479579e4c7e912fe9fdb0b309ed43cd3b Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 19:08:35 +0200 Subject: [PATCH 09/32] reverting style --- .../rpg/AndorsTrail/model/item/Inventory.java | 243 +++++------------- 1 file changed, 70 insertions(+), 173 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java index e47c7459a..3493c86f8 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java @@ -1,201 +1,98 @@ -package com.gpl.rpg.AndorsTrail.model.item; +package com.gpl.rpg.AndorsTrail.model.ability; -import android.content.ClipData; - -import com.gpl.rpg.AndorsTrail.context.WorldContext; import com.gpl.rpg.AndorsTrail.model.actor.Player; -import com.gpl.rpg.AndorsTrail.savegames.LegacySavegameFormatReaderForItemContainer; -import com.gpl.rpg.AndorsTrail.savegames.Savegames; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; - -public final class Inventory extends ItemContainer { - - public static enum WearSlot { - weapon, shield, head, body, hand, feet, neck, leftring, rightring; - - public static WearSlot fromString(String s, WearSlot default_) { - if (s == null) return default_; - return valueOf(s); - } -} - - public int gold = 0; - private static final int NUM_WORN_SLOTS = WearSlot.values().length; - public static final int NUM_QUICK_SLOTS = 3; - private final ItemType[] wear = new ItemType[NUM_WORN_SLOTS]; - public final ItemType[] quickitem = new ItemType[NUM_QUICK_SLOTS]; - - public Inventory() { } - - public void clear() { - for(int i = 0; i < NUM_WORN_SLOTS; ++i) wear[i] = null; - for(int i = 0; i < NUM_QUICK_SLOTS; ++i) quickitem[i] = null; - gold = 0; - items.clear(); +public final class SkillInfo { + public static final int MAXLEVEL_NONE = -1; + public static enum LevelUpType { + alwaysShown + ,onlyByQuests + ,firstLevelRequiresQuest } - public void add(final Loot loot) { - this.gold += loot.gold; - this.add(loot.items); - } - public boolean isEmptySlot(WearSlot slot) { - return wear[slot.ordinal()] == null; + public final SkillCollection.SkillID id; + public final int maxLevel; + public final LevelUpType levelupVisibility; + public final SkillLevelRequirement[] levelupRequirements; + public final SkillCollection.SkillCategory categoryType; + public SkillInfo( + SkillCollection.SkillID id + , int maxLevel + , LevelUpType levelupVisibility + , SkillCollection.SkillCategory categoryType + , SkillLevelRequirement[] levelupRequirements + ) { + this.id = id; + this.maxLevel = maxLevel; + this.levelupVisibility = levelupVisibility; + this.levelupRequirements = levelupRequirements; + this.categoryType = categoryType; } - public ItemType getItemTypeInWearSlot(WearSlot slot) { - return wear[slot.ordinal()]; + public boolean hasMaxLevel() { + if (maxLevel == MAXLEVEL_NONE) return false; + else return true; } - public void setItemTypeInWearSlot(WearSlot slot, ItemType type) { - wear[slot.ordinal()] = type; + public boolean hasLevelupRequirements() { + return levelupRequirements != null; } - public boolean isWearing(String itemTypeID) { - for(int i = 0; i < NUM_WORN_SLOTS; ++i) { - if (wear[i] == null) continue; - if (wear[i].id.equals(itemTypeID)) return true; + public boolean canLevelUpSkillTo(Player player, int requestedSkillLevel) { + if (!hasLevelupRequirements()) return true; + + for (SkillLevelRequirement requirement : levelupRequirements) { + if (!requirement.isSatisfiedByPlayer(player, requestedSkillLevel)) return false; } - return false; + return true; } - public boolean isWearing(String itemTypeID, int minNumber) { - if (minNumber == 0) return isWearing(itemTypeID); - for(int i = 0; i < NUM_WORN_SLOTS; ++i) { - if (wear[i] == null) continue; - if (wear[i].id.equals(itemTypeID)) minNumber--; + public static final class SkillLevelRequirement { + public static enum RequirementType { + skillLevel + ,experienceLevel + ,playerStat } - return minNumber <= 0; - } + public final RequirementType requirementType; + public final String skillOrStatID; + public final int everySkillLevelRequiresThisAmount; + public final int initialRequiredAmount; - public static boolean isArmorSlot(WearSlot slot) { - if (slot == null) return false; - switch (slot) { - case head: - case body: - case hand: - case feet: - return true; - default: - return false; + private SkillLevelRequirement(RequirementType requirementType, int everySkillLevelRequiresThisAmount, int initialRequiredAmount, String skillOrStatID) { + this.requirementType = requirementType; + this.skillOrStatID = skillOrStatID; + this.everySkillLevelRequiresThisAmount = everySkillLevelRequiresThisAmount; + this.initialRequiredAmount = initialRequiredAmount; } - } - - // Move to item container? - public Inventory buildQuestItems() { - Inventory questItems = new Inventory(); - for (ItemEntry i : this.items) { - if (i == null) break; - if (i.itemType.isQuestItem()) - questItems.items.add(i); + public static SkillLevelRequirement requireOtherSkill(SkillCollection.SkillID skillID, int everySkillLevelRequiresThisAmount) { + return new SkillLevelRequirement(RequirementType.skillLevel, everySkillLevelRequiresThisAmount, 0, skillID.name()); } - return questItems; - } - // Move to item container? - public Inventory buildUsableItems() { - Inventory usableItems = new Inventory(); - for (ItemEntry i : this.items) { - if (i == null) break; - if (i.itemType.isUsable()) - usableItems.items.add(i); + public static SkillLevelRequirement requireExperienceLevels(int everySkillLevelRequiresThisAmount, int initialRequiredAmount) { + return new SkillLevelRequirement(RequirementType.experienceLevel, everySkillLevelRequiresThisAmount, initialRequiredAmount, null); } - return usableItems; - } - // Move to item container? - public Inventory buildWeaponItems() { - Inventory weaponItems = new Inventory(); - for (ItemEntry i : this.items) { - if (i == null) break; - if (i.itemType.isWeapon()) - weaponItems.items.add(i); + public static SkillLevelRequirement requirePlayerStats(Player.StatID statID, int everySkillLevelRequiresThisAmount, int initialRequiredAmount) { + return new SkillLevelRequirement(RequirementType.playerStat, everySkillLevelRequiresThisAmount, initialRequiredAmount, statID.name()); } - return weaponItems; - } - // Move to item container? - public Inventory buildArmorItems() { - Inventory armorItems = new Inventory(); - for (ItemEntry i : this.items) { - if (i == null) break; - if (i.itemType.isEquippable() && !i.itemType.isWeapon()) - armorItems.items.add(i); + + public boolean isSatisfiedByPlayer(Player player, int requestedSkillLevel) { + final int minimumValueRequired = getRequiredValue(requestedSkillLevel); + final int playerValue = getRequirementActualValue(player); + if (playerValue >= minimumValueRequired) return true; + return false; } - return armorItems; - } - // Move to item container? - public Inventory buildOtherItems() { - Inventory otherItems = new Inventory(); - for (ItemEntry i : this.items) { - if (i == null) break; - if (i.itemType.isEquippable() || i.itemType.isUsable() || i.itemType.isQuestItem()) - continue; - otherItems.items.add(i); + + public int getRequiredValue(int requestedSkillLevel) { + return requestedSkillLevel * everySkillLevelRequiresThisAmount + initialRequiredAmount; } - return otherItems; - } - // ====== PARCELABLE =================================================================== - - public Inventory(DataInputStream src, WorldContext world, int fileversion) throws IOException { - this.readFromParcel(src, world, fileversion); - } - - @Override - public void readFromParcel(DataInputStream src, WorldContext world, int fileversion) throws IOException { - super.readFromParcel(src, world, fileversion); - gold = src.readInt(); - - if (fileversion < 23) LegacySavegameFormatReaderForItemContainer.refundUpgradedItems(this); - - for(int i = 0; i < NUM_WORN_SLOTS; ++i) { - wear[i] = null; - } - final int numWornSlots = src.readInt(); - for(int i = 0; i < numWornSlots; ++i) { - if (src.readBoolean()) { - wear[i] = world.itemTypes.getItemType(src.readUTF()); + private int getRequirementActualValue(Player player) { + switch (requirementType) { + case skillLevel: return player.getSkillLevel(SkillCollection.SkillID.valueOf(skillOrStatID)); + case experienceLevel: return player.getLevel(); + case playerStat: return player.getStatValue(Player.StatID.valueOf(skillOrStatID)); + default: return 0; } } - for(int i = 0; i < NUM_QUICK_SLOTS; ++i) { - quickitem[i] = null; - } - if (fileversion >= 19) { - final int quickSlots = src.readInt(); - for(int i = 0; i < quickSlots; ++i) { - if (src.readBoolean()) { - quickitem[i] = world.itemTypes.getItemType(src.readUTF()); - } - } - } - } - - @Override - public void writeToParcel(DataOutputStream dest) throws IOException { - super.writeToParcel(dest); - dest.writeInt(gold); - dest.writeInt(NUM_WORN_SLOTS); - for(int i = 0; i < NUM_WORN_SLOTS; ++i) { - if (wear[i] != null) { - dest.writeBoolean(true); - dest.writeUTF(wear[i].id); - } else { - dest.writeBoolean(false); - } - } - dest.writeInt(NUM_QUICK_SLOTS); - for(int i = 0; i < NUM_QUICK_SLOTS; ++i) { - if (quickitem[i] != null) { - dest.writeBoolean(true); - dest.writeUTF(quickitem[i].id); - } else - dest.writeBoolean(false); - } } } From 1905e39e43b34f48c532e67672b89d06c80a7f87 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 19:12:42 +0200 Subject: [PATCH 13/32] style --- AndorsTrail/res/layout/shoplist.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AndorsTrail/res/layout/shoplist.xml b/AndorsTrail/res/layout/shoplist.xml index 13e880ad7..c14692396 100644 --- a/AndorsTrail/res/layout/shoplist.xml +++ b/AndorsTrail/res/layout/shoplist.xml @@ -37,6 +37,7 @@ + android:layout_height="wrap_content" + /> From e2b8ac73e8484c17788502907a9480ef399f5dc2 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 19:13:03 +0200 Subject: [PATCH 14/32] a space --- AndorsTrail/res/layout/shoplist.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndorsTrail/res/layout/shoplist.xml b/AndorsTrail/res/layout/shoplist.xml index c14692396..5f6e93784 100644 --- a/AndorsTrail/res/layout/shoplist.xml +++ b/AndorsTrail/res/layout/shoplist.xml @@ -37,7 +37,7 @@ From 5283b04615f5e61b48fdb783886c28df4bf78122 Mon Sep 17 00:00:00 2001 From: HummusSamurai Date: Wed, 4 Jan 2017 19:16:44 +0200 Subject: [PATCH 15/32] git integration in Android Studio is ugly --- .../src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java index e47c7459a..32b7e6446 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java @@ -96,7 +96,7 @@ public final class Inventory extends ItemContainer { if (i == null) break; if (i.itemType.isQuestItem()) questItems.items.add(i); - } + } return questItems; } // Move to item container? From f61ba8bd069f33406eed0569f0833c2f749b1694 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 19:19:28 +0200 Subject: [PATCH 16/32] damn --- .../rpg/AndorsTrail/model/item/Inventory.java | 248 +++++++++++++----- 1 file changed, 176 insertions(+), 72 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java index 3493c86f8..2c680c855 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java @@ -1,97 +1,201 @@ -package com.gpl.rpg.AndorsTrail.model.ability; +package com.gpl.rpg.AndorsTrail.model.item; +import android.content.ClipData; + +import com.gpl.rpg.AndorsTrail.context.WorldContext; import com.gpl.rpg.AndorsTrail.model.actor.Player; +import com.gpl.rpg.AndorsTrail.savegames.LegacySavegameFormatReaderForItemContainer; +import com.gpl.rpg.AndorsTrail.savegames.Savegames; -public final class SkillInfo { - public static final int MAXLEVEL_NONE = -1; - public static enum LevelUpType { - alwaysShown - ,onlyByQuests - ,firstLevelRequiresQuest +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; + +public final class Inventory extends ItemContainer { + + public static enum WearSlot { + weapon, shield, head, body, hand, feet, neck, leftring, rightring; + + public static WearSlot fromString(String s, WearSlot default_) { + if (s == null) return default_; + return valueOf(s); + } +} + + public int gold = 0; + private static final int NUM_WORN_SLOTS = WearSlot.values().length; + public static final int NUM_QUICK_SLOTS = 3; + private final ItemType[] wear = new ItemType[NUM_WORN_SLOTS]; + public final ItemType[] quickitem = new ItemType[NUM_QUICK_SLOTS]; + + public Inventory() { } + + public void clear() { + for(int i = 0; i < NUM_WORN_SLOTS; ++i) wear[i] = null; + for(int i = 0; i < NUM_QUICK_SLOTS; ++i) quickitem[i] = null; + gold = 0; + items.clear(); } - public final SkillCollection.SkillID id; - public final int maxLevel; - public final LevelUpType levelupVisibility; - public final SkillLevelRequirement[] levelupRequirements; - public final SkillCollection.SkillCategory categoryType; - public SkillInfo( - SkillCollection.SkillID id - , int maxLevel - , LevelUpType levelupVisibility - , SkillCollection.SkillCategory categoryType - , SkillLevelRequirement[] levelupRequirements - ) { - this.id = id; - this.maxLevel = maxLevel; - this.levelupVisibility = levelupVisibility; - this.levelupRequirements = levelupRequirements; - this.categoryType = categoryType; + public void add(final Loot loot) { + this.gold += loot.gold; + this.add(loot.items); + } + public boolean isEmptySlot(WearSlot slot) { + return wear[slot.ordinal()] == null; } - public boolean hasMaxLevel() { - if (maxLevel == MAXLEVEL_NONE) return false; - else return true; + public ItemType getItemTypeInWearSlot(WearSlot slot) { + return wear[slot.ordinal()]; } - public boolean hasLevelupRequirements() { - return levelupRequirements != null; + public void setItemTypeInWearSlot(WearSlot slot, ItemType type) { + wear[slot.ordinal()] = type; } - public boolean canLevelUpSkillTo(Player player, int requestedSkillLevel) { - if (!hasLevelupRequirements()) return true; - - for (SkillLevelRequirement requirement : levelupRequirements) { - if (!requirement.isSatisfiedByPlayer(player, requestedSkillLevel)) return false; + public boolean isWearing(String itemTypeID) { + for(int i = 0; i < NUM_WORN_SLOTS; ++i) { + if (wear[i] == null) continue; + if (wear[i].id.equals(itemTypeID)) return true; } - return true; + return false; } - public static final class SkillLevelRequirement { - public static enum RequirementType { - skillLevel - ,experienceLevel - ,playerStat + public boolean isWearing(String itemTypeID, int minNumber) { + if (minNumber == 0) return isWearing(itemTypeID); + for(int i = 0; i < NUM_WORN_SLOTS; ++i) { + if (wear[i] == null) continue; + if (wear[i].id.equals(itemTypeID)) minNumber--; } - public final RequirementType requirementType; - public final String skillOrStatID; - public final int everySkillLevelRequiresThisAmount; - public final int initialRequiredAmount; + return minNumber <= 0; + } - private SkillLevelRequirement(RequirementType requirementType, int everySkillLevelRequiresThisAmount, int initialRequiredAmount, String skillOrStatID) { - this.requirementType = requirementType; - this.skillOrStatID = skillOrStatID; - this.everySkillLevelRequiresThisAmount = everySkillLevelRequiresThisAmount; - this.initialRequiredAmount = initialRequiredAmount; + public static boolean isArmorSlot(WearSlot slot) { + if (slot == null) return false; + switch (slot) { + case head: + case body: + case hand: + case feet: + return true; + default: + return false; } + } - public static SkillLevelRequirement requireOtherSkill(SkillCollection.SkillID skillID, int everySkillLevelRequiresThisAmount) { - return new SkillLevelRequirement(RequirementType.skillLevel, everySkillLevelRequiresThisAmount, 0, skillID.name()); - } - public static SkillLevelRequirement requireExperienceLevels(int everySkillLevelRequiresThisAmount, int initialRequiredAmount) { - return new SkillLevelRequirement(RequirementType.experienceLevel, everySkillLevelRequiresThisAmount, initialRequiredAmount, null); - } - public static SkillLevelRequirement requirePlayerStats(Player.StatID statID, int everySkillLevelRequiresThisAmount, int initialRequiredAmount) { - return new SkillLevelRequirement(RequirementType.playerStat, everySkillLevelRequiresThisAmount, initialRequiredAmount, statID.name()); - } - public boolean isSatisfiedByPlayer(Player player, int requestedSkillLevel) { - final int minimumValueRequired = getRequiredValue(requestedSkillLevel); - final int playerValue = getRequirementActualValue(player); - if (playerValue >= minimumValueRequired) return true; - return false; + // Move to item container? + public Inventory buildQuestItems() { + Inventory questItems = new Inventory(); + for (ItemEntry i : this.items) { + if (i == null) break; + if (i.itemType.isQuestItem()) + questItems.items.add(i); } - - public int getRequiredValue(int requestedSkillLevel) { - return requestedSkillLevel * everySkillLevelRequiresThisAmount + initialRequiredAmount; + return questItems; + } + // Move to item container? + public Inventory buildUsableItems() { + Inventory usableItems = new Inventory(); + for (ItemEntry i : this.items) { + if (i == null) break; + if (i.itemType.isUsable()) + usableItems.items.add(i); } + return usableItems; + } + // Move to item container? + public Inventory buildWeaponItems() { + Inventory weaponItems = new Inventory(); + for (ItemEntry i : this.items) { + if (i == null) break; + if (i.itemType.isWeapon()) + weaponItems.items.add(i); + } + return weaponItems; + } + // Move to item container? + public Inventory buildArmorItems() { + Inventory armorItems = new Inventory(); + for (ItemEntry i : this.items) { + if (i == null) break; + if (i.itemType.isEquippable() && !i.itemType.isWeapon()) + armorItems.items.add(i); + } + return armorItems; + } + // Move to item container? + public Inventory buildOtherItems() { + Inventory otherItems = new Inventory(); + for (ItemEntry i : this.items) { + if (i == null) break; + if (i.itemType.isEquippable() || i.itemType.isUsable() || i.itemType.isQuestItem()) + continue; + otherItems.items.add(i); + } + return otherItems; + } - private int getRequirementActualValue(Player player) { - switch (requirementType) { - case skillLevel: return player.getSkillLevel(SkillCollection.SkillID.valueOf(skillOrStatID)); - case experienceLevel: return player.getLevel(); - case playerStat: return player.getStatValue(Player.StatID.valueOf(skillOrStatID)); - default: return 0; + // ====== PARCELABLE =================================================================== + + public Inventory(DataInputStream src, WorldContext world, int fileversion) throws IOException { + this.readFromParcel(src, world, fileversion); + } + + @Override + public void readFromParcel(DataInputStream src, WorldContext world, int fileversion) throws IOException { + super.readFromParcel(src, world, fileversion); + gold = src.readInt(); + + if (fileversion < 23) LegacySavegameFormatReaderForItemContainer.refundUpgradedItems(this); + + for(int i = 0; i < NUM_WORN_SLOTS; ++i) { + wear[i] = null; + } + final int numWornSlots = src.readInt(); + for(int i = 0; i < numWornSlots; ++i) { + if (src.readBoolean()) { + wear[i] = world.itemTypes.getItemType(src.readUTF()); + } + } + for(int i = 0; i < NUM_QUICK_SLOTS; ++i) { + quickitem[i] = null; + } + if (fileversion >= 19) { + final int quickSlots = src.readInt(); + for(int i = 0; i < quickSlots; ++i) { + if (src.readBoolean()) { + quickitem[i] = world.itemTypes.getItemType(src.readUTF()); + } + } + } + } + + @Override + public void writeToParcel(DataOutputStream dest) throws IOException { + super.writeToParcel(dest); + dest.writeInt(gold); + dest.writeInt(NUM_WORN_SLOTS); + for(int i = 0; i < NUM_WORN_SLOTS; ++i) { + if (wear[i] != null) { + dest.writeBoolean(true); + dest.writeUTF(wear[i].id); + } else { + dest.writeBoolean(false); + } + } + dest.writeInt(NUM_QUICK_SLOTS); + for(int i = 0; i < NUM_QUICK_SLOTS; ++i) { + if (quickitem[i] != null) { + dest.writeBoolean(true); + dest.writeUTF(quickitem[i].id); + } else { + dest.writeBoolean(false); } } } From 7936a223f504b8b896771b97feb3cb207615a9c3 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 19:23:14 +0200 Subject: [PATCH 17/32] lord --- .../rpg/AndorsTrail/model/item/Inventory.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java index 2c680c855..c5f113be8 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java @@ -19,13 +19,20 @@ import java.util.Map; public final class Inventory extends ItemContainer { public static enum WearSlot { - weapon, shield, head, body, hand, feet, neck, leftring, rightring; - - public static WearSlot fromString(String s, WearSlot default_) { - if (s == null) return default_; - return valueOf(s); + weapon + ,shield + ,head + ,body + ,hand + ,feet + ,neck + ,leftring + ,rightring; + public static WearSlot fromString(String s, WearSlot default_) { + if (s == null) return default_; + return valueOf(s); + } } -} public int gold = 0; private static final int NUM_WORN_SLOTS = WearSlot.values().length; @@ -46,6 +53,7 @@ public final class Inventory extends ItemContainer { this.gold += loot.gold; this.add(loot.items); } + public boolean isEmptySlot(WearSlot slot) { return wear[slot.ordinal()] == null; } @@ -53,7 +61,6 @@ public final class Inventory extends ItemContainer { public ItemType getItemTypeInWearSlot(WearSlot slot) { return wear[slot.ordinal()]; } - public void setItemTypeInWearSlot(WearSlot slot, ItemType type) { wear[slot.ordinal()] = type; } From 988e94f62fe2639d107dff70e3cf55f2ada0b181 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 19:24:20 +0200 Subject: [PATCH 18/32] yup that happened --- .../src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java index c5f113be8..f0bc50355 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java @@ -1,7 +1,6 @@ package com.gpl.rpg.AndorsTrail.model.item; import android.content.ClipData; - import com.gpl.rpg.AndorsTrail.context.WorldContext; import com.gpl.rpg.AndorsTrail.model.actor.Player; import com.gpl.rpg.AndorsTrail.savegames.LegacySavegameFormatReaderForItemContainer; @@ -53,7 +52,7 @@ public final class Inventory extends ItemContainer { this.gold += loot.gold; this.add(loot.items); } - + public boolean isEmptySlot(WearSlot slot) { return wear[slot.ordinal()] == null; } From 7ea485f8ca8ad2fcf1d2fcce95277600effa6ced Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 19:36:47 +0200 Subject: [PATCH 19/32] please --- .../src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java index 3493c86f8..430e1b859 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillInfo.java @@ -91,7 +91,7 @@ public final class SkillInfo { case skillLevel: return player.getSkillLevel(SkillCollection.SkillID.valueOf(skillOrStatID)); case experienceLevel: return player.getLevel(); case playerStat: return player.getStatValue(Player.StatID.valueOf(skillOrStatID)); - default: return 0; + default: return 0; } } } From a186715eabad7f2a11374960cffefd325cb4be0b Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Wed, 4 Jan 2017 19:38:17 +0200 Subject: [PATCH 20/32] almost --- .../activity/fragment/HeroinfoActivity_Skills.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java index 219d65539..3be757014 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java @@ -23,8 +23,6 @@ import com.gpl.rpg.AndorsTrail.model.actor.Player; import com.gpl.rpg.AndorsTrail.view.SkillListAdapter; import java.util.ArrayList; - - public final class HeroinfoActivity_Skills extends Fragment { private static final int INTENTREQUEST_SKILLINFO = 12; @@ -146,12 +144,12 @@ public final class HeroinfoActivity_Skills extends Fragment { public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { - case INTENTREQUEST_SKILLINFO: - if (resultCode != Activity.RESULT_OK) break; + case INTENTREQUEST_SKILLINFO: + if (resultCode != Activity.RESULT_OK) break; - SkillCollection.SkillID skillID = SkillCollection.SkillID.valueOf(data.getExtras().getString("skillID")); - controllers.skillController.levelUpSkillManually(player, world.skills.getSkill(skillID)); - break; + SkillCollection.SkillID skillID = SkillCollection.SkillID.valueOf(data.getExtras().getString("skillID")); + controllers.skillController.levelUpSkillManually(player, world.skills.getSkill(skillID)); + break; } update(); } @@ -174,4 +172,4 @@ public final class HeroinfoActivity_Skills extends Fragment { } getCurrentCategoryAdapter().notifyDataSetInvalidated(); } -} \ No newline at end of file +} From a119fde366a298007de9978bd4a3abfabdfbc783 Mon Sep 17 00:00:00 2001 From: HummusSamurai Date: Wed, 4 Jan 2017 19:59:59 +0200 Subject: [PATCH 21/32] un-used import --- .../src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java index f0bc50355..a5c29cd5d 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Inventory.java @@ -1,6 +1,5 @@ package com.gpl.rpg.AndorsTrail.model.item; -import android.content.ClipData; import com.gpl.rpg.AndorsTrail.context.WorldContext; import com.gpl.rpg.AndorsTrail.model.actor.Player; import com.gpl.rpg.AndorsTrail.savegames.LegacySavegameFormatReaderForItemContainer; From 998c56d8ab3e810ef7ed20a25bb868642df386c4 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Thu, 5 Jan 2017 09:17:34 +0200 Subject: [PATCH 22/32] excess tabs --- .../model/ability/SkillCollection.java | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java index 5112aa19e..d636c9c8d 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java @@ -11,47 +11,47 @@ import java.util.Collection; public final class SkillCollection { public static enum SkillID { weaponChance - ,weaponDmg - ,barter - ,dodge - ,barkSkin - ,moreCriticals - ,betterCriticals - ,speed // Raises max ap - ,coinfinder - ,moreExp - ,cleave // +10ap on kill - ,eater // +1hp per kill - ,fortitude // +N hp per levelup - ,evasion // increase successful flee chance & reduce chance of monster attack - ,regeneration // +N hp per round - ,lowerExploss - ,magicfinder - ,resistanceMental // lowers chance to get negative active conditions by monsters (Mental like Dazed) - ,resistancePhysical // lowers chance to get negative active conditions by monsters (Physical Capacity like Minor fatigue) - ,resistanceBlood // lowers chance to get negative active conditions by monsters (Blood Disorder like Weak Poison) - ,shadowBless - ,crit1 // lowers atk ability - ,crit2 // lowers def ability ,rejuvenation // Reduces magnitudes of conditions - ,rejuvenation // Reduces magnitudes of conditions - ,taunt // Causes AP loss of attackers that miss - ,concussion // AC loss for monsters with (AC-BC)>N - ,weaponProficiencyDagger - ,weaponProficiency1hsword - ,weaponProficiency2hsword - ,weaponProficiencyAxe - ,weaponProficiencyBlunt - ,weaponProficiencyUnarmed - ,armorProficiencyShield - ,armorProficiencyUnarmored - ,armorProficiencyLight - ,armorProficiencyHeavy - ,fightstyleDualWield - ,fightstyle2hand - ,fightstyleWeaponShield - ,specializationDualWield - ,specialization2hand - ,specializationWeaponShield + ,weaponDmg + ,barter + ,dodge + ,barkSkin + ,moreCriticals + ,betterCriticals + ,speed // Raises max ap + ,coinfinder + ,moreExp + ,cleave // +10ap on kill + ,eater // +1hp per kill + ,fortitude // +N hp per levelup + ,evasion // increase successful flee chance & reduce chance of monster attack + ,regeneration // +N hp per round + ,lowerExploss + ,magicfinder + ,resistanceMental // lowers chance to get negative active conditions by monsters (Mental like Dazed) + ,resistancePhysical // lowers chance to get negative active conditions by monsters (Physical Capacity like Minor fatigue) + ,resistanceBlood // lowers chance to get negative active conditions by monsters (Blood Disorder like Weak Poison) + ,shadowBless + ,crit1 // lowers atk ability + ,crit2 // lowers def ability ,rejuvenation // Reduces magnitudes of conditions + ,rejuvenation // Reduces magnitudes of conditions + ,taunt // Causes AP loss of attackers that miss + ,concussion // AC loss for monsters with (AC-BC)>N + ,weaponProficiencyDagger + ,weaponProficiency1hsword + ,weaponProficiency2hsword + ,weaponProficiencyAxe + ,weaponProficiencyBlunt + ,weaponProficiencyUnarmed + ,armorProficiencyShield + ,armorProficiencyUnarmored + ,armorProficiencyLight + ,armorProficiencyHeavy + ,fightstyleDualWield + ,fightstyle2hand + ,fightstyleWeaponShield + ,specializationDualWield + ,specialization2hand + ,specializationWeaponShield } // should be in the same number &U order as in arrays.xml From 6c9fcd5b4656a0ca7032925bb69eb67b867de36f Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Thu, 5 Jan 2017 09:20:48 +0200 Subject: [PATCH 23/32] tabs --- .../AndorsTrail/model/ability/SkillCollection.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java index d636c9c8d..d405fd8a3 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java @@ -129,7 +129,7 @@ public final class SkillCollection { private static final int MAX_LEVEL_EVASION = Math.max( Constants.FLEE_FAIL_CHANCE_PERCENT / PER_SKILLPOINT_INCREASE_EVASION_FLEE_CHANCE_PERCENTAGE ,Constants.MONSTER_AGGRESSION_CHANCE_PERCENT / PER_SKILLPOINT_INCREASE_EVASION_MONSTER_ATTACK_CHANCE_PERCENTAGE - ); + ); public static final int MAX_LEVEL_LOWER_EXPLOSS = 100 / PER_SKILLPOINT_INCREASE_EXPLOSS_PERCENT; public static final int MAX_LEVEL_RESISTANCE = 70 / PER_SKILLPOINT_INCREASE_RESISTANCE_CHANCE_PERCENT; @@ -211,25 +211,25 @@ public final class SkillCollection { initializeSkill(new SkillInfo(SkillID.armorProficiencyHeavy, 4, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); initializeSkill(new SkillInfo(SkillID.fightstyleDualWield, 2, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(15, 0) - })); + })); initializeSkill(new SkillInfo(SkillID.fightstyle2hand, 2, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(15, 0) - })); + })); initializeSkill(new SkillInfo(SkillID.fightstyleWeaponShield, 2, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(15, 0) - })); + })); initializeSkill(new SkillInfo(SkillID.specializationDualWield, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(45, 0) ,SkillLevelRequirement.requireOtherSkill(SkillID.fightstyleDualWield, 2) - })); + })); initializeSkill(new SkillInfo(SkillID.specialization2hand, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(45, 0) ,SkillLevelRequirement.requireOtherSkill(SkillID.fightstyle2hand, 2) - })); + })); initializeSkill(new SkillInfo(SkillID.specializationWeaponShield, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.specialty, new SkillLevelRequirement[] { SkillLevelRequirement.requireExperienceLevels(45, 0) ,SkillLevelRequirement.requireOtherSkill(SkillID.fightstyleWeaponShield, 2) - })); + })); } public SkillInfo getSkill(SkillID skillID) { From 2b6ce058b6b75bb4d16f269faa43f9c5849335d7 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Thu, 5 Jan 2017 09:23:09 +0200 Subject: [PATCH 24/32] guess what more tabs --- .../model/ability/SkillCollection.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java index d405fd8a3..d5364d08d 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java @@ -143,32 +143,32 @@ public final class SkillCollection { initializeSkill(new SkillInfo(SkillID.barter, MAX_LEVEL_BARTER, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null)); initializeSkill(new SkillInfo(SkillID.dodge, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, null)); initializeSkill(new SkillInfo(SkillID.barkSkin, MAX_LEVEL_BARKSKIN, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, new SkillLevelRequirement[] { - SkillLevelRequirement.requireExperienceLevels(10, 0) - ,SkillLevelRequirement.requirePlayerStats(Player.StatID.blockChance, 15, 0) + SkillLevelRequirement.requireExperienceLevels(10, 0) + ,SkillLevelRequirement.requirePlayerStats(Player.StatID.blockChance, 15, 0) })); initializeSkill(new SkillInfo(SkillID.moreCriticals, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, null)); initializeSkill(new SkillInfo(SkillID.betterCriticals, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 1) + SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 1) })); initializeSkill(new SkillInfo(SkillID.speed, MAX_LEVEL_SPEED, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, new SkillLevelRequirement[] { - SkillLevelRequirement.requireExperienceLevels(15, 0) + SkillLevelRequirement.requireExperienceLevels(15, 0) })); initializeSkill(new SkillInfo(SkillID.coinfinder, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null)); initializeSkill(new SkillInfo(SkillID.moreExp, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null)); initializeSkill(new SkillInfo(SkillID.cleave, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.weaponChance, 1) - ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponDmg, 1) + SkillLevelRequirement.requireOtherSkill(SkillID.weaponChance, 1) + ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponDmg, 1) })); initializeSkill(new SkillInfo(SkillID.eater, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] { - SkillLevelRequirement.requirePlayerStats(Player.StatID.maxHP, 20, 20) + SkillLevelRequirement.requirePlayerStats(Player.StatID.maxHP, 20, 20) })); initializeSkill(new SkillInfo(SkillID.fortitude, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] { - SkillLevelRequirement.requireExperienceLevels(15, -10) + SkillLevelRequirement.requireExperienceLevels(15, -10) })); initializeSkill(new SkillInfo(SkillID.evasion, MAX_LEVEL_EVASION, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, null)); initializeSkill(new SkillInfo(SkillID.regeneration, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] { - SkillLevelRequirement.requirePlayerStats(Player.StatID.maxHP, 30, 0) - ,SkillLevelRequirement.requireOtherSkill(SkillID.fortitude, 1) + SkillLevelRequirement.requirePlayerStats(Player.StatID.maxHP, 30, 0) + ,SkillLevelRequirement.requireOtherSkill(SkillID.fortitude, 1) })); initializeSkill(new SkillInfo(SkillID.lowerExploss, MAX_LEVEL_LOWER_EXPLOSS, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null)); initializeSkill(new SkillInfo(SkillID.magicfinder, SkillInfo.MAXLEVEL_NONE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.utility, null)); @@ -177,8 +177,8 @@ public final class SkillCollection { initializeSkill(new SkillInfo(SkillID.resistanceBlood, MAX_LEVEL_RESISTANCE, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, null)); initializeSkill(new SkillInfo(SkillID.shadowBless, 1, SkillInfo.LevelUpType.onlyByQuests, SkillCategory.immunity, null)); initializeSkill(new SkillInfo(SkillID.crit1, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 3) - ,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 3) + SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 3) + ,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 3) })); initializeSkill(new SkillInfo(SkillID.crit2, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] { SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 6) @@ -186,18 +186,18 @@ public final class SkillCollection { ,SkillLevelRequirement.requireOtherSkill(SkillID.crit1, 1) })); initializeSkill(new SkillInfo(SkillID.rejuvenation, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.resistanceBlood, 3) - ,SkillLevelRequirement.requireOtherSkill(SkillID.resistanceMental, 3) - ,SkillLevelRequirement.requireOtherSkill(SkillID.resistancePhysical, 3) + SkillLevelRequirement.requireOtherSkill(SkillID.resistanceBlood, 3) + ,SkillLevelRequirement.requireOtherSkill(SkillID.resistanceMental, 3) + ,SkillLevelRequirement.requireOtherSkill(SkillID.resistancePhysical, 3) })); initializeSkill(new SkillInfo(SkillID.taunt, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.defense, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.evasion, 2) - ,SkillLevelRequirement.requireOtherSkill(SkillID.dodge, 4) + SkillLevelRequirement.requireOtherSkill(SkillID.evasion, 2) + ,SkillLevelRequirement.requireOtherSkill(SkillID.dodge, 4) })); initializeSkill(new SkillInfo(SkillID.concussion, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.offense, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.speed, 2) - ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponChance, 3) - ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponDmg, 5) + SkillLevelRequirement.requireOtherSkill(SkillID.speed, 2) + ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponChance, 3) + ,SkillLevelRequirement.requireOtherSkill(SkillID.weaponDmg, 5) })); initializeSkill(new SkillInfo(SkillID.weaponProficiencyDagger, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); initializeSkill(new SkillInfo(SkillID.weaponProficiency1hsword, 3, SkillInfo.LevelUpType.firstLevelRequiresQuest, SkillCategory.proficiency, null)); From 4b58722b0562a80cd112db01cf9b998a3d0713c5 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Thu, 5 Jan 2017 09:23:57 +0200 Subject: [PATCH 25/32] end already --- .../gpl/rpg/AndorsTrail/model/ability/SkillCollection.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java index d5364d08d..7fc01dc89 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java @@ -181,9 +181,9 @@ public final class SkillCollection { ,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 3) })); initializeSkill(new SkillInfo(SkillID.crit2, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.criticals, new SkillLevelRequirement[] { - SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 6) - ,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 6) - ,SkillLevelRequirement.requireOtherSkill(SkillID.crit1, 1) + SkillLevelRequirement.requireOtherSkill(SkillID.moreCriticals, 6) + ,SkillLevelRequirement.requireOtherSkill(SkillID.betterCriticals, 6) + ,SkillLevelRequirement.requireOtherSkill(SkillID.crit1, 1) })); initializeSkill(new SkillInfo(SkillID.rejuvenation, 1, SkillInfo.LevelUpType.alwaysShown, SkillCategory.immunity, new SkillLevelRequirement[] { SkillLevelRequirement.requireOtherSkill(SkillID.resistanceBlood, 3) From 410f796c31350034535bc0bce51f248884337fb9 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Thu, 5 Jan 2017 09:26:37 +0200 Subject: [PATCH 26/32] Update HeroinfoActivity_Inventory.java --- .../activity/fragment/HeroinfoActivity_Inventory.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java index a306c0c19..d47d8040c 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java @@ -36,9 +36,6 @@ public final class HeroinfoActivity_Inventory extends Fragment { private static final int INTENTREQUEST_ITEMINFO = 3; private static final int INTENTREQUEST_BULKSELECT_DROP = 11; - public static final int INTENTREQUEST_PRESETLOAD = 12; - public static final int INTENTREQUEST_PRESETSAVE = 13; - public static final int INTENTREQUEST_PRESETDELETE = 14; private WorldContext world; private ControllerContext controllers; @@ -55,12 +52,6 @@ public final class HeroinfoActivity_Inventory extends Fragment { private ItemContainerAdapter inventoryQuestListAdapter; private ItemContainerAdapter inventoryOtherListAdapter; - private Button inventory_preset_button; - - private TextView preset_quickswitch_save; - private TextView preset_quickswitch_load; - private TextView preset_quickswitch_delete; - private TextView heroinfo_stats_gold; private TextView heroinfo_stats_attack; @@ -484,4 +475,4 @@ public final class HeroinfoActivity_Inventory extends Fragment { updateItemList(); } -} \ No newline at end of file +} From ffd37a709ba4865ede1a160574cfcce311b7e571 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Fri, 6 Jan 2017 16:04:44 +0200 Subject: [PATCH 27/32] Added name under "Additional programming" Initials before surname due to ethnic saltiness --- AndorsTrail/res/values/authors.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/AndorsTrail/res/values/authors.xml b/AndorsTrail/res/values/authors.xml index 3078720ad..b736163ba 100644 --- a/AndorsTrail/res/values/authors.xml +++ b/AndorsTrail/res/values/authors.xml @@ -18,6 +18,7 @@ Additional programming by <a href="https://github.com/Zukero">Kevin Pochat</a><br /> Additional programming by Lucas Delvallet<br /> Additional programming by Florian Doublet<br /> + Additional programming by M.H. Alkotob<br /> Additional graphics by Karvis<br /> Russian translation by Dreamer..., e.solodookhin, shell.andor, konstmih, istasman, Aleksey Kabanov, Alexander Zubok, Paul Sulemenkov and dromoz<br /> Italian translation by k6blue, liogiu, Joker and Andrea Luciano Damico<br /> From a60e2ab4c5110774d5396820025ecd57bf234efc Mon Sep 17 00:00:00 2001 From: HummusSamurai Date: Fri, 13 Jan 2017 16:49:43 +0200 Subject: [PATCH 28/32] The sorting/category buttons in the inventory are now above the inventory list directly. --- .../res/layout-land/heroinfo_inventory.xml | 59 ++++++++++--------- AndorsTrail/res/layout/heroinfo_inventory.xml | 42 ++++++------- 2 files changed, 51 insertions(+), 50 deletions(-) diff --git a/AndorsTrail/res/layout-land/heroinfo_inventory.xml b/AndorsTrail/res/layout-land/heroinfo_inventory.xml index c6304089a..0f026c66d 100644 --- a/AndorsTrail/res/layout-land/heroinfo_inventory.xml +++ b/AndorsTrail/res/layout-land/heroinfo_inventory.xml @@ -13,6 +13,36 @@ android:gravity="left" > + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - Date: Fri, 13 Jan 2017 16:51:39 +0200 Subject: [PATCH 29/32] extra newlines --- AndorsTrail/res/layout-land/heroinfo_inventory.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/AndorsTrail/res/layout-land/heroinfo_inventory.xml b/AndorsTrail/res/layout-land/heroinfo_inventory.xml index 0f026c66d..19a00479b 100644 --- a/AndorsTrail/res/layout-land/heroinfo_inventory.xml +++ b/AndorsTrail/res/layout-land/heroinfo_inventory.xml @@ -13,8 +13,6 @@ android:gravity="left" > - - - \ No newline at end of file + From 7c61ad5f815555a4943f72b18978ea96dcbe47d9 Mon Sep 17 00:00:00 2001 From: Mohamad Alkotob Date: Fri, 13 Jan 2017 16:52:17 +0200 Subject: [PATCH 30/32] extra newlines --- AndorsTrail/res/layout/heroinfo_inventory.xml | 127 ++++++++++-------- 1 file changed, 70 insertions(+), 57 deletions(-) diff --git a/AndorsTrail/res/layout/heroinfo_inventory.xml b/AndorsTrail/res/layout/heroinfo_inventory.xml index b01aef908..19a00479b 100644 --- a/AndorsTrail/res/layout/heroinfo_inventory.xml +++ b/AndorsTrail/res/layout/heroinfo_inventory.xml @@ -3,73 +3,86 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" - android:gravity="left" + android:orientation="horizontal" > + + + + + + + + + + + + - + + - + + - + + + - - - - - - - - - - - \ No newline at end of file + From afaf284a592ed9154527569b3325a8d1736ffd73 Mon Sep 17 00:00:00 2001 From: "M.H. Alkotob" Date: Tue, 31 Jan 2017 10:21:41 +0200 Subject: [PATCH 31/32] request changes --- AndorsTrail/res/layout/heroinfo_inventory.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AndorsTrail/res/layout/heroinfo_inventory.xml b/AndorsTrail/res/layout/heroinfo_inventory.xml index 19a00479b..80e03e8ca 100644 --- a/AndorsTrail/res/layout/heroinfo_inventory.xml +++ b/AndorsTrail/res/layout/heroinfo_inventory.xml @@ -3,12 +3,12 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="horizontal" + android:orientation="vertical" > From 4eff7a97c9cf3eb7dbb90926a6ac7adbb9e576a7 Mon Sep 17 00:00:00 2001 From: "M.H. Alkotob" Date: Wed, 22 Feb 2017 14:40:13 +0200 Subject: [PATCH 32/32] Changed layout_height(s) to "wrap_content" --- AndorsTrail/res/layout/heroinfo_inventory.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AndorsTrail/res/layout/heroinfo_inventory.xml b/AndorsTrail/res/layout/heroinfo_inventory.xml index 80e03e8ca..557b4b119 100644 --- a/AndorsTrail/res/layout/heroinfo_inventory.xml +++ b/AndorsTrail/res/layout/heroinfo_inventory.xml @@ -7,7 +7,7 @@ >