Implemented Game Mode
added implementation loading of game modes Change-Id: I0d92ed433577f3f7ec265eab4af8d328675b7d9b Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -6,11 +6,6 @@
|
||||
android:key="roll_again"
|
||||
android:summary="@string/roll_again_summary"
|
||||
android:title="@string/roll_again" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="roll_mod"
|
||||
android:summary="@string/roll_mod_msg"
|
||||
android:title="@string/roll_mod" />
|
||||
|
||||
<com.TwentyCode.android.ExaltedDice.ColorDialogPreference
|
||||
android:key="color"
|
||||
@@ -20,10 +15,6 @@
|
||||
<PreferenceCategory android:title="@string/successes" >
|
||||
</PreferenceCategory>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="calc_successes"
|
||||
android:title="@string/calc_successes" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:dependency="calc_successes"
|
||||
|
||||
@@ -60,6 +60,9 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
private com.TwentyCode.android.ExaltedDice.NumberPicker mCompatNumberPicker;
|
||||
private com.TwentyCode.android.ExaltedDice.NumberPicker mCompatModPicker;
|
||||
private boolean isCompat = false;
|
||||
private boolean isSuccessesEanbled = false;
|
||||
private boolean isRollModEnabled = true;
|
||||
private boolean isCalculatingTotal = true;
|
||||
|
||||
/**
|
||||
* Applies the presets from the provided roll
|
||||
@@ -188,16 +191,12 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
initCompatPickers();
|
||||
|
||||
Intent i = this.getIntent();
|
||||
if(i != null){
|
||||
if(i != null)
|
||||
if(i.hasExtra(KEY_GAME_NAME)){
|
||||
mGameName = i.getStringExtra(KEY_GAME_NAME);
|
||||
mGameId = i.getLongExtra(KEY_GAME_ID, -1);
|
||||
this.setTitle(mGameName);
|
||||
}
|
||||
if(i.hasExtra(KEY_GAME_MODE)){
|
||||
setGameMode(i.getStringExtra(KEY_GAME_MODE));
|
||||
}
|
||||
}
|
||||
|
||||
mListView = (ListView) findViewById(R.id.list);
|
||||
mListView.setOnItemClickListener(this);
|
||||
@@ -335,20 +334,9 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
refresh();
|
||||
applyRollPresets(mDb.getGameRollCount(mGameId));
|
||||
|
||||
if(mSettings.getBoolean(Settings.KEY_ROLL_MOD, true)){
|
||||
if(isCompat)
|
||||
mCompatModPicker.setVisibility(View.VISIBLE);
|
||||
else
|
||||
mModPicker.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if(isCompat){
|
||||
mCompatModPicker.setVisibility(View.GONE);
|
||||
mCompatModPicker.setValue(parseMod("+0"));
|
||||
} else {
|
||||
mModPicker.setVisibility(View.GONE);
|
||||
mModPicker.setValue(parseMod("+0"));
|
||||
}
|
||||
}
|
||||
Intent i = getIntent();
|
||||
if(i.hasExtra(KEY_GAME_MODE))
|
||||
setGameMode(i.getStringExtra(KEY_GAME_MODE));
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@@ -429,12 +417,20 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
* EXALTED
|
||||
*/
|
||||
if(mode.equals(getString(R.string.game_mode_exalted))){
|
||||
/*
|
||||
* TODO
|
||||
* + set die to d10
|
||||
* + enable successes
|
||||
* + remove roll modifier
|
||||
*/
|
||||
isSuccessesEanbled = true;
|
||||
isRollModEnabled = false;
|
||||
isCalculatingTotal = false;
|
||||
mListAdapter.setRollModEnabled(false);
|
||||
|
||||
if(isCompat){
|
||||
mCompatModPicker.setVisibility(View.GONE);
|
||||
mCompatDPicker.setCurrent(parseD("D10"));
|
||||
mCompatDPicker.setEnabled(false);
|
||||
} else {
|
||||
mModPicker.setVisibility(View.GONE);
|
||||
mDPicker.setValue(parseD("D10"));
|
||||
mDPicker.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -443,7 +439,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
else if(mode.equals(getString(R.string.game_mode_dd))){
|
||||
/*
|
||||
* TODO
|
||||
* + disable successes
|
||||
* nothing
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -502,15 +498,16 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
total = total + item;
|
||||
}
|
||||
|
||||
if(isCalculatingTotal)
|
||||
resultsString.append(getString(R.string.total)+ total);
|
||||
|
||||
if(mSettings.getBoolean(Settings.KEY_ROLL_MOD, true))
|
||||
if(isRollModEnabled)
|
||||
if(isCompat)
|
||||
resultsString.append(getString(R.string.total_plus_mod)+ (total + Integer.parseInt(mCompatModPicker.getValue().replace("+", ""))));
|
||||
else
|
||||
resultsString.append(getString(R.string.total_plus_mod)+ (total + Integer.parseInt(mModValues[mModPicker.getValue()].replace("+", ""))));
|
||||
|
||||
if(mSettings.getBoolean(Settings.KEY_CALC_SUCCESSES, true))
|
||||
if(isSuccessesEanbled)
|
||||
resultsString.append(getString(R.string.sucesses)+ successes(roll));
|
||||
|
||||
rolled.put(Database.KEY_LOG, resultsString.toString());
|
||||
@@ -546,11 +543,13 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
roll.put(Database.KEY_D_TYPE, mCompatDPicker.getValue());
|
||||
roll.put(Database.KEY_NUMBER, mCompatNumberPicker.getCurrent());
|
||||
roll.putAll(results(mCompatNumberPicker.getCurrent()));
|
||||
if(isRollModEnabled)
|
||||
roll.put(Database.KEY_MOD, DatabaseUtils.sqlEscapeString(mCompatModPicker.getValue()));
|
||||
} else{
|
||||
roll.put(Database.KEY_D_TYPE, mDiceValues[mDPicker.getValue()]);
|
||||
roll.put(Database.KEY_NUMBER, mNumberPicker.getValue());
|
||||
roll.putAll(results(mNumberPicker.getValue()));
|
||||
if(isRollModEnabled)
|
||||
roll.put(Database.KEY_MOD, DatabaseUtils.sqlEscapeString(mModValues[mModPicker.getValue()]));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.Menu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -105,7 +105,10 @@ public class GameListActivity extends Activity implements OnClickListener, Datab
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
startActivity(new Intent(this, ExaltedDice.class).putExtra(ExaltedDice.KEY_GAME_NAME, mDb.getGameName(id +1)).putExtra(ExaltedDice.KEY_GAME_ID, id+1));
|
||||
startActivity(new Intent(this, ExaltedDice.class)
|
||||
.putExtra(ExaltedDice.KEY_GAME_NAME, mDb.getGameName(id +1))
|
||||
.putExtra(ExaltedDice.KEY_GAME_ID, id+1)
|
||||
.putExtra(ExaltedDice.KEY_GAME_MODE, mDb.getGameOptions(id+1).getAsString(Database.KEY_MODE)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ public class RollHistoryDatabaseAdapter extends BaseAdapter {
|
||||
private LayoutInflater mInflater;
|
||||
private int mCount;
|
||||
private SharedPreferences mSettings;
|
||||
private boolean isRollModEnabled = true;
|
||||
|
||||
/**
|
||||
* Creates a new RollHistoryDatabaseAdapter
|
||||
@@ -92,7 +93,11 @@ public class RollHistoryDatabaseAdapter extends BaseAdapter {
|
||||
}
|
||||
ContentValues roll = getItem(position);
|
||||
|
||||
holder.mRoll.setText("Rolled: "+roll.getAsInteger(Database.KEY_NUMBER) + " "+roll.getAsString(Database.KEY_D_TYPE) +" "+ roll.getAsString(Database.KEY_MOD).replace("'", ""));
|
||||
holder.mRoll.setText("Rolled: "+roll.getAsInteger(Database.KEY_NUMBER) + " "+roll.getAsString(Database.KEY_D_TYPE));
|
||||
|
||||
if(isRollModEnabled)
|
||||
holder.mRoll.append(" "+ roll.getAsString(Database.KEY_MOD).replace("'", ""));
|
||||
|
||||
holder.mStats.setText(roll.getAsString(Database.KEY_LOG));
|
||||
holder.mRolled.setText(roll.getAsString(Database.KEY_ROLLED));
|
||||
|
||||
@@ -129,4 +134,13 @@ public class RollHistoryDatabaseAdapter extends BaseAdapter {
|
||||
TextView mRolled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled state for displaying the roll mod
|
||||
* @param isEnabled
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void setRollModEnabled(boolean isEnabled) {
|
||||
isRollModEnabled = isEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,9 +31,7 @@ public class Settings extends PreferenceActivity implements OnPreferenceClickLis
|
||||
private static final CharSequence EMAIL = "email";
|
||||
|
||||
public static final String KEY_ROLL_AGAIN = "roll_again";
|
||||
public static final String KEY_CALC_SUCCESSES = "calc_successes";
|
||||
public static final String KEY_TENS_COUNT_TWICE = "tens_count_twice";
|
||||
public static final String KEY_ROLL_MOD = "roll_mod";
|
||||
public static final String KEY_COLOR = "color";
|
||||
// public static final String KEY_ = "";
|
||||
// public static final String KEY_ = "";
|
||||
|
||||
Reference in New Issue
Block a user