Back to Majik 3D MMORPG information archive main page.
forum index

Scripting example - dice game

Message 1343

From: dazzt
Date: 2002-03-25 01:15:24


This example is a use case that tries to determine what requirements do we need from the scripts, both client- and server-side. If you have other good examples in mind that covers some issuesnot mentioned in this example, feel free to make more examples.

In a local hilltop inn there is a dice table where players can play the dice game.\tEach player bets a sum of money for the game. After a round has finished, the winner collects the money currently on the bet (I'm not going to concern the actual game here, i.e. how the game runs or how is winner calculated, it's irrelevant from the point of scripting).

Server components:
- Dice game object
  - Handles the game logic

Client components:
- A model of the dice table
- A model of a die
- A script linked to the dice table that coordinates the gameplay

The flow of the game goes roughly like this:
   Player A waits until the table is free
   Player A creates a game
   Player B joins the game
   Player C joins the game
   Player A starts the game

  
     Player A defines the size of the bet
     Players bet a sum of money
     Player A starts the round
     Player A throws dice
     Player B throws dice
     Player C throws dice
     The winner is determined, money is given to the winner

   Player C leaves the game
   Player A leaves the game
   Player B leaves the game

Client actions required:
  Player A must have some way to select 'create game' from the table
  - Each item could have a set of defined actions that the player is able to do (think old Lucasarts adventures :)). For example, clicking a right button over an object could bring a menu that shows a list of possible actions.
\t
   Players B's and C's client-side scripts (of the dice table object) receive a notification that a game has been created and is waiting for players. The scripts modify the 'actions'-menu for the table object accordingly to include 'Join Game'.

   Player A's script receives a notification each time a player has joined the game. After there are two players, a 'start game' option appears.

   Player A defines the size of the bet for the round
     - Client scripts need to be able to query information from the player

   Player B and C are asked to pay the necessary amount of money. Player A's script gets a notification when the payments are done.

UI-wise it would be the most convenient if Player A had some kind of 'control bar' that appears when he created the game. The bar would include buttons for the actions needed to host the game. A similar bar could appear to other players as well, but with less controls (bet size indicator, 'pay', 'throw dice', 'leave game')

The server object doesn't need to have much logic in this case, it merely keeps track of the bets and money transfers.