Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

new loot dialog options: rare items #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion AndorsTrail/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,17 @@
<string name="preferences_combat_speed_title">Скорость схватки</string>
<string name="preferences_combat_speed">Выбор скорости атаки монстров.</string>

<string name="preferences_display_loot_dialog">Показывать диалог</string>
<string name="preferences_display_loot_dialog">Всегда показывать диалог</string>
<string name="preferences_display_loot_dialog_on_items">Показывать диалог при нахождении предметов</string>
<string name="preferences_display_loot_dialog_on_items_or_toast">Диалог для предметов, иначе нотификация</string>
<string name="preferences_display_loot_toast">Короткое уведомление</string>
<string name="preferences_display_loot_toast_on_items">Нотификация при нахождении предметов</string>
<string name="preferences_display_loot_toast_rare_else_none">Нотификация при нахождении редких предметов</string>
<string name="preferences_display_loot_dialog_rare_else_none">Диалог при нахождении редких предметов</string>
<string name="preferences_display_loot_dialog_rare_else_toast">Диалог при нахождении редких предметов, иначе нотификация</string>
<string name="preferences_display_loot_never">Не показывать</string>


<string name="preferences_attackspeed_instant">Мгновенно (без анимации)</string>
<string name="preferences_attackspeed_fast">Быстро</string>
<string name="preferences_attackspeed_normal">Нормально</string>
Expand Down
6 changes: 6 additions & 0 deletions AndorsTrail/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<item>@string/preferences_display_loot_dialog_on_items_or_toast</item>
<item>@string/preferences_display_loot_toast</item>
<item>@string/preferences_display_loot_toast_on_items</item>
<item>@string/preferences_display_loot_toast_rare_else_none</item>
<item>@string/preferences_display_loot_dialog_rare_else_none</item>
<item>@string/preferences_display_loot_dialog_rare_else_toast</item>
<item>@string/preferences_display_loot_never</item>
</string-array>
<string-array name="preferences_display_loot_values">
Expand All @@ -22,6 +25,9 @@
<item>4</item>
<item>1</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>2</item>
</string-array>

Expand Down
3 changes: 3 additions & 0 deletions AndorsTrail/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@
<string name="preferences_display_loot_dialog_on_items_or_toast">Dialog for items, notif. otherwise</string>
<string name="preferences_display_loot_toast">Show short notification</string>
<string name="preferences_display_loot_toast_on_items">Show notification only when finding items</string>
<string name="preferences_display_loot_toast_rare_else_none">Show notification for rare items</string>
<string name="preferences_display_loot_dialog_rare_else_none">Show loot dialog for rare items</string>
<string name="preferences_display_loot_dialog_rare_else_toast">Show loot dialog for rare items, notif.otherwise</string>
<string name="preferences_display_loot_never">Do not display</string>

