Class BetManager

java.lang.Object
games.stendhal.server.core.scripting.ScriptImpl
games.stendhal.server.script.BetManager
All Implemented Interfaces:
TurnListener, Script

public class BetManager extends ScriptImpl implements TurnListener
Creates an NPC which manages bets.

A game master has to tell him on what the players can bet:

 /script BetManager.class accept fire water earth
 

Then players can bet by saying something like

 bet 50 ham on fire
 bet 5 cheese on water
 
The NPC retrieves the items from the player and registers the bet.

The game master starts the action closing the betting time:

 /script BetManager.class action
 

After the game the game master has to tell the NPC who won:

 /script BetManager.class winner fire
 
.

The NPC will than tell all players the results and give it to winners:

 mort bet 50 ham on fire and won an additional 50 ham
 hendrik lost 5 cheese betting on water
 

Note: Betting is possible in "idle conversation state" to enable interaction of a large number of players in a short time. (The last time i did a show-fight i was losing count because there where more than 15 players)
Author:
hendrik
  • Field Details

    • npc

      protected ScriptingNPC npc
      The NPC.
    • state

      protected games.stendhal.server.script.BetManager.State state
      Holds the current state.
    • betInfos

      protected List<BetManager.BetInfo> betInfos
      List of bets.
    • targets

      protected List<String> targets
      Possible targets.
    • winner

      protected String winner
      Winner (in state State.PAYING_BETS).
  • Constructor Details

    • BetManager

      public BetManager()
  • Method Details

    • onTurnReached

      public void onTurnReached(int currentTurn)
      Description copied from interface: TurnListener
      This method is called when the turn number is reached.
      Specified by:
      onTurnReached in interface TurnListener
      Parameters:
      currentTurn - current turn number
    • load

      public void load(Player admin, List<String> args, ScriptingSandbox sandbox)
      Description copied from interface: Script
      Initial load of this script.
      Specified by:
      load in interface Script
      Overrides:
      load in class ScriptImpl
      Parameters:
      admin - the admin who load it or null on server start.
      args - the arguments the admin specified or null on server start.
      sandbox - all modifications to the game must be done using this object in order for the script to be unloadable
    • execute

      public void execute(Player admin, List<String> args)
      Description copied from interface: Script
      Executes this script.
      Specified by:
      execute in interface Script
      Overrides:
      execute in class ScriptImpl
      Parameters:
      admin - the admin who load it or null on server start.
      args - the arguments the admin specified or null on server start.