Powers display
This commit is contained in:
parent
9a9af9d6e5
commit
2fc2ff61ba
11 changed files with 370 additions and 68 deletions
|
@ -36,45 +36,6 @@ class AttackAdapter extends ArrayAdapter<Power> {
|
|||
((TextView) mView.findViewById(R.id.keywords)).setText(attack.getKeywords());
|
||||
((TextView) mView.findViewById(R.id.frequency)).setText(attack.getFrequencyString());
|
||||
((TextView) mView.findViewById(R.id.extra)).setText(attack.getRangeString() + " " + attack.getDistance());
|
||||
final AttackAdapter current = this;
|
||||
mView.findViewById(R.id.delete);
|
||||
// mView.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// SnackbarManager.show(
|
||||
// Snackbar.with(getContext()).text("¿Quieres borrarlo?").actionLabel("Sí").actionListener(new ActionClickListener() {
|
||||
// @Override
|
||||
// public void onActionClicked(Snackbar snackbar) {
|
||||
// //delete the item
|
||||
// String name = p.getString("power" + position, "");
|
||||
// if (name != null && !name.isEmpty()) {
|
||||
// getContext().getSharedPreferences(name, Context.MODE_PRIVATE).edit().clear().apply();
|
||||
// Log.d("Tag", activity.getApplicationContext().getFilesDir().getParent()
|
||||
// + File.separator + "shared_prefs" + File.separator + name + ".xml");
|
||||
// try {
|
||||
// if (!new File(activity.getApplicationContext().getFilesDir().getParent()
|
||||
// + File.separator + "shared_prefs" + File.separator + name + ".xml").delete())
|
||||
// throw new Exception();
|
||||
// } catch (Exception e) {
|
||||
// Toast.makeText(getContext(), "Error deleting player files", Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
// int max = p.getInt("powers", 0);
|
||||
// SharedPreferences.Editor ed = p.edit();
|
||||
// for (int i = position; i < max - 1; i++)
|
||||
// ed.putString("power" + i, p.getString("power" + (i + 1), "max"));
|
||||
// ed.putInt("powers", max - 1).apply();
|
||||
// load();
|
||||
// ed.remove("power" + (max - 1)).apply();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ));
|
||||
// //TODO: convert text to resource
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// );
|
||||
// };
|
||||
}
|
||||
return mView;
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ class Player implements Serializable {
|
|||
this.pg = maxPg;
|
||||
this.maxPg = maxPg;
|
||||
}
|
||||
void setMaxPgOnLevelUp() {maxPg += CLASS_STATS[PG_ON_LEVEL_UP][classInt];}
|
||||
private void setMaxPgOnLevelUp() {maxPg += CLASS_STATS[PG_ON_LEVEL_UP][classInt];}
|
||||
|
||||
int getPg() {return pg;}
|
||||
void setPg(int pg) {this.pg = pg; setState();}
|
||||
|
@ -206,10 +206,8 @@ class Player implements Serializable {
|
|||
String getName() {return name;}
|
||||
String getClassName() {return CLASS_STRINGS[classInt];}
|
||||
String getRaceName() {return RACE_STRINGS[raceInt];}
|
||||
void setRaceInt(int raceInt) {this.raceInt = raceInt;}
|
||||
int getRaceInt() {return raceInt;}
|
||||
|
||||
void setAtk(int[] atk) {this.atk = atk; if(classInt != NULL) setClass();}
|
||||
private void setAtk(int[] atk) {this.atk = atk; if(classInt != NULL) setClass();}
|
||||
|
||||
int getFue() {return atk[FUE];}
|
||||
int getCon() {return atk[CON];}
|
||||
|
@ -222,7 +220,7 @@ class Player implements Serializable {
|
|||
int getRef() {return def[REF];}
|
||||
int getVol() {return def[VOL];}
|
||||
|
||||
void setClass() {
|
||||
private void setClass() {
|
||||
if(level == 1) maxPg = atk[CON] + CLASS_STATS[INITIAL_PG][classInt];
|
||||
maxCurativeEfforts = Player.getModifier(atk[CON]) + CLASS_STATS[DAILY_CURATIVE_EFFORTS][classInt];
|
||||
//TODO: implement armor!
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.kauron.dungeonmanager;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -45,16 +46,22 @@ class Power implements Serializable{
|
|||
|
||||
String getKeywords() {return keywords;}
|
||||
|
||||
String getTypeString() {return ACTIONS[action];}
|
||||
String getFrequencyString() {return FREQ[freq];}
|
||||
int getFreq() {return freq;}
|
||||
|
||||
String getRangeString() {return DISTANCES[range];}
|
||||
int getRange() {return range;}
|
||||
|
||||
int getAtk() {return atk;}
|
||||
int getDef() {return def;}
|
||||
int getFreq() {return freq;}
|
||||
|
||||
int getDistance() {return distance;}
|
||||
|
||||
String getName(){return name;}
|
||||
String getImpact() {return impact;}
|
||||
String getObjective() {return objective;}
|
||||
String getOther() {return "";}
|
||||
|
||||
//TODO: add other element to include further description
|
||||
|
||||
boolean isUsed(){return used;}
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package com.kauron.dungeonmanager;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.os.Bundle;
|
||||
|
@ -131,9 +134,7 @@ public class ShowPlayer extends ActionBarActivity {
|
|||
try {
|
||||
boolean levelUp = player.addPx(Integer.parseInt(input.getText().toString()));
|
||||
if (levelUp) {
|
||||
//levelUp
|
||||
//TODO: improve leveling up by using a sliding guide
|
||||
player.setMaxPgOnLevelUp();
|
||||
}
|
||||
p.edit().putInt("px", player.getPx()).apply();
|
||||
if(levelUp)
|
||||
|
@ -479,12 +480,82 @@ public class ShowPlayer extends ActionBarActivity {
|
|||
}
|
||||
|
||||
attackList.setAdapter(new AttackAdapter(this, powers));
|
||||
|
||||
final Activity thisActivity = this;
|
||||
attackList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Toast.makeText(getApplicationContext(), ((Power)parent.getItemAtPosition(position)).getName(), Toast.LENGTH_LONG).show();
|
||||
//TODO: show here dialog with power's complete information, and buttons to use, recharge or delete
|
||||
|
||||
final Dialog dialog = new Dialog(ShowPlayer.this);
|
||||
dialog.setContentView(R.layout.attack_display);
|
||||
// set the custom dialog components - text, image and button
|
||||
// Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
|
||||
// // if button is clicked, close the custom dialog
|
||||
// dialogButton.setOnClickListener(new OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// dialog.dismiss();
|
||||
// }
|
||||
// });
|
||||
|
||||
//identify all the elements from the VIEW and then add LISTENERS
|
||||
Power power = (Power) parent.getItemAtPosition(position);
|
||||
View nameText = dialog.findViewById(R.id.nameText);
|
||||
switch(power.getFreq()){
|
||||
case Power.A_VOLUNTAD:
|
||||
nameText.setBackgroundColor(getResources().getColor(R.color.at_will));
|
||||
break;
|
||||
case Power.ENCUENTRO:
|
||||
nameText.setBackgroundColor(getResources().getColor(R.color.encounter));
|
||||
break;
|
||||
case Power.DIARIO:
|
||||
nameText.setBackgroundColor(getResources().getColor(R.color.daily));
|
||||
break;
|
||||
default:
|
||||
nameText.setBackgroundColor(getResources().getColor(R.color.green));
|
||||
}
|
||||
//TODO: fix the title gap
|
||||
((TextView) nameText) .setText(power.getName());
|
||||
((TextView) dialog.findViewById(R.id.typeText)) .setText(power.getTypeString());
|
||||
((TextView) dialog.findViewById(R.id.rangeText)) .setText(power.getRangeString() + " ");
|
||||
((TextView) dialog.findViewById(R.id.freqText)) .setText(power.getFrequencyString());
|
||||
((TextView) dialog.findViewById(R.id.keywordsText)) .setText(power.getKeywords());
|
||||
((TextView) dialog.findViewById(R.id.distanceText)) .setText(String.valueOf(power.getDistance()));
|
||||
((TextView) dialog.findViewById(R.id.objectiveText)).setText(power.getObjective());
|
||||
((TextView) dialog.findViewById(R.id.impactText)) .setText(power.getImpact());
|
||||
((TextView) dialog.findViewById(R.id.otherText)) .setText(power.getOther());
|
||||
|
||||
String[] attack = getResources().getStringArray(R.array.attack_array);
|
||||
String[] defense = getResources().getStringArray(R.array.defense_array);
|
||||
//TODO: add attack and defense array
|
||||
((TextView) dialog.findViewById(R.id.attackText)) .setText(attack[power.getAtk()]
|
||||
+ " " + getResources().getString(R.string.vs)
|
||||
+ " " + defense[power.getDef()]);
|
||||
|
||||
dialog.findViewById(R.id.useButton).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//TODO: use power
|
||||
Toast.makeText(getApplicationContext(), "Use it", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.findViewById(R.id.deleteButton).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//TODO: delete power
|
||||
Toast.makeText(getApplicationContext(), "Delete it", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.findViewById(R.id.editButton).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//TODO: edit power
|
||||
Toast.makeText(getApplicationContext(), "Edit it", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Reference in a new issue