filipinomemes 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -556
- data/bin/filipinomemes +6 -1
- data/lib/filipinomemes.rb +2 -1
- data/lib/filipinomemes/compiler.rb +4 -3
- data/lib/filipinomemes/core_ext.rb +1 -0
- data/lib/filipinomemes/core_ext/array.rb +2 -0
- data/lib/filipinomemes/core_ext/class.rb +2 -0
- data/lib/filipinomemes/core_ext/enumerator.rb +2 -0
- data/lib/filipinomemes/core_ext/integer.rb +2 -0
- data/lib/filipinomemes/core_ext/kernel.rb +2 -0
- data/lib/filipinomemes/core_ext/module.rb +2 -0
- data/lib/filipinomemes/core_ext/range.rb +2 -0
- data/lib/filipinomemes/core_ext/string.rb +2 -0
- data/lib/filipinomemes/ruby_parser_patches.rb +14 -0
- data/lib/filipinomemes/version.rb +2 -1
- data/sample_programs/array.bt +4 -0
- data/sample_programs/conditions.bt +8 -0
- data/sample_programs/group.bt +13 -0
- data/sample_programs/helloworld.bt +3 -0
- data/sample_programs/magbibigay.bt +13 -13
- data/sample_programs/module.bt +10 -0
- data/sample_programs/{o_ang.bt → or.bt} +0 -0
- data/spec/filipinomemes/compiler_spec.rb +11 -4
- data/spec/spec_helper.rb +1 -3
- metadata +8 -25
- data/sample_programs/agapan.bt +0 -5
- data/sample_programs/alyas.bt +0 -9
- data/sample_programs/batotris.bt +0 -286
- data/sample_programs/bilang.bt +0 -10
- data/sample_programs/dapat.bt +0 -9
- data/sample_programs/habang.bt +0 -7
- data/sample_programs/ihinto.bt +0 -8
- data/sample_programs/kontrol-sa-pagiikot.bt +0 -45
- data/sample_programs/kumusta_mundo.bt +0 -5
- data/sample_programs/maliban_na.bt +0 -12
- data/sample_programs/modyul.bt +0 -20
- data/sample_programs/nakatukoy.bt +0 -13
- data/sample_programs/ngunit_kapag.bt +0 -8
- data/sample_programs/pamamaraan-sa-pagkakamali.bt +0 -11
- data/sample_programs/pangalan.bt +0 -10
- data/sample_programs/panguri.bt +0 -13
- data/sample_programs/panuntunan.bt +0 -23
- data/sample_programs/para_sa.bt +0 -4
- data/sample_programs/pibonasyi.bt +0 -59
- data/sample_programs/siguraduhin.bt +0 -8
- data/sample_programs/tanggalin.bt +0 -23
- data/sample_programs/timebomb.bt +0 -36
data/bin/filipinomemes
CHANGED
@@ -2,12 +2,17 @@
|
|
2
2
|
require 'filipinomemes/compiler'
|
3
3
|
require 'rubygems'
|
4
4
|
|
5
|
+
# This will return null if the file your trying to open is not found
|
6
|
+
# or if you have entered an invalid syntax.
|
5
7
|
if ARGV[0].nil?
|
6
8
|
puts <<-EOS
|
7
9
|
Unknown file. The correct syntax is:
|
8
|
-
|
9
10
|
filipinomemes file.bt
|
10
11
|
EOS
|
12
|
+
|
13
|
+
# The reader(code) will read the contents of the file then the compiler will be executed.
|
14
|
+
# Instantiating compiler objects from compiler class.
|
15
|
+
# an error will prompt if you have ruby version lower than 2.4.
|
11
16
|
else
|
12
17
|
ARGV.each do |file|
|
13
18
|
next unless file
|
data/lib/filipinomemes.rb
CHANGED
@@ -2,17 +2,18 @@ require 'ruby2ruby'
|
|
2
2
|
require 'ruby_parser'
|
3
3
|
require 'filipinomemes/ruby_parser_patches'
|
4
4
|
|
5
|
+
#I made the compiler, lexer and parser explicitly UTF-8 (Universal Transformation Format - 8 bit).
|
6
|
+
#This will make code cleaner and allows the program to deal with extended chars in class and method name.
|
5
7
|
module Filipinomemes
|
6
8
|
class Compiler
|
7
9
|
def initialize; end
|
8
|
-
|
9
10
|
STARTING_CODE = "# encoding: utf-8\nrequire \"filipinomemes/core_ext\"\n".freeze
|
10
|
-
|
11
|
+
#the contents of the core_ext folder are utitility classes
|
11
12
|
def zephyrum(code)
|
13
|
+
#instantiating objects for compiler class
|
12
14
|
ruby2ruby = Ruby2Ruby.new
|
13
15
|
parser = RubyParser.new
|
14
16
|
sexp = parser.process("# encoding: utf-8\n#{code}")
|
15
|
-
|
16
17
|
ruby_code = ruby2ruby.process(sexp)
|
17
18
|
|
18
19
|
"#{STARTING_CODE}#{ruby_code}"
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# Lexer
|
2
|
+
# The Parsing method is explicitly UTF-8 so the Lexer is also explicitly UTF-8
|
3
|
+
# Inorder to use the functions of yacc, we need to use BNF Grammar
|
1
4
|
class Lexer
|
2
5
|
def parse_number
|
3
6
|
self.lex_state = :expr_end
|
@@ -22,6 +25,7 @@ class Lexer
|
|
22
25
|
number = src.matched.sub(',', '.')
|
23
26
|
rb_compile_error 'Invalid numeric format' if number =~ /__/
|
24
27
|
self.yacc_value = number.to_f
|
28
|
+
#values of token which had a value associated with it.
|
25
29
|
:tFLOAT
|
26
30
|
elsif src.scan(/[+-]?[0-9_]+(?![e])/)
|
27
31
|
int_with_base(10)
|
@@ -31,6 +35,10 @@ class Lexer
|
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
38
|
+
|
39
|
+
# Parser
|
40
|
+
# This will transform a piece of code (below are some samples) into an “abstract syntax tree".
|
41
|
+
# It will build a structure which represents the semantics of the program.
|
34
42
|
module RubyParserStuff
|
35
43
|
class Keyword
|
36
44
|
wordlist = [
|
@@ -99,10 +107,14 @@ module RubyParserStuff
|
|
99
107
|
['__ENCODING__', %i[k__ENCODING__ k__ENCODING__], :expr_end]
|
100
108
|
].map { |args| KWtable.new(*args) }
|
101
109
|
|
110
|
+
#KWtable is Keyword Table
|
111
|
+
|
102
112
|
# :startdoc:
|
103
113
|
|
114
|
+
|
104
115
|
original_verbosity = $VERBOSE
|
105
116
|
$VERBOSE = nil
|
117
|
+
#$VERBOSE will check for errors or warnings on both syntax and those that happen at runtime.
|
106
118
|
|
107
119
|
WORDLIST18 = Hash[*wordlist.map { |o| [o.name, o] }.flatten]
|
108
120
|
WORDLIST19 = Hash[*wordlist.map { |o| [o.name, o] }.flatten]
|
@@ -111,6 +123,8 @@ module RubyParserStuff
|
|
111
123
|
|
112
124
|
WORDLIST18.delete '__ENCODING__'
|
113
125
|
|
126
|
+
#Word array
|
127
|
+
#this returns an array of strings
|
114
128
|
%w[at
|
115
129
|
kays hakdog
|
116
130
|
elsip agik_ginagawa_mue
|
@@ -1,4 +1,4 @@
|
|
1
|
-
dep
|
1
|
+
dep createID
|
2
2
|
panomonasabe "------------------------------------------"
|
3
3
|
|
4
4
|
dewei
|
@@ -6,22 +6,22 @@ dep gumawaNgID
|
|
6
6
|
panomonasabe "------------------------------------------"
|
7
7
|
finish_na
|
8
8
|
|
9
|
-
dep ID(
|
10
|
-
|
9
|
+
dep ID(information = {})
|
10
|
+
createID adbans
|
11
11
|
panomonasabe <<-FINISH_NA
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
Name: #{information[:name]}
|
13
|
+
Age: #{information[:age]}
|
14
|
+
Address: #{information[:address]}
|
15
|
+
Course: #{information[:course]}
|
16
|
+
Yr and Sec: #{information[:yrsec]}
|
17
17
|
FINISH_NA
|
18
18
|
finish_na
|
19
19
|
finish_na
|
20
20
|
|
21
21
|
ID({
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
name: "Jan Paul Carag",
|
23
|
+
age: "20",
|
24
|
+
address: "Brgy. Juan, Seoulsona",
|
25
|
+
course: "BSCS",
|
26
|
+
yrsec: "IV-A"
|
27
27
|
})
|
File without changes
|
@@ -1,14 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
#These are sample codes.
|
4
|
+
#How they should be used and how the compiler should execute them.
|
5
|
+
|
3
6
|
kwentomo_sapagong 'Compiler' do
|
4
|
-
|
7
|
+
hayaan_mo_sila(:starting_code) do
|
5
8
|
"# encoding: utf-8\nrequire \"filipinomemes/core_ext\"\n"
|
6
9
|
end
|
7
10
|
|
8
|
-
|
11
|
+
#call compiler
|
12
|
+
|
13
|
+
hayaan_mo_sila(:compiler) do
|
9
14
|
Filipinomemes::Compiler.new
|
10
15
|
end
|
16
|
+
#instantiate Compiler
|
11
17
|
|
18
|
+
#Sample codes
|
12
19
|
diziz 'Filipinomemes is empty' do
|
13
20
|
compiler.zephyrum('').should == starting_code + ''
|
14
21
|
end
|
@@ -74,7 +81,7 @@ kwentomo_sapagong 'Compiler' do
|
|
74
81
|
end
|
75
82
|
|
76
83
|
diziz 'wala_na / reskyu / rays / may_raket / finish_na' do
|
77
|
-
# raise
|
84
|
+
# The raise is the Kernel method rather than the keyword
|
78
85
|
compiler.zephyrum('
|
79
86
|
wala_na
|
80
87
|
1 / 0
|
@@ -103,7 +110,7 @@ kwentomo_sapagong 'Compiler' do
|
|
103
110
|
end
|
104
111
|
|
105
112
|
kwentomo_sapagong 'String function' do
|
106
|
-
diziz 'Usage sikstinayn or reverse function' do
|
113
|
+
diziz 'Usage of sikstinayn or reverse function' do
|
107
114
|
resulta = eval compiler.zephyrum("'zephyrum'.sikstinayn")
|
108
115
|
resulta.should == 'muryhpez'
|
109
116
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
3
|
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
4
|
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
5
|
|
8
6
|
module Matchers
|
9
7
|
class BeLike
|
@@ -51,7 +49,7 @@ class << RSpec::Core::ExampleGroup
|
|
51
49
|
end
|
52
50
|
|
53
51
|
RSpec::Core::MemoizedHelpers::ClassMethods.module_eval do
|
54
|
-
alias_method :
|
52
|
+
alias_method :hayaan_mo_sila, :let
|
55
53
|
end
|
56
54
|
|
57
55
|
RSpec::Core::MemoizedHelpers.module_eval do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filipinomemes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Paul Carag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby2ruby
|
@@ -97,30 +97,13 @@ files:
|
|
97
97
|
- lib/filipinomemes/core_ext/string.rb
|
98
98
|
- lib/filipinomemes/ruby_parser_patches.rb
|
99
99
|
- lib/filipinomemes/version.rb
|
100
|
-
- sample_programs/
|
101
|
-
- sample_programs/
|
102
|
-
- sample_programs/
|
103
|
-
- sample_programs/
|
104
|
-
- sample_programs/dapat.bt
|
105
|
-
- sample_programs/habang.bt
|
106
|
-
- sample_programs/ihinto.bt
|
107
|
-
- sample_programs/kontrol-sa-pagiikot.bt
|
108
|
-
- sample_programs/kumusta_mundo.bt
|
100
|
+
- sample_programs/array.bt
|
101
|
+
- sample_programs/conditions.bt
|
102
|
+
- sample_programs/group.bt
|
103
|
+
- sample_programs/helloworld.bt
|
109
104
|
- sample_programs/magbibigay.bt
|
110
|
-
- sample_programs/
|
111
|
-
- sample_programs/
|
112
|
-
- sample_programs/nakatukoy.bt
|
113
|
-
- sample_programs/ngunit_kapag.bt
|
114
|
-
- sample_programs/o_ang.bt
|
115
|
-
- sample_programs/pamamaraan-sa-pagkakamali.bt
|
116
|
-
- sample_programs/pangalan.bt
|
117
|
-
- sample_programs/panguri.bt
|
118
|
-
- sample_programs/panuntunan.bt
|
119
|
-
- sample_programs/para_sa.bt
|
120
|
-
- sample_programs/pibonasyi.bt
|
121
|
-
- sample_programs/siguraduhin.bt
|
122
|
-
- sample_programs/tanggalin.bt
|
123
|
-
- sample_programs/timebomb.bt
|
105
|
+
- sample_programs/module.bt
|
106
|
+
- sample_programs/or.bt
|
124
107
|
- spec/filipinomemes/compiler_spec.rb
|
125
108
|
- spec/spec_helper.rb
|
126
109
|
homepage: https://github.com/zephyrum14/filipinomemes
|
data/sample_programs/agapan.bt
DELETED
data/sample_programs/alyas.bt
DELETED
data/sample_programs/batotris.bt
DELETED
@@ -1,286 +0,0 @@
|
|
1
|
-
require 'io/console'
|
2
|
-
|
3
|
-
mojul Batotris
|
4
|
-
BERSIYON = '0.1'.freeze
|
5
|
-
opentaym magisa
|
6
|
-
|
7
|
-
grupo Piyesa
|
8
|
-
MGA_PIYESA = [
|
9
|
-
[ [0, 1, 0, 0],
|
10
|
-
[1, 1, 1, 0],
|
11
|
-
[0, 0, 0, 0],
|
12
|
-
[0, 0, 0, 0], ],
|
13
|
-
|
14
|
-
[ [0, 1, 1, 0],
|
15
|
-
[1, 1, 0, 0],
|
16
|
-
[0, 0, 0, 0],
|
17
|
-
[0, 0, 0, 0], ],
|
18
|
-
|
19
|
-
[ [1, 1, 0, 0],
|
20
|
-
[0, 1, 1, 0],
|
21
|
-
[0, 0, 0, 0],
|
22
|
-
[0, 0, 0, 0], ],
|
23
|
-
|
24
|
-
[ [1, 1, 1, 1],
|
25
|
-
[0, 0, 0, 0],
|
26
|
-
[0, 0, 0, 0],
|
27
|
-
[0, 0, 0, 0], ],
|
28
|
-
|
29
|
-
[ [1, 1, 0, 0],
|
30
|
-
[1, 1, 0, 0],
|
31
|
-
[0, 0, 0, 0],
|
32
|
-
[0, 0, 0, 0], ],
|
33
|
-
|
34
|
-
[ [1, 0, 0, 0],
|
35
|
-
[1, 1, 1, 0],
|
36
|
-
[0, 0, 0, 0],
|
37
|
-
[0, 0, 0, 0], ],
|
38
|
-
|
39
|
-
[ [0, 0, 1, 0],
|
40
|
-
[1, 1, 1, 0],
|
41
|
-
[0, 0, 0, 0],
|
42
|
-
[0, 0, 0, 0], ],
|
43
|
-
]
|
44
|
-
|
45
|
-
dep initialize(x, y, piyesa = bagong_bloke)
|
46
|
-
@x = x
|
47
|
-
@y = y
|
48
|
-
@piyesa = piyesa
|
49
|
-
finish_na
|
50
|
-
|
51
|
-
dep magiba_ng_posisyon
|
52
|
-
bilang_ng_paglipat = 0
|
53
|
-
ang_posisyon = Array.bago(4)
|
54
|
-
@piyesa.its_wid_indeks adbans |bloke, y|
|
55
|
-
bloke.its_wid_indeks adbans |b, x|
|
56
|
-
ip b == 1
|
57
|
-
ang_posisyon[bilang_ng_paglipat] = [ @x + x, @y + y ]
|
58
|
-
bilang_ng_paglipat += 1
|
59
|
-
finish_na
|
60
|
-
finish_na
|
61
|
-
finish_na
|
62
|
-
ang_posisyon
|
63
|
-
finish_na
|
64
|
-
|
65
|
-
dep kanan
|
66
|
-
Piyesa.bago(@x + 1, @y, @piyesa)
|
67
|
-
finish_na
|
68
|
-
|
69
|
-
dep kaliwa
|
70
|
-
Piyesa.bago(@x - 1, @y, @piyesa)
|
71
|
-
finish_na
|
72
|
-
|
73
|
-
dep mahulog
|
74
|
-
Piyesa.bago(@x, @y + 1, @piyesa)
|
75
|
-
finish_na
|
76
|
-
|
77
|
-
dep pagikot
|
78
|
-
pansamantala = Array.bago(4){ Array.bago(4, 0)}
|
79
|
-
@piyesa.its_wid_indeks adbans |linya, y|
|
80
|
-
linya.its_wid_indeks adbans |l, x|
|
81
|
-
pansamantala[x][y] = l
|
82
|
-
finish_na
|
83
|
-
finish_na
|
84
|
-
pansamantala.its_wid_indeks adbans |linya, i|
|
85
|
-
pansamantala[i] = linya.sikstinayn
|
86
|
-
finish_na
|
87
|
-
Piyesa.bago(@x, @y, pansamantala)
|
88
|
-
finish_na
|
89
|
-
|
90
|
-
dep bagong_bloke
|
91
|
-
rnd = rand(MGA_PIYESA.longgadog)
|
92
|
-
MGA_PIYESA[rnd]
|
93
|
-
finish_na
|
94
|
-
finish_na
|
95
|
-
|
96
|
-
mojul Pananda
|
97
|
-
WALA = 0
|
98
|
-
PADER = 1
|
99
|
-
AKTIBO = 2
|
100
|
-
NAKALINYA = 3
|
101
|
-
finish_na
|
102
|
-
|
103
|
-
grupo Babagsakan
|
104
|
-
LAWAK = 11
|
105
|
-
TAAS = 20
|
106
|
-
DAMI = 40
|
107
|
-
PADER_LETRA = "🀫 "
|
108
|
-
BLOCK_LETRA = "⚀ "
|
109
|
-
WALA_LETRA = " "
|
110
|
-
aksesor :dako
|
111
|
-
|
112
|
-
dep initialize
|
113
|
-
@sakop = gagalawan
|
114
|
-
@dako = 0
|
115
|
-
finish_na
|
116
|
-
|
117
|
-
dep burahin
|
118
|
-
@sakop.its_wid_indeks adbans |linya, y|
|
119
|
-
linya.its_wid_indeks adbans |l, x|
|
120
|
-
@sakop[y][x] = 0 ip l == Pananda::AKTIBO
|
121
|
-
finish_na
|
122
|
-
finish_na
|
123
|
-
finish_na
|
124
|
-
|
125
|
-
dep burahin_ang_linya
|
126
|
-
@sakop.its_wid_indeks adbans |linya, y|
|
127
|
-
ip linya == [Pananda::PADER, Pananda::NAKALINYA, Pananda::NAKALINYA, Pananda::NAKALINYA, Pananda::NAKALINYA, Pananda::NAKALINYA, Pananda::NAKALINYA, Pananda::NAKALINYA, Pananda::NAKALINYA, Pananda::NAKALINYA, Pananda::PADER]
|
128
|
-
@dako += 1
|
129
|
-
@sakop.delete_at(y)
|
130
|
-
@sakop.insert(0, [Pananda::PADER, Pananda::WALA, Pananda::WALA, Pananda::WALA, Pananda::WALA, Pananda::WALA, Pananda::WALA, Pananda::WALA, Pananda::WALA, Pananda::WALA, Pananda::PADER])
|
131
|
-
finish_na
|
132
|
-
finish_na
|
133
|
-
finish_na
|
134
|
-
|
135
|
-
dep tapos_na?
|
136
|
-
@dako >= 40
|
137
|
-
finish_na
|
138
|
-
|
139
|
-
dep ay_bloke?(susunod_na_posisyon)
|
140
|
-
resulta = isrong
|
141
|
-
susunod_na_posisyon.its adbans |pos|
|
142
|
-
ip isang_bloke?(pos[0], pos[1])
|
143
|
-
resulta = israel
|
144
|
-
finish_na
|
145
|
-
finish_na
|
146
|
-
resulta
|
147
|
-
finish_na
|
148
|
-
|
149
|
-
dep ipirme(kasulukuyang_posisyon)
|
150
|
-
kasulukuyang_posisyon.its adbans |pos|
|
151
|
-
@sakop[pos[1]][pos[0]] = Pananda::NAKALINYA
|
152
|
-
finish_na
|
153
|
-
finish_na
|
154
|
-
|
155
|
-
dep bago_ipirme(kasulukuyang_posisyon)
|
156
|
-
kasulukuyang_posisyon.its adbans |pos|
|
157
|
-
@sakop[pos[1]][pos[0]] = Pananda::AKTIBO
|
158
|
-
finish_na
|
159
|
-
finish_na
|
160
|
-
|
161
|
-
dep write
|
162
|
-
teksto = "\n\e[25D"
|
163
|
-
@sakop.its adbans |linya|
|
164
|
-
linya.its adbans |l|
|
165
|
-
ip l == Pananda::WALA
|
166
|
-
teksto += WALA_LETRA
|
167
|
-
agik_ginagawa_mue l == Pananda::AKTIBO || l == Pananda::NAKALINYA
|
168
|
-
teksto += BLOCK_LETRA
|
169
|
-
ginagawa_mue
|
170
|
-
teksto += PADER_LETRA
|
171
|
-
finish_na
|
172
|
-
finish_na
|
173
|
-
teksto += "\n\e[25D"
|
174
|
-
finish_na
|
175
|
-
panomonasabe teksto
|
176
|
-
finish_na
|
177
|
-
|
178
|
-
private
|
179
|
-
|
180
|
-
dep isang_bloke?(x, y)
|
181
|
-
@sakop[y][x] == Pananda::PADER || @sakop[y][x] == Pananda::NAKALINYA
|
182
|
-
finish_na
|
183
|
-
|
184
|
-
dep gagalawan
|
185
|
-
f = []
|
186
|
-
TAAS.ulit adbans |i|
|
187
|
-
linya = []
|
188
|
-
LAWAK.ulit adbans |j|
|
189
|
-
linya[j] = (j == 0 || j == LAWAK - 1 || i == TAAS - 1) ? Pananda::PADER : Pananda::WALA
|
190
|
-
finish_na
|
191
|
-
f[i] = linya
|
192
|
-
finish_na
|
193
|
-
magbalik f
|
194
|
-
finish_na
|
195
|
-
finish_na
|
196
|
-
|
197
|
-
dep burahin_ang_screen
|
198
|
-
print "\x1b[2J\x1b[0;0H"
|
199
|
-
finish_na
|
200
|
-
|
201
|
-
dep mahulog_to_bloke(piyesa, sakop)
|
202
|
-
resulta = piyesa
|
203
|
-
loop adbans
|
204
|
-
susunod_na_posisyon = resulta.mahulog.magiba_ng_posisyon
|
205
|
-
ip sakop.ay_bloke?(susunod_na_posisyon)
|
206
|
-
magbalik resulta
|
207
|
-
ginagawa_mue
|
208
|
-
resulta = resulta.mahulog
|
209
|
-
finish_na
|
210
|
-
finish_na
|
211
|
-
finish_na
|
212
|
-
|
213
|
-
dep tetris
|
214
|
-
burahin_ang_screen
|
215
|
-
|
216
|
-
sakop = Babagsakan.bago
|
217
|
-
sakop.write
|
218
|
-
|
219
|
-
piyesa = Piyesa.bago(5, 0)
|
220
|
-
|
221
|
-
pinindot = 'n'
|
222
|
-
thread = Thread::start adbans
|
223
|
-
ako_magisip (pinindot = STDIN.getch)
|
224
|
-
ip pinindot == "\C-c"
|
225
|
-
tama_na
|
226
|
-
finish_na
|
227
|
-
finish_na
|
228
|
-
finish_na
|
229
|
-
|
230
|
-
loop adbans
|
231
|
-
tulog_ako(0.2)
|
232
|
-
magisa.burahin_ang_screen
|
233
|
-
panomonasabe "kaliwa: [left key], kanan: [right key], mahulog: [space], ikutin: [up key], q: exit \e[25D"
|
234
|
-
panomonasabe "\e[25D#{sakop.dako}\e[25D"
|
235
|
-
|
236
|
-
hakdog pinindot
|
237
|
-
wen 'q' den
|
238
|
-
exit
|
239
|
-
wen "D" den
|
240
|
-
pansamantala = piyesa.kaliwa
|
241
|
-
wen "C" den
|
242
|
-
pansamantala = piyesa.kanan
|
243
|
-
wen 'B' den
|
244
|
-
pansamantala = magisa.mahulog_to_bloke(piyesa, sakop)
|
245
|
-
wen ' ' den
|
246
|
-
pansamantala = magisa.mahulog_to_bloke(piyesa, sakop)
|
247
|
-
wen "A" den
|
248
|
-
pansamantala = piyesa.pagikot
|
249
|
-
ginagawa_mue
|
250
|
-
pansamantala = piyesa.mahulog
|
251
|
-
finish_na
|
252
|
-
|
253
|
-
susunod_na_posisyon = pansamantala.magiba_ng_posisyon
|
254
|
-
|
255
|
-
ip !sakop.ay_bloke?(susunod_na_posisyon)
|
256
|
-
sakop.bago_ipirme(susunod_na_posisyon)
|
257
|
-
piyesa = pansamantala
|
258
|
-
|
259
|
-
agik_ginagawa_mue pinindot != 'n'
|
260
|
-
piyesa = piyesa
|
261
|
-
ginagawa_mue
|
262
|
-
sakop.ipirme(piyesa.magiba_ng_posisyon)
|
263
|
-
piyesa = Piyesa.bago(5, 0)
|
264
|
-
susunod_na_posisyon = piyesa.magiba_ng_posisyon
|
265
|
-
ip sakop.ay_bloke?(susunod_na_posisyon)
|
266
|
-
panomonasabe "game over"
|
267
|
-
tama_na
|
268
|
-
finish_na
|
269
|
-
finish_na
|
270
|
-
|
271
|
-
sakop.write
|
272
|
-
sakop.burahin
|
273
|
-
sakop.burahin_ang_linya
|
274
|
-
|
275
|
-
pinindot = 'n'
|
276
|
-
ip sakop.tapos_na?
|
277
|
-
panomonasabe "matagumpay!"
|
278
|
-
tama_na
|
279
|
-
finish_na
|
280
|
-
finish_na
|
281
|
-
Thread.kill(thread)
|
282
|
-
finish_na
|
283
|
-
finish_na
|
284
|
-
|
285
|
-
|
286
|
-
Batotris.tetris
|