1
0
Fork 0

Added attack and defense class-based computation

This commit is contained in:
Carlos Galindo 2015-02-21 18:49:45 +01:00
parent 78b1f2ddd6
commit 84b93fe74d
7 changed files with 269 additions and 96 deletions

View file

@ -39,18 +39,15 @@ public class HealthDialogFragment extends DialogFragment {
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
String message = getString(R.string.new_energies1) +
" " + getArguments().getInt("curativeEfforts") + " " +
getString(R.string.new_energies2);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(message) builder.setMessage(R.string.new_energies_message)
.setTitle(R.string.new_energies_title) .setTitle(R.string.new_energies)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.me, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
mListener.heal(HealthDialogFragment.this, true); mListener.heal(HealthDialogFragment.this, true);
} }
}) })
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.other, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
mListener.heal(HealthDialogFragment.this, false); mListener.heal(HealthDialogFragment.this, false);

View file

@ -34,7 +34,7 @@ public class Introduction extends ActionBarActivity {
classSpinner = (Spinner) findViewById(R.id.classSpinner); classSpinner = (Spinner) findViewById(R.id.classSpinner);
classSpinner.setAdapter( classSpinner.setAdapter(
new ArrayAdapter<String>( new ArrayAdapter<>(
this, this,
android.R.layout.simple_spinner_dropdown_item, android.R.layout.simple_spinner_dropdown_item,
Player.classStrings Player.classStrings
@ -43,7 +43,7 @@ public class Introduction extends ActionBarActivity {
raceSpinner = (Spinner) findViewById(R.id.raceSpinner); raceSpinner = (Spinner) findViewById(R.id.raceSpinner);
raceSpinner.setAdapter( raceSpinner.setAdapter(
new ArrayAdapter<String>( new ArrayAdapter<>(
this, this,
android.R.layout.simple_spinner_dropdown_item, android.R.layout.simple_spinner_dropdown_item,
Player.raceStrings Player.raceStrings

View file

@ -211,6 +211,7 @@ public class MainActivity extends ActionBarActivity
private void healthStatusCheck() { private void healthStatusCheck() {
int status = player.getState(); int status = player.getState();
int lastState = player.getLastState();
Button pg = (Button) findViewById(R.id.pgCurrent); Button pg = (Button) findViewById(R.id.pgCurrent);
pg.setText(String.valueOf(player.getPg())); pg.setText(String.valueOf(player.getPg()));
if (status == Player.MUERTO) { if (status == Player.MUERTO) {
@ -242,9 +243,23 @@ public class MainActivity extends ActionBarActivity
} else if (status == Player.DEBILITADO) { } else if (status == Player.DEBILITADO) {
pg.setBackgroundColor(android.R.drawable.btn_default); pg.setBackgroundColor(android.R.drawable.btn_default);
pg.setTextColor(Color.RED); pg.setTextColor(Color.RED);
if(lastState != Player.SAME) {
Toast.makeText(
getApplicationContext(),
R.string.state_changed_debilitado,
Toast.LENGTH_LONG
).show();
}
} else if (status == Player.MALHERIDO) { } else if (status == Player.MALHERIDO) {
pg.setBackgroundColor(android.R.drawable.btn_default); pg.setBackgroundColor(android.R.drawable.btn_default);
pg.setTextColor(Color.YELLOW); pg.setTextColor(Color.YELLOW);
if(lastState != Player.SAME) {
Toast.makeText(
getApplicationContext(),
R.string.state_changed_malherido,
Toast.LENGTH_LONG
).show();
}
} else { } else {
pg.setTextColor(getResources().getColor( pg.setTextColor(getResources().getColor(
R.color.abc_primary_text_material_dark R.color.abc_primary_text_material_dark
@ -278,7 +293,6 @@ public class MainActivity extends ActionBarActivity
p.getInt("sab", 10), p.getInt("sab", 10),
p.getInt("car", 10), p.getInt("car", 10),
}, },
new int[3],
new int[18], new int[18],
new Power[4]); new Power[4]);
} else { } else {
@ -305,6 +319,7 @@ public class MainActivity extends ActionBarActivity
((Button) findViewById(R.id.pgCurrent)).setText(String.valueOf(player.getPg())); ((Button) findViewById(R.id.pgCurrent)).setText(String.valueOf(player.getPg()));
//attacks
((TextView) findViewById(R.id.FUE)).setText( ((TextView) findViewById(R.id.FUE)).setText(
getString(R.string.FUE) + ": " + player.getFue() getString(R.string.FUE) + ": " + player.getFue()
); );
@ -324,6 +339,20 @@ public class MainActivity extends ActionBarActivity
getString(R.string.CAR) + ": " + player.getCar() getString(R.string.CAR) + ": " + player.getCar()
); );
//defenses
((TextView) findViewById(R.id.CA)).setText(
getString(R.string.CA) + ": " + player.getCa()
);
((TextView) findViewById(R.id.FORT)).setText(
getString(R.string.FORT) + ": " + player.getFort()
);
((TextView) findViewById(R.id.REF)).setText(
getString(R.string.REF) + ": " + player.getRef()
);
((TextView) findViewById(R.id.VOL)).setText(
getString(R.string.VOL) + ": " + player.getVol()
);
} }

View file

@ -27,8 +27,9 @@ public class Player {
/** /**
* Values for defenses * Values for defenses
*/ */
public static final int CA = 1, FORT = 2, REF = 3, VOL = 4; public static final int CA = 0, FORT = 1, REF = 2, VOL = 3;
//TODO: develop abilities
/** /**
* Values for abilities * Values for abilities
*/ */
@ -48,11 +49,11 @@ public class Player {
/** /**
* Values for the current living state * Values for the current living state
*/ */
public static final int OK = 1, MALHERIDO = 2, DEBILITADO = 3, MUERTO = 4, public static final int OK = 1, MALHERIDO = 2, DEBILITADO = 3, MUERTO = 4, SAME = 5,
USE_CURATIVE_EFFORT = -1, CURED = 1, NOT_CURED = 0, MAXED = -1; USE_CURATIVE_EFFORT = -1, CURED = 1, NOT_CURED = 0, MAXED = -1;
private int pg, maxPg; private int pg, maxPg;
private int state; private int state, lastState;
private int curativeEfforts, maxCurativeEfforts; private int curativeEfforts, maxCurativeEfforts;
//TODO: convert race and class to integer values //TODO: convert race and class to integer values
private int classInt, raceInt; private int classInt, raceInt;
@ -64,17 +65,17 @@ public class Player {
public Player( public Player(
String name, String className, String raceName, String name, String className, String raceName,
int level, int[] atk, int[] def, int[] abilities, int level, int[] atk, int[] abilities,
Power[] powers Power[] powers
){ ){
this.name = name; this.name = name;
this.level = level;
this.raceName = raceName;
this.className = className; this.className = className;
this.def = new int[4];
setAtk(atk); setAtk(atk);
setState(); setState();
this.raceName = raceName;
this.level = level;
this.def = def;
this.abilities = abilities; this.abilities = abilities;
this.powers = powers; this.powers = powers;
} }
@ -104,14 +105,14 @@ public class Player {
else { else {
if(uses && pg < maxPg) curativeEfforts--; if(uses && pg < maxPg) curativeEfforts--;
if (pg < 0) { if (pg < 0) {
pg = 0;
} else { } else {
pg += maxPg / 4; pg += maxPg / 4;
} }
} }
} else { } else {
if (pg < 0) { if (pg < 0) {
pg = 0;
} else { } else {
pg += recovered; pg += recovered;
} }
@ -123,11 +124,13 @@ public class Player {
return CURED; return CURED;
} }
public int getLastState() {return lastState == state ? SAME : lastState;}
public int getState() {return state;} public int getState() {return state;}
private void setState() { private void setState() {
if (pg < maxPg / -2) state = MUERTO; lastState = state;
else if (pg < 0) state = DEBILITADO; if (pg <= maxPg / -2) state = MUERTO;
else if(pg < maxPg / 2) state = MALHERIDO; else if (pg <= 0) state = DEBILITADO;
else if(pg <= maxPg / 2) state = MALHERIDO;
else state = OK; else state = OK;
} }
@ -143,6 +146,7 @@ public class Player {
public String getRaceName() {return raceName;} public String getRaceName() {return raceName;}
public void setRaceName(String raceName) {this.raceName = raceName;} public void setRaceName(String raceName) {this.raceName = raceName;}
//TODO: implement time in the app
public void rest(boolean length) { public void rest(boolean length) {
if(length) { if(length) {
curativeEfforts = maxCurativeEfforts; curativeEfforts = maxCurativeEfforts;
@ -160,24 +164,37 @@ public class Player {
public int getCar() {return atk[CAR];} public int getCar() {return atk[CAR];}
public int getDes() {return atk[DES];} public int getDes() {return atk[DES];}
public int getInt() {return atk[INT];} 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];}
//TODO: set the pg level dependant
public void setClass() { public void setClass() {
int pgExtra = 0, curativeEffortsExtra = 0, defCA = 0, defFORT = 0, defVOL = 0, defREF = 0;
if(className.equals(classStrings[1])){ if(className.equals(classStrings[1])){
//Ardiente //Ardiente
} else if (className.equals(classStrings[2])) { } else if (className.equals(classStrings[2])) {
//Brujo //Brujo
//TODO: Kauron //TODO: Kauron
pg = maxPg = 12 + atk[CON]; pgExtra = 12;
curativeEfforts = maxCurativeEfforts = 6 + Player.getModifier(atk[CON]); curativeEffortsExtra = 6;
return; //TODO: temporal defVOL = defREF = 1;
} else if (className.equals(classStrings[3])) { } else if (className.equals(classStrings[3])) {
//Buscador //Buscador
} else if (className.equals(classStrings[4])) { } else if (className.equals(classStrings[4])) {
//Clérigo //Clérigo
//TODO: Gárafran //TODO: Gárafran
pgExtra = 12;
curativeEffortsExtra = 7;
defVOL = 2;
} else if (className.equals(classStrings[5])) { } else if (className.equals(classStrings[5])) {
//Explorador //Explorador
//TODO: Aria Saferi //TODO: Aria Saferi
pgExtra = 12;
curativeEffortsExtra= 6;
defFORT = 1;
defREF = 1;
} else if (className.equals(classStrings[6])) { } else if (className.equals(classStrings[6])) {
//Guerrero //Guerrero
} else if (className.equals(classStrings[7])) { } else if (className.equals(classStrings[7])) {
@ -189,6 +206,9 @@ public class Player {
} else if (className.equals(classStrings[10])) { } else if (className.equals(classStrings[10])) {
//Paladín //Paladín
//TODO: Ceaelynna //TODO: Ceaelynna
pgExtra = 15;
curativeEffortsExtra = 10;
defFORT = defREF = defVOL = 1;
} else if (className.equals(classStrings[11])) { } else if (className.equals(classStrings[11])) {
//Pícaro //Pícaro
} else if (className.equals(classStrings[12])) { } else if (className.equals(classStrings[12])) {
@ -198,9 +218,16 @@ public class Player {
} else { } else {
//Señor de la Guerra //Señor de la Guerra
//TODO: Mushu //TODO: Mushu
pgExtra = 12;
curativeEffortsExtra = 7;
defVOL = 2;
} }
pg = maxPg = 15; pg = maxPg = atk[CON] + pgExtra;
curativeEfforts = maxCurativeEfforts = 15; curativeEfforts = maxCurativeEfforts = Player.getModifier(atk[CON]) + curativeEffortsExtra;
def[CA] = 10 + level / 2 + Player.getModifier(Math.max(atk[CON], atk[FUE])) + defCA;
def[FORT] = 10 + level / 2 + Player.getModifier(Math.max(atk[CON], atk[FUE])) + defFORT;
def[REF] = 10 + level / 2 + Player.getModifier(Math.max(atk[DES], atk[INT])) + defREF;
def[VOL] = 10 + level / 2 + Player.getModifier(Math.max(atk[CAR], atk[SAB])) + defVOL;
} }
public static int getModifier(int i) { public static int getModifier(int i) {

View file

@ -97,12 +97,35 @@
android:id="@+id/curativeEffortsText"/> android:id="@+id/curativeEffortsText"/>
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/attackContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@+id/curativeEffortsContainer"
android:orientation="vertical">
<TextView
android:id="@+id/titleAttack"
android:text="@string/attack"
android:textAllCaps="true"
android:layout_marginBottom="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingLeft="8dip"
android:paddingRight="8dip"/>
<GridLayout <GridLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/curativeEffortsContainer" android:id="@+id/attackGrid"
android:id="@+id/thirdLayout" android:columnCount="3"
android:columnCount="3"> android:rowCount="2">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -169,6 +192,82 @@
android:id="@+id/CAR" android:id="@+id/CAR"
android:hint="@string/CAR" /> android:hint="@string/CAR" />
</GridLayout> </GridLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/defenseContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@+id/attackContainer"
android:orientation="vertical">
<TextView
android:id="@+id/titleDefense"
android:text="@string/defense"
android:textAllCaps="true"
android:layout_marginBottom="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingLeft="8dip"
android:paddingRight="8dip"/>
<GridLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/defenseGrid"
android:columnCount="2"
android:rowCount="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="0"
android:layout_column="0"
android:id="@+id/CA"
android:hint="@string/CA" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="0"
android:layout_column="1"
android:id="@+id/FORT"
android:hint="@string/FORT" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="1"
android:layout_column="0"
android:id="@+id/REF"
android:hint="@string/REF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:ems="4"
android:layout_row="1"
android:layout_column="1"
android:id="@+id/VOL"
android:hint="@string/VOL" />
</GridLayout>
</LinearLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -13,7 +13,7 @@
<string name="missing_info_error">Tienes que rellenar todos los campos</string> <string name="missing_info_error">Tienes que rellenar todos los campos</string>
<string name="new_energies1">Te quedan</string> <string name="new_energies1">Te quedan</string>
<string name="new_energies2">esfuerzos curativos.</string> <string name="new_energies2">esfuerzos curativos.</string>
<string name="new_energies_title">¿Usar un esfuerzo curativo?</string> <string name="new_energies">Nuevas energías</string>
<string name="no">No</string> <string name="no">No</string>
<string name="no_curative_efforts_error">No te quedan esfuerzos curativos</string> <string name="no_curative_efforts_error">No te quedan esfuerzos curativos</string>
<string name="ok">Ok</string> <string name="ok">Ok</string>
@ -31,7 +31,7 @@
<string name="curative_efforts">Esfuerzos curativos</string> <string name="curative_efforts">Esfuerzos curativos</string>
<string name="pg">PG</string> <string name="pg">PG</string>
<string name="action_reset">Borrar datos</string> <string name="action_reset">Borrar datos</string>
<string name="curative_display_text1">Tienes</string> <string name="curative_display_text1">Te quedan</string>
<string name="curative_display_text2">de</string> <string name="curative_display_text2">de</string>
<string name="curative_display_text3">esfuerzos curativos diarios</string> <string name="curative_display_text3">esfuerzos curativos diarios</string>
<string name="die">Morir</string> <string name="die">Morir</string>
@ -40,9 +40,20 @@
<string name="reset_confirmation">Todos los datos se perderán irrevocablemente</string> <string name="reset_confirmation">Todos los datos se perderán irrevocablemente</string>
<string name="reset_confirmation_title">¿Estás seguro?</string> <string name="reset_confirmation_title">¿Estás seguro?</string>
<string name="CAR">CAR</string> <string name="CAR">CAR</string>
<string name="CON" translatable="false">CON</string> <string name="CON">CON</string>
<string name="DES" translatable="false">DES</string> <string name="DES">DES</string>
<string name="FUE" translatable="false">FUE</string> <string name="FUE">FUE</string>
<string name="INT" translatable="false">INT</string> <string name="INT">INT</string>
<string name="SAB" translatable="false">SAB</string> <string name="SAB">SAB</string>
<string name="state_changed_debilitado">Te has caído al suelo debilitado, no puedes moverte ni hacer nada.</string>
<string name="state_changed_malherido">¡Sólo tienes la mitad de la vida!</string>
<string name="new_energies_message">¿Quién va a usar un esfuerzo curativo?</string>
<string name="me">Yo</string>
<string name="other">Otro</string>
<string name="attack">Ataque</string>
<string name="defense">Defensa</string>
<string name="CA">CA</string>
<string name="FORT">FORT</string>
<string name="REF">REF</string>
<string name="VOL">VOL</string>
</resources> </resources>

View file

@ -2,10 +2,16 @@
<resources> <resources>
<string name="app_name" translatable="false">DungeonManager</string> <string name="app_name" translatable="false">DungeonManager</string>
<string name="attack">Attack</string>
<string name="action_cure">Cure</string> <string name="action_cure">Cure</string>
<string name="action_undo">Undo</string> <string name="action_undo">Undo</string>
<string name="pg">PG</string> <string name="pg">PG</string>
<string name="die">Die</string> <string name="die">Die</string>
<string name="CA">CA</string>
<string name="FORT">FORT</string>
<string name="REF">REF</string>
<string name="VOL">VOL</string>
<string name="defense">Defense</string>
<string name="curative_efforts">Curative efforts</string> <string name="curative_efforts">Curative efforts</string>
<string name="curative_display_text1">You have</string> <string name="curative_display_text1">You have</string>
<string name="curative_display_text2">out of</string> <string name="curative_display_text2">out of</string>
@ -20,9 +26,11 @@
<string name="action_undo_current_pg">Action undone</string> <string name="action_undo_current_pg">Action undone</string>
<string name="action_edit_basics">Edit character</string> <string name="action_edit_basics">Edit character</string>
<string name="adventurer_name">Adventurer name</string> <string name="adventurer_name">Adventurer name</string>
<string name="state_changed_malherido">You have less than half of your maximum health</string>
<string name="new_energies_message">Who is using a curative effort?</string>
<string name="class_name">Class</string> <string name="class_name">Class</string>
<string name="race_name">Race</string> <string name="race_name">Race</string>
<string name="state_changed_debilitado">You have fainted. You can\'t move or do anything!</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="ok">Ok</string> <string name="ok">Ok</string>
<string name="yes">Yes</string> <string name="yes">Yes</string>
@ -32,7 +40,7 @@
<string name="message_death">Your character has died</string> <string name="message_death">Your character has died</string>
<string name="new_energies1">You have</string> <string name="new_energies1">You have</string>
<string name="new_energies2">curative efforts</string> <string name="new_energies2">curative efforts</string>
<string name="new_energies_title">Use a curative effort?</string> <string name="new_energies">New energies</string>
<string name="title_activity_introduction">Edit character</string> <string name="title_activity_introduction">Edit character</string>
<string name="action_finish">Done</string> <string name="action_finish">Done</string>
@ -44,6 +52,8 @@
<string name="maxed_curative">You have reached your maximum level of PG</string> <string name="maxed_curative">You have reached your maximum level of PG</string>
<string name="suffer_damage">Input the damage suffered</string> <string name="suffer_damage">Input the damage suffered</string>
<string name="suffer_damage_hint">PG lost</string> <string name="suffer_damage_hint">PG lost</string>
<string name="me">Me</string>
<string name="other">Otro</string>
<string name="FUE">FUE</string> <string name="FUE">FUE</string>
<string name="CON">CON</string> <string name="CON">CON</string>