|
@@ -707,7 +707,7 @@ door::Panel make_panel3(void) {
|
|
|
{
|
|
|
door::updateFunction cardsleftUpdate = [](void) -> std::string {
|
|
|
std::string text = "Cards left:";
|
|
|
- text.append(std::to_string(52 - card_number));
|
|
|
+ text.append(std::to_string(51 - card_number));
|
|
|
return text;
|
|
|
};
|
|
|
std::string cardsleftString = "Cards left:--";
|
|
@@ -848,7 +848,6 @@ int play_cards(door::Door &door, DBData &db, std::mt19937 &rng) {
|
|
|
int height = 3;
|
|
|
Deck d(deck_color, height);
|
|
|
door::Panel *c;
|
|
|
- door << door::reset << door::cls;
|
|
|
|
|
|
|
|
|
|
|
@@ -873,7 +872,6 @@ int play_cards(door::Door &door, DBData &db, std::mt19937 &rng) {
|
|
|
door::Panel spaceAceTriPeaks = make_tripeaks();
|
|
|
int tp_off_x = (mx - spaceAceTriPeaks.getWidth()) / 2;
|
|
|
spaceAceTriPeaks.set(tp_off_x, off_y);
|
|
|
- door << spaceAceTriPeaks;
|
|
|
|
|
|
off_y += 3;
|
|
|
|
|
@@ -901,53 +899,103 @@ int play_cards(door::Door &door, DBData &db, std::mt19937 &rng) {
|
|
|
pc.set(left_panel + off_x, off_yp + 5);
|
|
|
}
|
|
|
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
- int cx, cy, level;
|
|
|
- cardgo(29, space, height, cx, cy, level);
|
|
|
- c = d.back(level);
|
|
|
- c->set(cx + off_x, cy + off_y);
|
|
|
-
|
|
|
- p3.set(cx + off_x, cy + off_y + height);
|
|
|
- door << p1 << p3 << p2 << pc;
|
|
|
- door << *c;
|
|
|
- std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
|
- }
|
|
|
+ bool dealing = true;
|
|
|
+ int r = 0;
|
|
|
+ while ((r >= 0) and (r != 'Q')) {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ door << door::reset << door::cls;
|
|
|
+ door << spaceAceTriPeaks;
|
|
|
|
|
|
- for (int x = 0; x < 28; x++) {
|
|
|
- int cx, cy, level;
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ int cx, cy, level;
|
|
|
+ cardgo(29, space, height, cx, cy, level);
|
|
|
+
|
|
|
+ if (card_number == 51)
|
|
|
+ level = 0;
|
|
|
+ c = d.back(level);
|
|
|
+ c->set(cx + off_x, cy + off_y);
|
|
|
+
|
|
|
+ p3.set(cx + off_x, cy + off_y + height);
|
|
|
+ door << p1 << p3 << p2 << pc;
|
|
|
+ door << *c;
|
|
|
+ if (dealing)
|
|
|
+ std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
|
+ }
|
|
|
|
|
|
- cardgo(x, space, height, cx, cy, level);
|
|
|
-
|
|
|
-
|
|
|
- std::this_thread::sleep_for(std::chrono::milliseconds(75));
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- c = d.back(level);
|
|
|
- c->set(cx + off_x, cy + off_y);
|
|
|
- door << *c;
|
|
|
- }
|
|
|
+ for (int x = 0; x < (dealing ? 28 : 29); x++) {
|
|
|
+ int cx, cy, level;
|
|
|
|
|
|
- for (int x = 18; x < 29; x++) {
|
|
|
- int cx, cy, level;
|
|
|
+ cardgo(x, space, height, cx, cy, level);
|
|
|
+
|
|
|
+
|
|
|
+ if (dealing)
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(75));
|
|
|
|
|
|
- state.at(x) = 1;
|
|
|
- cardgo(x, space, height, cx, cy, level);
|
|
|
-
|
|
|
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
|
|
+ if (dealing) {
|
|
|
+ c = d.back(level);
|
|
|
+ c->set(cx + off_x, cy + off_y);
|
|
|
+ door << *c;
|
|
|
+ } else {
|
|
|
+
|
|
|
+ int s = state.at(x);
|
|
|
+
|
|
|
+ switch (s) {
|
|
|
+ case 0:
|
|
|
+ c = d.back(level);
|
|
|
+ c->set(cx + off_x, cy + off_y);
|
|
|
+ door << *c;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+
|
|
|
+ if (x == 28)
|
|
|
+ c = d.card(deck1.at(card_number));
|
|
|
+ else
|
|
|
+ c = d.card(deck1.at(x));
|
|
|
+ c->set(cx + off_x, cy + off_y);
|
|
|
+ door << *c;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- c = d.card(deck1.at(x));
|
|
|
- c->set(cx + off_x, cy + off_y);
|
|
|
- door << *c;
|
|
|
- }
|
|
|
+ if (dealing)
|
|
|
+ for (int x = 18; x < 29; x++) {
|
|
|
+ int cx, cy, level;
|
|
|
|
|
|
- p3.update(door);
|
|
|
- door << door::reset;
|
|
|
+ state.at(x) = 1;
|
|
|
+ cardgo(x, space, height, cx, cy, level);
|
|
|
+
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
|
|
|
|
|
- int r = door.sleep_key(door.inactivity);
|
|
|
+ c = d.card(deck1.at(x));
|
|
|
+ c->set(cx + off_x, cy + off_y);
|
|
|
+ door << *c;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ }
|
|
|
+ dealing = false;
|
|
|
+
|
|
|
+ p3.update(door);
|
|
|
+ door << door::reset;
|
|
|
+
|
|
|
+ r = door.sleep_key(door.inactivity);
|
|
|
+ if ((r < 0x1000) and (r > 0)) {
|
|
|
+ r = std::toupper(r);
|
|
|
+ if (r == ' ') {
|
|
|
+ if (card_number < 51)
|
|
|
+ card_number++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return r;
|
|
|
}
|
|
|
|
|
@@ -1129,7 +1177,8 @@ int main(int argc, char *argv[]) {
|
|
|
auto lastClock = std::chrono::system_clock::from_time_t(last_call);
|
|
|
auto delta = nowClock - lastClock;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
int hours = chrono::duration_cast<chrono::hours>(delta).count();
|
|
|
int days = hours / 24;
|
|
|
int minutes = chrono::duration_cast<chrono::minutes>(delta).count();
|
|
@@ -1180,8 +1229,8 @@ int main(int argc, char *argv[]) {
|
|
|
mx = door.width;
|
|
|
my = door.height;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
display_starfield_space_ace(door, rng);
|
|
|
|