Backgammon

Backgammon Codeless

The following code is generated automatically by Treescript:

 

(class (public) Bg-form extends Form

  var (auto) (

    Game-server game-server;

    Button next-btn;

    Button back-btn;

    Button new-game-btn;

    Button exit-btn;

    Board-grid board-grid;

    Layer-book board-container;

    Bitmap board-bitmap;

    Card-stack white-stack;

    Card-stack black-stack;

    Editable-grid score-grid;

    Rack-grid dice;

    Card-stack double-cube;

    Card-stack undo-double;

  )

  (proc (public static) main (String-list args)

    var (

      Bg-form form1 (new Bg-form);

    )

  )

  (proc (public) Bg-form

    do (

      : game-server init-game;

      show;

    )

  )

  (proc (auto) next-btn_click (Event e)

    do (

      : game-server next-player;

    )

  )

  (proc (auto) back-btn_click (Event e)

    do (

      : game-server previous-player;

    )

  )

  (proc (auto) new-game-btn_click (Event e)

    do (

      : game-server new-game;

    )

  )

  (proc (auto) exit-btn_click (Event e)

    do (

      : game-server quit-player;

    )

  )

)

 

Backgammon Automation

Feature No. 1: Roll dice at beginning of every turn

 

(proc (auto) next-btn_click (Event e)

  do (

    : game-server next-player;

    roll-dice;

  )

)

(proc roll-dice

  do (

    : dice-grid init;

  )

)

 

Feature No. 2: Update player scores at end of every game

 

(proc (auto) new-game-btn_click (Event e)

  do (

    update-score-grid;

    : game-server new-game;

  )

)

{

  white-cb: check box with caption "White Wins"

  win-typ-grp: radio group with 3 radio buttons:

  - Normal

  - Gammon

  - Backgammon

}

(proc update-score-grid

  var (

    int score-row;

    int score;

  )

  do (

    = score-row (? (: white-cb checked) 0 1);

    = score (* (+ 1 (: win-typ-grp item-index))

      (str-to-int (: double-cube get-top

      text-boxes get-obj get-text))

    );

    : score-grid (set-cell score-row 1 (+ score

      (str-to-int (: score-grid (get-cell score-row 1))))

    );

  )

)