From dd782f6d3282f45d6a1696204b7923663189d69b Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 11 Mar 2025 10:22:19 +0100 Subject: [PATCH] rogueviz::seuphorica:: a better system for hand ordering --- rogueviz/seuphorica.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rogueviz/seuphorica.cpp b/rogueviz/seuphorica.cpp index 216af2df..c62267ae 100644 --- a/rogueviz/seuphorica.cpp +++ b/rogueviz/seuphorica.cpp @@ -774,6 +774,7 @@ void is_clone(struct tile& orig, struct tile& clone) { } void sort_hand() { + return; sort(drawn.begin(), drawn.end(), [] (tile &t1, tile &t2) { auto h1 = tb_hand.locate_tile(t1); auto h2 = tb_hand.locate_tile(t2); @@ -782,6 +783,12 @@ void sort_hand() { }); } +void move_to_front(int &b) { + while(b > 0) { + swap(drawn[b], drawn[b-1]); b--; + } + } + void seuphorica_menu(); int start_tick; @@ -992,10 +999,11 @@ void seuphorica_screen() { } if(box_moved == &drawn && current_box == &drawn) { sort_hand(); + move_to_front(tile_boxid); return; } if(box_moved == &drawn && current_box == &shop) { - swap(drawn[tile_boxid], drawn[0]); + move_to_front(tile_boxid); back_to_shop(); sort_hand(); } @@ -1014,7 +1022,7 @@ void seuphorica_screen() { if(box_moved == &drawn && current_box == nullptr && mouseover) { auto at = mouseover; if(in_board(at) && !board.count(at) && tile_orientation.count(at)) { - swap(drawn[tile_boxid], drawn[0]); + move_to_front(tile_boxid); drop_hand_on(at); sort_hand(); }