<string name="preferences_attackspeed_instant">Instant (no animations)</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public final class AndorsTrailPreferences {
public static final int DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST = 4;
public static final int DISPLAYLOOT_TOAST = 1;
public static final int DISPLAYLOOT_TOAST_FOR_ITEMS = 5;
public static final int DISPLAYLOOT_TOAST_RARE_ELSE_NONE = 6;
public static final int DISPLAYLOOT_DIALOG_RARE_ELSE_NONE = 7;
public static final int DISPLAYLOOT_DIALOG_RARE_ELSE_TOAST = 8;
public static final int DISPLAYLOOT_NONE = 2;
public static final int MOVEMENTMETHOD_STRAIGHT = 0;
public static final int MOVEMENTMETHOD_DIRECTIONAL = 1;
Expand Down
35 changes: 29 additions & 6 deletions AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,24 +373,47 @@ public void onPlayerSteppedOnGroundLoot(Loot loot) {

@Override
public void onPlayerPickedUpGroundLoot(Loot loot) {
if (controllers.preferences.displayLoot == AndorsTrailPreferences.DISPLAYLOOT_NONE) return;
if (!showToastForPickedUpItems(loot)) return;
if (!showToastForLoot(loot)) return;

final String msg = Dialogs.getGroundLootPickedUpMessage(this, loot);
showToast(msg, Toast.LENGTH_LONG);
}

private boolean showToastForPickedUpItems(Loot loot) {
switch (controllers.preferences.displayLoot) {
case AndorsTrailPreferences.DISPLAYLOOT_TOAST:
public static boolean showToastForLoot(int displayLootPreference, Loot loot) {
switch (displayLootPreference) {
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS:
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST:
case AndorsTrailPreferences.DISPLAYLOOT_TOAST:
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_RARE_ELSE_TOAST:
return true;
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS:
case AndorsTrailPreferences.DISPLAYLOOT_TOAST_FOR_ITEMS:
return loot.hasItems();
case AndorsTrailPreferences.DISPLAYLOOT_TOAST_RARE_ELSE_NONE:
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_RARE_ELSE_NONE:
return loot.hasRareItems();
}
return false;
}

public static boolean showDialogForLoot(int displayLootPreference, Loot loot) {
switch (displayLootPreference) {
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS:
return true;
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS:
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST:
return loot.hasItems();
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_RARE_ELSE_TOAST:
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_RARE_ELSE_NONE:
return loot.hasRareItems();
}
return false;
}

private boolean showToastForLoot(Loot loot) {
return showToastForLoot(controllers.preferences.displayLoot, loot);
}

@Override
public void onPlayerFoundMonsterLoot(Collection<Loot> loot, int exp) {
final Loot combinedLoot = Loot.combine(loot);
Expand All @@ -403,7 +426,7 @@ public void onPlayerPickedUpMonsterLoot(Collection<Loot> loot, int exp) {
if (controllers.preferences.displayLoot == AndorsTrailPreferences.DISPLAYLOOT_NONE) return;

final Loot combinedLoot = Loot.combine(loot);
if (!showToastForPickedUpItems(combinedLoot)) return;
if (!showToastForLoot(combinedLoot)) return;

final String msg = Dialogs.getMonsterLootPickedUpMessage(this, combinedLoot, exp);
showToast(msg, Toast.LENGTH_LONG);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gpl.rpg.AndorsTrail.controller;

import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences;
import com.gpl.rpg.AndorsTrail.activity.MainActivity;
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.controller.listeners.QuickSlotListeners;
Expand Down Expand Up @@ -93,13 +94,13 @@ public void useItem(ItemType type) {
}

public void playerSteppedOnLootBag(Loot loot) {
if (pickupLootBagWithoutConfirmation(loot)) {
if (confirmOnPickupLootBag(loot)) {
controllers.mapController.worldEventListeners.onPlayerSteppedOnGroundLoot(loot);
consumeNonItemLoot(loot);
} else {
controllers.mapController.worldEventListeners.onPlayerPickedUpGroundLoot(loot);
pickupAll(loot);
removeLootBagIfEmpty(loot);
} else {
controllers.mapController.worldEventListeners.onPlayerSteppedOnGroundLoot(loot);
consumeNonItemLoot(loot);
}
}

Expand All @@ -115,22 +116,15 @@ public void lootMonsterBags(Collection<Loot> killedMonsterBags, int totalExpThis
}
}

private boolean pickupLootBagWithoutConfirmation(Loot bag) {
private boolean confirmOnPickupLootBag(Loot bag) {
if (bag.isContainer()) return false;
switch (controllers.preferences.displayLoot) {
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS:
return false;
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS:
case AndorsTrailPreferences.DISPLAYLOOT_DIALOG_FOR_ITEMS_ELSE_TOAST:
if (bag.hasItems()) return false;
}
return true;
return MainActivity.showDialogForLoot(controllers.preferences.displayLoot, bag);
}

private boolean pickupLootBagsWithoutConfirmation(Collection<Loot> bags) {
if (controllers.preferences.displayLoot == AndorsTrailPreferences.DISPLAYLOOT_DIALOG_ALWAYS) return false;
for (Loot bag : bags) {
if (!pickupLootBagWithoutConfirmation(bag)) return false;
if (confirmOnPickupLootBag(bag)) return false;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public int findItemIndex(String itemTypeID) {
}
return -1;
}
public boolean hasItem(String itemTypeID) { return findItem(itemTypeID) != null; }
public boolean hasItem(String itemTypeID, int minimumQuantity) {
return getItemQuantity(itemTypeID) >= minimumQuantity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public final class ItemType {

public static enum DisplayType {
public enum DisplayType {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the "static" modifier ?

Copy link
Author

@vn971 vn971 Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's just no need for that, since inner enums are static anyway. http://stackoverflow.com/questions/663834/in-java-are-enum-types-inside-a-class-static
But I guess if that's a common code style in AT, I could revert that part.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Zukero should I revert that part?

ordinary
,quest
,legendary
Expand Down
6 changes: 6 additions & 0 deletions AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Loot.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public boolean hasItemsOrGold() {
public boolean hasItems() {
return !items.isEmpty();
}
public boolean hasRareItems() {
for (ItemContainer.ItemEntry item: items.items) {
if (!item.itemType.isOrdinaryItem()) return true;
}
return false;
}
public boolean isContainer() {
return !isVisible;
}
Expand Down