console-tetris 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ea4f8df04182b22ced1835e19e5a7af68e68a2e
4
- data.tar.gz: 368d6f29f2b770bc4ea68b365abedd5a4d4b7f74
3
+ metadata.gz: b7a63eaef53112b4769b21342488b1f40eb0cda2
4
+ data.tar.gz: 94edf57be236fce05ad15668093522a3ee4abf2d
5
5
  SHA512:
6
- metadata.gz: 90e1228d4f0373fc82fd2b2ca02d3cba89ddfd15d532d6209f0816579306b32b780efceb1d71e6328dda0af5f1870edcd48b7464e42f537e2f909442757a9872
7
- data.tar.gz: 8a624b0564031794f2d6068987f82ae23c49cab44f13e11195193a56aee0e27ec7536985bf8204e572db3ef20391af50a5734c79cb848df92bce08da22c05ee2
6
+ metadata.gz: c4de5d34d902ecee323772f9437a3be3edfbf5b1fac57e6f906195b40933719afddd7dcc11ccfc6b68c52718a51bbe9a29f8945fbe8643e86057655c657572ef
7
+ data.tar.gz: 467dc3544d0bd71331916fa53936931cba34f2ff67a3c82c096f3db91eb5d5eb86349e3d416f12a97ef798aad530aa65ebc9d3c874c05b55c521efd265bd61f1
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # Console::Tetris
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/console_tetris`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
3
  ## Installation
8
4
 
9
5
  Add this line to your application's Gemfile:
@@ -20,17 +16,10 @@ Or install it yourself as:
20
16
 
21
17
  $ gem install console-tetris
22
18
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
19
+ ## Commands
32
20
 
33
- ## Contributing
21
+ `.` : move right
34
22
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/console-tetris. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
23
+ `z` : move left
36
24
 
25
+ `Enter` : rotate
@@ -17,8 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
18
  f.match(%r{^(test|spec|features)/})
19
19
  end
20
- spec.bindir = "exe"
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
22
21
  spec.require_paths = ["lib"]
23
22
 
24
23
  spec.add_development_dependency "bundler", "~> 1.13"
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ConsoleTetris
4
+ module AsciiArt
5
+ GAMEOVER = <<-'EOS'
6
+ _____ __ __ _____ ______ ________ _____
7
+ / ____| /\ | \/ || ___| / __ \ \ / / ____|| __ \
8
+ | | __ / \ | \ / || |__ | | | \ \ / /| |__ | |__) |
9
+ | | |_ | / /\ \ | |\/| || __| | | | |\ \/ / | __| | _ /
10
+ | |__| |/ ____ \| | | || |___ | |__| | \ / | |____ | | \ \
11
+ \_____/_/ \_\_| |_||_____| \____/ \/ |______||_| \_\
12
+ EOS
13
+
14
+ ONE = <<-'EOS'
15
+ __
16
+ /_ |
17
+ | |
18
+ | |
19
+ | |
20
+ |_|
21
+ EOS
22
+
23
+ TWO = <<-'EOS'
24
+ ___
25
+ |__ \
26
+ ) |
27
+ / /
28
+ / /_
29
+ |____|
30
+ EOS
31
+
32
+ THREE = <<-'EOS'
33
+ ____
34
+ |___ \
35
+ __) |
36
+ |__ <
37
+ ___) |
38
+ |____/
39
+ EOS
40
+
41
+ FOUR = <<-'EOS'
42
+ _ _
43
+ | || |
44
+ | || |_
45
+ |__ _|
46
+ | |
47
+ |_|
48
+ EOS
49
+
50
+ FIVE = <<-'EOS'
51
+ _____
52
+ | ____|
53
+ | |__
54
+ |___ \
55
+ ___) |
56
+ |____/
57
+ EOS
58
+
59
+ SIX = <<-'EOS'
60
+ __
61
+ / /
62
+ / /_
63
+ | '_ \
64
+ | (_) |
65
+ \___/
66
+ EOS
67
+
68
+ SEVEN = <<-'EOS'
69
+ ______
70
+ |____ |
71
+ / /
72
+ / /
73
+ / /
74
+ /_/
75
+ EOS
76
+
77
+ EIGHT = <<-'EOS'
78
+ ___
79
+ / _ \
80
+ | (_) |
81
+ > _ <
82
+ | (_) |
83
+ \___/
84
+ EOS
85
+
86
+ NINE = <<-'EOS'
87
+ ___
88
+ / _ \
89
+ | (_) |
90
+ \__, |
91
+ / /
92
+ /_/
93
+ EOS
94
+
95
+ ZERO = <<-'EOS'
96
+ ___
97
+ / _ \
98
+ | | | |
99
+ | | | |
100
+ | |_| |
101
+ \___/
102
+ EOS
103
+
104
+ NUMBER_TO_ENGLISH = {
105
+ 1 => 'one',
106
+ 2 => 'two',
107
+ 3 => 'three',
108
+ 4 => 'four',
109
+ 5 => 'five',
110
+ 6 => 'six',
111
+ 7 => 'seven',
112
+ 8 => 'eight',
113
+ 9 => 'nine',
114
+ 0 => 'zero'
115
+ }.freeze
116
+
117
+ module_function
118
+
119
+ def number_to_aa(number)
120
+ number_aas = number.to_s.chars.map {|c| const_get(NUMBER_TO_ENGLISH[c.to_i].upcase) }
121
+
122
+ splitted_number_aas = number_aas.map {|n| n.split("\n") }
123
+
124
+ 6.times.map {|i| splitted_number_aas.map {|aa| aa[i].to_s.ljust(8) }.join('') }.join("\n")
125
+ end
126
+ end
127
+ end
@@ -1,16 +1,10 @@
1
+ require_relative './ascii_art'
2
+
1
3
  class ConsoleTetris
2
4
  class BackgroundBoard
3
5
  attr_accessor :point
4
6
 
5
7
  BOARD_SIZE = {x: 10, y: 20}
6
- GAMEOVER = <<-'EOS'
7
- _____ __ __ _____ ______ ________ _____
8
- / ____| /\ | \/ || ___| / __ \ \ / / ____|| __ \
9
- | | __ / \ | \ / || |__ | | | \ \ / /| |__ | |__) |
10
- | | |_ | / /\ \ | |\/| || __| | | | |\ \/ / | __| | _ /
11
- | |__| |/ ____ \| | | || |___ | |__| | \ / | |____ | | \ \
12
- \_____/_/ \_\_| |_||_____| \____/ \/ |______||_| \_\
13
- EOS
14
8
 
15
9
  class << self
16
10
  def blank_board
@@ -78,8 +72,8 @@ class ConsoleTetris
78
72
  def print_gameover
79
73
  print "\e[2J"
80
74
  print "\e[1;1H"
81
- print "\e[G#{point.to_s.rjust(7, ' ')} 点!!!!\n"
82
- print GAMEOVER.gsub(/^/, "\e[G")
75
+ print "#{AsciiArt.number_to_aa(point).gsub(/^/, "\e[G")} Points!!!!\n"
76
+ print AsciiArt::GAMEOVER.gsub(/^/, "\e[G")
83
77
  end
84
78
  end
85
79
  end
@@ -1,3 +1,3 @@
1
1
  class ConsoleTetris
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console-tetris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pekepek
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,7 +55,8 @@ dependencies:
55
55
  description: you can play Tetris
56
56
  email:
57
57
  - ishihata@33i.co.jp
58
- executables: []
58
+ executables:
59
+ - console_tetris
59
60
  extensions: []
60
61
  extra_rdoc_files: []
61
62
  files:
@@ -66,6 +67,7 @@ files:
66
67
  - bin/console_tetris
67
68
  - console-tetris.gemspec
68
69
  - lib/console_tetris.rb
70
+ - lib/console_tetris/ascii_art.rb
69
71
  - lib/console_tetris/background_board.rb
70
72
  - lib/console_tetris/tetrimino.rb
71
73
  - lib/console_tetris/version.rb