From b2038dcc699ba7694864a52709daabe56c780bb6 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Tue, 8 Oct 2019 17:14:19 +0300 Subject: [PATCH] Add time to task finish --- ROADMAP.md | 4 ++-- src/expansion.cr | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 2880893..3073753 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -10,8 +10,8 @@ ## Управление - [x] Цикл ввода-вывода -- [ ] Просмотр задач в очереди -- [ ] Время завершения задачи при создании +- [x] Просмотр задач в очереди +- [x] Время завершения задачи при создании - [x] Сообщение о выйгрыше ## Механики diff --git a/src/expansion.cr b/src/expansion.cr index 24b01fa..6f29ae2 100644 --- a/src/expansion.cr +++ b/src/expansion.cr @@ -85,8 +85,15 @@ def render_commands(world) if items.size != 0 printf "Queue:\n" end + wts = world.ts items.each do |i| - printf " %s, %s\n", render_time(i.ts), i.command.desc + ts_diff = i.ts - wts + if ts_diff < 60 + done_time = sprintf " %02ds", ts_diff + else + done_time = sprintf "%d:%02d", ts_diff // 60, ts_diff % 60 + end + printf " %s, %s, %s\n", render_time(i.ts), done_time, i.command.desc end end