Some cleaning up of the difficulty handling so that we can use it as the
basis for our star system. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3038 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleController.java,v 1.9 2004/05/05 02:38:22 ray Exp $
|
||||
// $Id: PuzzleController.java,v 1.10 2004/06/22 14:08:58 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.client;
|
||||
|
||||
@@ -851,19 +851,6 @@ public abstract class PuzzleController extends GameController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the puzzle difficulty level is changed.
|
||||
*/
|
||||
public void difficultyChanged (final int level)
|
||||
{
|
||||
// dispatch this to our delegates
|
||||
applyToDelegates(PuzzleControllerDelegate.class, new DelegateOp() {
|
||||
public void apply (PlaceControllerDelegate delegate) {
|
||||
((PuzzleControllerDelegate)delegate).difficultyChanged(level);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player is knocked out of the game to give the puzzle
|
||||
* a chance to perform any post-knockout actions that may be desired.
|
||||
@@ -962,10 +949,7 @@ public abstract class PuzzleController extends GameController
|
||||
protected AttributeChangeListener _mlist = new AttributeChangeListener() {
|
||||
public void attributeChanged (AttributeChangedEvent event) {
|
||||
String name = event.getName();
|
||||
if (name.equals(PuzzleObject.DIFFICULTY)) {
|
||||
difficultyChanged(_puzobj.difficulty);
|
||||
|
||||
} else if (name.equals(PuzzleObject.SEED)) {
|
||||
if (name.equals(PuzzleObject.SEED)) {
|
||||
generateNewBoard();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleControllerDelegate.java,v 1.2 2004/02/25 14:48:44 mdb Exp $
|
||||
// $Id: PuzzleControllerDelegate.java,v 1.3 2004/06/22 14:08:58 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.client;
|
||||
|
||||
@@ -146,13 +146,6 @@ public class PuzzleControllerDelegate extends GameControllerDelegate
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the puzzle difficulty level is changed.
|
||||
*/
|
||||
public void difficultyChanged (int level)
|
||||
{
|
||||
}
|
||||
|
||||
/** Our puzzle controller. */
|
||||
protected PuzzleController _ctrl;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleService.java,v 1.1 2003/11/26 01:42:34 mdb Exp $
|
||||
// $Id: PuzzleService.java,v 1.2 2004/06/22 14:08:58 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.client;
|
||||
|
||||
@@ -43,10 +43,4 @@ public interface PuzzleService extends InvocationService
|
||||
* Requests that this client depart whatever puzzle they occupy.
|
||||
*/
|
||||
public void leavePuzzle (Client client);
|
||||
|
||||
/**
|
||||
* Requests that the difficulty level of the puzzle this client is
|
||||
* currently occupying be changed to the specified difficulty level.
|
||||
*/
|
||||
public void changeDifficulty (Client client, int level);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleMarshaller.java,v 1.1 2003/11/26 01:42:34 mdb Exp $
|
||||
// $Id: PuzzleMarshaller.java,v 1.2 2004/06/22 14:08:58 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.data;
|
||||
|
||||
@@ -90,15 +90,4 @@ public class PuzzleMarshaller extends InvocationMarshaller
|
||||
});
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #changeDifficulty} requests. */
|
||||
public static final int CHANGE_DIFFICULTY = 4;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void changeDifficulty (Client arg1, int arg2)
|
||||
{
|
||||
sendRequest(arg1, CHANGE_DIFFICULTY, new Object[] {
|
||||
new Integer(arg2)
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleObject.dobj,v 1.1 2003/11/26 01:42:34 mdb Exp $
|
||||
// $Id: PuzzleObject.dobj,v 1.2 2004/06/22 14:08:58 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.data;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class PuzzleObject extends GameObject
|
||||
public PuzzleGameMarshaller puzzleGameService;
|
||||
|
||||
/** The puzzle difficulty level. */
|
||||
public int difficulty = DEFAULT_DIFFICULTY;
|
||||
public int difficulty;
|
||||
|
||||
/** The status of each of the players in the game. The status value
|
||||
* is one of {@link #PLAYER_KNOCKED_OUT} or {@link
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleObject.java,v 1.1 2003/11/26 01:42:34 mdb Exp $
|
||||
// $Id: PuzzleObject.java,v 1.2 2004/06/22 14:08:58 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.data;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PuzzleObject extends GameObject
|
||||
public PuzzleGameMarshaller puzzleGameService;
|
||||
|
||||
/** The puzzle difficulty level. */
|
||||
public int difficulty = DEFAULT_DIFFICULTY;
|
||||
public int difficulty;
|
||||
|
||||
/** The status of each of the players in the game. The status value
|
||||
* is one of {@link #PLAYER_KNOCKED_OUT} or {@link
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleDispatcher.java,v 1.1 2003/11/26 01:42:34 mdb Exp $
|
||||
// $Id: PuzzleDispatcher.java,v 1.2 2004/06/22 14:08:58 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.server;
|
||||
|
||||
@@ -62,13 +62,6 @@ public class PuzzleDispatcher extends InvocationDispatcher
|
||||
);
|
||||
return;
|
||||
|
||||
case PuzzleMarshaller.CHANGE_DIFFICULTY:
|
||||
((PuzzleProvider)provider).changeDifficulty(
|
||||
source,
|
||||
((Integer)args[0]).intValue()
|
||||
);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchRequest(source, methodId, args);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleManager.java,v 1.8 2004/03/06 11:29:19 mdb Exp $
|
||||
// $Id: PuzzleManager.java,v 1.9 2004/06/22 14:08:58 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.server;
|
||||
|
||||
@@ -248,6 +248,11 @@ public abstract class PuzzleManager extends GameManager
|
||||
// initialize the player status
|
||||
_puzobj.setPlayerStatus(new int[size]);
|
||||
|
||||
// compute the starting difficulty
|
||||
_puzobj.setDifficulty(computeDifficulty());
|
||||
Log.info("Computed difficulty [game=" + _puzobj.which() +
|
||||
", difficulty=" + _puzobj.difficulty + "].");
|
||||
|
||||
// initialize the player boards
|
||||
initBoards();
|
||||
|
||||
@@ -284,6 +289,20 @@ public abstract class PuzzleManager extends GameManager
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* When a puzzle game starts, the manager is given the opportunity to
|
||||
* configure the puzzle difficulty based on information known about
|
||||
* the player. Additionally, when the game resets due to the player
|
||||
* clearing the board, etc. this will be called again, so the
|
||||
* difficulty can be ramped up as the player progresses. In situations
|
||||
* where ratings and experience are tracked, the difficulty can be
|
||||
* seeded based on the players prior performance.
|
||||
*/
|
||||
protected int computeDifficulty ()
|
||||
{
|
||||
return DEFAULT_DIFFICULTY;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected void gameDidStart ()
|
||||
{
|
||||
@@ -658,29 +677,6 @@ public abstract class PuzzleManager extends GameManager
|
||||
*/
|
||||
protected abstract BoardSummary newBoardSummary (Board board);
|
||||
|
||||
// documentation inherited
|
||||
public void attributeChanged (AttributeChangedEvent event)
|
||||
{
|
||||
super.attributeChanged(event);
|
||||
|
||||
if (event.getName().equals(PuzzleObject.DIFFICULTY)) {
|
||||
difficultyChanged(_puzobj.difficulty);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the puzzle difficulty level is changed.
|
||||
*/
|
||||
public void difficultyChanged (final int level)
|
||||
{
|
||||
// let our delegates do their business
|
||||
applyToDelegates(new DelegateOp() {
|
||||
public void apply (PlaceManagerDelegate delegate) {
|
||||
((PuzzleManagerDelegate)delegate).difficultyChanged(level);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// documentation inherited from interface PuzzleGameProvider
|
||||
public void updateProgress (ClientObject caller, int roundId, int[] events)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleManagerDelegate.java,v 1.2 2003/11/26 03:17:16 mdb Exp $
|
||||
// $Id: PuzzleManagerDelegate.java,v 1.3 2004/06/22 14:08:58 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.server;
|
||||
|
||||
@@ -20,12 +20,5 @@ public class PuzzleManagerDelegate extends GameManagerDelegate
|
||||
_puzmgr = puzmgr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the puzzle difficulty level is changed.
|
||||
*/
|
||||
public void difficultyChanged (int level)
|
||||
{
|
||||
}
|
||||
|
||||
protected PuzzleManager _puzmgr;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PuzzleProvider.java,v 1.3 2004/03/06 11:29:19 mdb Exp $
|
||||
// $Id: PuzzleProvider.java,v 1.4 2004/06/22 14:08:58 mdb Exp $
|
||||
|
||||
package com.threerings.puzzle.server;
|
||||
|
||||
@@ -115,35 +115,6 @@ public class PuzzleProvider
|
||||
((PuzzlerObject)user).setPuzzleLoc(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request from a client to change the difficulty level of
|
||||
* their current puzzle.
|
||||
*/
|
||||
public void changeDifficulty (ClientObject caller, int level)
|
||||
{
|
||||
BodyObject user = (BodyObject)caller;
|
||||
int puzzleOid = ((PuzzlerObject)user).getPuzzleLoc();
|
||||
|
||||
// make sure they're currently in a puzzle
|
||||
if (puzzleOid == -1) {
|
||||
Log.warning("Received change difficulty request from user that " +
|
||||
"isn't in a puzzle [user=" + user.who() + "].");
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure the puzzle in question actually exists
|
||||
PlaceManager pmgr = _plreg.getPlaceManager(puzzleOid);
|
||||
if (pmgr == null) {
|
||||
Log.info("Requested to change difficulty of a non-existent " +
|
||||
"puzzle [user=" + user.who() + "].");
|
||||
return;
|
||||
}
|
||||
|
||||
// change the puzzle difficulty level
|
||||
PuzzleObject puzobj = (PuzzleObject)pmgr.getPlaceObject();
|
||||
puzobj.setDifficulty(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the specified body from whatever puzzle they currently occupy
|
||||
* to the puzzle identified by the supplied oid.
|
||||
|
||||
Reference in New Issue
Block a user