diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 984f35921..04f4626aa 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -562,6 +562,11 @@ This game is missing %1$d remote player[s]. Would you like to invite someone to join -- assuming you haven\'t already? + + \u0020(You are expecting multiple + remote players. Be sure to address your invitation to + that many people.) + Let\'s play Crosswords Tap on this link to start a game: %1$s . diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index 1b469de19..29aab2c5e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -270,7 +270,8 @@ public class BoardActivity extends XWActivity int item ) { GameUtils.launchInviteActivity( BoardActivity.this, m_room, - m_gi.dictLang ); + m_gi.dictLang, + m_gi.nPlayers ); } }; dialog = new AlertDialog.Builder( this ) @@ -296,7 +297,11 @@ public class BoardActivity extends XWActivity case DLG_INVITE: AlertDialog ad = (AlertDialog)dialog; String format = getString( R.string.invite_msgf ); - ad.setMessage( String.format( format, m_missing) ); + String message = String.format( format, m_missing ); + if ( m_missing > 1 ) { + message += getString( R.string.invite_multiple ); + } + ad.setMessage( message ); break; default: super.onPrepareDialog( id, dialog ); @@ -706,7 +711,7 @@ public class BoardActivity extends XWActivity // Let's only invite for two-person games for now. Simple // case first.... - if ( nMissing == 1 /* && is_2_person_game() */ && !m_haveInvited ) { + if ( !m_haveInvited ) { m_haveInvited = true; m_room = room; m_missing = nMissing; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index af7bdabb6..34eb8f642 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -356,7 +356,8 @@ public class GameUtils { } public static String makeNewNetGame( Context context, String room, - int[] lang, int nPlayers ) + int[] lang, int nPlayersT, + int nPlayersH ) { CommsAddrRec addr = new CommsAddrRec( context ); addr.ip_relay_invite = room; @@ -364,10 +365,11 @@ public class GameUtils { CurGameInfo gi = new CurGameInfo( context, true ); gi.setLang( lang[0] ); lang[0] = gi.dictLang; + gi.setNPlayers( nPlayersT, nPlayersH ); gi.juggle(); // Will need to add a setNPlayers() method to gi to make this // work - Assert.assertTrue( gi.nPlayers == nPlayers ); + Assert.assertTrue( gi.nPlayers == nPlayersT ); String path = saveNew( context, gi ); GameLock lock = new GameLock( path, true ).lock(); @@ -381,20 +383,21 @@ public class GameUtils { int lang, int nPlayers ) { int[] langarr = { lang }; - return makeNewNetGame( context, room, langarr, nPlayers ); + return makeNewNetGame( context, room, langarr, nPlayers, 1 ); } public static String makeNewNetGame( Context context, NetLaunchInfo info ) { - return makeNewNetGame( context, info.room, info.lang, info.nPlayers ); + return makeNewNetGame( context, info.room, info.lang, + info.nPlayers ); } public static void launchInviteActivity( Context context, String room, - int lang ) + int lang, int nPlayers ) { Random random = new Random(); Uri gameUri = NetLaunchInfo.makeLaunchUri( context, room, - lang, 2 ); + lang, nPlayers ); if ( null != gameUri ) { Intent intent = new Intent( Intent.ACTION_SEND ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java index 68f68b5a8..9fa44390b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java @@ -57,7 +57,8 @@ public class NetLaunchInfo { room = data.getQueryParameter( "room" ); String langStr = data.getQueryParameter( "lang" ); lang = Integer.decode( langStr ); - nPlayers = 2; // Should this be a param? + String np = data.getQueryParameter( "np" ); + nPlayers = Integer.decode( np ); m_valid = true; } catch ( Exception e ) { Utils.logf( "unable to parse \"%s\"", data.toString() ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java index bec39eca3..0b7b1a8b9 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java @@ -91,11 +91,12 @@ public class NewGameActivity extends XWActivity { String room = null; String path; int[] lang = {0}; + final int nPlayers = 2; // hard-coded for no-configure case if ( networked ) { Random random = new Random(); room = String.format( "%X", random.nextInt() ).substring( 0, 4 ); - path = GameUtils.makeNewNetGame( this, room, lang, 2 ); + path = GameUtils.makeNewNetGame( this, room, lang, nPlayers, 1 ); } else { path = GameUtils.saveNew( this, new CurGameInfo( this ) ); } @@ -103,7 +104,7 @@ public class NewGameActivity extends XWActivity { if ( launch ) { GameUtils.launchGame( this, path, networked ); if ( networked ) { - GameUtils.launchInviteActivity( this, room, lang[0] ); + GameUtils.launchInviteActivity( this, room, lang[0], nPlayers ); } } else { GameUtils.doConfig( this, path, GameConfig.class ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java index dd111409d..368cea03e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java @@ -310,6 +310,19 @@ public class CurGameInfo { return added; } + public void setNPlayers( int nPlayersTotal, int nPlayersHere ) + { + assert( nPlayersTotal < MAX_NUM_PLAYERS ); + assert( nPlayersHere < nPlayersTotal ); + + nPlayers = nPlayersTotal; + + for ( int ii = 0; ii < nPlayersTotal; ++ii ) { + players[ii].isLocal = ii < nPlayersHere; + assert( !players[ii].isRobot() ); + } + } + public void setFirstLocalName( String name ) { for ( int ii = 0; ii < nPlayers; ++ii ) { if ( players[ii].isLocal ) { diff --git a/xwords4/android/scripts/redir.php b/xwords4/android/scripts/redir.php index 4179c9510..05a6c401d 100644 --- a/xwords4/android/scripts/redir.php +++ b/xwords4/android/scripts/redir.php @@ -8,6 +8,7 @@ $scheme = "newxwgame"; $host = "10.0.2.2"; $lang = $_REQUEST["lang"]; $room = $_REQUEST["room"]; +$np = $_REQUEST["np"]; print << Crosswords SMS redirect + content="0;url=$scheme://$host?room=$room&lang=$lang&np=$np"> redirecting to Crosswords....
redirecting to Crosswords....