From 7d3b032f89ef164956a5873776496b2d41c540d4 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Sat, 21 Feb 2015 16:22:20 +0100 Subject: [PATCH] Introducing autogeneration --- .../kauron/dungeonmanager/Introduction.java | 86 ++++--- .../kauron/dungeonmanager/MainActivity.java | 46 +++- .../ddns/kauron/dungeonmanager/Player.java | 90 ++++++-- .../main/res/layout/activity_introduction.xml | 211 ++++++++++-------- app/src/main/res/layout/activity_main.xml | 74 ++++++ app/src/main/res/values-es/strings.xml | 10 +- app/src/main/res/values/strings.xml | 7 + 7 files changed, 367 insertions(+), 157 deletions(-) diff --git a/app/src/main/java/com/ddns/kauron/dungeonmanager/Introduction.java b/app/src/main/java/com/ddns/kauron/dungeonmanager/Introduction.java index 0fdcefe..60029c7 100644 --- a/app/src/main/java/com/ddns/kauron/dungeonmanager/Introduction.java +++ b/app/src/main/java/com/ddns/kauron/dungeonmanager/Introduction.java @@ -13,7 +13,8 @@ import android.widget.Toast; public class Introduction extends ActionBarActivity { - EditText name, className, raceName, level, maxPg, curativeEfforts, maxCurativeEfforts, pgE; + EditText name, level; + EditText fue, con, des, sab, intel, car; Spinner classSpinner, raceSpinner; @Override @@ -22,19 +23,20 @@ public class Introduction extends ActionBarActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_introduction); name = (EditText) findViewById(R.id.editNameIntro); - className = (EditText) findViewById(R.id.editClassIntro); - raceName = (EditText) findViewById(R.id.editRaceIntro); level = (EditText) findViewById(R.id.editLevelIntro); - maxPg = (EditText) findViewById(R.id.editMaxPgIntro); - curativeEfforts = (EditText) findViewById(R.id.editEffortIntro); - maxCurativeEfforts = (EditText) findViewById(R.id.editMaxEffortIntro); - pgE = (EditText) findViewById(R.id.editPgIntro); + + fue = (EditText) findViewById(R.id.FUE); + con = (EditText) findViewById(R.id.CON); + des = (EditText) findViewById(R.id.DES); + sab = (EditText) findViewById(R.id.SAB); + intel = (EditText) findViewById(R.id.INT); + car = (EditText) findViewById(R.id.CAR); classSpinner = (Spinner) findViewById(R.id.classSpinner); classSpinner.setAdapter( new ArrayAdapter( this, - android.R.layout.simple_spinner_item, + android.R.layout.simple_spinner_dropdown_item, Player.classStrings ) ); @@ -43,7 +45,7 @@ public class Introduction extends ActionBarActivity { raceSpinner.setAdapter( new ArrayAdapter( this, - android.R.layout.simple_spinner_item, + android.R.layout.simple_spinner_dropdown_item, Player.raceStrings ) ); @@ -85,43 +87,54 @@ public class Introduction extends ActionBarActivity { private boolean finished() { SharedPreferences p = getSharedPreferences("basics", MODE_PRIVATE); SharedPreferences.Editor ed = p.edit(); - String nameString = name.getText().toString(); - String classString = className.getText().toString(); - String raceString = raceName.getText().toString(); + String classString = Player.classStrings[classSpinner.getSelectedItemPosition()]; + String raceString = Player.raceStrings[raceSpinner.getSelectedItemPosition()]; - int levelInt = 0, maxPgInt = 0, pg = 0, curEff = 0, mCurEff = 0; + int levelInt = 0; if (!level.getText().toString().isEmpty()) levelInt = Integer.parseInt(level.getText().toString()); - if (!maxPg.getText().toString().isEmpty()) - maxPgInt = Integer.parseInt(maxPg.getText().toString()); - if (!pgE.getText().toString().isEmpty()) - pg = Integer.parseInt(pgE.getText().toString()); - if (!curativeEfforts.getText().toString().isEmpty()) - curEff = Integer.parseInt(curativeEfforts.getText().toString()); - if (!maxCurativeEfforts.getText().toString().isEmpty()) - mCurEff = Integer.parseInt(maxCurativeEfforts.getText().toString()); + + int fue = 0, con = 0, des = 0, intel = 0, sab = 0, car = 0; + if (!this.car.getText().toString().isEmpty()) + car = Integer.parseInt(this.car.getText().toString()); + if (!this.fue.getText().toString().isEmpty()) + fue = Integer.parseInt(this.fue.getText().toString()); + if (!this.con.getText().toString().isEmpty()) + con = Integer.parseInt(this.con.getText().toString()); + if (!this.des.getText().toString().isEmpty()) + des = Integer.parseInt(this.des.getText().toString()); + if (!this.intel.getText().toString().isEmpty()) + intel = Integer.parseInt(this.intel.getText().toString()); + if (!this.sab.getText().toString().isEmpty()) + sab = Integer.parseInt(this.sab.getText().toString()); if(getIntent().getExtras().getBoolean("first_time")) { if ( !nameString.isEmpty() && - !classString.isEmpty() && - !raceString.isEmpty() && + !classString.equals(Player.classStrings[0]) && + !raceString.equals(Player.raceStrings[0]) && levelInt != 0 && - maxPgInt != 0 && - pg != 0 && - curEff != 0 && - mCurEff != 0 + car != 0 && + fue != 0 && + con != 0 && + des != 0 && + intel != 0 && + sab != 0 ) { //first save it all ed.putString("playerName", nameString); ed.putString("className", classString); ed.putString("raceName", raceString); ed.putInt("level", levelInt); - ed.putInt("maxPg", maxPgInt); - ed.putInt("pg", pg); - ed.putInt("maxCurativeEfforts", mCurEff); - ed.putInt("curativeEfforts", curEff); + + ed.putInt("fue", fue); + ed.putInt("car", car); + ed.putInt("int", intel); + ed.putInt("sab", sab); + ed.putInt("con", con); + ed.putInt("des", des); + ed.putBoolean("saved", true); } else { return false; @@ -131,10 +144,13 @@ public class Introduction extends ActionBarActivity { if (!classString.isEmpty()) ed.putString("className", classString); if (!raceString.isEmpty()) ed.putString("raceName", raceString); if (levelInt != 0) ed.putInt("level", levelInt); - if (maxPgInt != 0) ed.putInt("maxPg", maxPgInt); - if (pg != 0) ed.putInt("pg", pg); - if (mCurEff != 0) ed.putInt("maxCurativeEfforts", mCurEff); - if (curEff != 0) ed.putInt("curativeEfforts", curEff); + + if (fue != 0) ed.putInt("fue", fue); + if (car != 0) ed.putInt("car", car); + if (intel != 0) ed.putInt("int", intel); + if (sab != 0) ed.putInt("sab", sab); + if (con != 0) ed.putInt("con", con); + if (des != 0) ed.putInt("des", des); } ed.apply(); return true; diff --git a/app/src/main/java/com/ddns/kauron/dungeonmanager/MainActivity.java b/app/src/main/java/com/ddns/kauron/dungeonmanager/MainActivity.java index 3406d46..5017505 100644 --- a/app/src/main/java/com/ddns/kauron/dungeonmanager/MainActivity.java +++ b/app/src/main/java/com/ddns/kauron/dungeonmanager/MainActivity.java @@ -124,6 +124,7 @@ public class MainActivity extends ActionBarActivity super.onResume(); Log.e("UTIL", "resume"); restoreData(); + healthStatusCheck(); updateCurativeString(); } @@ -249,17 +250,27 @@ public class MainActivity extends ActionBarActivity private void restoreData(){ SharedPreferences p = getSharedPreferences("basics", MODE_PRIVATE); //restore state + if (!p.getBoolean("saved", false)) { + Intent intent = new Intent(this, Introduction.class); + startActivity(intent.putExtra( + "first_time", + !p.getBoolean("saved", false) + )); + } if(player == null) { player = new Player( p.getString("playerName", getString(R.string.adventurer_name)), p.getString("className", getString(R.string.class_name)), p.getString("raceName", getString(R.string.race_name)), p.getInt("level", 1), - p.getInt("maxPg", 15), - p.getInt("pg", 15), - p.getInt("maxCurativeEfforts", 5), - p.getInt("curativeEfforts", 5), - new int[6], + new int[] { + p.getInt("fue", 10), + p.getInt("con", 10), + p.getInt("des", 10), + p.getInt("int", 10), + p.getInt("sab", 10), + p.getInt("car", 10), + }, new int[3], new int[18], new Power[4]); @@ -280,14 +291,33 @@ public class MainActivity extends ActionBarActivity ((TextView) findViewById(R.id.raceText)).setText(player.getRaceName()); ((TextView) findViewById(R.id.classText)).setText(player.getClassName()); ((TextView) findViewById(R.id.lvl)).setText(String.valueOf(player.getLevel())); + ((Button) findViewById(R.id.pgCurrent)).setText(String.valueOf(player.getPg())); + + ((TextView) findViewById(R.id.FUE)).setText( + getString(R.string.FUE) + ": " + player.getFue() + ); + ((TextView) findViewById(R.id.CON)).setText( + getString(R.string.CON) + ": " + player.getCon() + ); + ((TextView) findViewById(R.id.DES)).setText( + getString(R.string.DES) + ": " + player.getDes() + ); + ((TextView) findViewById(R.id.INT)).setText( + getString(R.string.INT) + ": " + player.getInt() + ); + ((TextView) findViewById(R.id.SAB)).setText( + getString(R.string.SAB) + ": " + player.getSab() + ); + ((TextView) findViewById(R.id.CAR)).setText( + getString(R.string.CAR) + ": " + player.getCar() + ); + + } private void saveData() { getSharedPreferences("basics", MODE_PRIVATE).edit() - .putString("playerName", player.getName()) - .putString("className", player.getClassName()) - .putString("raceName", player.getRaceName()) .putInt("level", player.getLevel()) .putInt("maxPg", player.getMaxPg()) .putInt("pg", player.getPg()) diff --git a/app/src/main/java/com/ddns/kauron/dungeonmanager/Player.java b/app/src/main/java/com/ddns/kauron/dungeonmanager/Player.java index ab2af79..00d9ddb 100644 --- a/app/src/main/java/com/ddns/kauron/dungeonmanager/Player.java +++ b/app/src/main/java/com/ddns/kauron/dungeonmanager/Player.java @@ -5,21 +5,24 @@ public class Player { /** * Names for the classes */ - public static final String[] classStrings = new String[] { - "Selecciona una clase","Brujo", "Clérigo", "Señor de la guerra" + public static final String[] classStrings = { + "Clase", "Ardiente", "Brujo", "Buscador", "Clérigo", "Explorador", + "Guerrero", "Mago", "Mente de Batalla", "Monje", "Paladín", "Pícaro", "Psiónico", + "Sacerdote Rúnico", "Señor de la guerra" }; /** * Names for the races */ public static final String[] raceStrings = new String[] { - "Selecciona una raza", "Enano", "Elfo", "Tiflin", "Humano", "Mediano" + "Raza", "Dracónido", "Eladrín", "Elfo", "Enano", "Gitzherai", "Humanos", "Medianos", + "Mente del Fragmento", "Minotauro", "Salvaje", "Semielfo", "Tiflin" }; /** * Values for attack */ - public static final int FUE = 1, CON = 2, DES = 3, INT = 4, SAB = 5, CAR = 6; + public static final int FUE = 0, CON = 1, DES = 2, INT = 3, SAB = 4, CAR = 5; /** * Values for defenses @@ -59,22 +62,58 @@ public class Player { private int[] atk, def, abilities; private Power[] powers; - - public Player(String name, String className, String raceName, int level, int maxPg, int pg, - int maxCurativeEfforts, int curativeEfforts, int[] atk, int[] def, int[] abilities, Power[] powers){ - this.maxPg = maxPg; - this.pg = pg; + public Player( + String name, String className, String raceName, + int level, int[] atk, int[] def, int[] abilities, + Power[] powers + ) { setState(); this.name = name; this.className = className; + + if(className.equals(classStrings[1])){ + //Ardiente + } else if (className.equals(classStrings[2])) { + //Brujo + //TODO: Kauron + maxPg = atk[CON] + 12; + maxCurativeEfforts = 6 + atk[CON]; + } else if (className.equals(classStrings[3])) { + //Buscador + } else if (className.equals(classStrings[4])) { + //Clérigo + //TODO: Gárafran + } else if (className.equals(classStrings[5])) { + //Explorador + //TODO: Aria Saferi + } else if (className.equals(classStrings[6])) { + //Guerrero + } else if (className.equals(classStrings[7])) { + //Mago + } else if (className.equals(classStrings[8])) { + //Mente de Batalla + } else if (className.equals(classStrings[9])) { + //Monje + } else if (className.equals(classStrings[10])) { + //Paladín + //TODO: Ceaelynna + } else if (className.equals(classStrings[11])) { + //Pícaro + } else if (className.equals(classStrings[12])) { + //Psiónico + } else if (className.equals(classStrings[13])) { + //Sacerdote rúnico + } else { + //Señor de la Guerra + //TODO: Mushu + } + this.raceName = raceName; this.level = level; this.atk = atk; this.def = def; this.abilities = abilities; this.powers = powers; - this.maxCurativeEfforts = maxCurativeEfforts; - this.curativeEfforts = curativeEfforts; } @@ -101,10 +140,18 @@ public class Player { if(uses && curativeEfforts <= 0) return NOT_CURED; else { if(uses && pg < maxPg) curativeEfforts--; - pg += maxPg / 4; + if (pg < 0) { + + } else { + pg += maxPg / 4; + } } } else { - pg += recovered; + if (pg < 0) { + + } else { + pg += recovered; + } } setState(); @@ -138,4 +185,21 @@ public class Player { } } } + + public void setAtk(int[] atk) {this.atk = atk;} + public int[] getAtk() {return atk;} + + public void setFue(int fue) {atk[FUE] = fue;} + public void setCon(int con) {atk[CON] = con;} + public void setSab(int sab) {atk[SAB] = sab;} + public void setCar(int car) {atk[CAR] = car;} + public void setDes(int des) {atk[DES] = des;} + public void setInt(int intel) {atk[INT] = intel;} + + 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];} } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_introduction.xml b/app/src/main/res/layout/activity_introduction.xml index 17c2205..bc0a3ac 100644 --- a/app/src/main/res/layout/activity_introduction.xml +++ b/app/src/main/res/layout/activity_introduction.xml @@ -6,114 +6,129 @@ android:paddingBottom="@dimen/activity_vertical_margin" tools:context="com.ddns.kauron.dungeonmanager.Introduction"> - + android:id="@+id/firstLayout" + android:orientation="horizontal"> - + - + + - + android:orientation="horizontal" + android:id="@+id/secondLayout" + android:layout_below="@+id/firstLayout"> - + - + + - + android:layout_below="@+id/secondLayout" + android:id="@+id/thirdLayout" + android:columnCount="3"> + + android:layout_row="0" + android:layout_column="0" - + android:id="@+id/FUE" + android:hint="@string/FUE" /> + + + + + + + + + + + - diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 43eeb7a..2781ec8 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -97,4 +97,78 @@ android:id="@+id/curativeEffortsText"/> + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 05ac7e1..0099b2f 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -1,6 +1,5 @@ - DungeonManager Curar Editar personaje Hecho @@ -22,10 +21,9 @@ Indica el daño sufrido Editar personaje - Esfuerzos curativos + Máx. esfuerzos curativos PG perdidos Deshacer - Crear evento Guardar Acción deshecha Dragones y Mazmorras @@ -41,4 +39,10 @@ Los datos han sido borrados Todos los datos se perderán irrevocablemente ¿Estás seguro? + CAR + CON + DES + FUE + INT + SAB \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e8586ad..77d3a84 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -44,4 +44,11 @@ You have reached your maximum level of PG Input the damage suffered PG lost + + FUE + CON + DES + INT + CAR + SAB