diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 18bb2d5..b7cd214 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -29,6 +29,10 @@ + + diff --git a/app/src/main/java/com/kauron/dungeonmanager/AttackAdapter.java b/app/src/main/java/com/kauron/dungeonmanager/AttackAdapter.java index f141034..f427afc 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/AttackAdapter.java +++ b/app/src/main/java/com/kauron/dungeonmanager/AttackAdapter.java @@ -1,10 +1,19 @@ package com.kauron.dungeonmanager; import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.TextView; + +import com.nispok.snackbar.Snackbar; +import com.nispok.snackbar.SnackbarManager; +import com.nispok.snackbar.listeners.ActionClickListener; class AttackAdapter extends ArrayAdapter { AttackAdapter(Context context, Power[] powers) { @@ -12,11 +21,32 @@ class AttackAdapter extends ArrayAdapter { } @Override - public View getView(int position, View convertView, ViewGroup parent) { + public View getView(final int position, final View convertView, ViewGroup parent) { LayoutInflater mInflater = LayoutInflater.from(getContext()); View mView = mInflater.inflate(R.layout.attack_row, parent, false); - Power attack = getItem(position); + final Power attack = getItem(position); + + ((TextView) mView.findViewById(R.id.name)).setText(attack.getName()); + ((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; + ((ImageView) mView.findViewById(R.id.delete)).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) { + current.remove(attack); + } + }) + ); + //TODO: convert text to resource + } + }); + return mView; } } diff --git a/app/src/main/java/com/kauron/dungeonmanager/Player.java b/app/src/main/java/com/kauron/dungeonmanager/Player.java index 27508ae..af33672 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/Player.java +++ b/app/src/main/java/com/kauron/dungeonmanager/Player.java @@ -1,6 +1,6 @@ package com.kauron.dungeonmanager; -public class Player { +class Player { /** * Names for the classes @@ -107,7 +107,7 @@ public class Player { //TODO: implement fully operational powers displayed as cards private Power[] powers; - public Player( + Player( String name, int classInt, int raceInt, int px, int[] atk, int[] abilities, Power[] powers @@ -128,22 +128,22 @@ public class Player { } - public int getPx() {return px;} - public void setPx (int px) {this.px = px; setLevel();} - public boolean addPx(int px) { + int getPx() {return px;} + void setPx (int px) {this.px = px; setLevel();} + boolean addPx(int px) { int lastLevel = level; setPx(this.px + px); return lastLevel < level; } - public int getMaxCurativeEfforts() {return maxCurativeEfforts;} - public void setMaxCurativeEfforts(int maxCurativeEfforts) {this.maxCurativeEfforts = maxCurativeEfforts;} + int getMaxCurativeEfforts() {return maxCurativeEfforts;} + void setMaxCurativeEfforts(int maxCurativeEfforts) {this.maxCurativeEfforts = maxCurativeEfforts;} - public int getCurativeEfforts() {return curativeEfforts;} - public void setCurativeEffort(int curativeEfforts) {this.curativeEfforts = curativeEfforts;} + int getCurativeEfforts() {return curativeEfforts;} + void setCurativeEffort(int curativeEfforts) {this.curativeEfforts = curativeEfforts;} - public int getLevel() {return level;} - public void setLevel() { + int getLevel() {return level;} + void setLevel() { for (int i = 0; i < LEVEL_PX.length; i++){ if(px < LEVEL_PX[i]) { level = i; return; @@ -154,21 +154,21 @@ public class Player { } - public int getMaxPg() {return maxPg;} - public void setMaxPg(int maxPg) { + int getMaxPg() {return maxPg;} + void setMaxPg(int maxPg) { if(this.maxPg == 0) this.pg = maxPg; this.maxPg = maxPg; } - public void setMaxPgOnLevelUp() {maxPg += CLASS_STATS[PG_ON_LEVEL_UP][classInt];} + void setMaxPgOnLevelUp() {maxPg += CLASS_STATS[PG_ON_LEVEL_UP][classInt];} - public int getPg() {return pg;} - public void setPg(int pg) {this.pg = pg; setState();} - public void losePg(int damage) { + int getPg() {return pg;} + void setPg(int pg) {this.pg = pg; setState();} + void losePg(int damage) { pg -= damage; setState(); } - public int recoverPg(int recovered, boolean uses) { + int recoverPg(int recovered, boolean uses) { if(recovered == USE_CURATIVE_EFFORT){ if(uses && curativeEfforts <= 0) return NOT_CURED; else { @@ -193,8 +193,8 @@ public class Player { return CURED; } - public int getLastState() {return lastState == state ? SAME : lastState;} - public int getState() {return state;} + int getLastState() {return lastState == state ? SAME : lastState;} + int getState() {return state;} private void setState() { lastState = state; if (pg <= maxPg / -2) state = MUERTO; @@ -203,49 +203,49 @@ public class Player { else state = OK; } - public String getName() {return name;} - public void setName(String name) {this.name = name;} + String getName() {return name;} + void setName(String name) {this.name = name;} - public int getClassInt() {return classInt;} - public void setClassInt(int classInt) { + int getClassInt() {return classInt;} + void setClassInt(int classInt) { this.classInt = classInt; if (atk != null) setClass(); } - public String getClassName() {return CLASS_STRINGS[classInt];} + String getClassName() {return CLASS_STRINGS[classInt];} - public String getRaceName() {return RACE_STRINGS[raceInt];} - public void setRaceInt(int raceInt) {this.raceInt= raceInt;} - public int getRaceInt() {return raceInt;} + String getRaceName() {return RACE_STRINGS[raceInt];} + void setRaceInt(int raceInt) {this.raceInt= raceInt;} + int getRaceInt() {return raceInt;} //TODO: implement turns (for bonuses and continuous damage in the app - public void rest(boolean isLong) { + void rest(boolean isLong) { if(isLong) { pg = maxPg; curativeEfforts = maxCurativeEfforts; for (Power p : powers) - if (p != null && p.getType() == Power.DIARIO) + if (p != null && p.getFrequency() == Power.DIARIO) p.recover(); setState(); } for (Power p : powers) - if (p != null && p.getType() == Power.ENCUENTRO) + if (p != null && p.getFrequency() == Power.ENCUENTRO) p.recover(); } - public void setAtk(int[] atk) {this.atk = atk; if(classInt != NULL) setClass();} + void setAtk(int[] atk) {this.atk = atk; if(classInt != NULL) setClass();} - public int getFue() {return atk[FUE];} - public int getCon() {return atk[CON];} - public int getSab() {return atk[SAB];} - public int getCar() {return atk[CAR];} - public int getDes() {return atk[DES];} - public int getInt() {return atk[INT];} - public int getCa() {return def[CA];} - public int getFort() {return def[FORT];} - public int getRef() {return def[REF];} - public int getVol() {return def[VOL];} + int getFue() {return atk[FUE];} + int getCon() {return atk[CON];} + int getSab() {return atk[SAB];} + int getCar() {return atk[CAR];} + int getDes() {return atk[DES];} + int getInt() {return atk[INT];} + int getCa() {return def[CA];} + int getFort() {return def[FORT];} + int getRef() {return def[REF];} + int getVol() {return def[VOL];} - public void setClass() { + 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: fix ca bonuses! @@ -258,7 +258,7 @@ public class Player { CLASS_STATS[DEF_VOL][classInt]; } - public static int getModifier(int i) { + static int getModifier(int i) { return i / 2 - 5; } } \ No newline at end of file diff --git a/app/src/main/java/com/kauron/dungeonmanager/PlayerAdapter.java b/app/src/main/java/com/kauron/dungeonmanager/PlayerAdapter.java new file mode 100644 index 0000000..46019f0 --- /dev/null +++ b/app/src/main/java/com/kauron/dungeonmanager/PlayerAdapter.java @@ -0,0 +1,40 @@ +package com.kauron.dungeonmanager; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ProgressBar; +import android.widget.TextView; + +class PlayerAdapter extends ArrayAdapter { + + PlayerAdapter(Context context, Player[] players) { + super(context, R.layout.player_row, players); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + LayoutInflater mInflater = LayoutInflater.from(getContext()); + View mView = mInflater.inflate(R.layout.player_row, parent, false); + + final Player player = getItem(position); + + ((TextView) mView.findViewById(R.id.name)).setText(player.getName()); + ((TextView) mView.findViewById(R.id.other)).setText(player.getClassName() + " " + player.getRaceName()); + ((TextView) mView.findViewById(R.id.level)) + .setText( + getContext().getResources().getString(R.string.level) + + " " + player.getLevel() + ); + + ProgressBar pg = (ProgressBar) mView.findViewById(R.id.progressBar); + pg.setMax(player.getMaxPg()); + pg.setProgress(player.getPg()); + + return mView; + } + + +} diff --git a/app/src/main/java/com/kauron/dungeonmanager/Power.java b/app/src/main/java/com/kauron/dungeonmanager/Power.java index 4b17d31..18259db 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/Power.java +++ b/app/src/main/java/com/kauron/dungeonmanager/Power.java @@ -1,28 +1,64 @@ package com.kauron.dungeonmanager; -public class Power { +class Power { + public static final int MELEE = 1, AREA = 2, RANGED = 3; public static final int DIARIO = 4, A_VOLUNTAD = 2, ENCUENTRO = 3, OPORTUNIDAD = 1; private boolean used; - private int type; - private String name; - private int atk, def, damage; + private int frequency, range, distance; + private String name, keywords; + private int atk, def; + /** An array filled with the maximum damage of each die. + * The position 0 is the damage that doesn't depend on dies. + * Example: 1d6 + 1d4 + 4 is stored as {4, 4, 6}*/ + private int[] damage; + //TODO: modify this so that it takes an array of the same size always, each with each kind of damage - public Power(String name, int type){ + Power(String name, int frequency, int range, int distance, String keywords, int atk, int def, int[] damage){ this.name = name; - this.type = type; + this.keywords = keywords; + this.frequency = frequency; + this.range = range; + this.distance = distance; + this.atk = atk; + this.def = def; + this.damage = damage; used = false; } - public String getName(){return name;} - public int getType(){return type;} + String getName(){return name;} + int getFrequency() {return frequency;} + String getFrequencyString(){ + //TODO: change lists to arrays in resources + switch(frequency) { + case 1: return "Oportunidad"; + case 2: return "A voluntad"; + case 3: return "Encuentro"; + case 4: return "Diario"; + default: return null; + } + } + int getRange() {return range;} + String getRangeString() { + switch(range){ + case 1: return "Cuerpo a cuerpo"; + case 2: return "Área"; + case 3: return "A distancia"; + default: return null; + } + } + int getDistance() {return distance;} + String getKeywords() {return keywords;} + int getAtk() {return atk;} + int getDef() {return def;} + int[] getDamage() {return damage;} - public boolean isUsed(){return used;} + boolean isUsed(){return used;} - public void use(){ - if(type >= ENCUENTRO && !used) + void use(){ + if(frequency >= ENCUENTRO && !used) used = true; } - public void recover(){used = false;} + void recover(){used = false;} } \ No newline at end of file diff --git a/app/src/main/java/com/kauron/dungeonmanager/PowerEditor.java b/app/src/main/java/com/kauron/dungeonmanager/PowerEditor.java new file mode 100644 index 0000000..ba48561 --- /dev/null +++ b/app/src/main/java/com/kauron/dungeonmanager/PowerEditor.java @@ -0,0 +1,41 @@ +package com.kauron.dungeonmanager; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + + +public class PowerEditor extends ActionBarActivity { + + public static final String NAME="name", FREQ="freq", KEYWORDS="keywords", RANGE="range", DISTANCE="distance"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_power_editor); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_power_editor, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/res/drawable-hdpi/ic_add_user.png b/app/src/main/res/drawable-hdpi/ic_add_user.png new file mode 100644 index 0000000..354b260 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_add_user.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_delete.png b/app/src/main/res/drawable-hdpi/ic_delete.png new file mode 100644 index 0000000..1bde929 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_delete.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_edit.png b/app/src/main/res/drawable-hdpi/ic_edit.png new file mode 100644 index 0000000..04db68d Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_edit.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_add_user.png b/app/src/main/res/drawable-mdpi/ic_add_user.png new file mode 100644 index 0000000..65efcf3 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_add_user.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_delete.png b/app/src/main/res/drawable-mdpi/ic_delete.png new file mode 100644 index 0000000..6613652 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_delete.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_edit.png b/app/src/main/res/drawable-mdpi/ic_edit.png new file mode 100644 index 0000000..7804a81 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_edit.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_add_user.png b/app/src/main/res/drawable-xhdpi/ic_add_user.png new file mode 100644 index 0000000..d565a21 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_add_user.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_delete.png b/app/src/main/res/drawable-xhdpi/ic_delete.png new file mode 100644 index 0000000..70a530d Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_delete.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_edit.png b/app/src/main/res/drawable-xhdpi/ic_edit.png new file mode 100644 index 0000000..17aff35 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_edit.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_add_user.png b/app/src/main/res/drawable-xxhdpi/ic_add_user.png new file mode 100644 index 0000000..b8d83ee Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_add_user.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete.png b/app/src/main/res/drawable-xxhdpi/ic_delete.png new file mode 100644 index 0000000..e111a9a Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_delete.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_edit.png b/app/src/main/res/drawable-xxhdpi/ic_edit.png new file mode 100644 index 0000000..37e6a8e Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_edit.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index a57b37f..a59ef49 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -11,6 +11,17 @@ android:background="@color/primary" android:layout_width="match_parent" android:layout_height="wrap_content"> + + + + + + tools:text="@string/FUE" /> + tools:text="@string/CON" /> + tools:text="@string/DES" /> + tools:text="@string/INT" /> + tools:text="@string/SAB" /> + tools:text="@string/CAR" /> @@ -372,7 +384,7 @@ android:layout_row="0" android:layout_column="0" android:id="@+id/CA" - android:hint="@string/CA" /> + tools:text="@string/CA" /> + tools:text="@string/FORT" /> + tools:text="@string/REF" /> + tools:text="@string/VOL" /> diff --git a/app/src/main/res/layout/activity_power_editor.xml b/app/src/main/res/layout/activity_power_editor.xml new file mode 100644 index 0000000..2f2d883 --- /dev/null +++ b/app/src/main/res/layout/activity_power_editor.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_welcome.xml b/app/src/main/res/layout/activity_welcome.xml index ac2b636..5df66dc 100644 --- a/app/src/main/res/layout/activity_welcome.xml +++ b/app/src/main/res/layout/activity_welcome.xml @@ -2,29 +2,57 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.kauron.dungeonmanager.Welcome" android:orientation="vertical"> + -