mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
replace robot smart checkbox with a spinner having three settings.
Keep the kludge whereby the settings in all the players are kept the same.
This commit is contained in:
parent
d2ddc5cee7
commit
9ebbbb0fec
6 changed files with 67 additions and 19 deletions
|
@ -199,11 +199,13 @@
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<CheckBox android:id="@+id/smart_robot"
|
<Spinner android:id="@+id/smart_robot"
|
||||||
android:layout_width="fill_parent"
|
android:prompt="@string/robot_spinner_prompt"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:text="@string/smart_robot"
|
android:layout_height="wrap_content"
|
||||||
/>
|
android:drawSelectorOnTop="true"
|
||||||
|
android:entries="@array/robot_levels"
|
||||||
|
/>
|
||||||
|
|
||||||
<Spinner android:id="@+id/phonies_spinner"
|
<Spinner android:id="@+id/phonies_spinner"
|
||||||
android:prompt="@string/phonies_spinner_prompt"
|
android:prompt="@string/phonies_spinner_prompt"
|
||||||
|
|
|
@ -73,6 +73,12 @@
|
||||||
<item>@string/phonies_disallow</item>
|
<item>@string/phonies_disallow</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="robot_levels">
|
||||||
|
<item>@string/robot_smartest</item>
|
||||||
|
<item>@string/robot_smarter</item>
|
||||||
|
<item>@string/robot_smart</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string-array name="connect_frequencies">
|
<string-array name="connect_frequencies">
|
||||||
<item>@string/connect_thirty_seconds</item>
|
<item>@string/connect_thirty_seconds</item>
|
||||||
<item>@string/connect_five_mins</item>
|
<item>@string/connect_five_mins</item>
|
||||||
|
|
|
@ -177,8 +177,6 @@
|
||||||
<string name="settings_label">Other settings</string>
|
<string name="settings_label">Other settings</string>
|
||||||
<string name="minutes_label">Minutes per player</string>
|
<string name="minutes_label">Minutes per player</string>
|
||||||
|
|
||||||
<string name="smart_robot">Smart robot</string>
|
|
||||||
|
|
||||||
<string name="download_dicts">Download more...</string>
|
<string name="download_dicts">Download more...</string>
|
||||||
|
|
||||||
<string name="confirm_save_title">Confirm save</string>
|
<string name="confirm_save_title">Confirm save</string>
|
||||||
|
@ -230,6 +228,11 @@
|
||||||
<string name="phonies_ignore">Ignore phonies</string>
|
<string name="phonies_ignore">Ignore phonies</string>
|
||||||
<string name="phonies_warn">Warn if phonies</string>
|
<string name="phonies_warn">Warn if phonies</string>
|
||||||
<string name="phonies_disallow">Disallow phonies</string>
|
<string name="phonies_disallow">Disallow phonies</string>
|
||||||
|
<string name="robot_spinner_prompt">How smart is the robot player?</string>
|
||||||
|
<string name="robot_smart">Smart robot</string>
|
||||||
|
<string name="robot_smarter">Smarter robot</string>
|
||||||
|
<string name="robot_smartest">Smartest robot</string>
|
||||||
|
|
||||||
<string name="menu_prefs">Settings</string>
|
<string name="menu_prefs">Settings</string>
|
||||||
<string name="gamel_menu_dicts">Dictionaries</string>
|
<string name="gamel_menu_dicts">Dictionaries</string>
|
||||||
<string name="menu_revert_all">Restore all</string>
|
<string name="menu_revert_all">Restore all</string>
|
||||||
|
@ -257,7 +260,8 @@
|
||||||
|
|
||||||
<string name="default_dict">Game dictionary</string>
|
<string name="default_dict">Game dictionary</string>
|
||||||
<string name="default_phonies">Handle phonies</string>
|
<string name="default_phonies">Handle phonies</string>
|
||||||
<string name="phonies_spinner_prompt">Handle phonies (words not in dictionary)</string>
|
<string name="phonies_spinner_prompt">How to handle \"phonies\"
|
||||||
|
(words not in dictionary)</string>
|
||||||
<string name="board_size">Board size</string>
|
<string name="board_size">Board size</string>
|
||||||
<string name="default_timerenabled">Use game timer</string>
|
<string name="default_timerenabled">Use game timer</string>
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@ public class GameConfig extends XWActivity
|
||||||
// private Spinner m_connectSpinner;
|
// private Spinner m_connectSpinner;
|
||||||
private Spinner m_phoniesSpinner;
|
private Spinner m_phoniesSpinner;
|
||||||
private Spinner m_dictSpinner;
|
private Spinner m_dictSpinner;
|
||||||
|
private Spinner m_smartnessSpinner;
|
||||||
private String[] m_dictItems;
|
private String[] m_dictItems;
|
||||||
private String[] m_dicts;
|
private String[] m_dicts;
|
||||||
private int m_browsePosition;
|
private int m_browsePosition;
|
||||||
|
@ -443,6 +444,9 @@ public class GameConfig extends XWActivity
|
||||||
m_phoniesSpinner = (Spinner)findViewById( R.id.phonies_spinner );
|
m_phoniesSpinner = (Spinner)findViewById( R.id.phonies_spinner );
|
||||||
m_phoniesSpinner.setSelection( m_gi.phoniesAction.ordinal() );
|
m_phoniesSpinner.setSelection( m_gi.phoniesAction.ordinal() );
|
||||||
|
|
||||||
|
m_smartnessSpinner = (Spinner)findViewById( R.id.smart_robot );
|
||||||
|
setSmartnessSpinner();
|
||||||
|
|
||||||
Utils.setChecked( this, R.id.hints_allowed, !m_gi.hintsNotAllowed );
|
Utils.setChecked( this, R.id.hints_allowed, !m_gi.hintsNotAllowed );
|
||||||
Utils.setInt( this, R.id.timer_minutes_edit,
|
Utils.setInt( this, R.id.timer_minutes_edit,
|
||||||
m_gi.gameSeconds/60/m_gi.nPlayers );
|
m_gi.gameSeconds/60/m_gi.nPlayers );
|
||||||
|
@ -459,8 +463,6 @@ public class GameConfig extends XWActivity
|
||||||
check.setOnCheckedChangeListener( lstnr );
|
check.setOnCheckedChangeListener( lstnr );
|
||||||
Utils.setChecked( this, R.id.use_timer, m_gi.timerEnabled );
|
Utils.setChecked( this, R.id.use_timer, m_gi.timerEnabled );
|
||||||
|
|
||||||
Utils.setChecked( this, R.id.smart_robot, m_gi.getRobotsAreSmart() );
|
|
||||||
|
|
||||||
String fmt = getString( m_notNetworkedGame ?
|
String fmt = getString( m_notNetworkedGame ?
|
||||||
R.string.title_game_configf
|
R.string.title_game_configf
|
||||||
: R.string.title_gamenet_configf );
|
: R.string.title_gamenet_configf );
|
||||||
|
@ -665,6 +667,28 @@ public class GameConfig extends XWActivity
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setSmartnessSpinner()
|
||||||
|
{
|
||||||
|
int setting = -1;
|
||||||
|
switch ( m_gi.getRobotSmartness() ) {
|
||||||
|
case 1:
|
||||||
|
setting = 0;
|
||||||
|
break;
|
||||||
|
case 50:
|
||||||
|
setting = 1;
|
||||||
|
break;
|
||||||
|
case 99:
|
||||||
|
case 100:
|
||||||
|
setting = 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Utils.logf( "setSmartnessSpinner got %d from getRobotSmartness()",
|
||||||
|
m_gi.getRobotSmartness() );
|
||||||
|
Assert.fail();
|
||||||
|
}
|
||||||
|
m_smartnessSpinner.setSelection( setting );
|
||||||
|
}
|
||||||
|
|
||||||
// private void configConnectSpinner()
|
// private void configConnectSpinner()
|
||||||
// {
|
// {
|
||||||
// m_connectSpinner = (Spinner)findViewById( R.id.connect_spinner );
|
// m_connectSpinner = (Spinner)findViewById( R.id.connect_spinner );
|
||||||
|
@ -831,11 +855,13 @@ public class GameConfig extends XWActivity
|
||||||
m_gi.timerEnabled = Utils.getChecked( this, R.id.use_timer );
|
m_gi.timerEnabled = Utils.getChecked( this, R.id.use_timer );
|
||||||
m_gi.gameSeconds = 60 * m_gi.nPlayers *
|
m_gi.gameSeconds = 60 * m_gi.nPlayers *
|
||||||
Utils.getInt( this, R.id.timer_minutes_edit );
|
Utils.getInt( this, R.id.timer_minutes_edit );
|
||||||
m_gi.setRobotsAreSmart( Utils.getChecked( this, R.id.smart_robot ) );
|
|
||||||
|
|
||||||
int position = m_phoniesSpinner.getSelectedItemPosition();
|
int position = m_phoniesSpinner.getSelectedItemPosition();
|
||||||
m_gi.phoniesAction = CurGameInfo.XWPhoniesChoice.values()[position];
|
m_gi.phoniesAction = CurGameInfo.XWPhoniesChoice.values()[position];
|
||||||
|
|
||||||
|
position = m_smartnessSpinner.getSelectedItemPosition();
|
||||||
|
m_gi.setRobotSmartness(position * 49 + 1);
|
||||||
|
|
||||||
if ( !m_notNetworkedGame ) {
|
if ( !m_notNetworkedGame ) {
|
||||||
m_car.ip_relay_seeksPublicRoom = m_joinPublicCheck.isChecked();
|
m_car.ip_relay_seeksPublicRoom = m_joinPublicCheck.isChecked();
|
||||||
Utils.logf( "ip_relay_seeksPublicRoom: %s",
|
Utils.logf( "ip_relay_seeksPublicRoom: %s",
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class CurGameInfo {
|
||||||
// private int[] m_visiblePlayers;
|
// private int[] m_visiblePlayers;
|
||||||
// private int m_nVisiblePlayers;
|
// private int m_nVisiblePlayers;
|
||||||
private boolean m_inProgress;
|
private boolean m_inProgress;
|
||||||
private boolean m_smart;
|
private int m_smartness;
|
||||||
|
|
||||||
public CurGameInfo( Context context )
|
public CurGameInfo( Context context )
|
||||||
{
|
{
|
||||||
|
@ -79,6 +79,7 @@ public class CurGameInfo {
|
||||||
timerEnabled = CommonPrefs.getDefaultTimerEnabled( context );
|
timerEnabled = CommonPrefs.getDefaultTimerEnabled( context );
|
||||||
allowPickTiles = false;
|
allowPickTiles = false;
|
||||||
allowHintRect = false;
|
allowHintRect = false;
|
||||||
|
m_smartness = 0; // needs to be set from players
|
||||||
|
|
||||||
// Always create MAX_NUM_PLAYERS so jni code doesn't ever have
|
// Always create MAX_NUM_PLAYERS so jni code doesn't ever have
|
||||||
// to cons up a LocalPlayer instance.
|
// to cons up a LocalPlayer instance.
|
||||||
|
@ -89,7 +90,7 @@ public class CurGameInfo {
|
||||||
if ( isNetworked ) {
|
if ( isNetworked ) {
|
||||||
players[1].isLocal = false;
|
players[1].isLocal = false;
|
||||||
} else {
|
} else {
|
||||||
players[0].setIsRobot( 1 );
|
players[0].setRobotSmartness( 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,17 +132,26 @@ public class CurGameInfo {
|
||||||
m_inProgress = inProgress;
|
m_inProgress = inProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getRobotsAreSmart()
|
public int getRobotSmartness()
|
||||||
{
|
{
|
||||||
return m_smart;
|
if ( m_smartness == 0 ) {
|
||||||
|
m_smartness = 1; // default if no robots
|
||||||
|
for ( int ii = 0; ii < nPlayers; ++ii ) {
|
||||||
|
if ( players[ii].isRobot() ) {
|
||||||
|
m_smartness = players[ii].robotIQ;
|
||||||
|
break; // should all be the same
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m_smartness;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRobotsAreSmart( boolean smart )
|
public void setRobotSmartness( int smartness )
|
||||||
{
|
{
|
||||||
m_smart = smart;
|
m_smartness = smartness;
|
||||||
for ( int ii = 0; ii < nPlayers; ++ii ) {
|
for ( int ii = 0; ii < nPlayers; ++ii ) {
|
||||||
if ( players[ii].isRobot() ) {
|
if ( players[ii].isRobot() ) {
|
||||||
players[ii].setIsRobot( smart ? 1 : 100 );
|
players[ii].robotIQ = smartness;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class LocalPlayer {
|
||||||
robotIQ = isRobot ? 1 : 0;
|
robotIQ = isRobot ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsRobot( int iq )
|
public void setRobotSmartness( int iq )
|
||||||
{
|
{
|
||||||
Assert.assertTrue( iq > 0 );
|
Assert.assertTrue( iq > 0 );
|
||||||
robotIQ = iq;
|
robotIQ = iq;
|
||||||
|
|
Loading…
Add table
Reference in a new issue