Initial commit
1
app/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
91
app/app.iml
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<configuration>
|
||||
<option name="GRADLE_PROJECT_PATH" value=":app" />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
|
||||
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
|
||||
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
25
app/build.gradle
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 21
|
||||
buildToolsVersion "21.1.2"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.ddns.kauron.dungeonmanager"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 21
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:21.0.3'
|
||||
}
|
||||
17
app/proguard-rules.pro
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:\Users\Carlos\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.ddns.kauron.dungeonmanager;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
||||
29
app/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.ddns.kauron.dungeonmanager" >
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".Introduction"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:label="@string/title_activity_introduction" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.ddns.kauron.dungeonmanager.MainActivity" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
app/src/main/ic_launcher-web.png
Normal file
|
After Width: | Height: | Size: 124 KiB |
|
|
@ -0,0 +1,66 @@
|
|||
package com.ddns.kauron.dungeonmanager;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class HealthDialogFragment extends DialogFragment {
|
||||
|
||||
static HealthDialogFragment newInstance(int curativeEfforts) {
|
||||
HealthDialogFragment f = new HealthDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("curativeEfforts", curativeEfforts);
|
||||
f.setArguments(args);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
public interface HealthDialogListener {
|
||||
public void curativeEffort(DialogFragment dialog, boolean uses);
|
||||
}
|
||||
|
||||
|
||||
HealthDialogListener mListener;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
try{
|
||||
mListener = (HealthDialogListener) activity;
|
||||
}catch(ClassCastException e){
|
||||
throw new ClassCastException(activity.toString() + " must implement HealthDialogListener");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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());
|
||||
builder.setMessage(message)
|
||||
.setTitle(R.string.new_energies_title)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mListener.curativeEffort(HealthDialogFragment.this, true);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mListener.curativeEffort(HealthDialogFragment.this, false);
|
||||
}
|
||||
})
|
||||
.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
package com.ddns.kauron.dungeonmanager;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
public class Introduction extends ActionBarActivity {
|
||||
|
||||
EditText name, className, raceName, level, maxPg;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@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_introduction, 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_finish) {
|
||||
if(finished()) {
|
||||
this.finish();
|
||||
} else {
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
R.string.missing_info_error,
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
//TODO: fix this
|
||||
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();
|
||||
int levelInt = 0, maxPgInt = 0;
|
||||
try {
|
||||
levelInt = Integer.parseInt(level.getText().toString());
|
||||
maxPgInt = Integer.parseInt(level.getText().toString());
|
||||
} catch (Exception e) {}
|
||||
if(getIntent().getExtras().getBoolean("first_time")) {
|
||||
if (!nameString.isEmpty() &&
|
||||
!classString.isEmpty() &&
|
||||
!raceString.isEmpty() &&
|
||||
levelInt != 0 &&
|
||||
maxPgInt != 0) {
|
||||
//first save it all
|
||||
ed.putString("playerName", nameString);
|
||||
ed.putString("className", classString);
|
||||
ed.putString("raceName", raceString);
|
||||
if(p.getInt("pg", Integer.MIN_VALUE) == Integer.MIN_VALUE)
|
||||
ed.putInt("pg", maxPgInt);
|
||||
ed.putInt("level", levelInt);
|
||||
ed.putInt("maxPg", maxPgInt);
|
||||
ed.putBoolean("saved", true);
|
||||
ed.apply();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(!nameString.isEmpty()) ed.putString("playerName", nameString);
|
||||
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);
|
||||
ed.apply();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,209 @@
|
|||
package com.ddns.kauron.dungeonmanager;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
public class MainActivity extends ActionBarActivity
|
||||
implements HealthDialogFragment.HealthDialogListener{
|
||||
|
||||
public static final int CURRENT_PG = 1, NULL = 0;
|
||||
|
||||
public Player player;
|
||||
private boolean undo;
|
||||
private int undoObject, undoPreviousValue;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
restoreData();
|
||||
undo = false;
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@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_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu (Menu menu) {
|
||||
menu.findItem(R.id.action_undo).setVisible(undo);
|
||||
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_cure) {
|
||||
showHealthDialog();
|
||||
return true;
|
||||
} else if (id == R.id.action_edit_basics) {
|
||||
SharedPreferences p = getSharedPreferences("basics", MODE_PRIVATE);
|
||||
Intent intent = new Intent(this, Introduction.class);
|
||||
startActivity(intent.putExtra(
|
||||
"first_time",
|
||||
!p.getBoolean("saved", false)
|
||||
));
|
||||
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);
|
||||
}
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
message,
|
||||
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);
|
||||
} else if (id == R.id.action_save) {
|
||||
saveData();
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void showHealthDialog(){
|
||||
DialogFragment dialog = HealthDialogFragment.newInstance(player.getCurativeEfforts());
|
||||
dialog.show(getFragmentManager(), "HealthDialogFragment");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void curativeEffort(DialogFragment dialog, boolean uses) {
|
||||
int hasCured = player.recoverPg(Player.USE_CURATIVE_EFFORT, uses);
|
||||
if (hasCured == Player.NOT_CURED) {
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
R.string.no_curative_efforts_error,
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
} else {
|
||||
if(hasCured == Player.MAXED){
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
R.string.maxed_curative,
|
||||
Toast.LENGTH_LONG
|
||||
).show();
|
||||
}
|
||||
healthStatusCheck();
|
||||
}
|
||||
}
|
||||
|
||||
public void onCurrentPgClick(final View view){
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
alert.setTitle(getString(R.string.suffer_damage));
|
||||
|
||||
// Set an EditText view to get user input
|
||||
final EditText input = new EditText(this);
|
||||
input.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
input.setHint(R.string.suffer_damage_hint);
|
||||
|
||||
|
||||
alert.setView(input);
|
||||
|
||||
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
Button pg = (Button) findViewById(R.id.pgCurrent);
|
||||
try {
|
||||
int preValue = Integer.parseInt(pg.getText().toString());
|
||||
int damage = Integer.parseInt(input.getText().toString());
|
||||
player.losePg(damage);
|
||||
pg.setText(
|
||||
String.valueOf(player.getPg())
|
||||
);
|
||||
//finished correctly, then apply values to undo's
|
||||
healthStatusCheck();
|
||||
undo = true;
|
||||
undoPreviousValue = preValue;
|
||||
undoObject = CURRENT_PG;
|
||||
invalidateOptionsMenu();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
});
|
||||
|
||||
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
// Canceled.
|
||||
}
|
||||
});
|
||||
|
||||
alert.show();
|
||||
}
|
||||
|
||||
private void healthStatusCheck(){
|
||||
int status = player.getState();
|
||||
Button pg = (Button) findViewById(R.id.pgCurrent);
|
||||
pg.setText(String.valueOf(player.getPg()));
|
||||
if (status == Player.MUERTO) {
|
||||
pg.setText("");
|
||||
} else if (status == Player.DEBILITADO)
|
||||
pg.setTextColor(Color.RED);
|
||||
else if (status == Player.MALHERIDO)
|
||||
pg.setTextColor(Color.YELLOW);
|
||||
else pg.setTextColor(getResources().getColor(R.color.abc_primary_text_material_dark));
|
||||
}
|
||||
|
||||
|
||||
private void restoreData(){
|
||||
SharedPreferences p = getSharedPreferences("basics", MODE_PRIVATE);
|
||||
//restore state
|
||||
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[3],
|
||||
new int[18],
|
||||
new Power[4]);
|
||||
//set restored values to the respective fields
|
||||
((TextView) findViewById(R.id.nameText)).setText(player.getName());
|
||||
((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.getMaxPg()));
|
||||
}
|
||||
|
||||
private void saveData() {
|
||||
|
||||
}
|
||||
}
|
||||
115
app/src/main/java/com/ddns/kauron/dungeonmanager/Player.java
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
package com.ddns.kauron.dungeonmanager;
|
||||
|
||||
public class Player {
|
||||
/**
|
||||
* Values for attack
|
||||
*/
|
||||
public static final int FUE = 1, CON = 2, DES = 3, INT = 4, SAB = 5, CAR = 6;
|
||||
|
||||
/**
|
||||
* Values for defenses
|
||||
*/
|
||||
public static final int CA = 1, FORT = 2, REF = 3, VOL = 4;
|
||||
|
||||
/**
|
||||
* Values for abilities
|
||||
*/
|
||||
public static final int ACROBACIAS = 1, AGUANTE = 2, ARCANOS = 3, ATLETISMO = 4, DIPLOMACIA = 5,
|
||||
DUNGEONS = 6, ENGAÑAR = 7, HISTORIA = 8, HURTO = 9, INTIMIDAR = 10, NATURALEZA = 11,
|
||||
PERCEPCIÓN = 12, PERSPICACIA = 13, RECURSOS = 14, RELIGIÓN = 15, SANAR = 16, SIGILO = 17;
|
||||
|
||||
/**
|
||||
* Names for the abilities
|
||||
*/
|
||||
public static final String[] abilityString = new String[] {
|
||||
"Acrobacias", "Aguante", "Arcanos", "Atletismo", "Diplomacia", "Dungeons", "Engañar",
|
||||
"Historia", "Hurto", "Intimidar", "Naturaleza", "Percepción", "Perspicacia", "Recursos",
|
||||
"Religión", "Sanar", "Sigilo"
|
||||
};
|
||||
|
||||
/**
|
||||
* Values for the current living state
|
||||
*/
|
||||
public static final int OK = 1, MALHERIDO = 2, DEBILITADO = 3, MUERTO = 4,
|
||||
USE_CURATIVE_EFFORT = -1, CURED = 1, NOT_CURED = 0, MAXED = -1;
|
||||
|
||||
private int pg, maxPg;
|
||||
private int state;
|
||||
private int curativeEfforts, maxCurativeEfforts;
|
||||
private int[] atk, def, abilities;
|
||||
private Power[] powers;
|
||||
private String name, className, raceName;
|
||||
private int level;
|
||||
|
||||
|
||||
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;
|
||||
setState();
|
||||
this.name = name;
|
||||
this.className = className;
|
||||
this.raceName = raceName;
|
||||
this.level = level;
|
||||
this.atk = atk;
|
||||
this.def = def;
|
||||
this.abilities = abilities;
|
||||
this.powers = powers;
|
||||
this.maxCurativeEfforts = maxCurativeEfforts;
|
||||
this.curativeEfforts = curativeEfforts;
|
||||
}
|
||||
|
||||
|
||||
public int getCurativeEfforts() {return curativeEfforts;}
|
||||
public void setCurativeEffort(int curativeEfforts) {this.curativeEfforts = curativeEfforts;}
|
||||
|
||||
public int getLevel() {return level;}
|
||||
|
||||
public int getMaxPg() {return maxPg;}
|
||||
public void setMaxPg(int pg) {this.pg = pg;}
|
||||
|
||||
public int getPg() {return pg;}
|
||||
public void setPg(int pg) {this.pg = pg;}
|
||||
public void losePg(int damage) {
|
||||
pg -= damage;
|
||||
setState();
|
||||
}
|
||||
public int recoverPg(int recovered, boolean uses) {
|
||||
if(recovered == USE_CURATIVE_EFFORT){
|
||||
if(uses && curativeEfforts <= 0) return NOT_CURED;
|
||||
else {
|
||||
if(uses) curativeEfforts--;
|
||||
pg += maxPg / 4;
|
||||
}
|
||||
} else {
|
||||
pg += recovered;
|
||||
}
|
||||
setState();
|
||||
|
||||
if (pg > maxPg) {pg = maxPg; return MAXED;}
|
||||
|
||||
return CURED;
|
||||
}
|
||||
|
||||
public int getState() {return state;}
|
||||
private void setState() {
|
||||
if (pg < maxPg / -2) state = MUERTO;
|
||||
else if (pg < 0) state = DEBILITADO;
|
||||
else if(pg < maxPg / 2) state = MALHERIDO;
|
||||
else state = OK;
|
||||
}
|
||||
|
||||
public String getName() {return name;}
|
||||
public String getClassName() {return className;}
|
||||
public String getRaceName() {return raceName;}
|
||||
|
||||
|
||||
public void rest(boolean length) {
|
||||
if(length) {
|
||||
curativeEfforts = maxCurativeEfforts;
|
||||
for(Power p : powers){
|
||||
if(p != null) p.recover();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
app/src/main/java/com/ddns/kauron/dungeonmanager/Power.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package com.ddns.kauron.dungeonmanager;
|
||||
|
||||
public class Power {
|
||||
public static final int DIARIO = 1, A_VOLUNTAD = 2, ENCUENTRO = 3, OPORTUNIDAD = 4;
|
||||
|
||||
private boolean used;
|
||||
private int type;
|
||||
private String name;
|
||||
|
||||
|
||||
public Power(String name, int type){
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
used = false;
|
||||
}
|
||||
|
||||
public String getName(){return name;}
|
||||
public int getType(){return type;}
|
||||
|
||||
public boolean isUsed(){return used;}
|
||||
|
||||
public void use(){used = true;}
|
||||
public void recover(){used = false;}
|
||||
}
|
||||
BIN
app/src/main/res/drawable-hdpi/ic_action_done.png
Normal file
|
After Width: | Height: | Size: 282 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_edit.png
Normal file
|
After Width: | Height: | Size: 383 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_heal.png
Normal file
|
After Width: | Height: | Size: 254 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_name.png
Normal file
|
After Width: | Height: | Size: 798 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_save.png
Normal file
|
After Width: | Height: | Size: 258 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_undo.png
Normal file
|
After Width: | Height: | Size: 443 B |
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
app/src/main/res/drawable-mdpi/ic_action_done.png
Normal file
|
After Width: | Height: | Size: 220 B |