diff --git a/xwords4/common/comtypes.h b/xwords4/common/comtypes.h index 5b07b7220..e4cfe0b30 100644 --- a/xwords4/common/comtypes.h +++ b/xwords4/common/comtypes.h @@ -237,7 +237,9 @@ typedef struct CommonPrefs { #ifdef XWFEATURE_CROSSHAIRS XP_Bool hideCrosshairs; /* applies to all games */ #endif +#ifdef XWFEATURE_ROBOTPHONIES XP_U16 makePhonyPct; +#endif } CommonPrefs; typedef struct _PlayerDicts { diff --git a/xwords4/common/model.c b/xwords4/common/model.c index 958c52b70..55881394f 100644 --- a/xwords4/common/model.c +++ b/xwords4/common/model.c @@ -1255,8 +1255,10 @@ juggleMoveIfDebug( MoveInfo* move ) } } } +#endif /* Reverse the *letters on* the tiles */ +#ifdef XWFEATURE_ROBOTPHONIES void reverseTiles( MoveInfo* move ) { diff --git a/xwords4/common/server.c b/xwords4/common/server.c index b2f3a6062..32da190b2 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -106,7 +106,9 @@ typedef struct ServerNonvolatiles { XP_U16 robotThinkMin, robotThinkMax; /* not saved (yet) */ XP_U16 robotTradePct; #endif +#ifdef XWFEATURE_ROBOTPHONIES XP_U16 makePhonyPct; +#endif RemoteAddress addresses[MAX_NUM_PLAYERS]; XWStreamCtxt* prevMoveStream; /* save it to print later */ @@ -625,7 +627,9 @@ server_prefsChanged( ServerCtxt* server, const CommonPrefs* cp ) server->nv.robotThinkMax = cp->robotThinkMax; server->nv.robotTradePct = cp->robotTradePct; #endif +#ifdef XWFEATURE_ROBOTPHONIES server->nv.makePhonyPct = cp->makePhonyPct; +#endif } /* server_prefsChanged */ XP_S16 @@ -1370,7 +1374,7 @@ makeRobotMove( ServerCtxt* server ) /* if canMove is false, this is a fake move, a pass */ if ( canMove || NPASSES_OK(server) ) { -#ifdef DEBUG +#ifdef XWFEATURE_ROBOTPHONIES if ( server->nv.makePhonyPct > XP_RANDOM() % 100 ) { reverseTiles( &newMove ); } diff --git a/xwords4/linux/Makefile b/xwords4/linux/Makefile index 0c7487e4f..9330bc0a8 100644 --- a/xwords4/linux/Makefile +++ b/xwords4/linux/Makefile @@ -161,7 +161,7 @@ DEFINES += -DXWFEATURE_SMS -DXWFEATURE_BASE64 DEFINES += -DXWFEATURE_DIRECTIP # Robot can be made to think, to simulate for relay mostly -DEFINES += -DXWFEATURE_SLOW_ROBOT +DEFINES += -DXWFEATURE_SLOW_ROBOT -DXWFEATURE_ROBOTPHONIES DEFINES += -DXWFEATURE_DEVICE diff --git a/xwords4/linux/cursesboard.c b/xwords4/linux/cursesboard.c index d306d9260..496236c24 100644 --- a/xwords4/linux/cursesboard.c +++ b/xwords4/linux/cursesboard.c @@ -591,7 +591,9 @@ initNoDraw( CursesBoardState* cbState, sqlite3_int64 rowid, cGlobals->cp.robotThinkMax = params->robotThinkMax; cGlobals->cp.robotTradePct = params->robotTradePct; #endif +#ifdef XWFEATURE_ROBOTPHONIES cGlobals->cp.makePhonyPct = params->makePhonyPct; +#endif if ( linuxOpenGame( cGlobals, &result->procs, returnAddr ) ) { result = ref( result ); diff --git a/xwords4/linux/gtkboard.c b/xwords4/linux/gtkboard.c index aadedff35..b0ee10fab 100644 --- a/xwords4/linux/gtkboard.c +++ b/xwords4/linux/gtkboard.c @@ -2372,7 +2372,9 @@ initGlobalsNoDraw( GtkGameGlobals* globals, LaunchParams* params, cGlobals->cp.robotThinkMax = params->robotThinkMax; cGlobals->cp.robotTradePct = params->robotTradePct; #endif +#ifdef XWFEATURE_ROBOTPHONIES cGlobals->cp.makePhonyPct = params->makePhonyPct; +#endif #ifdef XWFEATURE_CROSSHAIRS cGlobals->cp.hideCrosshairs = params->hideCrosshairs; #endif diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 187391eed..7efa0b494 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -897,7 +897,9 @@ typedef enum { ,CMD_SLOWROBOT ,CMD_TRADEPCT #endif +#ifdef XWFEATURE_ROBOTPHONIES ,CMD_MAKE_PHONY_PCT +#endif #ifdef USE_GLIBLOOP /* just because hard to implement otherwise */ ,CMD_UNDOPCT #endif @@ -1035,8 +1037,10 @@ static CmdInfoRec CmdInfoRecs[] = { ,{ CMD_SLOWROBOT, true, "slow-robot", "make robot slower to test network" } ,{ CMD_TRADEPCT, true, "trade-pct", "what pct of the time should robot trade" } #endif +#ifdef XWFEATURE_ROBOTPHONIES ,{ CMD_MAKE_PHONY_PCT, true, "make-phony-pct", "what pct of the time should robot play a bad word" } +#endif #ifdef USE_GLIBLOOP ,{ CMD_UNDOPCT, true, "undo-pct", "each second, what are the odds of doing an undo" } @@ -2964,7 +2968,8 @@ main( int argc, char** argv ) usage(argv[0], "must be 0 <= n <= 100" ); } break; - +#endif +#ifdef XWFEATURE_ROBOTPHONIES case CMD_MAKE_PHONY_PCT: mainParams.makePhonyPct = atoi( optarg ); if ( mainParams.makePhonyPct < 0 || mainParams.makePhonyPct > 100 ) { diff --git a/xwords4/linux/main.h b/xwords4/linux/main.h index a96642b53..27fabcc67 100644 --- a/xwords4/linux/main.h +++ b/xwords4/linux/main.h @@ -129,7 +129,9 @@ typedef struct LaunchParams { XP_U16 robotThinkMin, robotThinkMax; XP_U16 robotTradePct; #endif +#ifdef XWFEATURE_ROBOTPHONIES XP_U16 makePhonyPct; +#endif XP_Bool commsDisableds[COMMS_CONN_NTYPES][2]; DeviceRole serverRole;