Tick for each AI, pass the tick to the delegates.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1283 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: GameManager.java,v 1.27 2002/04/19 18:33:10 ray Exp $
|
// $Id: GameManager.java,v 1.28 2002/04/19 21:16:42 ray Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.game;
|
package com.threerings.parlor.game;
|
||||||
|
|
||||||
@@ -83,6 +83,9 @@ public class GameManager extends PlaceManager
|
|||||||
_AIs[ii] = -1;
|
_AIs[ii] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set up a delegate op for AI ticking
|
||||||
|
_tickAIOp = new TickAIDelegateOp();
|
||||||
|
|
||||||
// and register ourselves to receive AI ticks
|
// and register ourselves to receive AI ticks
|
||||||
AIGameTicker.registerAIGame(this);
|
AIGameTicker.registerAIGame(this);
|
||||||
}
|
}
|
||||||
@@ -254,7 +257,21 @@ public class GameManager extends PlaceManager
|
|||||||
*/
|
*/
|
||||||
protected void tickAIs ()
|
protected void tickAIs ()
|
||||||
{
|
{
|
||||||
// subclasses should implement their AI gameplay here
|
for (int ii=0; ii < _AIs.length; ii++) {
|
||||||
|
byte level = _AIs[ii];
|
||||||
|
if (level != -1) {
|
||||||
|
tickAI(ii, level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by tickAIs to tick each AI in the game.
|
||||||
|
*/
|
||||||
|
protected void tickAI (int pidx, byte level)
|
||||||
|
{
|
||||||
|
_tickAIOp.setAI(pidx, level);
|
||||||
|
applyToDelegates(_tickAIOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -393,6 +410,22 @@ public class GameManager extends PlaceManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected class TickAIDelegateOp implements DelegateOp
|
||||||
|
{
|
||||||
|
public void apply (PlaceManagerDelegate delegate) {
|
||||||
|
((GameManagerDelegate) delegate).tickAI(_pidx, _level);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAI (int pidx, byte level)
|
||||||
|
{
|
||||||
|
_pidx = pidx;
|
||||||
|
_level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int _pidx;
|
||||||
|
protected byte _level;
|
||||||
|
}
|
||||||
|
|
||||||
/** A reference to our game configuration. */
|
/** A reference to our game configuration. */
|
||||||
protected GameConfig _gconfig;
|
protected GameConfig _gconfig;
|
||||||
|
|
||||||
@@ -408,4 +441,7 @@ public class GameManager extends PlaceManager
|
|||||||
/** If AIs are present, contains their skill levels, or -1 at human
|
/** If AIs are present, contains their skill levels, or -1 at human
|
||||||
* player indexes.. */
|
* player indexes.. */
|
||||||
protected byte[] _AIs;
|
protected byte[] _AIs;
|
||||||
|
|
||||||
|
/** Our delegate operator to tick AIs. */
|
||||||
|
protected TickAIDelegateOp _tickAIOp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: GameManagerDelegate.java,v 1.2 2002/04/14 00:26:05 mdb Exp $
|
// $Id: GameManagerDelegate.java,v 1.3 2002/04/19 21:16:42 ray Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.game;
|
package com.threerings.parlor.game;
|
||||||
|
|
||||||
@@ -34,6 +34,16 @@ public class GameManagerDelegate extends PlaceManagerDelegate
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the manager when we should do some AI.
|
||||||
|
*
|
||||||
|
* @param pidx the player index to fake some gameplay for.
|
||||||
|
* @param skill the base skill level of the AI (0 - 100 inclusive).
|
||||||
|
*/
|
||||||
|
public void tickAI (int pidx, byte skill)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the game manager after the game ended.
|
* Called by the game manager after the game ended.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user