timequiz 0.1.7 → 0.2
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 +4 -4
- data/lib/console.rb +24 -15
- data/lib/events.rb +2 -2
- data/lib/timequiz.rb +0 -1
- data/lib/user_input.rb +6 -4
- data/lib/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 161df9cb4463fb4472eccf28b3a6eeb622d53565657f1a7f49e5ac427ffa785d
|
|
4
|
+
data.tar.gz: aaeb2fac8f159d546e7287cbd58373495e205c7a8a7de667ded43e4a1243cc95
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0270c77e8884705fb75d1ecd598d71798fc674961babc9567c8ebdc5682e0f1c572e6f5ad51b63ed559457441ecb487fe47dbfc5d9c0a9843c26c42a47659b78
|
|
7
|
+
data.tar.gz: 7f823869746b8eb95a0dbbd182dec42397b864d793225a2954daca3a56c0b0f987f0415957580bcd7ec8843313334fd5e1ad42d12c0043b7194847d4c4adbc32
|
data/lib/console.rb
CHANGED
|
@@ -21,6 +21,18 @@ require_relative 'constants'
|
|
|
21
21
|
module Console
|
|
22
22
|
# Some definitions which may change one day, become configurable one day,
|
|
23
23
|
# need to be accessed (one day) from somewhere else or not.
|
|
24
|
+
|
|
25
|
+
@@won_text = %q"__ __ _ __ __
|
|
26
|
+
\ \/ /___ __ __ | | / /___ ____ / /
|
|
27
|
+
\ / __ \/ / / / | | /| / / __ \/ __ \ / /
|
|
28
|
+
/ / /_/ / /_/ / | |/ |/ / /_/ / / / / /_/
|
|
29
|
+
/_/\____/\__,_/ |__/|__/\____/_/ /_/ (_)"
|
|
30
|
+
@@fail_text = %q" __
|
|
31
|
+
__ __ _ | |
|
|
32
|
+
| | |___ _ _ | |___ ___ ___ | |
|
|
33
|
+
|_ _| . | | | | | . |_ -| -_| |__|
|
|
34
|
+
|_| |___|___| |_|___|___|___| |__|"
|
|
35
|
+
|
|
24
36
|
@@win_sequence = %w"won.. won.. Won.. WOn.. wON.. wON!. woN!! won!! won.! won.. _on.. __n.. ___.. ___.. w__.. wo_.. "
|
|
25
37
|
@@wait_sequence = %w"U\ V\ Y\ T\ |\ ¦\ :\ .\ _\ .\ o\ O\ "
|
|
26
38
|
@@fail_sequence = %w":-|\ :-|\ :-[\ :-[\ :-(\ :-(\ 8-(\ 8-(\ 8-(\ 8-(\ 8-(\ 8-(\ 8-(\ 8-(\ .... |... lo.. Los. LOso LOSe LOSE lOSE loSE lose"
|
|
@@ -29,7 +41,7 @@ module Console
|
|
|
29
41
|
def start_game
|
|
30
42
|
available = $events
|
|
31
43
|
clear
|
|
32
|
-
puts "
|
|
44
|
+
puts bold("\nPut the following events into the right chronological order (e.g.: 2 3 1).")
|
|
33
45
|
@m_events = Array.new
|
|
34
46
|
out = ''
|
|
35
47
|
$num_events.times do |i|
|
|
@@ -45,7 +57,7 @@ module Console
|
|
|
45
57
|
|
|
46
58
|
response = int_array_input($num_events, (1..$num_events) )
|
|
47
59
|
if response == :quit_game
|
|
48
|
-
score @@points
|
|
60
|
+
score @@points, true
|
|
49
61
|
exit true
|
|
50
62
|
end
|
|
51
63
|
|
|
@@ -54,23 +66,22 @@ module Console
|
|
|
54
66
|
if good_order(response)
|
|
55
67
|
@@points += $num_events
|
|
56
68
|
win
|
|
57
|
-
score(@@points)
|
|
58
69
|
else
|
|
59
70
|
lose
|
|
60
|
-
score(@@points)
|
|
61
71
|
end
|
|
72
|
+
score(@@points)
|
|
62
73
|
|
|
63
74
|
# Start the loop. Add events as requested.
|
|
64
75
|
until @m_events.length == $MAX_NUM_EVENTS do
|
|
65
76
|
ui = ask_new_event
|
|
66
77
|
if ui == :quit_game
|
|
67
|
-
score @@points
|
|
78
|
+
score @@points, true
|
|
68
79
|
exit true
|
|
69
80
|
end
|
|
70
81
|
if('a' == ui)
|
|
71
82
|
ev = new_event
|
|
72
83
|
if ev == :all_events_done
|
|
73
|
-
score(@@points)
|
|
84
|
+
score(@@points, true)
|
|
74
85
|
exit true
|
|
75
86
|
end
|
|
76
87
|
|
|
@@ -78,7 +89,7 @@ module Console
|
|
|
78
89
|
# 1) exclude new event from the choices (hence -1), allow 0 as 'earlier than any'.
|
|
79
90
|
r = int_input(0..(@m_events.length - 1) )
|
|
80
91
|
if r == :quit_game
|
|
81
|
-
score @@points
|
|
92
|
+
score @@points, true
|
|
82
93
|
exit true
|
|
83
94
|
end
|
|
84
95
|
# User-input can be 0, which complicates the comparison with the
|
|
@@ -98,11 +109,10 @@ module Console
|
|
|
98
109
|
if ok
|
|
99
110
|
@@points += 1
|
|
100
111
|
win
|
|
101
|
-
score(@@points)
|
|
102
112
|
else
|
|
103
113
|
lose
|
|
104
|
-
score(@@points)
|
|
105
114
|
end
|
|
115
|
+
score(@@points)
|
|
106
116
|
else
|
|
107
117
|
detail( a2i(ui) )
|
|
108
118
|
end
|
|
@@ -154,18 +164,17 @@ module Console
|
|
|
154
164
|
UserInput::input()
|
|
155
165
|
end
|
|
156
166
|
|
|
157
|
-
def score(pts)
|
|
158
|
-
|
|
167
|
+
def score(pts, all_done = false)
|
|
168
|
+
intro = (all_done ? 'Final score' : 'Current score')
|
|
169
|
+
puts ' (' << intro << ': %i %s)' %[pts, (pts == 1 ? 'point' : 'points')]
|
|
159
170
|
end
|
|
160
171
|
|
|
161
172
|
def lose
|
|
162
|
-
|
|
163
|
-
wait @@fail_sequence, 1, cmt
|
|
173
|
+
wait @@fail_sequence, 1, red(@@fail_text )
|
|
164
174
|
end
|
|
165
175
|
|
|
166
176
|
def win
|
|
167
|
-
|
|
168
|
-
wait(@@win_sequence, 1, cmt)
|
|
177
|
+
wait(@@win_sequence, 1, green(@@won_text) )
|
|
169
178
|
end
|
|
170
179
|
|
|
171
180
|
def show_correct_order
|
data/lib/events.rb
CHANGED
|
@@ -26,8 +26,8 @@ $events << ['Foundation of the Royal Society in London', 1660, 'From its first m
|
|
|
26
26
|
$events << ['Galileo Galilée observes the first known satellites of Jupiter', 1610, 'A few weeks after his observations, Galileo determined that he was observing not stars, but objects in orbit around Jupiter. Today, Jupiter’s four largest satellites—Io, Europa, Ganymede, and Callisto—are named the Galilean moons in honor of their discoverer.']
|
|
27
27
|
$events << ['The Persian astronomer Al Soufi is born', 903, 'Abd-al-Rahman Al Sufi published his famous "Book of Fixed Stars" in 964 describing much of his work, both in textual descriptions and pictures. In his descriptions and pictures of Andromeda, he included "A Little Cloud" which is actually the Andromeda Galaxy M31.']
|
|
28
28
|
$events << ["Failed British Macartney Embassy in China",1793, 'The British mission traveled to China in 1792–93 in an attempt to secure more favourable trade and diplomatic relations for the United Kingdom. Macartney was expected by his hosts to kneel three times and to touch his head several times on the ground in acknowledgment of the emperor as the “son of heaven” (tianzi) and of China as the Central Kingdom (Zhongguo). He refused to kowtow, however, and instead went down on only one knee, as he would before a British monarch. The whole mission was marked by misunderstandings, and the Embassy failed to achieve its goals.']
|
|
29
|
-
$events << ['Copernicus publishes “De revolutionibus orbium coelestium”', 1543,'
|
|
30
|
-
$events << ['
|
|
29
|
+
$events << ['Copernicus publishes “De revolutionibus orbium coelestium”', 1543,"Copernicus' major work, first edition 1543 in Nuremberg, was a compendium of six books published during the year of his death, though he had arrived at his theory several decades earlier: Copernicus held that the Earth is another planet revolving around the fixed Sun once a year and turning on its axis once a day."]
|
|
30
|
+
$events << ['First universal time, “Greenich Meen Time”', 1884, 'People had been trying to standardise time for years, but nobody could agree. And so, to settle the subject once and for all, in 1884 a conference was called by the president of the USA, Chester Arthur. On 13 October 1884, the International Meridian Conference resolved by 22 votes to one, and two abstentions (one of which was France, obviously), that Greenwich would be the prime meridian of longitude.']
|
|
31
31
|
$events << ['Begining of the Islamic Calendar', 622, 'The Islamic Calendar, also known as the Hijri or lunar calendar, began on July 16, 622 CE, marking the first day of the first year of the Hegira (Hijra). This significant event commemorates the migration of the Prophet Muhammad from Mecca to Medina, a pivotal moment in Islamic history that not only shaped the early Muslim community but also established a new chronological framework for Muslims.']
|
|
32
32
|
$events << ['Introduction of the Gregorian Calendar', 1582, 'After centuries, the Julian Calendar had added ten days too many to the calendar, so Pope Gregory decreed that the day after the 4th of October 1582 should be the 15th of October 1582, thus correcting the error.']
|
|
33
33
|
$events << ['The Tunguska event', 1908, 'On June 30, 1908, an asteroid plunged into Earth’s atmosphere and exploded in the skies over Siberia. Local eyewitnesses in the sparsely populated region reported seeing a fireball and hearing a large explosion. They also reported massive forest fires, and trees blown over for miles (NASA).']
|
data/lib/timequiz.rb
CHANGED
|
@@ -175,7 +175,6 @@ class Timequiz
|
|
|
175
175
|
# response.each_with_index {|r, i| response_years[r-1] = @m_events[i].year}
|
|
176
176
|
response.each_with_index {|r, i| response_years[i] = @m_events[r-1].year}
|
|
177
177
|
debug('response is ' << response.join(', ') << "\nresponse_years is : " << response_years.join(', ') )
|
|
178
|
-
puts 'response is ' << response.join(', ') << "\nresponse_years is : " << response_years.join(', ')
|
|
179
178
|
|
|
180
179
|
# do not change the displayed index
|
|
181
180
|
sort_years(false)
|
data/lib/user_input.rb
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
require 'io/wait'
|
|
19
19
|
require 'io/console'
|
|
20
|
+
require_relative 'color_output'
|
|
20
21
|
|
|
21
22
|
# Provides functions to convert terminal input to desired data-types and does
|
|
22
23
|
# some verifications.
|
|
@@ -141,15 +142,16 @@ class UserInput
|
|
|
141
142
|
ar = []
|
|
142
143
|
until ar.length == len
|
|
143
144
|
if(range)
|
|
144
|
-
print ' (Available: '
|
|
145
|
+
print bold(' (Available: ')
|
|
145
146
|
disp = range.to_a - ar
|
|
146
147
|
if disp.length > 2
|
|
147
|
-
|
|
148
|
+
print disp.join(', ')
|
|
148
149
|
elsif disp.length == 2
|
|
149
|
-
|
|
150
|
+
print disp.first.to_s << ' or ' << disp.last.to_s
|
|
150
151
|
else
|
|
151
|
-
|
|
152
|
+
print disp.first.to_s
|
|
152
153
|
end
|
|
154
|
+
puts bold(')')
|
|
153
155
|
end
|
|
154
156
|
|
|
155
157
|
begin
|
data/lib/version.rb
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
***************************************************************************/
|
|
16
16
|
=end
|
|
17
17
|
|
|
18
|
-
VERSION = '0.
|
|
19
|
-
SUMMARY = '
|
|
18
|
+
VERSION = '0.2'
|
|
19
|
+
SUMMARY = 'Nicer console output.'
|
|
20
20
|
AUTHOR = 'Michael Uplawski'
|
|
21
21
|
AUTHOR_MAIL = '<michael.uplawski@uplawski.eu>'
|
|
22
22
|
YEARS = 2017 - 2025
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: timequiz
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: '0.2'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Uplawski
|
|
@@ -58,5 +58,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
58
58
|
requirements: []
|
|
59
59
|
rubygems_version: 3.6.7
|
|
60
60
|
specification_version: 4
|
|
61
|
-
summary:
|
|
61
|
+
summary: Nicer console output.
|
|
62
62
|
test_files: []
|