Commit 4b6c383f authored by Jonathan Michalon's avatar Jonathan Michalon
Browse files

Prepared Stack for transfert by handling TileID lists.

parent 809314ac
......@@ -42,6 +42,23 @@ namespace OVCC
{
this.fill (ts);
}
public Stack.from_tile_ids (SList<uint> ids, TilesDef tiles)
{
foreach (var id in ids) {
add_nth (tiles.get_tile (id), -1);
}
}
public SList<uint> get_id_list ()
{
SList<uint> list = new SList<uint>();
foreach (var e in this._stack.head) {
list.prepend (e.id);
}
list.reverse();
return list;
}
public void dump ()
{
......@@ -60,14 +77,22 @@ namespace OVCC
int n)
{
var t = tile.dup ();
this._stack.push_nth (t, n);
if (n == 0) {
this._stack.push_head (t);
}
else if (n == -1) {
this._stack.push_tail (t);
}
else {
this._stack.push_nth (t, n);
}
this.item_added (t);
this.notify_property ("size");
}
public void add (Tile t)
{
this.add_nth (t, Random.int_range (0, (int32)this.size + 1));
this.notify_property ("size");
}
public Tile pop ()
......
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