Added support for handling games with multiple rounds.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@237 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -32,48 +32,45 @@ public interface EZGameService extends InvocationService
|
||||
/**
|
||||
* Request to set the specified property.
|
||||
*
|
||||
* @param value either a byte[] if setting a non-array property
|
||||
* or a property at an array index, or a byte[][] if setting
|
||||
* an array property where index is -1.
|
||||
* @param value either a byte[] if setting a non-array property or a property at an array
|
||||
* index, or a byte[][] if setting an array property where index is -1.
|
||||
*/
|
||||
public void setProperty (
|
||||
Client client, String propName, Object value, int index,
|
||||
boolean testAndSet, Object testValue, InvocationListener listener);
|
||||
public void setProperty (Client client, String propName, Object value, int index,
|
||||
boolean testAndSet, Object testValue, InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Request to end the turn, possibly futzing the next turn holder unless
|
||||
* -1 is specified for the nextPlayerIndex.
|
||||
* Request to end the turn, possibly futzing the next turn holder unless -1 is specified for
|
||||
* the nextPlayerIndex.
|
||||
*/
|
||||
public void endTurn (
|
||||
Client client, int nextPlayerId, InvocationListener listener);
|
||||
public void endTurn (Client client, int nextPlayerId, InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Request to end the game, with the specified player oids assigned
|
||||
* as winners.
|
||||
* Requests to end the current round. If nextRoundDelay is greater than zero, the next round
|
||||
* will be started in the specified number of seconds.
|
||||
*/
|
||||
public void endGame (
|
||||
Client client, int[] winnerOids, InvocationListener listener);
|
||||
public void endRound (Client client, int nextRoundDelay, InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Request to send a private message to one other player in
|
||||
* the game.
|
||||
* Request to end the game, with the specified player oids assigned as winners.
|
||||
*/
|
||||
public void endGame (Client client, int[] winnerOids, InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Request to send a private message to one other player in the game.
|
||||
*
|
||||
* @param value either a byte[] if setting a non-array property
|
||||
* or a property at an array index, or a byte[][] if setting
|
||||
* an array property where index is -1.
|
||||
* @param value either a byte[] if setting a non-array property or a property at an array
|
||||
* index, or a byte[][] if setting an array property where index is -1.
|
||||
*/
|
||||
public void sendMessage (
|
||||
Client client, String msgName, Object value, int playerId,
|
||||
InvocationListener listener);
|
||||
public void sendMessage (Client client, String msgName, Object value, int playerId,
|
||||
InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Ask the dictionary service for a set of random letters
|
||||
* appropriate for the given language/culture settings. These will be
|
||||
* returned via a message back to the caller.
|
||||
* Ask the dictionary service for a set of random letters appropriate for the given
|
||||
* language/culture settings. These will be returned via a message back to the caller.
|
||||
*
|
||||
* @param client stores information about the caller
|
||||
* @param locale is an RFC 3066 string specifying language settings,
|
||||
* for example, "en" or "en-us".
|
||||
* @param locale is an RFC 3066 string specifying language settings, for example, "en" or
|
||||
* "en-us".
|
||||
* @param count is the number of letters to be returned.
|
||||
* @param listener is the callback function
|
||||
*/
|
||||
@@ -81,13 +78,12 @@ public interface EZGameService extends InvocationService
|
||||
Client client, String locale, int count, ResultListener listener);
|
||||
|
||||
/**
|
||||
* Ask the dictionary service whether the specified word is valid
|
||||
* with the given language/culture settings. The result will be returned
|
||||
* via a message back to the caller.
|
||||
* Ask the dictionary service whether the specified word is valid with the given
|
||||
* language/culture settings. The result will be returned via a message back to the caller.
|
||||
*
|
||||
* @param client stores information about the caller
|
||||
* @param locale is an RFC 3066 string specifying language settings,
|
||||
* for example, "en" or "en-us".
|
||||
* @param locale is an RFC 3066 string specifying language settings, for example, "en" or
|
||||
* "en-us".
|
||||
* @param word is the word to be checked against the dictionary.
|
||||
* @param listener is the callback function
|
||||
*/
|
||||
@@ -99,46 +95,39 @@ public interface EZGameService extends InvocationService
|
||||
*
|
||||
* @param clearExisting if true, wipe the old contents.
|
||||
*/
|
||||
public void addToCollection (
|
||||
Client client, String collName, byte[][] data, boolean clearExisting,
|
||||
InvocationListener listener);
|
||||
public void addToCollection (Client client, String collName, byte[][] data,
|
||||
boolean clearExisting, InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Merge the specified collection into the other.
|
||||
*/
|
||||
public void mergeCollection (
|
||||
Client client, String srcColl, String intoColl,
|
||||
InvocationListener listener);
|
||||
Client client, String srcColl, String intoColl, InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Pick or deal some number of elements from the specified collection,
|
||||
* and either set a property in the flash object, or delivery the
|
||||
* picks to the specified player index via a game message.
|
||||
* Pick or deal some number of elements from the specified collection, and either set a
|
||||
* property in the flash object, or delivery the picks to the specified player index via a game
|
||||
* message.
|
||||
*/
|
||||
public void getFromCollection (
|
||||
Client client, String collName, boolean consume, int count,
|
||||
String msgOrPropName, int playerId, ConfirmListener listener);
|
||||
public void getFromCollection (Client client, String collName, boolean consume, int count,
|
||||
String msgOrPropName, int playerId, ConfirmListener listener);
|
||||
|
||||
/**
|
||||
* Start a ticker that will send out timestamp information at
|
||||
* the interval specified.
|
||||
* Start a ticker that will send out timestamp information at the interval specified.
|
||||
*
|
||||
* @param msOfDelay must be at least 50, or 0 may be set to halt
|
||||
* and clear a previously started ticker.
|
||||
* @param msOfDelay must be at least 50, or 0 may be set to halt and clear a previously started
|
||||
* ticker.
|
||||
*/
|
||||
public void setTicker (
|
||||
Client client, String tickerName, int msOfDelay,
|
||||
InvocationListener listener);
|
||||
Client client, String tickerName, int msOfDelay, InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Request to get the specified user's cookie.
|
||||
*/
|
||||
public void getCookie (
|
||||
Client client, int playerId, InvocationListener listener);
|
||||
public void getCookie (Client client, int playerId, InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Request to set our cookie.
|
||||
*/
|
||||
public void setCookie (
|
||||
Client client, byte[] cookie, InvocationListener listener);
|
||||
public void setCookie (Client client, byte[] cookie, InvocationListener listener);
|
||||
}
|
||||
|
||||
@@ -76,8 +76,21 @@ public class EZGameMarshaller extends InvocationMarshaller
|
||||
});
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #endRound} requests. */
|
||||
public static final int END_ROUND = 4;
|
||||
|
||||
// from interface EZGameService
|
||||
public void endRound (Client arg1, int arg2, InvocationService.InvocationListener arg3)
|
||||
{
|
||||
ListenerMarshaller listener3 = new ListenerMarshaller();
|
||||
listener3.listener = arg3;
|
||||
sendRequest(arg1, END_ROUND, new Object[] {
|
||||
Integer.valueOf(arg2), listener3
|
||||
});
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #endTurn} requests. */
|
||||
public static final int END_TURN = 4;
|
||||
public static final int END_TURN = 5;
|
||||
|
||||
// from interface EZGameService
|
||||
public void endTurn (Client arg1, int arg2, InvocationService.InvocationListener arg3)
|
||||
@@ -90,7 +103,7 @@ public class EZGameMarshaller extends InvocationMarshaller
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #getCookie} requests. */
|
||||
public static final int GET_COOKIE = 5;
|
||||
public static final int GET_COOKIE = 6;
|
||||
|
||||
// from interface EZGameService
|
||||
public void getCookie (Client arg1, int arg2, InvocationService.InvocationListener arg3)
|
||||
@@ -103,7 +116,7 @@ public class EZGameMarshaller extends InvocationMarshaller
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #getDictionaryLetterSet} requests. */
|
||||
public static final int GET_DICTIONARY_LETTER_SET = 6;
|
||||
public static final int GET_DICTIONARY_LETTER_SET = 7;
|
||||
|
||||
// from interface EZGameService
|
||||
public void getDictionaryLetterSet (Client arg1, String arg2, int arg3, InvocationService.ResultListener arg4)
|
||||
@@ -116,7 +129,7 @@ public class EZGameMarshaller extends InvocationMarshaller
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #getFromCollection} requests. */
|
||||
public static final int GET_FROM_COLLECTION = 7;
|
||||
public static final int GET_FROM_COLLECTION = 8;
|
||||
|
||||
// from interface EZGameService
|
||||
public void getFromCollection (Client arg1, String arg2, boolean arg3, int arg4, String arg5, int arg6, InvocationService.ConfirmListener arg7)
|
||||
@@ -129,7 +142,7 @@ public class EZGameMarshaller extends InvocationMarshaller
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #mergeCollection} requests. */
|
||||
public static final int MERGE_COLLECTION = 8;
|
||||
public static final int MERGE_COLLECTION = 9;
|
||||
|
||||
// from interface EZGameService
|
||||
public void mergeCollection (Client arg1, String arg2, String arg3, InvocationService.InvocationListener arg4)
|
||||
@@ -142,7 +155,7 @@ public class EZGameMarshaller extends InvocationMarshaller
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #sendMessage} requests. */
|
||||
public static final int SEND_MESSAGE = 9;
|
||||
public static final int SEND_MESSAGE = 10;
|
||||
|
||||
// from interface EZGameService
|
||||
public void sendMessage (Client arg1, String arg2, Object arg3, int arg4, InvocationService.InvocationListener arg5)
|
||||
@@ -155,7 +168,7 @@ public class EZGameMarshaller extends InvocationMarshaller
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #setCookie} requests. */
|
||||
public static final int SET_COOKIE = 10;
|
||||
public static final int SET_COOKIE = 11;
|
||||
|
||||
// from interface EZGameService
|
||||
public void setCookie (Client arg1, byte[] arg2, InvocationService.InvocationListener arg3)
|
||||
@@ -168,7 +181,7 @@ public class EZGameMarshaller extends InvocationMarshaller
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #setProperty} requests. */
|
||||
public static final int SET_PROPERTY = 11;
|
||||
public static final int SET_PROPERTY = 12;
|
||||
|
||||
// from interface EZGameService
|
||||
public void setProperty (Client arg1, String arg2, Object arg3, int arg4, boolean arg5, Object arg6, InvocationService.InvocationListener arg7)
|
||||
@@ -181,7 +194,7 @@ public class EZGameMarshaller extends InvocationMarshaller
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #setTicker} requests. */
|
||||
public static final int SET_TICKER = 12;
|
||||
public static final int SET_TICKER = 13;
|
||||
|
||||
// from interface EZGameService
|
||||
public void setTicker (Client arg1, String arg2, int arg3, InvocationService.InvocationListener arg4)
|
||||
|
||||
@@ -77,6 +77,13 @@ public class EZGameDispatcher extends InvocationDispatcher
|
||||
);
|
||||
return;
|
||||
|
||||
case EZGameMarshaller.END_ROUND:
|
||||
((EZGameProvider)provider).endRound(
|
||||
source,
|
||||
((Integer)args[0]).intValue(), (InvocationService.InvocationListener)args[1]
|
||||
);
|
||||
return;
|
||||
|
||||
case EZGameMarshaller.END_TURN:
|
||||
((EZGameProvider)provider).endTurn(
|
||||
source,
|
||||
|
||||
@@ -110,6 +110,33 @@ public class EZGameManager extends GameManager
|
||||
_turnDelegate.endTurn(nextTurnHolder);
|
||||
}
|
||||
|
||||
// from EZGameProvider
|
||||
public void endRound (ClientObject caller, int nextRoundDelay,
|
||||
InvocationService.InvocationListener listener)
|
||||
throws InvocationException
|
||||
{
|
||||
validateStateModification(caller, false);
|
||||
|
||||
// let the game know that it is doing something stupid
|
||||
if (_gameObj.roundId < 0) {
|
||||
throw new InvocationException("m.round_already_ended");
|
||||
}
|
||||
|
||||
// while we are between rounds, our round id is the negation of the round that just ended
|
||||
_gameObj.setRoundId(-_gameObj.roundId);
|
||||
|
||||
// queue up the start of the next round if requested
|
||||
if (nextRoundDelay > 0) {
|
||||
new Interval(CrowdServer.omgr) {
|
||||
public void expired () {
|
||||
if (_gameObj.isInPlay()) {
|
||||
_gameObj.setRoundId(-_gameObj.roundId + 1);
|
||||
}
|
||||
}
|
||||
}.schedule(nextRoundDelay * 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
// from EZGameProvider
|
||||
public void endGame (ClientObject caller, int[] winnerOids,
|
||||
InvocationService.InvocationListener listener)
|
||||
|
||||
@@ -51,6 +51,12 @@ public interface EZGameProvider extends InvocationProvider
|
||||
public void endGame (ClientObject caller, int[] arg1, InvocationService.InvocationListener arg2)
|
||||
throws InvocationException;
|
||||
|
||||
/**
|
||||
* Handles a {@link EZGameService#endRound} request.
|
||||
*/
|
||||
public void endRound (ClientObject caller, int arg1, InvocationService.InvocationListener arg2)
|
||||
throws InvocationException;
|
||||
|
||||
/**
|
||||
* Handles a {@link EZGameService#endTurn} request.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user