From 6800aa6c50a41556333fe7109ec5f8a1fd7e512d Mon Sep 17 00:00:00 2001 From: KUSANAGI Mitsuhisa Date: Sat, 24 Mar 2018 11:40:01 +0900 Subject: [PATCH 1/2] :memo: Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5690c5a..71ea508 100644 --- a/README.md +++ b/README.md @@ -48,12 +48,14 @@ $ ./awktc.awk * ![Black piece](./md-images/special_piece.png) - __Special Piece__ - Destroys horizontal lines even if they have gaps of blocks. +### All Clear Bonus ### + +If you clear all the pieces, then you will get an "All Clear Bonus". + Changing the Playfield Width ---------------------------- -You can change the playfield width between 4 and 24 cells. - -By default, the playfield width is 12 cells. +You can change the playfield width between 4 and 24 cells. By default, the playfield width is 12 cells. ### Example Minimum Width ### From 8e55e7fe9815c158889e4a478626172994bd71e1 Mon Sep 17 00:00:00 2001 From: KUSANAGI Mitsuhisa Date: Sat, 24 Mar 2018 12:20:00 +0900 Subject: [PATCH 2/2] :sparkles: Implement an "All Clear Bonus" --- awktc.awk | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/awktc.awk b/awktc.awk index 8642fd4..15d4a04 100755 --- a/awktc.awk +++ b/awktc.awk @@ -20,6 +20,7 @@ BEGIN { MAX_LEVEL = 99; MAX_LINES = 999999; MAX_SCORE = 999999; + SCORE_UNIT = 100; DELAY_SEC = 0.1; READING_KEY_CMD = "((while :; do echo ''; sleep " DELAY_SEC "; done) &" \ @@ -253,6 +254,15 @@ function _delete_line(target_y, x, y) { } } +function _is_all_clear( x) { + for (x = 1; x < field_w - 1; x++) { + if (field_data[x, field_h - 2] != 0) { + return 0; + } + } + return 1; +} + function update_field( deleted_lines, is_line_created, i, x, y) { deleted_lines = 0; for (i = 0; i < PIECE_H; i++) { @@ -278,7 +288,10 @@ function update_field( deleted_lines, is_line_created, i, x, y) { lines += deleted_lines; score += (deleted_lines * 2 \ + int(deleted_lines / PIECE_H) \ - - 1) * 100 * level; + - 1) * SCORE_UNIT * level; + if (_is_all_clear()) { + score += SCORE_UNIT * 10 * (field_w - BORDER_W); + } if (curr_level_exp >= next_level_exp) { level_up(); }