Various fixez
This commit is contained in:
parent
91e8eed8b0
commit
7cc93f960d
8 changed files with 183 additions and 47 deletions
|
@ -9,6 +9,7 @@
|
|||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
|
||||
|
|
|
@ -5,13 +5,16 @@ import android.support.v7.app.ActionBarActivity;
|
|||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
public class Introduction extends ActionBarActivity {
|
||||
|
||||
EditText name, className, raceName, level, maxPg, curativeEfforts, maxCurativeEfforts, pgE;
|
||||
Spinner classSpinner, raceSpinner;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -26,6 +29,24 @@ public class Introduction extends ActionBarActivity {
|
|||
curativeEfforts = (EditText) findViewById(R.id.editEffortIntro);
|
||||
maxCurativeEfforts = (EditText) findViewById(R.id.editMaxEffortIntro);
|
||||
pgE = (EditText) findViewById(R.id.editPgIntro);
|
||||
|
||||
classSpinner = (Spinner) findViewById(R.id.classSpinner);
|
||||
classSpinner.setAdapter(
|
||||
new ArrayAdapter<String>(
|
||||
this,
|
||||
android.R.layout.simple_spinner_item,
|
||||
Player.classStrings
|
||||
)
|
||||
);
|
||||
|
||||
raceSpinner = (Spinner) findViewById(R.id.raceSpinner);
|
||||
raceSpinner.setAdapter(
|
||||
new ArrayAdapter<String>(
|
||||
this,
|
||||
android.R.layout.simple_spinner_item,
|
||||
Player.raceStrings
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ public class MainActivity extends ActionBarActivity
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
restoreData();
|
||||
undo = false;
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
@ -74,25 +73,32 @@ public class MainActivity extends ActionBarActivity
|
|||
restoreData();
|
||||
return true;
|
||||
} else if (id == R.id.action_undo) {
|
||||
String message = "";
|
||||
if(undoObject == CURRENT_PG){
|
||||
((Button) findViewById(R.id.pgCurrent)).setText(String.valueOf(undoPreviousValue));
|
||||
undoObject = NULL;
|
||||
message = getString(R.string.action_undo_current_pg);
|
||||
}
|
||||
undo();
|
||||
return true;
|
||||
} else if (id == R.id.action_reset) {
|
||||
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
alert.setTitle(getString(R.string.reset_confirmation_title));
|
||||
alert.setMessage(getString(R.string.reset_confirmation));
|
||||
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
message,
|
||||
R.string.message_reset,
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
undo = false;
|
||||
invalidateOptionsMenu();
|
||||
return true;
|
||||
} else if (id == R.id.action_calendar_activity) {
|
||||
Intent intent = new Intent(Intent.ACTION_EDIT);
|
||||
intent.setType("vnd.android.cursor.item/event");
|
||||
intent.putExtra("title", R.string.dungeons_and_dragons);
|
||||
startActivity(intent);
|
||||
getSharedPreferences("basics", MODE_PRIVATE).edit().clear().apply();
|
||||
restoreData();
|
||||
}
|
||||
});
|
||||
|
||||
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
// Canceled.
|
||||
}
|
||||
});
|
||||
|
||||
alert.show();
|
||||
} else if (id == R.id.action_save) {
|
||||
saveData();
|
||||
} else if (id == R.id.action_load) {
|
||||
|
@ -118,6 +124,7 @@ public class MainActivity extends ActionBarActivity
|
|||
super.onResume();
|
||||
Log.e("UTIL", "resume");
|
||||
restoreData();
|
||||
updateCurativeString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -129,7 +136,6 @@ public class MainActivity extends ActionBarActivity
|
|||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
saveData();
|
||||
Log.e("UTIL", "destroy");
|
||||
}
|
||||
|
||||
|
@ -150,13 +156,7 @@ public class MainActivity extends ActionBarActivity
|
|||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
}
|
||||
((TextView) findViewById(R.id.curativeEffortsText)).setText(
|
||||
getString(R.string.curative_display_text1) + " " +
|
||||
player.getCurativeEfforts() + " " +
|
||||
getString(R.string.curative_display_text2) + " " +
|
||||
player.getMaxCurativeEfforts() + " " +
|
||||
getString(R.string.curative_display_text3)
|
||||
);
|
||||
updateCurativeString();
|
||||
healthStatusCheck();
|
||||
}
|
||||
}
|
||||
|
@ -183,10 +183,10 @@ public class MainActivity extends ActionBarActivity
|
|||
String.valueOf(player.getPg())
|
||||
);
|
||||
//finished correctly, then apply values to undo's
|
||||
healthStatusCheck();
|
||||
undo = true;
|
||||
undoPreviousValue = preValue;
|
||||
undoObject = CURRENT_PG;
|
||||
healthStatusCheck();
|
||||
invalidateOptionsMenu();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
@ -208,16 +208,41 @@ public class MainActivity extends ActionBarActivity
|
|||
if (status == Player.MUERTO) {
|
||||
pg.setTextColor(Color.BLACK);
|
||||
pg.setBackgroundColor(Color.RED);
|
||||
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
alert.setTitle(getString(R.string.reset_confirmation_title));
|
||||
alert.setMessage(getString(R.string.reset_confirmation));
|
||||
alert.setPositiveButton(R.string.action_undo, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
undo();
|
||||
}
|
||||
});
|
||||
|
||||
alert.setNegativeButton(R.string.die, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
R.string.message_death,
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
} else if (status == Player.DEBILITADO)
|
||||
getSharedPreferences("basics", MODE_PRIVATE).edit().clear().apply();
|
||||
restoreData();
|
||||
}
|
||||
});
|
||||
|
||||
alert.show();
|
||||
} else if (status == Player.DEBILITADO) {
|
||||
pg.setBackgroundColor(android.R.drawable.btn_default);
|
||||
pg.setTextColor(Color.RED);
|
||||
else if (status == Player.MALHERIDO)
|
||||
} else if (status == Player.MALHERIDO) {
|
||||
pg.setBackgroundColor(android.R.drawable.btn_default);
|
||||
pg.setTextColor(Color.YELLOW);
|
||||
else pg.setTextColor(getResources().getColor(R.color.abc_primary_text_material_dark));
|
||||
} else {
|
||||
pg.setTextColor(getResources().getColor(
|
||||
R.color.abc_primary_text_material_dark
|
||||
));
|
||||
pg.setBackgroundColor(android.R.drawable.btn_default);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -239,7 +264,16 @@ public class MainActivity extends ActionBarActivity
|
|||
new int[18],
|
||||
new Power[4]);
|
||||
} else {
|
||||
|
||||
player.setName(p.getString("playerName", getString(R.string.adventurer_name)));
|
||||
player.setClassName(p.getString("className", getString(R.string.class_name)));
|
||||
player.setRaceName(p.getString("raceName", getString(R.string.race_name)));
|
||||
player.setLevel(p.getInt("level", 1));
|
||||
player.setMaxPg(p.getInt("maxPg", 15));
|
||||
player.setPg(p.getInt("pg", 15));
|
||||
healthStatusCheck();
|
||||
player.setMaxCurativeEfforts(p.getInt("maxCurativeEfforts", 5));
|
||||
player.setCurativeEffort(p.getInt("curativeEfforts", 5));
|
||||
updateCurativeString();
|
||||
}
|
||||
//set restored values to the respective fields
|
||||
((TextView) findViewById(R.id.nameText)).setText(player.getName());
|
||||
|
@ -261,4 +295,31 @@ public class MainActivity extends ActionBarActivity
|
|||
.putInt("curativeEfforts", player.getCurativeEfforts())
|
||||
.apply();
|
||||
}
|
||||
|
||||
private void updateCurativeString() {
|
||||
((TextView) findViewById(R.id.curativeEffortsText)).setText(
|
||||
getString(R.string.curative_display_text1) + " " +
|
||||
player.getCurativeEfforts() + " " +
|
||||
getString(R.string.curative_display_text2) + " " +
|
||||
player.getMaxCurativeEfforts() + " " +
|
||||
getString(R.string.curative_display_text3)
|
||||
);
|
||||
}
|
||||
|
||||
private void undo() {
|
||||
String message = "";
|
||||
if(undoObject == CURRENT_PG){
|
||||
((Button) findViewById(R.id.pgCurrent)).setText(String.valueOf(undoPreviousValue));
|
||||
player.setPg(undoPreviousValue);
|
||||
undoObject = NULL;
|
||||
message = getString(R.string.action_undo_current_pg);
|
||||
}
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
message,
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
undo = false;
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,21 @@
|
|||
package com.ddns.kauron.dungeonmanager;
|
||||
|
||||
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"
|
||||
};
|
||||
|
||||
/**
|
||||
* Names for the races
|
||||
*/
|
||||
public static final String[] raceStrings = new String[] {
|
||||
"Selecciona una raza", "Enano", "Elfo", "Tiflin", "Humano", "Mediano"
|
||||
};
|
||||
|
||||
/**
|
||||
* Values for attack
|
||||
*/
|
||||
|
@ -36,11 +51,14 @@ public class Player {
|
|||
private int pg, maxPg;
|
||||
private int state;
|
||||
private int curativeEfforts, maxCurativeEfforts;
|
||||
private int[] atk, def, abilities;
|
||||
private Power[] powers;
|
||||
//TODO: convert race and class to integer values
|
||||
private int classInt, raceInt;
|
||||
private String name, className, raceName;
|
||||
private int level;
|
||||
|
||||
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){
|
||||
|
@ -61,17 +79,19 @@ public class Player {
|
|||
|
||||
|
||||
public int getMaxCurativeEfforts() {return maxCurativeEfforts;}
|
||||
public void setMaxCurativeEfforts(int maxCurativeEfforts) {this.maxCurativeEfforts = maxCurativeEfforts;}
|
||||
|
||||
public int getCurativeEfforts() {return curativeEfforts;}
|
||||
public void setCurativeEffort(int curativeEfforts) {this.curativeEfforts = curativeEfforts;}
|
||||
|
||||
public int getLevel() {return level;}
|
||||
public void setLevel(int level) {this.level = level;}
|
||||
|
||||
public int getMaxPg() {return maxPg;}
|
||||
public void setMaxPg(int pg) {this.pg = pg;}
|
||||
public void setMaxPg(int maxPg) {this.maxPg = maxPg;}
|
||||
|
||||
public int getPg() {return pg;}
|
||||
public void setPg(int pg) {this.pg = pg;}
|
||||
public void setPg(int pg) {this.pg = pg; setState();}
|
||||
public void losePg(int damage) {
|
||||
pg -= damage;
|
||||
setState();
|
||||
|
@ -102,9 +122,13 @@ public class Player {
|
|||
}
|
||||
|
||||
public String getName() {return name;}
|
||||
public String getClassName() {return className;}
|
||||
public String getRaceName() {return raceName;}
|
||||
public void setName(String name) {this.name = name;}
|
||||
|
||||
public String getClassName() {return className;}
|
||||
public void setClassName(String className) {this.className = className;}
|
||||
|
||||
public String getRaceName() {return raceName;}
|
||||
public void setRaceName(String raceName) {this.raceName = raceName;}
|
||||
|
||||
public void rest(boolean length) {
|
||||
if(length) {
|
||||
|
|
|
@ -100,4 +100,20 @@
|
|||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:hint="@string/curative_efforts" />
|
||||
|
||||
<Spinner
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/classSpinner"
|
||||
android:layout_below="@+id/editPgIntro"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<Spinner
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/raceSpinner"
|
||||
android:layout_below="@+id/classSpinner"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
app:showAsAction="ifRoom"
|
||||
android:icon="@drawable/ic_action_edit"/>
|
||||
<item
|
||||
android:id="@+id/action_calendar_activity"
|
||||
android:title="@string/action_calendar_activity"
|
||||
android:id="@+id/action_reset"
|
||||
android:title="@string/action_reset"
|
||||
android:orderInCategory="30"
|
||||
app:showAsAction="never" />
|
||||
|
||||
|
|
|
@ -32,4 +32,13 @@
|
|||
<string name="action_load">Cargar</string>
|
||||
<string name="curative_efforts">Esfuerzos curativos</string>
|
||||
<string name="pg">PG</string>
|
||||
<string name="action_reset">Borrar datos</string>
|
||||
<string name="curative_display_text1">Tienes</string>
|
||||
<string name="curative_display_text2">de</string>
|
||||
<string name="curative_display_text3">esfuerzos curativos diarios</string>
|
||||
<string name="die">Morir</string>
|
||||
<string name="message_death">Has muerto</string>
|
||||
<string name="message_reset">Los datos han sido borrados</string>
|
||||
<string name="reset_confirmation">Todos los datos se perderán irrevocablemente</string>
|
||||
<string name="reset_confirmation_title">¿Estás seguro?</string>
|
||||
</resources>
|
|
@ -5,6 +5,7 @@
|
|||
<string name="action_cure">Cure</string>
|
||||
<string name="action_undo">Undo</string>
|
||||
<string name="pg">PG</string>
|
||||
<string name="die">Die</string>
|
||||
<string name="curative_efforts">Curative efforts</string>
|
||||
<string name="curative_display_text1">You have</string>
|
||||
<string name="curative_display_text2">out of</string>
|
||||
|
@ -12,7 +13,10 @@
|
|||
<string name="action_load">Load</string>
|
||||
<string name="dungeons_and_dragons">Dungeons and Dragons</string>
|
||||
<string name="action_save">Save</string>
|
||||
<string name="action_calendar_activity">Create event</string>
|
||||
<string name="action_reset">Reset</string>
|
||||
<string name="message_reset">All the data has been cleared</string>
|
||||
<string name="reset_confirmation_title">Are you sure?</string>
|
||||
<string name="reset_confirmation">All data will be lost!</string>
|
||||
<string name="action_undo_current_pg">Action undone</string>
|
||||
<string name="action_edit_basics">Edit character</string>
|
||||
<string name="adventurer_name">Adventurer name</string>
|
||||
|
|
Reference in a new issue