mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-01-22 19:35:44 +01:00
Code cleanup: make classes final where possible.
This commit is contained in:
@@ -4,7 +4,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
public class AndorsTrailPreferences {
|
||||
public final class AndorsTrailPreferences {
|
||||
public static final int DISPLAYLOOT_DIALOG = 0;
|
||||
public static final int DISPLAYLOOT_TOAST = 1;
|
||||
public static final int DISPLAYLOOT_NONE = 2;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@@ -18,7 +18,6 @@ import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ActorConditionInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.BulkSelectionInterface;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ConversationActivity;
|
||||
@@ -32,7 +31,6 @@ import com.gpl.rpg.AndorsTrail.activity.LevelUpActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MonsterEncounterActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.MonsterInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.Preferences;
|
||||
import com.gpl.rpg.AndorsTrail.activity.HeroinfoActivity_Quests;
|
||||
import com.gpl.rpg.AndorsTrail.activity.ShopActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.SkillInfoActivity;
|
||||
import com.gpl.rpg.AndorsTrail.activity.StartScreenActivity;
|
||||
@@ -117,36 +115,41 @@ public final class Dialogs {
|
||||
}
|
||||
|
||||
public static String getGroundLootMessage(final Context ctx, final Loot loot) {
|
||||
String msg = "";
|
||||
if (!loot.items.isEmpty()) msg = ctx.getString(R.string.dialog_groundloot_message);
|
||||
|
||||
if (loot.gold > 0) {
|
||||
msg += ctx.getString(R.string.dialog_loot_foundgold, loot.gold);
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
if (!loot.items.isEmpty()) {
|
||||
sb.append(ctx.getString(R.string.dialog_groundloot_message));
|
||||
}
|
||||
msg += getLootMessage(ctx, loot);
|
||||
return msg;
|
||||
if (loot.gold > 0) {
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_foundgold, loot.gold));
|
||||
}
|
||||
appendLootMessage(ctx, loot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public static String getMonsterLootMessage(final Context ctx, final Loot combinedLoot, final int exp) {
|
||||
String msg = ctx.getString(R.string.dialog_monsterloot_message);
|
||||
StringBuilder sb = new StringBuilder(60);
|
||||
sb.append(ctx.getString(R.string.dialog_monsterloot_message));
|
||||
|
||||
if (exp > 0) {
|
||||
msg += ctx.getString(R.string.dialog_monsterloot_gainedexp, exp);
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_monsterloot_gainedexp, exp));
|
||||
}
|
||||
msg += getLootMessage(ctx, combinedLoot);
|
||||
return msg;
|
||||
appendLootMessage(ctx, combinedLoot, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
private static String getLootMessage(final Context ctx, final Loot loot) {
|
||||
String msg = "";
|
||||
private static void appendLootMessage(final Context ctx, final Loot loot, final StringBuilder sb) {
|
||||
if (loot.gold > 0) {
|
||||
msg += ctx.getString(R.string.dialog_loot_foundgold, loot.gold);
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_foundgold, loot.gold));
|
||||
}
|
||||
int numItems = loot.items.countItems();
|
||||
if (numItems == 1) {
|
||||
msg += ctx.getString(R.string.dialog_loot_pickedupitem);
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_pickedupitem));
|
||||
} else if (numItems > 1){
|
||||
msg += ctx.getString(R.string.dialog_loot_pickedupitems, numItems);
|
||||
sb.append(' ');
|
||||
sb.append(ctx.getString(R.string.dialog_loot_pickedupitems, numItems));
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
public static void showMonsterLoot(final MainActivity mainActivity, final ViewContext view, final WorldContext world, final Iterable<Loot> lootBags, final Loot combinedLoot, final String msg) {
|
||||
@@ -154,7 +157,7 @@ public final class Dialogs {
|
||||
}
|
||||
|
||||
public static void showGroundLoot(final MainActivity mainActivity, final ViewContext view, final WorldContext world, final Loot loot, final String msg) {
|
||||
showLoot(mainActivity, view, world, loot, Arrays.asList(loot), R.string.dialog_monsterloot_title, msg);
|
||||
showLoot(mainActivity, view, world, loot, Collections.singletonList(loot), R.string.dialog_monsterloot_title, msg);
|
||||
}
|
||||
|
||||
private static void showLoot(final MainActivity mainActivity, final ViewContext view, final WorldContext world, final Loot combinedLoot, final Iterable<Loot> lootBags, final int title, final String msg) {
|
||||
@@ -277,11 +280,6 @@ public final class Dialogs {
|
||||
currentActivity.startActivityForResult(intent, StartScreenActivity.INTENTREQUEST_LOADGAME);
|
||||
}
|
||||
|
||||
public static void showQuestLog(final Activity currentActivity) {
|
||||
Intent intent = new Intent(currentActivity, HeroinfoActivity_Quests.class);
|
||||
currentActivity.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void showActorConditionInfo(final Context context, ActorConditionType conditionType) {
|
||||
Intent intent = new Intent(context, ActorConditionInfoActivity.class);
|
||||
intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/actorconditioninfo/" + conditionType.conditionTypeID));
|
||||
|
||||
@@ -128,8 +128,8 @@ public final class Savegames {
|
||||
|
||||
private static void onWorldLoaded(WorldContext world, ViewContext view) {
|
||||
view.actorStatsController.recalculatePlayerStats(world.model.player);
|
||||
Controller.resetMapsNotRecentlyVisited(world);
|
||||
MovementController.moveBlockedActors(world);
|
||||
view.controller.resetMapsNotRecentlyVisited();
|
||||
view.movementController.moveBlockedActors();
|
||||
}
|
||||
|
||||
public static FileHeader quickload(Context androidContext, int slot) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.gpl.rpg.AndorsTrail;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.resource.DynamicTileLoader;
|
||||
import com.gpl.rpg.AndorsTrail.util.ConstRange;
|
||||
|
||||
@@ -30,7 +28,7 @@ public final class VisualEffectCollection {
|
||||
return new VisualEffect(frameIconIDs, duration, textColor);
|
||||
}
|
||||
|
||||
public final static class VisualEffect {
|
||||
public static final class VisualEffect {
|
||||
public final int[] frameIconIDs;
|
||||
public final int duration; // milliseconds
|
||||
public final int textColor;
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.os.AsyncTask;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.context.ViewContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.MovementController;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
import com.gpl.rpg.AndorsTrail.resource.ResourceLoader;
|
||||
|
||||
@@ -46,7 +45,7 @@ public final class WorldSetup {
|
||||
}
|
||||
}
|
||||
|
||||
public void startResourceLoader(final Resources r, final AndorsTrailPreferences preferences) {
|
||||
public void startResourceLoader(final Resources r) {
|
||||
if (isResourcesInitialized) return;
|
||||
|
||||
synchronized (this) {
|
||||
@@ -141,7 +140,7 @@ public final class WorldSetup {
|
||||
Context ctx = androidContext.get();
|
||||
int result = Savegames.loadWorld(world, view, ctx, loadFromSlot);
|
||||
if (result == Savegames.LOAD_RESULT_SUCCESS) {
|
||||
MovementController.cacheCurrentMapData(ctx.getResources(), world, world.model.currentMap);
|
||||
view.movementController.cacheCurrentMapData(ctx.getResources(), world.model.currentMap);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public final class AboutActivity extends Activity implements ImageGetter {
|
||||
tv.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
TextView t = (TextView) findViewById(R.id.about_version);
|
||||
t.setText("v" + AndorsTrailApplication.CURRENT_VERSION_DISPLAY);
|
||||
t.setText('v' + AndorsTrailApplication.CURRENT_VERSION_DISPLAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,12 +78,13 @@ public final class AboutActivity extends Activity implements ImageGetter {
|
||||
Drawable r = res.getDrawable(R.drawable.ui_quickslots);
|
||||
r.setBounds(0, 0, r.getIntrinsicWidth(), r.getIntrinsicHeight());
|
||||
return r;
|
||||
} else if (s.equals("char_hero.png")) {
|
||||
}
|
||||
if (s.equals("char_hero.png")) {
|
||||
Drawable r = res.getDrawable(R.drawable.char_hero);
|
||||
r.setBounds(0, 0, r.getIntrinsicWidth(), r.getIntrinsicHeight()*4/5);
|
||||
return r;
|
||||
}
|
||||
else if (s.equals("monster.png")) d = res.getDrawable(R.drawable.monsters_eye4);
|
||||
if (s.equals("monster.png")) d = res.getDrawable(R.drawable.monsters_eye4);
|
||||
else if (s.equals("flee_example.png")) d = res.getDrawable(R.drawable.ui_flee_example);
|
||||
else if (s.equals("doubleattackexample.png")) d = res.getDrawable(R.drawable.ui_doubleattackexample);
|
||||
else return null;
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionType;
|
||||
import com.gpl.rpg.AndorsTrail.view.AbilityModifierInfoView;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemEffectsView_OnUse;
|
||||
|
||||
public class ActorConditionInfoActivity extends Activity {
|
||||
public final class ActorConditionInfoActivity extends Activity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -27,7 +27,7 @@ public class ActorConditionInfoActivity extends Activity {
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
final WorldContext world = app.getWorld();
|
||||
|
||||
String conditionTypeID = getIntent().getData().getLastPathSegment().toString();
|
||||
String conditionTypeID = getIntent().getData().getLastPathSegment();
|
||||
ActorConditionType conditionType = world.actorConditionsTypes.getActorConditionType(conditionTypeID);
|
||||
|
||||
setContentView(R.layout.actorconditioninfo);
|
||||
|
||||
@@ -28,32 +28,33 @@ import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
* @author ejwessel
|
||||
* Creates the BulkSelectionInterface dialog that allows for buy/drop/selling
|
||||
*/
|
||||
public class BulkSelectionInterface extends Activity implements TextWatcher {
|
||||
public final class BulkSelectionInterface extends Activity implements TextWatcher {
|
||||
|
||||
// class variables
|
||||
final public static int BULK_INTERFACE_BUY = 0;
|
||||
final public static int BULK_INTERFACE_SELL = 1;
|
||||
final public static int BULK_INTERFACE_DROP = 2;
|
||||
public static final int BULK_INTERFACE_BUY = 0;
|
||||
public static final int BULK_INTERFACE_SELL = 1;
|
||||
public static final int BULK_INTERFACE_DROP = 2;
|
||||
|
||||
final private static int BUTTON_REPEAT_FIRST_TIME = 300; // Delay after the touch before the counting starts
|
||||
final private static int BUTTON_REPEAT_FURTHER_TIMES = 50; // Delay between two count events
|
||||
final private static int BUTTON_REPEAT_DOUBLE_AFTER = 10; // after how many count events the countValue doubles?
|
||||
private static final int BUTTON_REPEAT_FIRST_TIME = 300; // Delay after the touch before the counting starts
|
||||
private static final int BUTTON_REPEAT_FURTHER_TIMES = 50; // Delay between two count events
|
||||
private static final int BUTTON_REPEAT_DOUBLE_AFTER = 10; // after how many count events the countValue doubles?
|
||||
|
||||
private WorldContext world;
|
||||
private int interfaceType; // the type of interface either: BULK_INTERFACE_BUY, BULK_INTERFACE_SELL or BULK_INTERFACE_DROP
|
||||
private ItemType itemType;
|
||||
private int totalAvailableAmount;
|
||||
private int pricePerUnit;
|
||||
|
||||
private TextView bulkselection_amount_available;
|
||||
|
||||
private TextView bulkselection_summary_totalgold;
|
||||
private EditText bulkselection_amount_taken; // the amount we're going to take from the totalAmount
|
||||
private SeekBar bulkselection_slider;
|
||||
private Button okButton;
|
||||
|
||||
private final Handler timedEventHandler = new Handler(); // variables to count up or down on long presses on the buttons
|
||||
private int countValue, countTime;
|
||||
private int countValue;
|
||||
private int countTime;
|
||||
private final Runnable countEvent = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
incrementValueAndRepeat(BUTTON_REPEAT_FURTHER_TIMES);
|
||||
}
|
||||
@@ -92,7 +93,7 @@ public class BulkSelectionInterface extends Activity implements TextWatcher {
|
||||
// initialize UI variables
|
||||
TextView bulkselection_action_type = (TextView)findViewById(R.id.bulkselection_action_type);
|
||||
bulkselection_amount_taken = (EditText)findViewById(R.id.bulkselection_amount_taken);
|
||||
bulkselection_amount_available = (TextView)findViewById(R.id.bulkselection_amount_available);
|
||||
TextView bulkselection_amount_available = (TextView) findViewById(R.id.bulkselection_amount_available);
|
||||
bulkselection_slider = (SeekBar)findViewById(R.id.bulkselection_slider);
|
||||
bulkselection_summary_totalgold = (TextView)findViewById(R.id.bulkselection_summary_totalgold);
|
||||
okButton = (Button)findViewById(R.id.bulkselection_finalize_button);
|
||||
@@ -122,7 +123,7 @@ public class BulkSelectionInterface extends Activity implements TextWatcher {
|
||||
|
||||
// initialize the visual components visuals
|
||||
okButton.setText(actionText);
|
||||
bulkselection_action_type.setText(actionText + " ");
|
||||
bulkselection_action_type.setText(actionText + ' ');
|
||||
bulkselection_amount_available.setText(Integer.toString(totalAvailableAmount));
|
||||
bulkselection_slider.setMax(totalAvailableAmount - 1);
|
||||
|
||||
@@ -188,7 +189,7 @@ public class BulkSelectionInterface extends Activity implements TextWatcher {
|
||||
okButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (requiresConfirmation(itemType)) {
|
||||
if (requiresConfirmation()) {
|
||||
final String displayType = ItemInfoActivity.getDisplayTypeString(res, itemType).toLowerCase();
|
||||
final String message = res.getString(R.string.bulkselection_sell_confirmation, itemType.getName(world.model.player), displayType);
|
||||
|
||||
@@ -201,7 +202,7 @@ public class BulkSelectionInterface extends Activity implements TextWatcher {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
itemsResult(intent);
|
||||
}
|
||||
})
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
} else {
|
||||
@@ -209,7 +210,7 @@ public class BulkSelectionInterface extends Activity implements TextWatcher {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean requiresConfirmation(ItemType itemType) {
|
||||
private boolean requiresConfirmation() {
|
||||
if (interfaceType != BULK_INTERFACE_SELL) return false;
|
||||
if (itemType.isOrdinaryItem()) return false;
|
||||
return true;
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment.WorldMapSegmentMap;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
public class DisplayWorldMapActivity extends Activity {
|
||||
public final class DisplayWorldMapActivity extends Activity {
|
||||
private WorldContext world;
|
||||
|
||||
private WebView displayworldmap_webview;
|
||||
@@ -76,9 +76,9 @@ public class DisplayWorldMapActivity extends Activity {
|
||||
WorldMapSegmentMap map = segment.maps.get(world.model.currentMap.name);
|
||||
if (map == null) this.finish();
|
||||
|
||||
String url = "file://" + worldmap.getAbsolutePath() + "?"
|
||||
String url = "file://" + worldmap.getAbsolutePath() + '?'
|
||||
+ (world.model.player.position.x + map.worldPosition.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
+ ","
|
||||
+ ','
|
||||
+ (world.model.player.position.y + map.worldPosition.y-1) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE;
|
||||
L.log("Showing " + url);
|
||||
displayworldmap_webview.loadUrl(url);
|
||||
|
||||
@@ -35,11 +35,9 @@ public final class HeroinfoActivity_Inventory extends Activity {
|
||||
private TileCollection wornTiles;
|
||||
|
||||
private Player player;
|
||||
private ItemContainer container;
|
||||
private ItemContainerAdapter inventoryListAdapter;
|
||||
|
||||
private ListView inventoryList;
|
||||
private TextView heroinfo_stats_gold;
|
||||
private TextView heroinfo_stats_gold;
|
||||
private TextView heroinfo_stats_attack;
|
||||
private TextView heroinfo_stats_defense;
|
||||
|
||||
@@ -58,17 +56,17 @@ public final class HeroinfoActivity_Inventory extends Activity {
|
||||
this.player = world.model.player;
|
||||
|
||||
setContentView(R.layout.heroinfo_inventory);
|
||||
|
||||
inventoryList = (ListView) findViewById(R.id.inventorylist_root);
|
||||
|
||||
ListView inventoryList = (ListView) findViewById(R.id.inventorylist_root);
|
||||
registerForContextMenu(inventoryList);
|
||||
inventoryList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
ItemType itemType = inventoryListAdapter.getItem(position).itemType;
|
||||
showInventoryItemInfo(itemType.id);
|
||||
}
|
||||
});
|
||||
container = player.inventory;
|
||||
ItemContainer container = player.inventory;
|
||||
wornTiles = world.tileManager.loadTilesFor(player.inventory, getResources());
|
||||
inventoryListAdapter = new ItemContainerAdapter(this, world.tileManager, container, player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryListAdapter);
|
||||
@@ -95,17 +93,17 @@ public final class HeroinfoActivity_Inventory extends Activity {
|
||||
}
|
||||
|
||||
private void setWearSlot(final int inventorySlot, int viewId, int resourceId) {
|
||||
final ImageView view = (ImageView) findViewById(viewId);
|
||||
wornItemImage[inventorySlot] = view;
|
||||
final ImageView imageView = (ImageView) findViewById(viewId);
|
||||
wornItemImage[inventorySlot] = imageView;
|
||||
defaultWornItemImageResourceIDs[inventorySlot] = resourceId;
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
imageView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (player.inventory.isEmptySlot(inventorySlot)) return;
|
||||
view.setClickable(false); // Will be enabled again on update()
|
||||
imageView.setClickable(false); // Will be enabled again on update()
|
||||
showEquippedItemInfo(player.inventory.wear[inventorySlot], inventorySlot);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,7 +118,7 @@ public final class HeroinfoActivity_Inventory extends Activity {
|
||||
if (actionType == ItemInfoActivity.ITEMACTION_UNEQUIP) {
|
||||
view.itemController.unequipSlot(itemType, data.getExtras().getInt("inventorySlot"));
|
||||
} else if (actionType == ItemInfoActivity.ITEMACTION_EQUIP) {
|
||||
int slot = suggestInventorySlot(itemType, player);
|
||||
int slot = suggestInventorySlot(itemType);
|
||||
view.itemController.equipItem(itemType, slot);
|
||||
} else if (actionType == ItemInfoActivity.ITEMACTION_USE) {
|
||||
view.itemController.useItem(itemType);
|
||||
@@ -136,13 +134,12 @@ public final class HeroinfoActivity_Inventory extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
private static int suggestInventorySlot(ItemType itemType, Player player) {
|
||||
private int suggestInventorySlot(ItemType itemType) {
|
||||
int slot = itemType.category.inventorySlot;
|
||||
if (player.inventory.isEmptySlot(slot)) return slot;
|
||||
|
||||
if (slot == Inventory.WEARSLOT_LEFTRING) {
|
||||
return Inventory.WEARSLOT_RIGHTRING;
|
||||
} else if (itemType.isOffhandCapableWeapon()) {
|
||||
if (slot == Inventory.WEARSLOT_LEFTRING) return Inventory.WEARSLOT_RIGHTRING;
|
||||
if (itemType.isOffhandCapableWeapon()) {
|
||||
ItemType mainWeapon = player.inventory.wear[Inventory.WEARSLOT_WEAPON];
|
||||
if (mainWeapon != null && mainWeapon.isTwohandWeapon()) return slot;
|
||||
else if (player.inventory.isEmptySlot(Inventory.WEARSLOT_SHIELD)) return Inventory.WEARSLOT_SHIELD;
|
||||
@@ -164,7 +161,7 @@ public final class HeroinfoActivity_Inventory extends Activity {
|
||||
private void updateTraits() {
|
||||
heroinfo_stats_gold.setText(getResources().getString(R.string.heroinfo_gold, player.inventory.gold));
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder(10);
|
||||
ItemController.describeAttackEffect(
|
||||
player.getAttackChance(),
|
||||
player.getDamagePotential().current,
|
||||
@@ -174,7 +171,7 @@ public final class HeroinfoActivity_Inventory extends Activity {
|
||||
sb);
|
||||
heroinfo_stats_attack.setText(sb.toString());
|
||||
|
||||
sb = new StringBuilder();
|
||||
sb = new StringBuilder(10);
|
||||
ItemController.describeBlockEffect(player.getBlockChance(), player.getDamageResistance(), sb);
|
||||
heroinfo_stats_defense.setText(sb.toString());
|
||||
}
|
||||
@@ -185,13 +182,13 @@ public final class HeroinfoActivity_Inventory extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWornImage(ImageView view, int resourceIDEmptyImage, ItemType type) {
|
||||
private void updateWornImage(ImageView imageView, int resourceIDEmptyImage, ItemType type) {
|
||||
if (type != null) {
|
||||
world.tileManager.setImageViewTile(view, type, wornTiles);
|
||||
world.tileManager.setImageViewTile(imageView, type, wornTiles);
|
||||
} else {
|
||||
view.setImageResource(resourceIDEmptyImage);
|
||||
imageView.setImageResource(resourceIDEmptyImage);
|
||||
}
|
||||
view.setClickable(true);
|
||||
imageView.setClickable(true);
|
||||
}
|
||||
|
||||
private void updateItemList() {
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class HeroinfoActivity_Skills extends Activity {
|
||||
skillList.setAdapter(skillListAdapter);
|
||||
skillList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
Dialogs.showSkillInfo(HeroinfoActivity_Skills.this, (int) id);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -25,8 +25,7 @@ import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public final class HeroinfoActivity_Stats extends Activity {
|
||||
private WorldContext world;
|
||||
|
||||
|
||||
private Player player;
|
||||
|
||||
private Button levelUpButton;
|
||||
@@ -50,7 +49,7 @@ public final class HeroinfoActivity_Stats extends Activity {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
this.world = app.getWorld();
|
||||
final WorldContext world = app.getWorld();
|
||||
this.player = world.model.player;
|
||||
|
||||
setContentView(R.layout.heroinfo_stats);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
@@ -10,13 +8,14 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemEffectsView;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public final class ItemInfoActivity extends Activity {
|
||||
|
||||
public static int ITEMACTION_NONE = 1;
|
||||
@@ -25,15 +24,13 @@ public final class ItemInfoActivity extends Activity {
|
||||
public static int ITEMACTION_UNEQUIP = 4;
|
||||
public static int ITEMACTION_BUY = 5;
|
||||
public static int ITEMACTION_SELL = 6;
|
||||
|
||||
private WorldContext world;
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
this.world = app.getWorld();
|
||||
final WorldContext world = app.getWorld();
|
||||
|
||||
app.setWindowParameters(this);
|
||||
|
||||
@@ -55,9 +52,9 @@ public final class ItemInfoActivity extends Activity {
|
||||
|
||||
((ItemEffectsView) findViewById(R.id.iteminfo_effects)).update(
|
||||
itemType.effects_equip,
|
||||
itemType.effects_use == null ? null : Arrays.asList(itemType.effects_use),
|
||||
itemType.effects_hit == null ? null : Arrays.asList(itemType.effects_hit),
|
||||
itemType.effects_kill == null ? null : Arrays.asList(itemType.effects_kill),
|
||||
itemType.effects_use == null ? null : Collections.singletonList(itemType.effects_use),
|
||||
itemType.effects_hit == null ? null : Collections.singletonList(itemType.effects_hit),
|
||||
itemType.effects_kill == null ? null : Collections.singletonList(itemType.effects_kill),
|
||||
itemType.isWeapon()
|
||||
);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public final class LoadSaveActivity extends Activity implements OnClickListener
|
||||
this.model = app.getWorld().model;
|
||||
this.preferences = app.getPreferences();
|
||||
|
||||
String loadsave = getIntent().getData().getLastPathSegment().toString();
|
||||
String loadsave = getIntent().getData().getLastPathSegment();
|
||||
isLoading = (loadsave.equalsIgnoreCase("load"));
|
||||
|
||||
setContentView(R.layout.loadsave);
|
||||
@@ -105,7 +105,8 @@ public final class LoadSaveActivity extends Activity implements OnClickListener
|
||||
|
||||
if (preferences.displayOverwriteSavegame == AndorsTrailPreferences.CONFIRM_OVERWRITE_SAVEGAME_ALWAYS) {
|
||||
return getString(R.string.loadsave_save_overwrite_confirmation_all);
|
||||
} else if (preferences.displayOverwriteSavegame == AndorsTrailPreferences.CONFIRM_OVERWRITE_SAVEGAME_NEVER) {
|
||||
}
|
||||
if (preferences.displayOverwriteSavegame == AndorsTrailPreferences.CONFIRM_OVERWRITE_SAVEGAME_NEVER) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -126,7 +127,7 @@ public final class LoadSaveActivity extends Activity implements OnClickListener
|
||||
|
||||
if (message != null) {
|
||||
final String title =
|
||||
getString(R.string.loadsave_save_overwrite_confirmation_title) + " "
|
||||
getString(R.string.loadsave_save_overwrite_confirmation_title) + ' '
|
||||
+ getString(R.string.loadsave_save_overwrite_confirmation_slot, slot);
|
||||
new AlertDialog.Builder(this)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
|
||||
@@ -262,12 +262,12 @@ public final class MainActivity extends Activity implements PlayerMovementListen
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
if(quickitemview.isQuickButtonId(v.getId())){
|
||||
createQuickButtonMenu(menu, v, menuInfo);
|
||||
createQuickButtonMenu(menu);
|
||||
}
|
||||
lastSelectedMenu = null;
|
||||
}
|
||||
|
||||
private void createQuickButtonMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo){
|
||||
private void createQuickButtonMenu(ContextMenu menu){
|
||||
menu.add(Menu.NONE, R.id.quick_menu_unassign, Menu.NONE, R.string.inventory_unassign);
|
||||
SubMenu assignMenu = menu.addSubMenu(Menu.NONE, R.id.quick_menu_assign, Menu.NONE, R.string.inventory_assign);
|
||||
for(int i=0; i<world.model.player.inventory.items.size(); ++i){
|
||||
@@ -308,7 +308,7 @@ public final class MainActivity extends Activity implements PlayerMovementListen
|
||||
}
|
||||
|
||||
private void message(String msg) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
for(int i = 0; i < NUM_MESSAGES-1; ++i) {
|
||||
messages[i] = messages[i + 1];
|
||||
if (messages[i].length() > 0) {
|
||||
@@ -374,7 +374,7 @@ public final class MainActivity extends Activity implements PlayerMovementListen
|
||||
msg = getString(R.string.combat_result_herohit, monsterName, attackResult.damage);
|
||||
}
|
||||
if (attackResult.targetDied) {
|
||||
msg += " " + getString(R.string.combat_result_herokillsmonster, monsterName, attackResult.damage);
|
||||
msg += ' ' + getString(R.string.combat_result_herokillsmonster, monsterName, attackResult.damage);
|
||||
}
|
||||
message(msg);
|
||||
}
|
||||
|
||||
@@ -11,18 +11,19 @@ import android.widget.TextView;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.ViewContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
|
||||
public final class MonsterEncounterActivity extends Activity {
|
||||
private WorldContext world;
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
this.world = app.getWorld();
|
||||
final WorldContext world = app.getWorld();
|
||||
final ViewContext view = app.getViewContext();
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
@@ -34,7 +35,7 @@ public final class MonsterEncounterActivity extends Activity {
|
||||
|
||||
setContentView(R.layout.monsterencounter);
|
||||
|
||||
CharSequence difficulty = getText(MonsterInfoActivity.getMonsterDifficultyResource(world, monster));
|
||||
CharSequence difficulty = getText(MonsterInfoActivity.getMonsterDifficultyResource(view, monster));
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.monsterencounter_title);
|
||||
tv.setText(monster.getName());
|
||||
@@ -50,7 +51,7 @@ public final class MonsterEncounterActivity extends Activity {
|
||||
setResult(RESULT_OK);
|
||||
MonsterEncounterActivity.this.finish();
|
||||
}
|
||||
});
|
||||
});
|
||||
b = (Button) findViewById(R.id.monsterencounter_cancel);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
@@ -58,13 +59,13 @@ public final class MonsterEncounterActivity extends Activity {
|
||||
setResult(RESULT_CANCELED);
|
||||
MonsterEncounterActivity.this.finish();
|
||||
}
|
||||
});
|
||||
});
|
||||
b = (Button) findViewById(R.id.monsterencounter_info);
|
||||
b.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
Dialogs.showMonsterInfo(MonsterEncounterActivity.this, monster);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.context.ViewContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.CombatController;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.view.ItemEffectsView;
|
||||
import com.gpl.rpg.AndorsTrail.view.RangeBar;
|
||||
import com.gpl.rpg.AndorsTrail.view.TraitsInfoView;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
public final class MonsterInfoActivity extends Activity {
|
||||
|
||||
private WorldContext world;
|
||||
private ViewContext view;
|
||||
|
||||
private TextView monsterinfo_title;
|
||||
private TextView monsterinfo_difficulty;
|
||||
@@ -37,6 +37,7 @@ public final class MonsterInfoActivity extends Activity {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
this.world = app.getWorld();
|
||||
this.view = app.getViewContext();
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
setContentView(R.layout.monsterinfo);
|
||||
@@ -76,7 +77,7 @@ public final class MonsterInfoActivity extends Activity {
|
||||
private void updateTitle(Monster monster) {
|
||||
monsterinfo_title.setText(monster.getName());
|
||||
world.tileManager.setImageViewTile(monsterinfo_title, monster);
|
||||
monsterinfo_difficulty.setText(getMonsterDifficultyResource(world, monster));
|
||||
monsterinfo_difficulty.setText(getMonsterDifficultyResource(view, monster));
|
||||
}
|
||||
|
||||
private void updateTraits(Monster monster) {
|
||||
@@ -91,13 +92,13 @@ public final class MonsterInfoActivity extends Activity {
|
||||
monsterinfo_max_ap.setText(Integer.toString(monster.getMaxAP()));
|
||||
}
|
||||
|
||||
public static int getMonsterDifficultyResource(WorldContext world, Monster monster) {
|
||||
final int difficulty = CombatController.getMonsterDifficulty(world, monster);
|
||||
public static int getMonsterDifficultyResource(ViewContext viewContext, Monster monster) {
|
||||
final int difficulty = viewContext.combatController.getMonsterDifficulty(monster);
|
||||
if (difficulty >= 80) return R.string.monster_difficulty_veryeasy;
|
||||
else if (difficulty >= 60) return R.string.monster_difficulty_easy;
|
||||
else if (difficulty >= 40) return R.string.monster_difficulty_normal;
|
||||
else if (difficulty >= 20) return R.string.monster_difficulty_hard;
|
||||
else if (difficulty == 0) return R.string.monster_difficulty_impossible;
|
||||
else return R.string.monster_difficulty_veryhard;
|
||||
if (difficulty >= 60) return R.string.monster_difficulty_easy;
|
||||
if (difficulty >= 40) return R.string.monster_difficulty_normal;
|
||||
if (difficulty >= 20) return R.string.monster_difficulty_hard;
|
||||
if (difficulty == 0) return R.string.monster_difficulty_impossible;
|
||||
return R.string.monster_difficulty_veryhard;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ public final class ShopActivity extends TabActivity implements OnContainerItemCl
|
||||
private WorldContext world;
|
||||
private Player player;
|
||||
|
||||
private ListView shoplist_buy;
|
||||
private ListView shoplist_sell;
|
||||
private ItemContainer container_buy;
|
||||
private TextView shop_buy_gc;
|
||||
private TextView shop_sell_gc;
|
||||
@@ -49,8 +47,7 @@ public final class ShopActivity extends TabActivity implements OnContainerItemCl
|
||||
app.setWindowParameters(this);
|
||||
|
||||
final Monster npc = Dialogs.getMonsterFromIntent(getIntent(), world);
|
||||
final Player player = world.model.player;
|
||||
|
||||
|
||||
setContentView(R.layout.shop);
|
||||
|
||||
final Resources res = getResources();
|
||||
@@ -65,9 +62,9 @@ public final class ShopActivity extends TabActivity implements OnContainerItemCl
|
||||
h.setup();
|
||||
shop_buy_gc = (TextView) h.findViewById(R.id.shop_buy_gc);
|
||||
shop_sell_gc = (TextView) h.findViewById(R.id.shop_sell_gc);
|
||||
|
||||
shoplist_buy = (ListView) h.findViewById(R.id.shop_buy_list);
|
||||
shoplist_sell = (ListView) h.findViewById(R.id.shop_sell_list);
|
||||
|
||||
ListView shoplist_buy = (ListView) h.findViewById(R.id.shop_buy_list);
|
||||
ListView shoplist_sell = (ListView) h.findViewById(R.id.shop_sell_list);
|
||||
|
||||
container_buy = npc.getShopItems(player);
|
||||
|
||||
@@ -95,7 +92,7 @@ public final class ShopActivity extends TabActivity implements OnContainerItemCl
|
||||
public void onItemInfoClicked(int position, ItemType itemType, boolean isSelling) {
|
||||
int price;
|
||||
int resid;
|
||||
boolean enableButton = true;
|
||||
boolean enableButton;
|
||||
int action;
|
||||
if (isSelling) {
|
||||
resid = R.string.shop_sellitem;
|
||||
|
||||
@@ -21,16 +21,14 @@ import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
public final class SkillInfoActivity extends Activity {
|
||||
private WorldContext world;
|
||||
private Player player;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
if (!app.isInitialized()) { finish(); return; }
|
||||
this.world = app.getWorld();
|
||||
this.player = world.model.player;
|
||||
final WorldContext world = app.getWorld();
|
||||
final Player player = world.model.player;
|
||||
|
||||
app.setWindowParameters(this);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class StartScreenActivity extends Activity {
|
||||
setContentView(R.layout.startscreen);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv.setText("v" + AndorsTrailApplication.CURRENT_VERSION_DISPLAY);
|
||||
tv.setText('v' + AndorsTrailApplication.CURRENT_VERSION_DISPLAY);
|
||||
|
||||
startscreen_currenthero = (TextView) findViewById(R.id.startscreen_currenthero);
|
||||
startscreen_enterheroname = (EditText) findViewById(R.id.startscreen_enterheroname);
|
||||
@@ -108,7 +108,7 @@ public final class StartScreenActivity extends Activity {
|
||||
TileManager tileManager = app.getWorld().tileManager;
|
||||
tileManager.setDensity(res);
|
||||
tileManager.updatePreferences(preferences);
|
||||
app.getWorldSetup().startResourceLoader(res, preferences);
|
||||
app.getWorldSetup().startResourceLoader(res);
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_FORCE_STARTNEWGAME) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGRESOURCES) {
|
||||
@@ -126,7 +126,7 @@ public final class StartScreenActivity extends Activity {
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
String playerName = null;
|
||||
String playerName;
|
||||
String displayInfo = null;
|
||||
|
||||
FileHeader header = Savegames.quickload(this, Savegames.SLOT_QUICKSAVE);
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.gpl.rpg.AndorsTrail.controller.MonsterMovementController;
|
||||
import com.gpl.rpg.AndorsTrail.controller.MovementController;
|
||||
import com.gpl.rpg.AndorsTrail.controller.InputController;
|
||||
|
||||
public class ViewContext {
|
||||
public final class ViewContext {
|
||||
//Controllers
|
||||
public final Controller controller;
|
||||
public final GameRoundController gameRoundController;
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.gpl.rpg.AndorsTrail.model.map.MapCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.quest.QuestCollection;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
|
||||
public class WorldContext {
|
||||
public final class WorldContext {
|
||||
//Objectcollections
|
||||
public final ConversationLoader conversationLoader;
|
||||
public final ItemTypeCollection itemTypes;
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.gpl.rpg.AndorsTrail.model.listeners.ActorStatsListeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea;
|
||||
|
||||
public class ActorStatsController {
|
||||
public final class ActorStatsController {
|
||||
private final ViewContext view;
|
||||
private final WorldContext world;
|
||||
public final ActorConditionListeners actorConditionListeners = new ActorConditionListeners();
|
||||
@@ -133,7 +133,7 @@ public class ActorStatsController {
|
||||
ActorCondition c = actor.conditions.get(i);
|
||||
if (!type.conditionTypeID.equals(c.conditionType.conditionTypeID)) continue;
|
||||
if (c.magnitude > e.magnitude) return;
|
||||
else if (c.magnitude == e.magnitude) {
|
||||
if (c.magnitude == e.magnitude) {
|
||||
if (c.duration >= duration) return;
|
||||
}
|
||||
// If the actor already has this condition, but of a lower magnitude, we remove the old one and add this higher magnitude.
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.gpl.rpg.AndorsTrail.controller.listeners.CombatActionListeners;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.CombatSelectionListeners;
|
||||
import com.gpl.rpg.AndorsTrail.controller.listeners.CombatTurnListeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.AttackResult;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Actor;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
@@ -61,13 +60,13 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
currentActiveMonster = null;
|
||||
world.model.uiSelections.selectedPosition = null;
|
||||
world.model.uiSelections.selectedMonster = null;
|
||||
if (!killedMonsterBags.isEmpty()) {
|
||||
if (killedMonsterBags.isEmpty()) {
|
||||
view.gameRoundController.resume();
|
||||
} else {
|
||||
if (pickupLootBags) {
|
||||
view.itemController.lootMonsterBags(killedMonsterBags, totalExpThisFight);
|
||||
}
|
||||
killedMonsterBags.clear();
|
||||
} else {
|
||||
view.gameRoundController.resume();
|
||||
}
|
||||
totalExpThisFight = 0;
|
||||
}
|
||||
@@ -130,9 +129,9 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
}
|
||||
|
||||
public void executeMoveAttack(int dx, int dy) {
|
||||
if (isMonsterTurn()) {
|
||||
return;
|
||||
} else if (world.model.uiSelections.selectedMonster != null) {
|
||||
if (isMonsterTurn()) return;
|
||||
|
||||
if (world.model.uiSelections.selectedMonster != null) {
|
||||
executePlayerAttack();
|
||||
} else if (world.model.uiSelections.selectedPosition != null) {
|
||||
executeCombatMove(world.model.uiSelections.selectedPosition);
|
||||
@@ -155,23 +154,21 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
if (m != null) return;
|
||||
executeCombatMove(world.model.player.nextPosition);
|
||||
}
|
||||
|
||||
private Monster currentlyAttackedMonster;
|
||||
|
||||
private AttackResult lastAttackResult;
|
||||
private void executePlayerAttack() {
|
||||
if (view.effectController.isRunningVisualEffect()) return;
|
||||
if (!useAPs(world.model.player.getAttackCost())) return;
|
||||
final Monster target = world.model.uiSelections.selectedMonster;
|
||||
this.currentlyAttackedMonster = target;
|
||||
|
||||
final AttackResult attack = playerAttacks(world, target);
|
||||
|
||||
final AttackResult attack = playerAttacks(target);
|
||||
this.lastAttackResult = attack;
|
||||
|
||||
if (attack.isHit) {
|
||||
combatActionListeners.onPlayerAttackSuccess(target, attack);
|
||||
|
||||
if (lastAttackResult.targetDied) {
|
||||
playerKilledMonster(currentlyAttackedMonster);
|
||||
playerKilledMonster(target);
|
||||
}
|
||||
|
||||
startAttackEffect(attack, world.model.uiSelections.selectedPosition, this, CALLBACK_PLAYERATTACK);
|
||||
@@ -264,6 +261,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
}
|
||||
|
||||
private final Handler monsterTurnHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
monsterTurnHandler.removeMessages(0);
|
||||
CombatController.this.handleNextMonsterAction();
|
||||
@@ -310,7 +308,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
view.actorStatsController.useAPs(currentActiveMonster, currentActiveMonster.getAttackCost());
|
||||
|
||||
combatTurnListeners.onMonsterIsAttacking(currentActiveMonster);
|
||||
AttackResult attack = monsterAttacks(world.model, currentActiveMonster);
|
||||
AttackResult attack = monsterAttacks(currentActiveMonster);
|
||||
this.lastAttackResult = attack;
|
||||
|
||||
if (attack.isHit) {
|
||||
@@ -395,26 +393,26 @@ public final class CombatController implements VisualEffectCompletedCallback {
|
||||
if (averageDamagePerTurn <= 0) return 100;
|
||||
return (int) FloatMath.ceil(target.getMaxHP() / averageDamagePerTurn);
|
||||
}
|
||||
public static int getMonsterDifficulty(WorldContext world, Monster monster) {
|
||||
public int getMonsterDifficulty(Monster monster) {
|
||||
// returns [0..100) . 100 == easy.
|
||||
int turnsToKillMonster = getTurnsToKillTarget(world.model.player, monster);
|
||||
if (turnsToKillMonster >= 999) return 0;
|
||||
int turnsToKillPlayer = getTurnsToKillTarget(monster, world.model.player);
|
||||
int result = 50 + (turnsToKillPlayer - turnsToKillMonster) * 2;
|
||||
if (result <= 1) return 1;
|
||||
else if (result > 100) return 100;
|
||||
if (result > 100) return 100;
|
||||
return result;
|
||||
}
|
||||
|
||||
private AttackResult playerAttacks(WorldContext world, Monster currentMonster) {
|
||||
private AttackResult playerAttacks(Monster currentMonster) {
|
||||
AttackResult result = attack(world.model.player, currentMonster);
|
||||
view.skillController.applySkillEffectsFromPlayerAttack(result, world, currentMonster);
|
||||
view.skillController.applySkillEffectsFromPlayerAttack(result, currentMonster);
|
||||
return result;
|
||||
}
|
||||
|
||||
private AttackResult monsterAttacks(ModelContainer model, Monster currentMonster) {
|
||||
AttackResult result = attack(currentMonster, model.player);
|
||||
view.skillController.applySkillEffectsFromMonsterAttack(result, world, currentMonster);
|
||||
private AttackResult monsterAttacks(Monster currentMonster) {
|
||||
AttackResult result = attack(currentMonster, world.model.player);
|
||||
view.skillController.applySkillEffectsFromMonsterAttack(result, currentMonster);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ public final class Constants {
|
||||
public static final int FULLROUND_DURATION = 25000;
|
||||
public static final int TICKS_PER_ROUND = ROUND_DURATION / TICK_DELAY;
|
||||
public static final int TICKS_PER_FULLROUND = FULLROUND_DURATION / TICK_DELAY;
|
||||
public static final int SPLATTER_DURATION_MS = 20000;
|
||||
|
||||
public static final ConstRange monsterWaitTurns = new ConstRange(30,4);
|
||||
public static final long MAP_UNVISITED_RESPAWN_DURATION_MS = 3 * 60 * 1000; // 3 min in milliseconds
|
||||
|
||||
@@ -40,20 +40,20 @@ public final class Controller {
|
||||
}
|
||||
|
||||
private void steppedOnRestArea(MapObject area) {
|
||||
if (!view.preferences.confirmRest) {
|
||||
rest(area);
|
||||
} else {
|
||||
if (view.preferences.confirmRest) {
|
||||
worldEventListeners.onPlayerSteppedOnRestArea(area);
|
||||
} else {
|
||||
rest(area);
|
||||
}
|
||||
}
|
||||
|
||||
public void steppedOnMonster(Monster m, Coord p) {
|
||||
if (m.isAgressive()) {
|
||||
view.combatController.setCombatSelection(m, p);
|
||||
if (!view.preferences.confirmAttack) {
|
||||
view.combatController.enterCombat(CombatController.BEGIN_TURN_PLAYER);
|
||||
} else {
|
||||
if (view.preferences.confirmAttack) {
|
||||
worldEventListeners.onPlayerSteppedOnMonster(m);
|
||||
} else {
|
||||
view.combatController.enterCombat(CombatController.BEGIN_TURN_PLAYER);
|
||||
}
|
||||
} else {
|
||||
worldEventListeners.onPlayerStartedConversation(m, m.getPhraseID());
|
||||
@@ -98,7 +98,7 @@ public final class Controller {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void resetMapsNotRecentlyVisited(final WorldContext world) {
|
||||
public void resetMapsNotRecentlyVisited() {
|
||||
for (PredefinedMap m : world.maps.predefinedMaps) {
|
||||
if (m == world.model.currentMap) continue;
|
||||
if (m.isRecentlyVisited()) continue;
|
||||
|
||||
@@ -20,7 +20,9 @@ public final class GameRoundController implements TimedMessageTask.Callback {
|
||||
|
||||
private int ticksUntilNextRound = Constants.TICKS_PER_ROUND;
|
||||
private int ticksUntilNextFullRound = Constants.TICKS_PER_FULLROUND;
|
||||
public boolean onTick(TimedMessageTask task) {
|
||||
|
||||
@Override
|
||||
public boolean onTick(TimedMessageTask task) {
|
||||
if (!world.model.uiSelections.isMainActivityVisible) return false;
|
||||
if (world.model.uiSelections.isInCombat) return false;
|
||||
|
||||
@@ -62,7 +64,7 @@ public final class GameRoundController implements TimedMessageTask.Callback {
|
||||
}
|
||||
|
||||
public void onNewFullRound() {
|
||||
Controller.resetMapsNotRecentlyVisited(world);
|
||||
view.controller.resetMapsNotRecentlyVisited();
|
||||
view.actorStatsController.applyConditionsToMonsters(world.model.currentMap, true);
|
||||
view.actorStatsController.applyConditionsToPlayer(world.model.player, true);
|
||||
gameRoundListeners.onNewFullRound();
|
||||
|
||||
@@ -210,13 +210,11 @@ public final class ItemController {
|
||||
}
|
||||
}
|
||||
public boolean removeLootBagIfEmpty(final Loot loot) {
|
||||
if (!loot.hasItems()) {
|
||||
world.model.currentMap.removeGroundLoot(loot);
|
||||
lootBagListeners.onLootBagRemoved(world.model.currentMap, loot.position);
|
||||
return true; // The bag was removed.
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (loot.hasItems()) return false;
|
||||
|
||||
world.model.currentMap.removeGroundLoot(loot);
|
||||
lootBagListeners.onLootBagRemoved(world.model.currentMap, loot.position);
|
||||
return true; // The bag was removed.
|
||||
}
|
||||
|
||||
public boolean removeLootBagIfEmpty(final Iterable<Loot> lootBags) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public final class MonsterMovementController {
|
||||
for (MonsterSpawnArea a : world.model.currentMap.spawnAreas) {
|
||||
for (Monster m : a.monsters) {
|
||||
if (m.nextActionTime <= currentTime) {
|
||||
moveMonster(m, a, currentTime);
|
||||
moveMonster(m, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public final class MonsterMovementController {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void moveMonster(final Monster m, final MonsterSpawnArea area, long currentTime) {
|
||||
private void moveMonster(final Monster m, final MonsterSpawnArea area) {
|
||||
PredefinedMap map = world.model.currentMap;
|
||||
m.nextActionTime += getMillisecondsPerMove(m);
|
||||
if (m.movementDestination == null) {
|
||||
@@ -99,7 +99,7 @@ public final class MonsterMovementController {
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelCurrentMonsterMovement(final Monster m) {
|
||||
private static void cancelCurrentMonsterMovement(final Monster m) {
|
||||
m.movementDestination = null;
|
||||
m.nextActionTime += getMillisecondsPerMove(m) * Constants.rollValue(Constants.monsterWaitTurns);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public final class MonsterMovementController {
|
||||
|
||||
private static int sgn(int i) {
|
||||
if (i <= -1) return -1;
|
||||
else if (i >= 1) return 1;
|
||||
if (i >= 1) return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,15 +73,15 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
final ModelContainer model = world.model;
|
||||
|
||||
if (model.currentMap != null) model.currentMap.updateLastVisitTime();
|
||||
cacheCurrentMapData(res, world, newMap);
|
||||
cacheCurrentMapData(res, newMap);
|
||||
model.currentMap = newMap;
|
||||
model.player.position.set(place.position.topLeft);
|
||||
model.player.position.x += Math.min(offset_x, place.position.size.width-1);
|
||||
model.player.position.y += Math.min(offset_y, place.position.size.height-1);
|
||||
model.player.lastPosition.set(model.player.position);
|
||||
|
||||
if (!newMap.visited) playerVisitsMapFirstTime(newMap);
|
||||
else playerVisitsMap(newMap);
|
||||
if (newMap.visited) playerVisitsMap(newMap);
|
||||
else playerVisitsMapFirstTime(newMap);
|
||||
|
||||
refreshMonsterAggressiveness(newMap, model.player);
|
||||
view.effectController.updateSplatters(newMap);
|
||||
@@ -185,7 +185,7 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
if (m != null && !m.isAgressive()) return true; // avoid MOVEMENTAGGRESSIVENESS settings for NPCs
|
||||
|
||||
if (aggressiveness == AndorsTrailPreferences.MOVEMENTAGGRESSIVENESS_AGGRESSIVE && m == null) return false;
|
||||
else if (aggressiveness == AndorsTrailPreferences.MOVEMENTAGGRESSIVENESS_DEFENSIVE && m != null) return false;
|
||||
if (aggressiveness == AndorsTrailPreferences.MOVEMENTAGGRESSIVENESS_DEFENSIVE && m != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
placePlayerAsyncAt(MapObject.MAPEVENT_REST, world.model.player.getSpawnMap(), world.model.player.getSpawnPlace(), 0, 0);
|
||||
}
|
||||
|
||||
public static void moveBlockedActors(final WorldContext world) {
|
||||
public void moveBlockedActors() {
|
||||
final ModelContainer model = world.model;
|
||||
if (!world.model.currentMap.isWalkable(world.model.player.position)) {
|
||||
// If the player somehow spawned on an unwalkable tile, we move the player to the first mapchange area.
|
||||
@@ -270,7 +270,7 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
public static void cacheCurrentMapData(final Resources res, final WorldContext world, final PredefinedMap nextMap) {
|
||||
public void cacheCurrentMapData(final Resources res, final PredefinedMap nextMap) {
|
||||
LayeredTileMap mapTiles = TMXMapTranslator.readLayeredTileMap(res, world.tileManager.tileCache, nextMap);
|
||||
TileCollection cachedTiles = world.tileManager.loadTilesFor(nextMap, mapTiles, world, res);
|
||||
world.model.currentTileMap = mapTiles;
|
||||
@@ -284,7 +284,7 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
private int movementDx;
|
||||
private int movementDy;
|
||||
public void startMovement(int dx, int dy, Coord destination) {
|
||||
if (world.model.uiSelections.isInCombat) return;
|
||||
if (!mayMovePlayer()) return;
|
||||
if (dx == 0 && dy == 0) return;
|
||||
|
||||
movementDx = dx;
|
||||
@@ -295,7 +295,8 @@ public final class MovementController implements TimedMessageTask.Callback {
|
||||
public void stopMovement() {
|
||||
movementHandler.stop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onTick(TimedMessageTask task) {
|
||||
if (!world.model.uiSelections.isMainActivityVisible) return false;
|
||||
if (world.model.uiSelections.isInCombat) return false;
|
||||
|
||||
@@ -151,35 +151,35 @@ public final class SkillController {
|
||||
if (skillLevel <= 0) return false;
|
||||
return Constants.roll100(chancePerSkillLevel * skillLevel);
|
||||
}
|
||||
private void addConditionToActor(Actor target, WorldContext world, String conditionName, int magnitude, int duration) {
|
||||
private void addConditionToActor(Actor target, String conditionName, int magnitude, int duration) {
|
||||
ActorConditionType conditionType = world.actorConditionsTypes.getActorConditionType(conditionName);
|
||||
ActorConditionEffect effect = new ActorConditionEffect(conditionType, magnitude, duration, null);
|
||||
view.actorStatsController.applyActorCondition(target, effect);
|
||||
}
|
||||
|
||||
public void applySkillEffectsFromPlayerAttack(AttackResult result, WorldContext world, Monster monster) {
|
||||
public void applySkillEffectsFromPlayerAttack(AttackResult result, Monster monster) {
|
||||
if (!result.isHit) return;
|
||||
|
||||
Player player = world.model.player;
|
||||
|
||||
if (player.getAttackChance() - monster.getBlockChance() > SkillCollection.CONCUSSION_THRESHOLD) {
|
||||
if (rollForSkillChance(player, SkillCollection.SKILL_CONCUSSION, SkillCollection.PER_SKILLPOINT_INCREASE_CONCUSSION_CHANCE)) {
|
||||
addConditionToActor(monster, world, "concussion", 1, 5);
|
||||
addConditionToActor(monster, "concussion", 1, 5);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.isCriticalHit) {
|
||||
if (rollForSkillChance(player, SkillCollection.SKILL_CRIT2, SkillCollection.PER_SKILLPOINT_INCREASE_CRIT2_CHANCE)) {
|
||||
addConditionToActor(monster, world, "crit2", 1, 5);
|
||||
addConditionToActor(monster, "crit2", 1, 5);
|
||||
}
|
||||
|
||||
if (rollForSkillChance(player, SkillCollection.SKILL_CRIT1, SkillCollection.PER_SKILLPOINT_INCREASE_CRIT1_CHANCE)) {
|
||||
addConditionToActor(monster, world, "crit1", 1, 5);
|
||||
addConditionToActor(monster, "crit1", 1, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void applySkillEffectsFromMonsterAttack(AttackResult result, WorldContext world, Monster monster) {
|
||||
public void applySkillEffectsFromMonsterAttack(AttackResult result, Monster monster) {
|
||||
if (!result.isHit) {
|
||||
if (rollForSkillChance(world.model.player, SkillCollection.SKILL_TAUNT, SkillCollection.PER_SKILLPOINT_INCREASE_TAUNT_CHANCE)) {
|
||||
view.actorStatsController.changeActorAP(monster, -SkillCollection.TAUNT_AP_LOSS, false, false);
|
||||
|
||||
@@ -64,7 +64,7 @@ public final class VisualEffectController {
|
||||
visualEffectFrameListeners.onNewAnimationFrame(this, tileID, textYOffset);
|
||||
}
|
||||
|
||||
protected void onCompleted() {
|
||||
private void onCompleted() {
|
||||
--effectCount;
|
||||
visualEffectFrameListeners.onAnimationCompleted(this);
|
||||
if (callback != null) callback.onVisualEffectCompleted(callbackValue);
|
||||
@@ -120,9 +120,9 @@ public final class VisualEffectController {
|
||||
public BloodSplatter(int iconID, Coord position) {
|
||||
this.iconID = iconID;
|
||||
this.position = position;
|
||||
long now = System.currentTimeMillis();
|
||||
removeAfter = now + 20000;
|
||||
reduceIconAfter = now + 10000;
|
||||
final long now = System.currentTimeMillis();
|
||||
removeAfter = now + Constants.SPLATTER_DURATION_MS;
|
||||
reduceIconAfter = now + Constants.SPLATTER_DURATION_MS / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -167,7 +168,7 @@ public final class WorldMapController {
|
||||
private static String getWorldMapSegmentAsHtml(Resources res, WorldContext world, String segmentName) throws IOException {
|
||||
WorldMapSegment segment = world.maps.worldMapSegments.get(segmentName);
|
||||
|
||||
HashSet<String> displayedMapNames = new HashSet<String>();
|
||||
Collection<String> displayedMapNames = new HashSet<String>();
|
||||
Coord offsetWorldmapTo = new Coord(999999, 999999);
|
||||
for (WorldMapSegmentMap map : segment.maps.values()) {
|
||||
if (!shouldDisplayMapOnWorldmap(map.mapName)) continue;
|
||||
@@ -178,8 +179,8 @@ public final class WorldMapController {
|
||||
}
|
||||
|
||||
Coord bottomRight = new Coord(0, 0);
|
||||
|
||||
StringBuffer mapsAsHtml = new StringBuffer();
|
||||
|
||||
StringBuilder mapsAsHtml = new StringBuilder(1000);
|
||||
for (WorldMapSegmentMap segmentMap : segment.maps.values()) {
|
||||
File f = WorldMapController.getFileForMap(segmentMap.mapName);
|
||||
if (!f.exists()) continue;
|
||||
@@ -199,7 +200,7 @@ public final class WorldMapController {
|
||||
.append("px; top:")
|
||||
.append((segmentMap.worldPosition.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
|
||||
.append("px;\" />");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) mapsAsHtml.append("\n");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) mapsAsHtml.append('\n');
|
||||
|
||||
bottomRight.x = Math.max(bottomRight.x, segmentMap.worldPosition.x + size.width);
|
||||
bottomRight.y = Math.max(bottomRight.y, segmentMap.worldPosition.y + size.height);
|
||||
@@ -208,8 +209,8 @@ public final class WorldMapController {
|
||||
(bottomRight.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
,(bottomRight.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
|
||||
);
|
||||
|
||||
StringBuffer namedAreasAsHtml = new StringBuffer();
|
||||
|
||||
StringBuilder namedAreasAsHtml = new StringBuilder(500);
|
||||
for (NamedWorldMapArea area : segment.namedAreas.values()) {
|
||||
CoordRect r = determineNamedAreaBoundary(area, segment, world, displayedMapNames);
|
||||
if (r == null) continue;
|
||||
@@ -227,7 +228,7 @@ public final class WorldMapController {
|
||||
.append("px;\"><span>")
|
||||
.append(area.name)
|
||||
.append("</span></div>");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) namedAreasAsHtml.append("\n");
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) namedAreasAsHtml.append('\n');
|
||||
}
|
||||
|
||||
return res.getString(R.string.worldmap_template)
|
||||
@@ -243,7 +244,7 @@ public final class WorldMapController {
|
||||
return world.maps.findPredefinedMap(map.mapName).size;
|
||||
}
|
||||
|
||||
private static CoordRect determineNamedAreaBoundary(NamedWorldMapArea area, WorldMapSegment segment, WorldContext world, HashSet<String> displayedMapNames) {
|
||||
private static CoordRect determineNamedAreaBoundary(NamedWorldMapArea area, WorldMapSegment segment, WorldContext world, Collection<String> displayedMapNames) {
|
||||
Coord topLeft = null;
|
||||
Coord bottomRight = null;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.gpl.rpg.AndorsTrail.model.AttackResult;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
|
||||
public class CombatActionListeners extends ListOfListeners<CombatActionListener> implements CombatActionListener {
|
||||
public final class CombatActionListeners extends ListOfListeners<CombatActionListener> implements CombatActionListener {
|
||||
|
||||
private final Function2<CombatActionListener, Monster, AttackResult> onPlayerAttackMissed = new Function2<CombatActionListener, Monster, AttackResult>() {
|
||||
@Override public void call(CombatActionListener listener, Monster target, AttackResult attackResult) { listener.onPlayerAttackMissed(target, attackResult); }
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
|
||||
public class CombatSelectionListeners extends ListOfListeners<CombatSelectionListener> implements CombatSelectionListener {
|
||||
public final class CombatSelectionListeners extends ListOfListeners<CombatSelectionListener> implements CombatSelectionListener {
|
||||
|
||||
private final Function3<CombatSelectionListener, Monster, Coord, Coord> onMonsterSelected = new Function3<CombatSelectionListener, Monster, Coord, Coord>() {
|
||||
@Override public void call(CombatSelectionListener listener, Monster monster, Coord selectedPosition, Coord previousSelection) { listener.onMonsterSelected(monster, selectedPosition, previousSelection); }
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gpl.rpg.AndorsTrail.controller.listeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
|
||||
public class CombatTurnListeners extends ListOfListeners<CombatTurnListener> implements CombatTurnListener {
|
||||
public final class CombatTurnListeners extends ListOfListeners<CombatTurnListener> implements CombatTurnListener {
|
||||
|
||||
private final Function<CombatTurnListener> onCombatStarted = new Function<CombatTurnListener>() {
|
||||
@Override public void call(CombatTurnListener listener) { listener.onCombatStarted(); }
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gpl.rpg.AndorsTrail.controller.listeners;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
|
||||
public class GameRoundListeners extends ListOfListeners<GameRoundListener> implements GameRoundListener {
|
||||
public final class GameRoundListeners extends ListOfListeners<GameRoundListener> implements GameRoundListener {
|
||||
|
||||
private final Function<GameRoundListener> onNewTick = new Function<GameRoundListener>() {
|
||||
@Override public void call(GameRoundListener listener) { listener.onNewTick(); }
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
|
||||
public class LootBagListeners extends ListOfListeners<LootBagListener> implements LootBagListener {
|
||||
public final class LootBagListeners extends ListOfListeners<LootBagListener> implements LootBagListener {
|
||||
|
||||
private final Function2<LootBagListener, PredefinedMap, Coord> onLootBagCreated = new Function2<LootBagListener, PredefinedMap, Coord>() {
|
||||
@Override public void call(LootBagListener listener, PredefinedMap map, Coord p) { listener.onLootBagCreated(map, p); }
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
|
||||
public class MonsterMovementListeners extends ListOfListeners<MonsterMovementListener> implements MonsterMovementListener {
|
||||
public final class MonsterMovementListeners extends ListOfListeners<MonsterMovementListener> implements MonsterMovementListener {
|
||||
|
||||
private final Function1<MonsterMovementListener, Monster> onMonsterSteppedOnPlayer = new Function1<MonsterMovementListener, Monster>() {
|
||||
@Override public void call(MonsterMovementListener listener, Monster monster) { listener.onMonsterSteppedOnPlayer(monster); }
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
|
||||
public class MonsterSpawnListeners extends ListOfListeners<MonsterSpawnListener> implements MonsterSpawnListener {
|
||||
public final class MonsterSpawnListeners extends ListOfListeners<MonsterSpawnListener> implements MonsterSpawnListener {
|
||||
|
||||
private final Function2<MonsterSpawnListener, PredefinedMap, Monster> onMonsterSpawned = new Function2<MonsterSpawnListener, PredefinedMap, Monster>() {
|
||||
@Override public void call(MonsterSpawnListener listener, PredefinedMap map, Monster monster) { listener.onMonsterSpawned(map, monster); }
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
|
||||
public class PlayerMovementListeners extends ListOfListeners<PlayerMovementListener> implements PlayerMovementListener {
|
||||
public final class PlayerMovementListeners extends ListOfListeners<PlayerMovementListener> implements PlayerMovementListener {
|
||||
|
||||
private final Function2<PlayerMovementListener, Coord, Coord> onPlayerMoved = new Function2<PlayerMovementListener, Coord, Coord>() {
|
||||
@Override public void call(PlayerMovementListener listener, Coord newPosition, Coord previousPosition) { listener.onPlayerMoved(newPosition, previousPosition); }
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gpl.rpg.AndorsTrail.controller.listeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
|
||||
public class PlayerStatsListeners extends ListOfListeners<PlayerStatsListener> implements PlayerStatsListener {
|
||||
public final class PlayerStatsListeners extends ListOfListeners<PlayerStatsListener> implements PlayerStatsListener {
|
||||
|
||||
private final Function1<PlayerStatsListener, Player> onPlayerExperienceChanged = new Function1<PlayerStatsListener, Player>() {
|
||||
@Override public void call(PlayerStatsListener listener, Player p) { listener.onPlayerExperienceChanged(p); }
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gpl.rpg.AndorsTrail.controller.listeners;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
|
||||
public class QuickSlotListeners extends ListOfListeners<QuickSlotListener> implements QuickSlotListener {
|
||||
public final class QuickSlotListeners extends ListOfListeners<QuickSlotListener> implements QuickSlotListener {
|
||||
|
||||
private final Function1<QuickSlotListener, Integer> onQuickSlotChanged = new Function1<QuickSlotListener, Integer>() {
|
||||
@Override public void call(QuickSlotListener listener, Integer slotId) { listener.onQuickSlotChanged(slotId); }
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gpl.rpg.AndorsTrail.controller.listeners;
|
||||
import com.gpl.rpg.AndorsTrail.controller.VisualEffectController.VisualEffectAnimation;
|
||||
import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
|
||||
public class VisualEffectFrameListeners extends ListOfListeners<VisualEffectFrameListener> implements VisualEffectFrameListener {
|
||||
public final class VisualEffectFrameListeners extends ListOfListeners<VisualEffectFrameListener> implements VisualEffectFrameListener {
|
||||
|
||||
private final Function3<VisualEffectFrameListener, VisualEffectAnimation, Integer, Integer> onNewAnimationFrame = new Function3<VisualEffectFrameListener, VisualEffectAnimation, Integer, Integer>() {
|
||||
@Override public void call(VisualEffectFrameListener listener, VisualEffectAnimation animation, Integer tileID, Integer textYOffset) { listener.onNewAnimationFrame(animation, tileID, textYOffset); }
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MapObject;
|
||||
|
||||
public class WorldEventListeners extends ListOfListeners<WorldEventListener> implements WorldEventListener {
|
||||
public final class WorldEventListeners extends ListOfListeners<WorldEventListener> implements WorldEventListener {
|
||||
|
||||
private final Function2<WorldEventListener, Monster, String> onPlayerStartedConversation = new Function2<WorldEventListener, Monster, String>() {
|
||||
@Override public void call(WorldEventListener listener, Monster m, String phraseID) { listener.onPlayerStartedConversation(m, phraseID); }
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.io.IOException;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
|
||||
public class ActorCondition {
|
||||
public final class ActorCondition {
|
||||
public static final int MAGNITUDE_REMOVE_ALL = -99;
|
||||
public static final int DURATION_FOREVER = 999;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.resource.parsers.ActorConditionsTypeParser;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
public class ActorConditionTypeCollection {
|
||||
public final class ActorConditionTypeCollection {
|
||||
private final HashMap<String, ActorConditionType> conditionTypes = new HashMap<String, ActorConditionType>();
|
||||
|
||||
public ActorConditionType getActorConditionType(String conditionTypeID) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gpl.rpg.AndorsTrail.model.ability;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
|
||||
public class SkillInfo {
|
||||
public final class SkillInfo {
|
||||
public static final int MAXLEVEL_NONE = -1;
|
||||
public static final int LEVELUP_TYPE_ALWAYS_SHOWN = 0;
|
||||
public static final int LEVELUP_TYPE_ONLY_BY_QUESTS = 1;
|
||||
|
||||
@@ -46,12 +46,6 @@ public final class AbilityModifierTraits {
|
||||
this.increaseDamageResistance = increaseDamageResistance;
|
||||
}
|
||||
|
||||
public boolean hasAttackChanceEffect() { return increaseAttackChance != 0; }
|
||||
public boolean hasAttackDamageEffect() { return increaseMinDamage != 0 || increaseMaxDamage != 0; }
|
||||
public boolean hasBlockEffect() { return increaseBlockChance != 0; }
|
||||
public boolean hasCriticalSkillEffect() { return increaseCriticalSkill != 0; }
|
||||
public boolean hasCriticalMultiplierEffect() { return setCriticalMultiplier != 0 && setCriticalMultiplier != 1; }
|
||||
|
||||
public int calculateCost(boolean isWeapon) {
|
||||
final int costBC = (int) (3*Math.pow(Math.max(0, increaseBlockChance), 2.5) + 28*increaseBlockChance);
|
||||
final int costAC = (int) (0.4*Math.pow(Math.max(0,increaseAttackChance), 2.5) - 6*Math.pow(Math.abs(Math.min(0,increaseAttackChance)),2.7));
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gpl.rpg.AndorsTrail.model.ability.traits;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.util.ConstRange;
|
||||
|
||||
public class StatsModifierTraits {
|
||||
public final class StatsModifierTraits {
|
||||
public static final int VISUAL_EFFECT_NONE = -1;
|
||||
public final int visualEffectID;
|
||||
public final ConstRange currentHPBoost;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gpl.rpg.AndorsTrail.model.listeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorCondition;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Actor;
|
||||
|
||||
public class ActorConditionListeners extends ListOfListeners<ActorConditionListener> implements ActorConditionListener {
|
||||
public final class ActorConditionListeners extends ListOfListeners<ActorConditionListener> implements ActorConditionListener {
|
||||
|
||||
private final Function2<ActorConditionListener, Actor, ActorCondition> onActorConditionAdded = new Function2<ActorConditionListener, Actor, ActorCondition>() {
|
||||
@Override public void call(ActorConditionListener listener, Actor actor, ActorCondition condition) { listener.onActorConditionAdded(actor, condition); }
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gpl.rpg.AndorsTrail.model.listeners;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Actor;
|
||||
import com.gpl.rpg.AndorsTrail.model.listeners.ListOfListeners;
|
||||
|
||||
public class ActorStatsListeners extends ListOfListeners<ActorStatsListener> implements ActorStatsListener {
|
||||
public final class ActorStatsListeners extends ListOfListeners<ActorStatsListener> implements ActorStatsListener {
|
||||
|
||||
private final Function1<ActorStatsListener, Actor> onActorHealthChanged = new Function1<ActorStatsListener, Actor>() {
|
||||
@Override public void call(ActorStatsListener listener, Actor actor) { listener.onActorHealthChanged(actor); }
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
public class ListOfListeners<T> {
|
||||
private final ArrayList<WeakReference<T>> listeners = new ArrayList<WeakReference<T>>();
|
||||
|
||||
public void add(T listener) {
|
||||
public final void add(T listener) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
for (WeakReference<T> ref : listeners) {
|
||||
if (ref.get() == listener) {
|
||||
@@ -18,7 +18,7 @@ public class ListOfListeners<T> {
|
||||
}
|
||||
listeners.add(new WeakReference<T>(listener));
|
||||
}
|
||||
public void remove(T listenerToRemove) {
|
||||
public final void remove(T listenerToRemove) {
|
||||
for (int i = listeners.size()-1; i >= 0; --i) {
|
||||
T listener = listeners.get(i).get();
|
||||
if (listener == null || listener == listenerToRemove) {
|
||||
@@ -27,28 +27,28 @@ public class ListOfListeners<T> {
|
||||
}
|
||||
}
|
||||
|
||||
protected void callAllListeners(Function<T> e) {
|
||||
protected final void callAllListeners(Function<T> e) {
|
||||
for (int i = listeners.size()-1; i >= 0; --i) {
|
||||
T listener = listeners.get(i).get();
|
||||
if (listener == null) listeners.remove(i);
|
||||
else e.call(listener);
|
||||
}
|
||||
}
|
||||
protected <Arg1> void callAllListeners(Function1<T, Arg1> e, Arg1 arg) {
|
||||
protected final <Arg1> void callAllListeners(Function1<T, Arg1> e, Arg1 arg) {
|
||||
for (int i = listeners.size()-1; i >= 0; --i) {
|
||||
T listener = listeners.get(i).get();
|
||||
if (listener == null) listeners.remove(i);
|
||||
else e.call(listener, arg);
|
||||
}
|
||||
}
|
||||
protected <Arg1, Arg2> void callAllListeners(Function2<T, Arg1, Arg2> e, Arg1 arg1, Arg2 arg2) {
|
||||
protected final <Arg1, Arg2> void callAllListeners(Function2<T, Arg1, Arg2> e, Arg1 arg1, Arg2 arg2) {
|
||||
for (int i = listeners.size()-1; i >= 0; --i) {
|
||||
T listener = listeners.get(i).get();
|
||||
if (listener == null) listeners.remove(i);
|
||||
else e.call(listener, arg1, arg2);
|
||||
}
|
||||
}
|
||||
protected <Arg1, Arg2, Arg3> void callAllListeners(Function3<T, Arg1, Arg2, Arg3> e, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
|
||||
protected final <Arg1, Arg2, Arg3> void callAllListeners(Function3<T, Arg1, Arg2, Arg3> e, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
|
||||
for (int i = listeners.size()-1; i >= 0; --i) {
|
||||
T listener = listeners.get(i).get();
|
||||
if (listener == null) listeners.remove(i);
|
||||
|
||||
@@ -16,9 +16,9 @@ public class ResourceFileTokenizer {
|
||||
private static final String columnSeparator = "\\|";
|
||||
private static final String fieldPattern = "([^\\|]*?|\\{\\s*\\{.*?\\}\\s*\\})" + columnSeparator;
|
||||
private static String repeat(String s, int count) {
|
||||
String result = s;
|
||||
for(int i = 1; i < count; ++i) result += s;
|
||||
return result;
|
||||
StringBuilder result = new StringBuilder(s);
|
||||
for(int i = 1; i < count; ++i) result.append(s);
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ResourceFileTokenizer {
|
||||
|
||||
public ResourceFileTokenizer(int columns) {
|
||||
this.columns = columns;
|
||||
this.pattern = Pattern.compile("^" + repeat(fieldPattern, columns) + "$", Pattern.MULTILINE | Pattern.DOTALL);
|
||||
this.pattern = Pattern.compile('^' + repeat(fieldPattern, columns) + '$', Pattern.MULTILINE | Pattern.DOTALL);
|
||||
this.parts = new String[columns];
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ResourceFileTokenizer {
|
||||
}
|
||||
}
|
||||
|
||||
public <T> Collection<String> tokenizeRows(String input, HashMap<String, T> dest, ResourceObjectParser<Pair<String, T>> parser) {
|
||||
public final <T> Collection<String> tokenizeRows(String input, HashMap<String, T> dest, ResourceObjectParser<Pair<String, T>> parser) {
|
||||
HashSet<String> ids = new HashSet<String>();
|
||||
ArrayList<Pair<String, T>> objects = new ArrayList<Pair<String, T>>();
|
||||
tokenizeRows(input, objects, parser);
|
||||
@@ -74,7 +74,7 @@ public class ResourceFileTokenizer {
|
||||
private static final Pattern outerPattern = Pattern.compile("^\\{(.*)\\}$", Pattern.MULTILINE | Pattern.DOTALL);
|
||||
private static final Pattern innerPattern = Pattern.compile("\\{(.*?)\\}", Pattern.MULTILINE | Pattern.DOTALL);
|
||||
|
||||
public <T> void tokenizeArray(String input, ArrayList<T> dest, ResourceObjectParser<T> parser) {
|
||||
public final <T> void tokenizeArray(String input, ArrayList<T> dest, ResourceObjectParser<T> parser) {
|
||||
Matcher matcher = outerPattern.matcher(input);
|
||||
if (!matcher.find()) return;
|
||||
|
||||
@@ -88,8 +88,8 @@ public class ResourceFileTokenizer {
|
||||
T parseRow(String[] parts);
|
||||
}
|
||||
|
||||
public static abstract class ResourceParserFor<T> extends ResourceFileTokenizer implements ResourceObjectParser<Pair<String, T>> {
|
||||
public ResourceParserFor(int columns) {
|
||||
public abstract static class ResourceParserFor<T> extends ResourceFileTokenizer implements ResourceObjectParser<Pair<String, T>> {
|
||||
protected ResourceParserFor(int columns) {
|
||||
super(columns);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
|
||||
public class TileCollection {
|
||||
public final class TileCollection {
|
||||
private final Bitmap[] bitmaps;
|
||||
public final int maxTileID;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.BitmapFactory.Options;
|
||||
|
||||
public class TileCutter {
|
||||
public final class TileCutter {
|
||||
private final ResourceFileTileset sourceFile;
|
||||
private final Bitmap tilesetImage;
|
||||
private boolean recycle = true;
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.MonsterType;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
|
||||
public class LegacySavegameFormatReaderForMonster {
|
||||
public final class LegacySavegameFormatReaderForMonster {
|
||||
public static Monster readFromParcel_pre_v25(DataInputStream src, int fileversion, MonsterType monsterType) throws IOException {
|
||||
Monster m = new Monster(monsterType);
|
||||
m.position.set(new Coord(src, fileversion));
|
||||
|
||||
@@ -11,7 +11,7 @@ public final class Coord {
|
||||
public Coord(int x, int y) { this.x = x; this.y = y; }
|
||||
public Coord(Coord p) { this.x = p.x; this.y = p.y; }
|
||||
|
||||
public String toString() { return "(" + x + "," + y + ")"; }
|
||||
public String toString() { return "(" + x + ',' + y + ')'; }
|
||||
public void set(int x, int y) { this.x = x; this.y = y; }
|
||||
public void set(Coord r) {
|
||||
this.x = r.x;
|
||||
@@ -26,8 +26,8 @@ public final class Coord {
|
||||
final int dx = x - p.x;
|
||||
final int dy = y - p.y;
|
||||
if (dx == 0 && dy == 0) return false;
|
||||
else if (Math.abs(dx) > 1) return false;
|
||||
else if (Math.abs(dy) > 1) return false;
|
||||
if (Math.abs(dx) > 1) return false;
|
||||
if (Math.abs(dy) > 1) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,17 +17,17 @@ public final class CoordRect {
|
||||
}
|
||||
public boolean contains(Coord p) {
|
||||
if (p.x < topLeft.x) return false;
|
||||
else if (p.y < topLeft.y) return false;
|
||||
else if (p.x - topLeft.x >= size.width) return false;
|
||||
else if (p.y - topLeft.y >= size.height) return false;
|
||||
else return true;
|
||||
if (p.y < topLeft.y) return false;
|
||||
if (p.x - topLeft.x >= size.width) return false;
|
||||
if (p.y - topLeft.y >= size.height) return false;
|
||||
return true;
|
||||
}
|
||||
public boolean contains(final int x, final int y) {
|
||||
if (x < topLeft.x) return false;
|
||||
else if (y < topLeft.y) return false;
|
||||
else if (x - topLeft.x >= size.width) return false;
|
||||
else if (y - topLeft.y >= size.height) return false;
|
||||
else return true;
|
||||
if (y < topLeft.y) return false;
|
||||
if (x - topLeft.x >= size.width) return false;
|
||||
if (y - topLeft.y >= size.height) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -51,9 +51,9 @@ public final class CoordRect {
|
||||
final int dx = p.x - topLeft.x;
|
||||
final int dy = p.y - topLeft.y;
|
||||
if (dx < -1) return false;
|
||||
else if (dy < -1) return false;
|
||||
else if (dx > size.width) return false;
|
||||
else if (dy > size.height) return false;
|
||||
if (dy < -1) return false;
|
||||
if (dx > size.width) return false;
|
||||
if (dy > size.height) return false;
|
||||
return true;
|
||||
}
|
||||
public Coord findPositionAdjacentTo(Coord p) {
|
||||
@@ -69,6 +69,6 @@ public final class CoordRect {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "{" + topLeft.toString() + ", " + size.toString() + "}";
|
||||
return '{' + topLeft.toString() + ", " + size.toString() + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class L {
|
||||
public final class L {
|
||||
private static final String TAG = "AndorsTrail";
|
||||
|
||||
public static void log(String s) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.Map;
|
||||
* framework's implementation. See the framework SDK documentation for a class
|
||||
* overview.
|
||||
*/
|
||||
public class LruCache<K, V> {
|
||||
public final class LruCache<K, V> {
|
||||
private final LinkedHashMap<K, V> map;
|
||||
|
||||
/** Size of this cache in units. Not necessarily the number of elements. */
|
||||
|
||||
@@ -128,7 +128,7 @@ public final class CombatView extends RelativeLayout implements CombatSelectionL
|
||||
private void updateMonsterHealth(Monster m) {
|
||||
monsterHealth.update(m.getMaxHP(), m.getCurrentHP());
|
||||
}
|
||||
private void updatePlayerAP(Player player) {
|
||||
private void updatePlayerAP() {
|
||||
statusTextView.setText(res.getString(R.string.combat_status_ap, player.getCurrentAP()));
|
||||
}
|
||||
private void updateSelectedMonster(Monster selectedMonster) {
|
||||
@@ -156,7 +156,7 @@ public final class CombatView extends RelativeLayout implements CombatSelectionL
|
||||
}
|
||||
|
||||
public void updateStatus() {
|
||||
updatePlayerAP(player);
|
||||
updatePlayerAP();
|
||||
updateSelectedMonster(world.model.uiSelections.selectedMonster);
|
||||
updateAttackMoveButtonText();
|
||||
}
|
||||
@@ -232,7 +232,7 @@ public final class CombatView extends RelativeLayout implements CombatSelectionL
|
||||
|
||||
@Override
|
||||
public void onActorAPChanged(Actor actor) {
|
||||
if (actor == player) updatePlayerAP(player);
|
||||
if (actor == player) updatePlayerAP();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.gpl.rpg.AndorsTrail.model.actor.Actor;
|
||||
import com.gpl.rpg.AndorsTrail.model.listeners.ActorConditionListener;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
|
||||
public class DisplayActiveActorConditionIcons implements ActorConditionListener {
|
||||
public final class DisplayActiveActorConditionIcons implements ActorConditionListener {
|
||||
|
||||
private final AndorsTrailPreferences preferences;
|
||||
private final TileManager tileManager;
|
||||
@@ -177,7 +177,7 @@ public class DisplayActiveActorConditionIcons implements ActorConditionListener
|
||||
@Override public void onAnimationStart(Animation animation) { }
|
||||
}
|
||||
|
||||
protected void rearrangeIconsLeftOf(ActiveConditionIcon icon) {
|
||||
private void rearrangeIconsLeftOf(ActiveConditionIcon icon) {
|
||||
int i = currentConditionIcons.indexOf(icon);
|
||||
currentConditionIcons.remove(i);
|
||||
currentConditionIcons.add(icon);
|
||||
|
||||
@@ -107,7 +107,7 @@ public final class MainView extends SurfaceView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||
public void surfaceChanged(SurfaceHolder sh, int format, int w, int h) {
|
||||
if (w <= 0 || h <= 0) return;
|
||||
|
||||
this.scale = world.tileManager.scale;
|
||||
@@ -127,12 +127,12 @@ public final class MainView extends SurfaceView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
public void surfaceCreated(SurfaceHolder sh) {
|
||||
hasSurface = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
public void surfaceDestroyed(SurfaceHolder sh) {
|
||||
hasSurface = false;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ public final class MainView extends SurfaceView
|
||||
private void doDrawRect(Canvas canvas, CoordRect area) {
|
||||
|
||||
drawMapLayer(canvas, area, currentTileMap.layers[LayeredTileMap.LAYER_GROUND]);
|
||||
tryDrawMapLayer(canvas, area, currentTileMap, LayeredTileMap.LAYER_OBJECTS);
|
||||
tryDrawMapLayer(canvas, area, LayeredTileMap.LAYER_OBJECTS);
|
||||
|
||||
for (BloodSplatter splatter : currentMap.splatters) {
|
||||
drawFromMapPosition(canvas, area, splatter.position, splatter.iconID);
|
||||
@@ -296,7 +296,7 @@ public final class MainView extends SurfaceView
|
||||
}
|
||||
}
|
||||
|
||||
tryDrawMapLayer(canvas, area, currentTileMap, LayeredTileMap.LAYER_ABOVE);
|
||||
tryDrawMapLayer(canvas, area, LayeredTileMap.LAYER_ABOVE);
|
||||
|
||||
if (model.uiSelections.selectedPosition != null) {
|
||||
if (model.uiSelections.selectedMonster != null) {
|
||||
@@ -307,7 +307,7 @@ public final class MainView extends SurfaceView
|
||||
}
|
||||
}
|
||||
|
||||
private void tryDrawMapLayer(Canvas canvas, final CoordRect area, final LayeredTileMap currentTileMap, final int layerIndex) {
|
||||
private void tryDrawMapLayer(Canvas canvas, final CoordRect area, final int layerIndex) {
|
||||
if (currentTileMap.layers.length > layerIndex) drawMapLayer(canvas, area, currentTileMap.layers[layerIndex]);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import android.util.AttributeSet;
|
||||
import android.view.ContextMenu;
|
||||
import android.widget.Button;
|
||||
|
||||
public class QuickButton extends Button {
|
||||
public final class QuickButton extends Button {
|
||||
private final ColorFilter grayScaleFilter = new ColorMatrixColorFilter(
|
||||
new float[] { 0.30f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
0.30f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
@@ -21,7 +21,7 @@ public class QuickButton extends Button {
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
private boolean empty;
|
||||
private QuickButtonContextMenuInfo menuInfo;
|
||||
private final QuickButtonContextMenuInfo menuInfo;
|
||||
private final int textPadding;
|
||||
|
||||
public QuickButton(Context context, AttributeSet attrs) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.gpl.rpg.AndorsTrail.model.item.Inventory;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
|
||||
public class QuickitemView extends LinearLayout implements OnClickListener, QuickSlotListener {
|
||||
public final class QuickitemView extends LinearLayout implements OnClickListener, QuickSlotListener {
|
||||
private static final int NUM_QUICK_SLOTS = Inventory.NUM_QUICK_SLOTS;
|
||||
|
||||
private final WorldContext world;
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class SkillListAdapter extends ArrayAdapter<SkillInfo> {
|
||||
public int compare(SkillInfo a, SkillInfo b) {
|
||||
return a.id - b.id;
|
||||
}
|
||||
});
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public final class SkillListAdapter extends ArrayAdapter<SkillInfo> {
|
||||
String skillTitle = r.getString(SkillInfoActivity.getSkillTitleResourceID(skillID));
|
||||
final int skillLevel = player.getSkillLevel(skillID);
|
||||
if (skillLevel > 0) {
|
||||
skillTitle += " (" + skillLevel + ")";
|
||||
skillTitle += " (" + skillLevel + ')';
|
||||
}
|
||||
title.setText(skillTitle);
|
||||
description.setText(getSkillShortDescriptionResourceID(skillID));
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.WorldMapController;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
|
||||
public class ToolboxView extends LinearLayout implements OnClickListener {
|
||||
public final class ToolboxView extends LinearLayout implements OnClickListener {
|
||||
private final WorldContext world;
|
||||
private final AndorsTrailPreferences preferences;
|
||||
private final Animation showAnimation;
|
||||
|
||||
@@ -61,12 +61,12 @@ public final class TraitsInfoView {
|
||||
tv.setText(Integer.toString(attackCost));
|
||||
|
||||
row = (TableRow) group.findViewById(R.id.traitsinfo_attack_chance_row);
|
||||
if (attackChance != 0) {
|
||||
if (attackChance == 0) {
|
||||
row.setVisibility(View.GONE);
|
||||
} else {
|
||||
row.setVisibility(View.VISIBLE);
|
||||
tv = (TextView) group.findViewById(R.id.traitsinfo_attack_chance);
|
||||
tv.setText(Integer.toString(attackChance) + "%");
|
||||
} else {
|
||||
row.setVisibility(View.GONE);
|
||||
tv.setText(Integer.toString(attackChance) + '%');
|
||||
}
|
||||
|
||||
row = (TableRow) group.findViewById(R.id.traitsinfo_attack_damage_row);
|
||||
@@ -79,12 +79,12 @@ public final class TraitsInfoView {
|
||||
}
|
||||
|
||||
row = (TableRow) group.findViewById(R.id.traitsinfo_criticalhit_skill_row);
|
||||
if (criticalSkill != 0) {
|
||||
if (criticalSkill == 0) {
|
||||
row.setVisibility(View.GONE);
|
||||
} else {
|
||||
row.setVisibility(View.VISIBLE);
|
||||
tv = (TextView) group.findViewById(R.id.traitsinfo_criticalhit_skill);
|
||||
tv.setText(Integer.toString(criticalSkill));
|
||||
} else {
|
||||
row.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
row = (TableRow) group.findViewById(R.id.traitsinfo_criticalhit_multiplier_row);
|
||||
@@ -100,27 +100,27 @@ public final class TraitsInfoView {
|
||||
if (criticalSkill != 0 && criticalMultiplier != 0 && criticalMultiplier != 1) {
|
||||
row.setVisibility(View.VISIBLE);
|
||||
tv = (TextView) group.findViewById(R.id.traitsinfo_criticalhit_effectivechance);
|
||||
tv.setText(Integer.toString(Actor.getEffectiveCriticalChance(criticalSkill)) + "%");
|
||||
tv.setText(Integer.toString(Actor.getEffectiveCriticalChance(criticalSkill)) + '%');
|
||||
} else {
|
||||
row.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
row = (TableRow) group.findViewById(R.id.traitsinfo_block_chance_row);
|
||||
if (blockChance != 0) {
|
||||
if (blockChance == 0) {
|
||||
row.setVisibility(View.GONE);
|
||||
} else {
|
||||
row.setVisibility(View.VISIBLE);
|
||||
tv = (TextView) group.findViewById(R.id.traitsinfo_block_chance);
|
||||
tv.setText(Integer.toString(blockChance) + "%");
|
||||
} else {
|
||||
row.setVisibility(View.GONE);
|
||||
tv.setText(Integer.toString(blockChance) + '%');
|
||||
}
|
||||
|
||||
row = (TableRow) group.findViewById(R.id.traitsinfo_damageresist_row);
|
||||
if (damageResistance != 0) {
|
||||
if (damageResistance == 0) {
|
||||
row.setVisibility(View.GONE);
|
||||
} else {
|
||||
row.setVisibility(View.VISIBLE);
|
||||
tv = (TextView) group.findViewById(R.id.traitsinfo_damageresist);
|
||||
tv.setText(Integer.toString(damageResistance));
|
||||
} else {
|
||||
row.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
row = (TableRow) group.findViewById(R.id.traitsinfo_is_immune_to_critical_hits_row);
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.gpl.rpg.AndorsTrail.controller.InputController;
|
||||
|
||||
public final class VirtualDpadView extends ImageView implements OnClickListener {
|
||||
private final WorldContext world;
|
||||
private final ViewContext view;
|
||||
private final InputController inputController;
|
||||
|
||||
private int one_third_width;
|
||||
@@ -36,8 +35,8 @@ public final class VirtualDpadView extends ImageView implements OnClickListener
|
||||
super(context, attr);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivityContext(context);
|
||||
this.world = app.getWorld();
|
||||
this.view = app.getViewContext();
|
||||
this.inputController = this.view.inputController;
|
||||
final ViewContext view = app.getViewContext();
|
||||
this.inputController = view.inputController;
|
||||
|
||||
setImageResource(R.drawable.ui_dpad);
|
||||
setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
@@ -106,30 +105,39 @@ public final class VirtualDpadView extends ImageView implements OnClickListener
|
||||
isMinimizeable = preferences.dpadMinimizeable;
|
||||
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
if (dpadPosition == AndorsTrailPreferences.DPAD_POSITION_LOWER_RIGHT) {
|
||||
params.addRule(RelativeLayout.ALIGN_RIGHT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.main_mainview);
|
||||
} else if (dpadPosition == AndorsTrailPreferences.DPAD_POSITION_LOWER_LEFT) {
|
||||
params.addRule(RelativeLayout.ALIGN_LEFT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.main_mainview);
|
||||
} else if (dpadPosition == AndorsTrailPreferences.DPAD_POSITION_LOWER_CENTER) {
|
||||
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
|
||||
params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.main_mainview);
|
||||
} else if (dpadPosition == AndorsTrailPreferences.DPAD_POSITION_UPPER_RIGHT) {
|
||||
params.addRule(RelativeLayout.ALIGN_RIGHT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.ALIGN_TOP, R.id.main_mainview);
|
||||
} else if (dpadPosition == AndorsTrailPreferences.DPAD_POSITION_UPPER_LEFT) {
|
||||
params.addRule(RelativeLayout.ALIGN_LEFT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.ALIGN_TOP, R.id.main_mainview);
|
||||
} else if (dpadPosition == AndorsTrailPreferences.DPAD_POSITION_UPPER_CENTER) {
|
||||
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
|
||||
params.addRule(RelativeLayout.ALIGN_TOP, R.id.main_mainview);
|
||||
} else if (dpadPosition == AndorsTrailPreferences.DPAD_POSITION_CENTER_LEFT) {
|
||||
params.addRule(RelativeLayout.ALIGN_LEFT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
} else if (dpadPosition == AndorsTrailPreferences.DPAD_POSITION_CENTER_RIGHT) {
|
||||
params.addRule(RelativeLayout.ALIGN_RIGHT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
switch (dpadPosition) {
|
||||
case AndorsTrailPreferences.DPAD_POSITION_LOWER_RIGHT:
|
||||
params.addRule(RelativeLayout.ALIGN_RIGHT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.main_mainview);
|
||||
break;
|
||||
case AndorsTrailPreferences.DPAD_POSITION_LOWER_LEFT:
|
||||
params.addRule(RelativeLayout.ALIGN_LEFT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.main_mainview);
|
||||
break;
|
||||
case AndorsTrailPreferences.DPAD_POSITION_LOWER_CENTER:
|
||||
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
|
||||
params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.main_mainview);
|
||||
break;
|
||||
case AndorsTrailPreferences.DPAD_POSITION_UPPER_RIGHT:
|
||||
params.addRule(RelativeLayout.ALIGN_RIGHT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.ALIGN_TOP, R.id.main_mainview);
|
||||
break;
|
||||
case AndorsTrailPreferences.DPAD_POSITION_UPPER_LEFT:
|
||||
params.addRule(RelativeLayout.ALIGN_LEFT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.ALIGN_TOP, R.id.main_mainview);
|
||||
break;
|
||||
case AndorsTrailPreferences.DPAD_POSITION_UPPER_CENTER:
|
||||
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
|
||||
params.addRule(RelativeLayout.ALIGN_TOP, R.id.main_mainview);
|
||||
break;
|
||||
case AndorsTrailPreferences.DPAD_POSITION_CENTER_LEFT:
|
||||
params.addRule(RelativeLayout.ALIGN_LEFT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
break;
|
||||
case AndorsTrailPreferences.DPAD_POSITION_CENTER_RIGHT:
|
||||
params.addRule(RelativeLayout.ALIGN_RIGHT, R.id.main_mainview);
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
break;
|
||||
}
|
||||
|
||||
setLayoutParams(params);
|
||||
|
||||
Reference in New Issue
Block a user