Commit bf6ebf51 authored by Colomban Wendling's avatar Colomban Wendling
Browse files

Fix API of Board's constructor

parent bb9515d0
......@@ -61,18 +61,9 @@ namespace OVCC
public signal void tile_added (Tile t, Position pos);
public Board ()
public Board (Tile first)
{
}
public Board.from_stack (Stack s)
{
Position pos = {0, 0};
var first = s.pop();
if (first != null) {
do_add_tile (first, pos);
}
do_add_tile (first, {0, 0});
}
public bool is_tile_there (Position pos)
......
......@@ -90,7 +90,7 @@ namespace OVCC
public Game.from_tileset (TileSet ts)
{
var s = new Stack.from_tileset (ts);
Object (tileset: ts, stack: s, board: new Board.from_stack (s));
Object (tileset: ts, stack: s, board: new Board (s.pop ()));
stack.item_removed.connect (t => {
this.notify_property ("current-tile");
......
......@@ -84,7 +84,9 @@ test_board (OVCCStack *stack)
gsize n_success = 0;
gsize n_failed = 0;
board = ovcc_board_new_from_stack (stack);
tile = ovcc_stack_pop (stack);
board = ovcc_board_new (tile);
g_object_unref (tile);
while (NULL != (tile = ovcc_stack_pop (stack))) {
if (! try_place_tile (board, tile)) {
g_warning ("Failed to place tile %u", ovcc_tile_get_id (tile));
......@@ -133,7 +135,9 @@ test_player (OVCCStack *stack)
int answer;
int wise;
board = ovcc_board_new_from_stack (stack);
tile = ovcc_stack_pop (stack);
board = ovcc_board_new (tile);
g_object_unref (tile);
while (NULL != (tile = ovcc_stack_pop (stack))) {
ovcc_board_dump (board);
g_print ("The tile to place is:\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment