snaker 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/snaker +3 -0
- data/snaker.rb +14 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3a3cfc9fd4adcdd30afa66f90716dbf316bf7cb46c749e0bf0b71ce2abf7c432
|
4
|
+
data.tar.gz: b1a1af313addd79a1cd3e7aef43fc6c7a6684ce342439e795304bde6954b819f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 294b3dea9b44aafd5d6c9353a36b9b8fd3dd31d7f87160ca06f2213a495302b6eeb8a717f718c6972c67891c8b4e12f0bd95c31c568d2a7362abf8fb5c4aeaab
|
7
|
+
data.tar.gz: fbe531325f308a6ff2209947e44e1d7bbc16128f6d3a5d4972695ecb2d7129aaf22fc3640c17a0fc35a57d9bdee3d20afda00d69062a3a2fe6367d6995153c3a
|
data/bin/snaker
ADDED
data/snaker.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
R="\e[31m\u25C6\e[0m\e[32m ";U="\n\r";B="\u25FC ";Y="\u25CB ";$t=ARGV.first
|
2
|
+
.to_i.yield_self{|s|(s>12)?s:12};$r=0...$t+2;$i=[];$c=[];$k=[0,1];$x=->{$l=
|
3
|
+
[rand(1..$t),rand(1..$t)]while$l.nil?||$i[$l[0]][$l[1]]==B;$i[$l.first][$l[
|
4
|
+
1]]=R};require'io/console';$p=0;$s=0;$r.each{|x|$i.push$r.each_with_object(
|
5
|
+
[]){|y,r|r.push(x.between?(1,$t)&&y.between?(1,$t)?(Y):(B))}};Thread.new{$x
|
6
|
+
.();3.times{|i|$i[$t][1+i]=B;$c[i]=[$t,1+i]};loop{r=$c[$c.count-1][0];c=$c[
|
7
|
+
$c.size-1][1];(exit)if$i[r+$k[0]][c+$k[1]]==B;$i[r+$k.first][c+$k[1]]=B;$c.
|
8
|
+
push([r+$k[0],c+$k[1]]);(r==$l[0]&&c==$l[1])?($x.();$p+=(100-$s*10).itself.
|
9
|
+
yield_self{|a|a<1?1:(a)}+$u;$s=0):($i[$c[0][0]][$c[0][1]]=Y;$c.shift;$s+=1)
|
10
|
+
$u=($c.size-3)/10.0;system'clear';puts"\e[32m";$i.map(&lambda{|r|r.map(&$s.
|
11
|
+
method(:print));print(U)});print"\e[0mPoints:#{$p.to_i}#{U.to_s}Level:#{$u.
|
12
|
+
floor}#{U}Gems:#{($u*10).round(0)}";print(U);sleep(0.3-$u.floor.to_f/50.0)}
|
13
|
+
};loop{$stdin.getch;k=$stdin.read_nonblock(2)rescue(nil);$k=(k=='[A')?([-1,
|
14
|
+
0]):((k=='[B')?([1,0]):((k=='[C')?([0,1]):((k.eql?'[D')?([0,-1]):(exit))))}
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: snaker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Maciej Mensfeld
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: You can play on your production servers while pretending to work.
|
14
|
+
email:
|
15
|
+
- maciej@mensfeld.pl
|
16
|
+
executables:
|
17
|
+
- snaker
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/snaker
|
22
|
+
- snaker.rb
|
23
|
+
homepage: https://github.com/mensfeld/snaker
|
24
|
+
licenses:
|
25
|
+
- GPL-3.0 License
|
26
|
+
metadata:
|
27
|
+
source_code_uri: https://github.com/mensfeld/snaker
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubygems_version: 3.1.4
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Pure Ruby implementation of the Snake game.
|
47
|
+
test_files: []
|