"We'll add it when we need it" was what was said before, and now the

default non-fucking-obtuse dictionary has been replaced by a scrabble
dictionary that contains fucked-up wordfreak words.
You know, if you're playing a normal game "abys" is wrong, and "abyss"
is right.

So I at least added the parameter for selecting a dictionary.
Implementation pending.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@492 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Ray Greenwell
2007-11-12 20:09:41 +00:00
parent 679a5f1cfc
commit 1efafd649a
10 changed files with 77 additions and 48 deletions
+10 -4
View File
@@ -411,30 +411,36 @@ public class EZGameControl extends BaseControl
* separate message with the specified key, as an array of strings. * separate message with the specified key, as an array of strings.
* *
* @param locale RFC 3066 string that represents language settings * @param locale RFC 3066 string that represents language settings
* @param dictionary the dictionary to use, or null for the default.
* TODO: document possible parameters.
* @param count the number of letters to be produced * @param count the number of letters to be produced
* @param callback the function that will process the results, of the form: * @param callback the function that will process the results, of the form:
* <pre>function (letters :Array) :void</pre> * <pre>function (letters :Array) :void</pre>
* where letters is an array of strings containing letters for the given language settings * where letters is an array of strings containing letters for the given language settings
* (potentially empty). * (potentially empty).
*/ */
public function getDictionaryLetterSet (locale :String, count :int, callback :Function) :void public function getDictionaryLetterSet (
locale :String, dictionary :String, count :int, callback :Function) :void
{ {
callEZCode("getDictionaryLetterSet_v1", locale, count, callback); callEZCode("getDictionaryLetterSet_v2", locale, dictionary, count, callback);
} }
/** /**
* Checks to see if the dictionary for the given locale contains the given word. * Checks to see if the dictionary for the given locale contains the given word.
* *
* @param RFC 3066 string that represents language settings * @param RFC 3066 string that represents language settings
* @param dictionary the dictionary to use, or null for the default.
* TODO: document possible parameters.
* @param word the string contains the word to be checked * @param word the string contains the word to be checked
* @param callback the function that will process the results, of the form: * @param callback the function that will process the results, of the form:
* <pre>function (word :String, result :Boolean) :void</pre> * <pre>function (word :String, result :Boolean) :void</pre>
* where word is a copy of the word that was requested, and result specifies whether the word * where word is a copy of the word that was requested, and result specifies whether the word
* is valid given language settings * is valid given language settings
*/ */
public function checkDictionaryWord (locale :String, word :String, callback :Function) :void public function checkDictionaryWord (
locale :String, dictionary :String, word :String, callback :Function) :void
{ {
callEZCode("checkDictionaryWord_v1", locale, word, callback); callEZCode("checkDictionaryWord_v2", locale, dictionary, word, callback);
} }
/** /**
@@ -41,7 +41,7 @@ public interface EZGameService extends InvocationService
function addToCollection (arg1 :Client, arg2 :String, arg3 :TypedArray /* of class [B */, arg4 :Boolean, arg5 :InvocationService_InvocationListener) :void; function addToCollection (arg1 :Client, arg2 :String, arg3 :TypedArray /* of class [B */, arg4 :Boolean, arg5 :InvocationService_InvocationListener) :void;
// from Java interface EZGameService // from Java interface EZGameService
function checkDictionaryWord (arg1 :Client, arg2 :String, arg3 :String, arg4 :InvocationService_ResultListener) :void; function checkDictionaryWord (arg1 :Client, arg2 :String, arg3 :String, arg4 :String, arg5 :InvocationService_ResultListener) :void;
// from Java interface EZGameService // from Java interface EZGameService
function endGame (arg1 :Client, arg2 :TypedArray /* of int */, arg3 :InvocationService_InvocationListener) :void; function endGame (arg1 :Client, arg2 :TypedArray /* of int */, arg3 :InvocationService_InvocationListener) :void;
@@ -56,7 +56,7 @@ public interface EZGameService extends InvocationService
function getCookie (arg1 :Client, arg2 :int, arg3 :InvocationService_InvocationListener) :void; function getCookie (arg1 :Client, arg2 :int, arg3 :InvocationService_InvocationListener) :void;
// from Java interface EZGameService // from Java interface EZGameService
function getDictionaryLetterSet (arg1 :Client, arg2 :String, arg3 :int, arg4 :InvocationService_ResultListener) :void; function getDictionaryLetterSet (arg1 :Client, arg2 :String, arg3 :String, arg4 :int, arg5 :InvocationService_ResultListener) :void;
// from Java interface EZGameService // from Java interface EZGameService
function getFromCollection (arg1 :Client, arg2 :String, arg3 :Boolean, arg4 :int, arg5 :String, arg6 :int, arg7 :InvocationService_ConfirmListener) :void; function getFromCollection (arg1 :Client, arg2 :String, arg3 :Boolean, arg4 :int, arg5 :String, arg6 :int, arg7 :InvocationService_ConfirmListener) :void;
@@ -499,8 +499,8 @@ public class GameControlBackend
o["setUserCookie_v1"] = setUserCookie_v1; o["setUserCookie_v1"] = setUserCookie_v1;
o["isMyTurn_v1"] = isMyTurn_v1; o["isMyTurn_v1"] = isMyTurn_v1;
o["isInPlay_v1"] = isInPlay_v1; o["isInPlay_v1"] = isInPlay_v1;
o["getDictionaryLetterSet_v1"] = getDictionaryLetterSet_v1; o["getDictionaryLetterSet_v2"] = getDictionaryLetterSet_v2;
o["checkDictionaryWord_v1"] = checkDictionaryWord_v1; o["checkDictionaryWord_v2"] = checkDictionaryWord_v2;
o["populateCollection_v1"] = populateCollection_v1; o["populateCollection_v1"] = populateCollection_v1;
o["alterKeyEvents_v1"] = alterKeyEvents_v1; o["alterKeyEvents_v1"] = alterKeyEvents_v1;
o["focusContainer_v1"] = focusContainer_v1; o["focusContainer_v1"] = focusContainer_v1;
@@ -531,6 +531,8 @@ public class GameControlBackend
// compatability // compatability
o["endTurn_v2"] = startNextTurn_v1; // it's the same! o["endTurn_v2"] = startNextTurn_v1; // it's the same!
o["getDictionaryLetterSet_v1"] = getDictionaryLetterSet_v1;
o["checkDictionaryWord_v1"] = checkDictionaryWord_v1;
} }
/** /**
@@ -788,6 +790,12 @@ public class GameControlBackend
protected function getDictionaryLetterSet_v1 ( protected function getDictionaryLetterSet_v1 (
locale :String, count :int, callback :Function) :void locale :String, count :int, callback :Function) :void
{
getDictionaryLetterSet_v2(locale, null, count, callback);
}
protected function getDictionaryLetterSet_v2 (
locale :String, dictionary :String, count :int, callback :Function) :void
{ {
validateConnected(); validateConnected();
var listener :InvocationService_ResultListener; var listener :InvocationService_ResultListener;
@@ -801,17 +809,24 @@ public class GameControlBackend
var r : Array = result.split(","); var r : Array = result.split(",");
callback (r); callback (r);
}; };
listener = new ResultWrapper (failure, success); listener = new ResultWrapper(failure, success);
} else { } else {
listener = createLoggingResultListener ("checkDictionaryWord"); listener = createLoggingResultListener("checkDictionaryWord");
} }
// just relay the data over to the server // just relay the data over to the server
_ezObj.ezGameService.getDictionaryLetterSet(_ctx.getClient(), locale, count, listener); _ezObj.ezGameService.getDictionaryLetterSet(
_ctx.getClient(), locale, dictionary, count, listener);
} }
protected function checkDictionaryWord_v1 ( protected function checkDictionaryWord_v1 (
locale :String, word :String, callback :Function) :void locale :String, word :String, callback :Function) :void
{
checkDictionaryWord_v2(locale, null, word, callback);
}
protected function checkDictionaryWord_v2 (
locale :String, dictionary :String, word :String, callback :Function) :void
{ {
validateConnected(); validateConnected();
var listener :InvocationService_ResultListener; var listener :InvocationService_ResultListener;
@@ -825,14 +840,14 @@ public class GameControlBackend
var r : Boolean = Boolean(result); var r : Boolean = Boolean(result);
callback (word, r); callback (word, r);
}; };
listener = new ResultWrapper (failure, success); listener = new ResultWrapper(failure, success);
} else { } else {
listener = createLoggingResultListener ("checkDictionaryWord"); listener = createLoggingResultListener("checkDictionaryWord");
} }
// just relay the data over to the server // just relay the data over to the server
_ezObj.ezGameService.checkDictionaryWord(_ctx.getClient(), locale, word, listener); _ezObj.ezGameService.checkDictionaryWord(
_ctx.getClient(), locale, dictionary, word, listener);
} }
/** /**
@@ -62,12 +62,12 @@ public class EZGameMarshaller extends InvocationMarshaller
public static const CHECK_DICTIONARY_WORD :int = 2; public static const CHECK_DICTIONARY_WORD :int = 2;
// from interface EZGameService // from interface EZGameService
public function checkDictionaryWord (arg1 :Client, arg2 :String, arg3 :String, arg4 :InvocationService_ResultListener) :void public function checkDictionaryWord (arg1 :Client, arg2 :String, arg3 :String, arg4 :String, arg5 :InvocationService_ResultListener) :void
{ {
var listener4 :InvocationMarshaller_ResultMarshaller = new InvocationMarshaller_ResultMarshaller(); var listener5 :InvocationMarshaller_ResultMarshaller = new InvocationMarshaller_ResultMarshaller();
listener4.listener = arg4; listener5.listener = arg5;
sendRequest(arg1, CHECK_DICTIONARY_WORD, [ sendRequest(arg1, CHECK_DICTIONARY_WORD, [
arg2, arg3, listener4 arg2, arg3, arg4, listener5
]); ]);
} }
@@ -127,12 +127,12 @@ public class EZGameMarshaller extends InvocationMarshaller
public static const GET_DICTIONARY_LETTER_SET :int = 7; public static const GET_DICTIONARY_LETTER_SET :int = 7;
// from interface EZGameService // from interface EZGameService
public function getDictionaryLetterSet (arg1 :Client, arg2 :String, arg3 :int, arg4 :InvocationService_ResultListener) :void public function getDictionaryLetterSet (arg1 :Client, arg2 :String, arg3 :String, arg4 :int, arg5 :InvocationService_ResultListener) :void
{ {
var listener4 :InvocationMarshaller_ResultMarshaller = new InvocationMarshaller_ResultMarshaller(); var listener5 :InvocationMarshaller_ResultMarshaller = new InvocationMarshaller_ResultMarshaller();
listener4.listener = arg4; listener5.listener = arg5;
sendRequest(arg1, GET_DICTIONARY_LETTER_SET, [ sendRequest(arg1, GET_DICTIONARY_LETTER_SET, [
arg2, Integer.valueOf(arg3), listener4 arg2, arg3, Integer.valueOf(arg4), listener5
]); ]);
} }
@@ -78,11 +78,12 @@ public interface EZGameService extends InvocationService
* @param client stores information about the caller * @param client stores information about the caller
* @param locale is an RFC 3066 string specifying language settings, for example, "en" or * @param locale is an RFC 3066 string specifying language settings, for example, "en" or
* "en-us". * "en-us".
* @param dictionary is a String specifier of the dictionary to use, or null for the default.
* @param count is the number of letters to be returned. * @param count is the number of letters to be returned.
* @param listener is the callback function * @param listener is the callback function
*/ */
public void getDictionaryLetterSet ( public void getDictionaryLetterSet (
Client client, String locale, int count, ResultListener listener); Client client, String locale, String dictionary, int count, ResultListener listener);
/** /**
* Ask the dictionary service whether the specified word is valid with the given * Ask the dictionary service whether the specified word is valid with the given
@@ -91,11 +92,12 @@ public interface EZGameService extends InvocationService
* @param client stores information about the caller * @param client stores information about the caller
* @param locale is an RFC 3066 string specifying language settings, for example, "en" or * @param locale is an RFC 3066 string specifying language settings, for example, "en" or
* "en-us". * "en-us".
* @param dictionary is a String specifier of the dictionary to use, or null for the default.
* @param word is the word to be checked against the dictionary. * @param word is the word to be checked against the dictionary.
* @param listener is the callback function * @param listener is the callback function
*/ */
public void checkDictionaryWord ( public void checkDictionaryWord (
Client client, String locale, String word, ResultListener listener); Client client, String locale, String dictionary, String word, ResultListener listener);
/** /**
* Add to the specified named collection. * Add to the specified named collection.
@@ -54,12 +54,12 @@ public class EZGameMarshaller extends InvocationMarshaller
public static final int CHECK_DICTIONARY_WORD = 2; public static final int CHECK_DICTIONARY_WORD = 2;
// from interface EZGameService // from interface EZGameService
public void checkDictionaryWord (Client arg1, String arg2, String arg3, InvocationService.ResultListener arg4) public void checkDictionaryWord (Client arg1, String arg2, String arg3, String arg4, InvocationService.ResultListener arg5)
{ {
InvocationMarshaller.ResultMarshaller listener4 = new InvocationMarshaller.ResultMarshaller(); InvocationMarshaller.ResultMarshaller listener5 = new InvocationMarshaller.ResultMarshaller();
listener4.listener = arg4; listener5.listener = arg5;
sendRequest(arg1, CHECK_DICTIONARY_WORD, new Object[] { sendRequest(arg1, CHECK_DICTIONARY_WORD, new Object[] {
arg2, arg3, listener4 arg2, arg3, arg4, listener5
}); });
} }
@@ -119,12 +119,12 @@ public class EZGameMarshaller extends InvocationMarshaller
public static final int GET_DICTIONARY_LETTER_SET = 7; public static final int GET_DICTIONARY_LETTER_SET = 7;
// from interface EZGameService // from interface EZGameService
public void getDictionaryLetterSet (Client arg1, String arg2, int arg3, InvocationService.ResultListener arg4) public void getDictionaryLetterSet (Client arg1, String arg2, String arg3, int arg4, InvocationService.ResultListener arg5)
{ {
InvocationMarshaller.ResultMarshaller listener4 = new InvocationMarshaller.ResultMarshaller(); InvocationMarshaller.ResultMarshaller listener5 = new InvocationMarshaller.ResultMarshaller();
listener4.listener = arg4; listener5.listener = arg5;
sendRequest(arg1, GET_DICTIONARY_LETTER_SET, new Object[] { sendRequest(arg1, GET_DICTIONARY_LETTER_SET, new Object[] {
arg2, Integer.valueOf(arg3), listener4 arg2, arg3, Integer.valueOf(arg4), listener5
}); });
} }
@@ -91,8 +91,10 @@ public class DictionaryManager
* Retrieves a set of letters from a language definition file, and returns a random sampling of * Retrieves a set of letters from a language definition file, and returns a random sampling of
* /count/ elements. * /count/ elements.
*/ */
public void getLetterSet (final String locale, final int count, // TODO: honor the dictionary parameter
final InvocationService.ResultListener listener) public void getLetterSet (
final String locale, final String dictionary, final int count,
final InvocationService.ResultListener listener)
{ {
CrowdServer.invoker.postUnit(new Invoker.Unit("DictionaryManager.getLetterSet") { CrowdServer.invoker.postUnit(new Invoker.Unit("DictionaryManager.getLetterSet") {
public boolean invoke () { public boolean invoke () {
@@ -117,8 +119,10 @@ public class DictionaryManager
/** /**
* Checks if the specified word exists in the given language * Checks if the specified word exists in the given language
*/ */
public void checkWord (final String locale, final String word, // TODO: honor the dictionary parameter
final InvocationService.ResultListener listener) public void checkWord (
final String locale, final String dictionary, final String word,
final InvocationService.ResultListener listener)
{ {
CrowdServer.invoker.postUnit(new Invoker.Unit("DictionaryManager.checkWord") { CrowdServer.invoker.postUnit(new Invoker.Unit("DictionaryManager.checkWord") {
public boolean invoke () { public boolean invoke () {
@@ -66,7 +66,7 @@ public class EZGameDispatcher extends InvocationDispatcher
case EZGameMarshaller.CHECK_DICTIONARY_WORD: case EZGameMarshaller.CHECK_DICTIONARY_WORD:
((EZGameProvider)provider).checkDictionaryWord( ((EZGameProvider)provider).checkDictionaryWord(
source, source,
(String)args[0], (String)args[1], (InvocationService.ResultListener)args[2] (String)args[0], (String)args[1], (String)args[2], (InvocationService.ResultListener)args[3]
); );
return; return;
@@ -101,7 +101,7 @@ public class EZGameDispatcher extends InvocationDispatcher
case EZGameMarshaller.GET_DICTIONARY_LETTER_SET: case EZGameMarshaller.GET_DICTIONARY_LETTER_SET:
((EZGameProvider)provider).getDictionaryLetterSet( ((EZGameProvider)provider).getDictionaryLetterSet(
source, source,
(String)args[0], ((Integer)args[1]).intValue(), (InvocationService.ResultListener)args[2] (String)args[0], (String)args[1], ((Integer)args[2]).intValue(), (InvocationService.ResultListener)args[3]
); );
return; return;
@@ -221,20 +221,22 @@ public class EZGameManager extends GameManager
} }
// from EZGameProvider // from EZGameProvider
public void getDictionaryLetterSet (ClientObject caller, String locale, int count, public void getDictionaryLetterSet (
InvocationService.ResultListener listener) ClientObject caller, String locale, String dictionary, int count,
InvocationService.ResultListener listener)
throws InvocationException throws InvocationException
{ {
getDictionaryManager().getLetterSet(locale, count, listener); getDictionaryManager().getLetterSet(locale, dictionary, count, listener);
} }
// from EZGameProvider // from EZGameProvider
public void checkDictionaryWord (ClientObject caller, String locale, String word, public void checkDictionaryWord (
InvocationService.ResultListener listener) ClientObject caller, String locale, String dictionary, String word,
InvocationService.ResultListener listener)
throws InvocationException throws InvocationException
{ {
getDictionaryManager().checkWord(locale, word, listener); getDictionaryManager().checkWord(locale, dictionary, word, listener);
} }
/** /**
* Returns the dictionary manager if it has been properly initialized. Throws an INTERNAL_ERROR * Returns the dictionary manager if it has been properly initialized. Throws an INTERNAL_ERROR
@@ -42,7 +42,7 @@ public interface EZGameProvider extends InvocationProvider
/** /**
* Handles a {@link EZGameService#checkDictionaryWord} request. * Handles a {@link EZGameService#checkDictionaryWord} request.
*/ */
public void checkDictionaryWord (ClientObject caller, String arg1, String arg2, InvocationService.ResultListener arg3) public void checkDictionaryWord (ClientObject caller, String arg1, String arg2, String arg3, InvocationService.ResultListener arg4)
throws InvocationException; throws InvocationException;
/** /**
@@ -72,7 +72,7 @@ public interface EZGameProvider extends InvocationProvider
/** /**
* Handles a {@link EZGameService#getDictionaryLetterSet} request. * Handles a {@link EZGameService#getDictionaryLetterSet} request.
*/ */
public void getDictionaryLetterSet (ClientObject caller, String arg1, int arg2, InvocationService.ResultListener arg3) public void getDictionaryLetterSet (ClientObject caller, String arg1, String arg2, int arg3, InvocationService.ResultListener arg4)
throws InvocationException; throws InvocationException;
/** /**