cryptomania 2.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/cryptomania +5 -0
- data/config/environment.rb +8 -0
- data/lib/app/crypto_list.rb +59 -0
- data/lib/app/invested_crypto.rb +144 -0
- data/lib/app/player.rb +164 -0
- data/lib/app/scrapper.rb +99 -0
- data/lib/cryptomania.rb +169 -0
- data/utility/Crypto_Calculator.rb +22 -0
- data/utility/FancyText.rb +89 -0
- metadata +52 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f3d46f517bd16408053fbed118423e4b0032ebc628e7dd44cd68ad7a71bb3119
|
|
4
|
+
data.tar.gz: 51a59b5f74fe5418ddf270780c82616fe5bbb7abfb2ac785f987a76e81a90842
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 85e861229d5d9663fe955b672b6bf43945d78f75822719183e3b5228c93a4bb53162d5e16983dd42bd13cbc1cdbac2e2b0538428545d9c72289c2ada583cb2c0
|
|
7
|
+
data.tar.gz: 1c12b09bfa6f14ea409cd32953a8639dea98a00af3682c0b2fb29e5ebb7b06fb63c1e83a229ed0c63e1dc5108d2f07cd1043f207b87f3437fe16b8ffd0b0cfba
|
data/bin/cryptomania
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# require 'gemfile'
|
|
2
|
+
# require 'bundler/setup'
|
|
3
|
+
|
|
4
|
+
require_relative "../lib/cryptomania.rb"
|
|
5
|
+
require_relative "../lib/app/player.rb"
|
|
6
|
+
require_relative "../lib/app/crypto_list.rb"
|
|
7
|
+
require_relative "../lib/app/invested_crypto.rb"
|
|
8
|
+
require_relative "../lib/app/scrapper.rb"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require_relative '../../utility/Crypto_Calculator.rb'
|
|
2
|
+
require_relative './player.rb'
|
|
3
|
+
require_relative "../../utility/FancyText.rb"
|
|
4
|
+
require 'pastel'
|
|
5
|
+
|
|
6
|
+
class CryptoList
|
|
7
|
+
|
|
8
|
+
include CryptoCalculator::InstanceMethods
|
|
9
|
+
include FancyText::InstanceMethods
|
|
10
|
+
|
|
11
|
+
attr_accessor :crypto_list, :future_crypto_list
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def initialize crypto_list=nil, future_crypto_list=nil
|
|
15
|
+
@crypto_list = CRYPTO_LIST
|
|
16
|
+
@future_crypto_list = CRYPTO_LIST
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def set_player_crypto_list_on_past
|
|
20
|
+
Player.all[0].past_crypto_list = @crypto_list
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def set_player_crypto_list_on_future
|
|
24
|
+
Player.all[0].exited_crypto_data = @future_crypto_list
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def show_list_iterator(list_crypto)
|
|
28
|
+
pastel = Pastel.new
|
|
29
|
+
list_crypto.each.with_index(1) do |crypto, index|
|
|
30
|
+
puts pastel.green.bold("
|
|
31
|
+
#{index}. #{crypto[0].upcase} - #{crypto[1]} - #{crypto[2]} AUD
|
|
32
|
+
")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def list_past_data
|
|
37
|
+
get_rate(@crypto_list, Player.all[0].entry_date)
|
|
38
|
+
set_player_crypto_list_on_past
|
|
39
|
+
progressbar(
|
|
40
|
+
"Fetching currencies and their rates [:bar]",
|
|
41
|
+
"
|
|
42
|
+
Successfully Fetched!!
|
|
43
|
+
|
|
44
|
+
"
|
|
45
|
+
)
|
|
46
|
+
show_list_iterator(@crypto_list)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def list_future_data
|
|
51
|
+
get_rate(@future_crypto_list, Player.all[0].exit_date)
|
|
52
|
+
set_player_crypto_list_on_future
|
|
53
|
+
|
|
54
|
+
show_list_iterator(@future_crypto_list)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
require_relative './player.rb'
|
|
2
|
+
require_relative './crypto_list.rb'
|
|
3
|
+
|
|
4
|
+
class InvestedCrypto
|
|
5
|
+
|
|
6
|
+
attr_accessor :name, :entry_rate, :exit_rate, :amount_invested, :number_owned, :total_amount
|
|
7
|
+
@@all = []
|
|
8
|
+
@@pastel = Pastel.new
|
|
9
|
+
@@prompt = TTY::Prompt.new
|
|
10
|
+
|
|
11
|
+
def initialize name="", entry_rate=0, exit_rate=0, amount_invested=0, number_owned=0, total_amount=0
|
|
12
|
+
@name = name
|
|
13
|
+
@entry_rate = entry_rate
|
|
14
|
+
@exit_rate = exit_rate
|
|
15
|
+
@amount_invested = amount_invested
|
|
16
|
+
@number_owned = number_owned
|
|
17
|
+
@total_amount = total_amount
|
|
18
|
+
@@all << self
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.all
|
|
22
|
+
@@all
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.clear
|
|
26
|
+
@@all.clear
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.add_to_player
|
|
30
|
+
Player.all[0].crypto_invested = @@all
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.ask_for_number
|
|
34
|
+
@@prompt.ask("Please select the number for coin
|
|
35
|
+
you want to invest:") do |q|
|
|
36
|
+
q.validate(/^([1-9]|1[012345])$/, "Invalid Input")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.ask_for_amount
|
|
41
|
+
@@prompt.ask("
|
|
42
|
+
Please type the amount you want to invest:")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.set_invested_crypto_details(invested_crypto, name, rate, amount)
|
|
46
|
+
invested_crypto.name = name
|
|
47
|
+
invested_crypto.entry_rate = rate
|
|
48
|
+
invested_crypto.amount_invested = amount.to_i
|
|
49
|
+
invested_crypto.number_owned = (amount.to_i / rate).to_f.round(3)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def self.select_crypto_to_invest
|
|
54
|
+
player_new = Player.all[0]
|
|
55
|
+
until player_new.balance <= 0 do
|
|
56
|
+
|
|
57
|
+
invested_crypto = InvestedCrypto.new
|
|
58
|
+
|
|
59
|
+
selection = ask_for_number
|
|
60
|
+
amount_invested = ask_for_amount
|
|
61
|
+
|
|
62
|
+
selection_name = player_new.past_crypto_list.each_with_index.select{|crypto, index| selection.to_i == (index+1)}
|
|
63
|
+
player_new.balance = player_new.balance - amount_invested.to_i
|
|
64
|
+
|
|
65
|
+
puts @@pastel.cyan.bold("
|
|
66
|
+
You have invested #{amount_invested} AUD
|
|
67
|
+
in #{selection_name[0][0][0].upcase}.
|
|
68
|
+
|
|
69
|
+
You have #{player_new.balance} AUD left
|
|
70
|
+
|
|
71
|
+
")
|
|
72
|
+
|
|
73
|
+
set_invested_crypto_details(invested_crypto, selection_name[0][0][0], selection_name[0][0][2], amount_invested )
|
|
74
|
+
if_balance_negative?
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def self.if_balance_negative?
|
|
79
|
+
if Player.all[0].balance.negative?
|
|
80
|
+
@@all.last.amount_invested -= Player.all[0].balance.abs
|
|
81
|
+
sleep(2)
|
|
82
|
+
puts @@pastel.cyan.bold("
|
|
83
|
+
Due to insufficient balance, you have only
|
|
84
|
+
invested #{@@all.last.amount_invested} in
|
|
85
|
+
#{@@all.last.name.upcase}")
|
|
86
|
+
Player.all[0].balance = 0
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def self.show_investments
|
|
91
|
+
puts @@pastel.cyan.bold("
|
|
92
|
+
|
|
93
|
+
Below is your INVESTMENTS......
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
Coin-Name Owned Invested(AUD)
|
|
97
|
+
-------------- ----------- -----------------
|
|
98
|
+
")
|
|
99
|
+
@@all.each do |i|
|
|
100
|
+
|
|
101
|
+
puts @@pastel.green.bold("
|
|
102
|
+
#{i.name.upcase} #{i.number_owned} #{i.amount_invested}
|
|
103
|
+
|
|
104
|
+
")
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def self.set_exit_rate
|
|
109
|
+
Player.all[0].exited_crypto_data.each do |exited_data|
|
|
110
|
+
@@all.each do |investment|
|
|
111
|
+
if exited_data[0] == investment.name
|
|
112
|
+
investment.exit_rate = exited_data[2]
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def self.set_and_show_total_amount
|
|
119
|
+
puts @@pastel.cyan.bold("
|
|
120
|
+
|
|
121
|
+
Below is your investments' CALCULATIONS......
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
Coin-Name Owned Invested(AUD) TotalAmount(AUD)
|
|
125
|
+
-------------- ----------- ----------------- -----------------
|
|
126
|
+
")
|
|
127
|
+
@@all.each do |i|
|
|
128
|
+
i.total_amount = (i.number_owned * i.exit_rate).to_f.round(3)
|
|
129
|
+
puts @@pastel.green.bold("
|
|
130
|
+
#{i.name.upcase} #{i.number_owned} #{i.amount_invested} #{i.total_amount}
|
|
131
|
+
|
|
132
|
+
")
|
|
133
|
+
end
|
|
134
|
+
total
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def self.total
|
|
138
|
+
total_of_totals = 0
|
|
139
|
+
@@all.each do |i|
|
|
140
|
+
total_of_totals += i.total_amount
|
|
141
|
+
end
|
|
142
|
+
Player.all[0].total_balance = total_of_totals.to_f.round(3)
|
|
143
|
+
end
|
|
144
|
+
end
|
data/lib/app/player.rb
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
require 'tty-prompt'
|
|
2
|
+
require 'pastel'
|
|
3
|
+
require_relative "../../utility/FancyText.rb"
|
|
4
|
+
require_relative '../../utility/Crypto_Calculator.rb'
|
|
5
|
+
require_relative './crypto_list.rb'
|
|
6
|
+
require_relative './invested_crypto.rb'
|
|
7
|
+
require_relative './scrapper.rb'
|
|
8
|
+
require 'date'
|
|
9
|
+
require 'tty-font'
|
|
10
|
+
|
|
11
|
+
class Player
|
|
12
|
+
include FancyText::InstanceMethods
|
|
13
|
+
include CryptoCalculator::InstanceMethods
|
|
14
|
+
|
|
15
|
+
attr_accessor :name, :balance, :entry_date, :past_crypto_list, :crypto_invested, :exit_date, :exited_crypto_data, :total_balance
|
|
16
|
+
@@all = []
|
|
17
|
+
|
|
18
|
+
def initialize name="", balance = 10000, entry_date="", past_crypto_list=[], crypto_invested=[], exit_date="", exited_crypto_data = []
|
|
19
|
+
@name = name
|
|
20
|
+
@balance = balance
|
|
21
|
+
@entry_date = entry_date
|
|
22
|
+
@past_crypto_list = past_crypto_list
|
|
23
|
+
@crypto_invested = crypto_invested
|
|
24
|
+
@exit_date = exit_date
|
|
25
|
+
@exited_crypto_data = exited_crypto_data
|
|
26
|
+
@total_balance = total_balance
|
|
27
|
+
save
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def save
|
|
31
|
+
@@all << self
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.all
|
|
35
|
+
@@all
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def set_name
|
|
39
|
+
prompt = TTY::Prompt.new
|
|
40
|
+
@name = prompt.ask("
|
|
41
|
+
Enter Your Player Name: ")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def set_entry_date
|
|
45
|
+
pastel = Pastel.new
|
|
46
|
+
prompt = TTY::Prompt.new
|
|
47
|
+
|
|
48
|
+
random_year = 2018
|
|
49
|
+
|
|
50
|
+
slow_motion(random_year)
|
|
51
|
+
|
|
52
|
+
puts pastel.cyan.bold"
|
|
53
|
+
|
|
54
|
+
The year selected is #{random_year}
|
|
55
|
+
|
|
56
|
+
"
|
|
57
|
+
|
|
58
|
+
entered_date = prompt.ask(
|
|
59
|
+
"
|
|
60
|
+
Now, Please type any day in format DD-MM:") do |q|
|
|
61
|
+
q.validate(/([0-2][0-9]|(3)[0-1])[-|\/](((0)[0-9])|((1)[0-2]))/, "Invalid Date Format. TRY AGAIN!" )
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
@entry_date = "#{entered_date}-#{random_year}"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def permission_to_past
|
|
68
|
+
prompt = TTY::Prompt.new
|
|
69
|
+
choices = {yes: 1, no: 2}
|
|
70
|
+
permission =
|
|
71
|
+
prompt.select("
|
|
72
|
+
Are You Sure You Want To Go Back To #{@entry_date}?",
|
|
73
|
+
choices)
|
|
74
|
+
|
|
75
|
+
puts "\n"
|
|
76
|
+
puts "\n"
|
|
77
|
+
|
|
78
|
+
if permission == choices[:yes]
|
|
79
|
+
progressbar("Travelling to The Past [:bar]",
|
|
80
|
+
"
|
|
81
|
+
|
|
82
|
+
Successfully Travelled Back to #{@entry_date}!!")
|
|
83
|
+
|
|
84
|
+
welcome_to_time_message(@entry_date, "make")
|
|
85
|
+
else
|
|
86
|
+
permission_to_past
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def permission_to_scrape
|
|
91
|
+
prompt = TTY::Prompt.new
|
|
92
|
+
choices = {learn: 1, proceed: 2}
|
|
93
|
+
permission =
|
|
94
|
+
prompt.select("
|
|
95
|
+
Do You Want To Learn About Any Currency Before Investing ?",
|
|
96
|
+
choices)
|
|
97
|
+
|
|
98
|
+
puts "\n"
|
|
99
|
+
puts "\n"
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if permission == choices[:learn]
|
|
103
|
+
real_scrapping
|
|
104
|
+
permission_to_scrape
|
|
105
|
+
else
|
|
106
|
+
InvestedCrypto.select_crypto_to_invest
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def real_scrapping
|
|
111
|
+
prompt = TTY::Prompt.new
|
|
112
|
+
scrapping_permission =
|
|
113
|
+
prompt.select("
|
|
114
|
+
Please Select the CryptoCurrency You Want to Learn About: ",
|
|
115
|
+
SCRAPPING_CHOICES)
|
|
116
|
+
|
|
117
|
+
puts "\n"
|
|
118
|
+
puts "\n"
|
|
119
|
+
|
|
120
|
+
Scrapper.send(scrapping_permission)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def set_exit_date
|
|
126
|
+
pastel = Pastel.new
|
|
127
|
+
prompt = TTY::Prompt.new
|
|
128
|
+
|
|
129
|
+
@exit_date =
|
|
130
|
+
prompt.ask(
|
|
131
|
+
"
|
|
132
|
+
Please type any day after
|
|
133
|
+
#{@entry_date} and before 31-12-2021 in format DD-MM-YYYY: ") do |q|
|
|
134
|
+
q.validate(/([0-2][0-9]|(3)[0-1])[-|\/](((0)[0-9])|((1)[0-2]))[-|\/]\d{4}/, "Invalid Date Format. TRY AGAIN!" )
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
puts "\n"
|
|
138
|
+
puts "\n"
|
|
139
|
+
|
|
140
|
+
progressbar("Travelling Back To The Future [:bar]",
|
|
141
|
+
"
|
|
142
|
+
|
|
143
|
+
Successfully Travelled Ahead to #{@exit_date}!!")
|
|
144
|
+
|
|
145
|
+
welcome_to_time_message(@exit_date, "check on")
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def total_balance_message
|
|
149
|
+
pastel = Pastel.new
|
|
150
|
+
type_writter("
|
|
151
|
+
|
|
152
|
+
The 10,000 AUD you have invested in #{@entry_date}
|
|
153
|
+
has made the total balance of....
|
|
154
|
+
|
|
155
|
+
")
|
|
156
|
+
slow_motion(pastel.green.bold("#{@total_balance}"))
|
|
157
|
+
type_writter("
|
|
158
|
+
AUD in #{@exit_date}.
|
|
159
|
+
|
|
160
|
+
")
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
end
|
|
164
|
+
|
data/lib/app/scrapper.rb
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
require 'nokogiri'
|
|
2
|
+
require 'open-uri'
|
|
3
|
+
require 'pastel'
|
|
4
|
+
require 'awesome_print'
|
|
5
|
+
|
|
6
|
+
class Scrapper
|
|
7
|
+
@@pastel = Pastel.new
|
|
8
|
+
|
|
9
|
+
WIKIPEDIA = "https://en.wikipedia.org/wiki/"
|
|
10
|
+
|
|
11
|
+
def self.webCryptoName(name)
|
|
12
|
+
doc = get_page("https://en.wikipedia.org/wiki/#{name}")
|
|
13
|
+
history = doc.css("div.mw-body-content.mw-content-ltr div.mw-parser-output p")
|
|
14
|
+
brief_history_title(name.upcase)
|
|
15
|
+
text_iterator(history[0..5])
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.brief_history_title(coin_title)
|
|
19
|
+
puts @@pastel.magenta.on_white.bold("
|
|
20
|
+
A Brief on #{coin_title.upcase}...
|
|
21
|
+
")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.get_page(url)
|
|
25
|
+
html = URI.open(url)
|
|
26
|
+
doc = Nokogiri::HTML(html)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.text_iterator(scrapped_texts)
|
|
30
|
+
scrapped_texts.each do |t|
|
|
31
|
+
puts @@pastel.magenta.on_white.bold(" #{t.text}
|
|
32
|
+
")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def self.bitcoin_history
|
|
38
|
+
webCryptoName("Bitcoin")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.ethereum_history
|
|
42
|
+
webCryptoName("Ethereum")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.binancecoin_history
|
|
46
|
+
webCryptoName("Binancecoin")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.cardano_history
|
|
50
|
+
webCryptoName("Cardano_(blockchain_platform)")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.ripple_history
|
|
54
|
+
webCryptoName("Ripple_(payment_protocol)")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.loopring_history
|
|
58
|
+
webCryptoName("Decentralized_finance")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.dogecoin_history
|
|
62
|
+
webCryptoName("Dogecoin")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.qtum_history
|
|
66
|
+
webCryptoName("Quantum")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def self.tron_history
|
|
70
|
+
webCryptoName("Tron_(cryptocurrency)")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.litecoin_history
|
|
74
|
+
webCryptoName("Litecoin")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def self.decentraland_history
|
|
78
|
+
webCryptoName("Decentraland")
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.bitcoin_gold_history
|
|
82
|
+
webCryptoName("Bitcoin_Gold")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def self.iota_history
|
|
86
|
+
webCryptoName("IOTA_(technology)")
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def self.stellar_history
|
|
90
|
+
webCryptoName("Stellar_(payment_network)")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.monero_history
|
|
94
|
+
webCryptoName("Monero")
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
data/lib/cryptomania.rb
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
require_relative "../utility/FancyText.rb"
|
|
2
|
+
require 'tty-font'
|
|
3
|
+
|
|
4
|
+
class CryptoMania
|
|
5
|
+
include FancyText::InstanceMethods
|
|
6
|
+
|
|
7
|
+
def run
|
|
8
|
+
welcome
|
|
9
|
+
Player.new.set_name
|
|
10
|
+
hello_name
|
|
11
|
+
Player.all[0].set_entry_date
|
|
12
|
+
Player.all[0].permission_to_past
|
|
13
|
+
select_currencies_message
|
|
14
|
+
CryptoList.new.list_past_data
|
|
15
|
+
Player.all[0].permission_to_scrape
|
|
16
|
+
InvestedCrypto.show_investments
|
|
17
|
+
InvestedCrypto.add_to_player
|
|
18
|
+
waiting_message
|
|
19
|
+
Player.all[0].set_exit_date
|
|
20
|
+
lets_check_on_rates_message
|
|
21
|
+
CryptoList.new.list_future_data
|
|
22
|
+
InvestedCrypto.set_exit_rate
|
|
23
|
+
excited_message
|
|
24
|
+
InvestedCrypto.set_and_show_total_amount
|
|
25
|
+
Player.all[0].total_balance_message
|
|
26
|
+
win_message
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def welcome
|
|
31
|
+
pastel = Pastel.new
|
|
32
|
+
puts pastel.red.on_white.bold"
|
|
33
|
+
==============================
|
|
34
|
+
WELCOME TO THE CRYPTOMANIA
|
|
35
|
+
==============================
|
|
36
|
+
"
|
|
37
|
+
type_writter("
|
|
38
|
+
Everyone wants to know about the future and travel
|
|
39
|
+
ahead of time.
|
|
40
|
+
Its genuine, no one wants to to think about the
|
|
41
|
+
past and bother themselves worrying about something
|
|
42
|
+
that cannot be changed.
|
|
43
|
+
")
|
|
44
|
+
type_writter("
|
|
45
|
+
But this time, lets take a moment to go back to the
|
|
46
|
+
past and play a simulation game where at the end,
|
|
47
|
+
you could be either super-rich or not.
|
|
48
|
+
")
|
|
49
|
+
type_writter("
|
|
50
|
+
You are going to the past, any day between 2018 to 2021.
|
|
51
|
+
|
|
52
|
+
At the start of the game, you will be given 10,000 AUD.
|
|
53
|
+
And you will be given a list of Crypto Currencies you
|
|
54
|
+
can choose to invest on. You can choose as many currencies
|
|
55
|
+
you like to invest.
|
|
56
|
+
|
|
57
|
+
After that, you can skip to any day in the future between
|
|
58
|
+
the day you chose at first to be on and last day of 2021.
|
|
59
|
+
|
|
60
|
+
Then, all the total earnings you have made throughout
|
|
61
|
+
the time through those cryptos you have invested are
|
|
62
|
+
calculated and if you become able to double or more your
|
|
63
|
+
initial 10,000 AUD, YOU WIN !!
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
OK, Lets Start.....
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
")
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def hello_name
|
|
73
|
+
type_writter("
|
|
74
|
+
Hello, #{Player.all[0].name.upcase},
|
|
75
|
+
Allow me to have the pleasure of choosing
|
|
76
|
+
the year for you actually...hehe
|
|
77
|
+
|
|
78
|
+
Don't worry, you get to choose the month and day.
|
|
79
|
+
|
|
80
|
+
")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def select_currencies_message
|
|
84
|
+
type_writter("
|
|
85
|
+
|
|
86
|
+
Now its time to choose cryptos
|
|
87
|
+
you want to invest on....
|
|
88
|
+
Please, be mindful, you only have 10,000 AUD
|
|
89
|
+
to change your fortune. 🤑🤑
|
|
90
|
+
|
|
91
|
+
Below is a list of 15 top cryptocurrencies
|
|
92
|
+
of the time and their respective rates in AUD.
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
")
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def waiting_message
|
|
99
|
+
sleep(2)
|
|
100
|
+
type_writter("
|
|
101
|
+
|
|
102
|
+
Phewwww....That was a heck of a thing we did.
|
|
103
|
+
|
|
104
|
+
Now, we play WAITING GAME.......
|
|
105
|
+
|
|
106
|
+
WAITING.....
|
|
107
|
+
|
|
108
|
+
....
|
|
109
|
+
|
|
110
|
+
WAITING....
|
|
111
|
+
|
|
112
|
+
....
|
|
113
|
+
|
|
114
|
+
Oh WAIT!!
|
|
115
|
+
|
|
116
|
+
Did you forget we are in past time-line inside
|
|
117
|
+
a simulation game ??
|
|
118
|
+
|
|
119
|
+
We were allowed to time travel to the past,
|
|
120
|
+
then don't worry, we can also
|
|
121
|
+
time travel to the FUTURE...
|
|
122
|
+
|
|
123
|
+
So, lets cut off all the waiting game
|
|
124
|
+
and see how much money our investments
|
|
125
|
+
made, SHALL WE??
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
")
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def lets_check_on_rates_message
|
|
132
|
+
type_writter("
|
|
133
|
+
|
|
134
|
+
Below is the list of those 15 coins
|
|
135
|
+
from the past and their present rates.
|
|
136
|
+
|
|
137
|
+
")
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def excited_message
|
|
141
|
+
sleep(2)
|
|
142
|
+
type_writter("
|
|
143
|
+
|
|
144
|
+
WOOOOOOAHHHHH....looks like a lot has
|
|
145
|
+
changed 🧐🧐.
|
|
146
|
+
|
|
147
|
+
You sit tight, while the calculations are
|
|
148
|
+
being carried out.
|
|
149
|
+
|
|
150
|
+
")
|
|
151
|
+
progressbar("Calculating the profits [:bar]",
|
|
152
|
+
"
|
|
153
|
+
|
|
154
|
+
Calculations Successfull!!
|
|
155
|
+
|
|
156
|
+
")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def win_message
|
|
160
|
+
font = TTY::Font.new(:starwars)
|
|
161
|
+
pastel = Pastel.new
|
|
162
|
+
|
|
163
|
+
if Player.all[0].total_balance > 20000
|
|
164
|
+
puts pastel.green.bold(font.write(" YOU WIN! "))
|
|
165
|
+
else
|
|
166
|
+
puts pastel.red.bold(font.write(" YOU LOSE! "))
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
module CryptoCalculator
|
|
5
|
+
module InstanceMethods
|
|
6
|
+
def get_rate_from_api(asset_id_base, time)
|
|
7
|
+
uri = "https://api.coingecko.com/api/v3/coins/#{asset_id_base.gsub(/^"+|"+$/, '')}/history?date=#{time.gsub(/^"+|"+$/, '')}&localization=false"
|
|
8
|
+
res = HTTParty.get(uri)
|
|
9
|
+
parsed_data = JSON.parse(res.body)
|
|
10
|
+
sleep(0.3)
|
|
11
|
+
parsed_data["market_data"]["current_price"]["aud"]
|
|
12
|
+
# sleep 2
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_rate(crypto_list, date)
|
|
16
|
+
crypto_list.each do |crypto|
|
|
17
|
+
rate= get_rate_from_api(crypto[0], date)
|
|
18
|
+
crypto[2] = rate.to_f.round(3)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require 'pastel'
|
|
2
|
+
require 'tty-progressbar'
|
|
3
|
+
|
|
4
|
+
module FancyText
|
|
5
|
+
module InstanceMethods
|
|
6
|
+
|
|
7
|
+
SCRAPPING_CHOICES = {
|
|
8
|
+
Bitcoin: "bitcoin_history",
|
|
9
|
+
Ethereum: "ethereum_history",
|
|
10
|
+
BinanceCoin: "binancecoin_history",
|
|
11
|
+
Cardano: "cardano_history",
|
|
12
|
+
Ripple: "ripple_history",
|
|
13
|
+
Loopring: "loopring_history",
|
|
14
|
+
Dogecoin: "dogecoin_history",
|
|
15
|
+
QTUM: "qtum_history",
|
|
16
|
+
Tron: "tron_history",
|
|
17
|
+
Litecoin: "litecoin_history",
|
|
18
|
+
Decentraland: "decentraland_history",
|
|
19
|
+
BitcoinGold: "bitcoin_gold_history",
|
|
20
|
+
IOTA: "iota_history",
|
|
21
|
+
Stellar: "stellar_history",
|
|
22
|
+
Monero: "monero_history"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
CRYPTO_LIST= [
|
|
26
|
+
["bitcoin", "BTC"],
|
|
27
|
+
["ethereum", "ETH"],
|
|
28
|
+
["binancecoin", "BNB"],
|
|
29
|
+
["cardano", "ADA"],
|
|
30
|
+
["ripple", "XRP"],
|
|
31
|
+
["loopring", "LRC"],
|
|
32
|
+
["dogecoin", "DOGE"],
|
|
33
|
+
["qtum", "QTM"],
|
|
34
|
+
["tron", "TRX"],
|
|
35
|
+
["litecoin", "LTC"],
|
|
36
|
+
["decentraland", "MANA"],
|
|
37
|
+
["bitcoin-gold", "BTG"],
|
|
38
|
+
["iota", "MIOTA"],
|
|
39
|
+
["stellar", "XLM"],
|
|
40
|
+
["monero", "XMR"]
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
def type_writter string
|
|
44
|
+
pastel = Pastel.new
|
|
45
|
+
string.each_char do |c|
|
|
46
|
+
print pastel.cyan.bold c
|
|
47
|
+
time_slot = rand(0.009..0.02)
|
|
48
|
+
sleep(time_slot)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def slow_motion number
|
|
53
|
+
number.to_s.each_char do |c|
|
|
54
|
+
print c
|
|
55
|
+
time_slot = rand(0.8..1.2)
|
|
56
|
+
sleep(time_slot)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def progressbar(bar_text, success_message)
|
|
61
|
+
pastel = Pastel.new
|
|
62
|
+
bar =
|
|
63
|
+
TTY::ProgressBar.new(pastel.cyan.bold(bar_text),
|
|
64
|
+
width: 50)
|
|
65
|
+
|
|
66
|
+
130.times do |i|
|
|
67
|
+
sleep(0.03)
|
|
68
|
+
bar.advance
|
|
69
|
+
bar.update(total: 130) if i == 59
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
puts pastel.cyan.bold(
|
|
73
|
+
success_message)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def welcome_to_time_message(date, some_text)
|
|
77
|
+
pastel = Pastel.new
|
|
78
|
+
d = Date.strptime(date.split("-").join(""), '%d%m%Y')
|
|
79
|
+
day = d.strftime('%A')
|
|
80
|
+
|
|
81
|
+
type_writter("
|
|
82
|
+
|
|
83
|
+
Alright........what a lovely" )
|
|
84
|
+
print pastel.red.bold(" #{day} ")
|
|
85
|
+
type_writter("to #{some_text}
|
|
86
|
+
some investments.")
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: cryptomania
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '2.0'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ajay Ghimire
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: invest and win
|
|
14
|
+
email: ajayghimire1998@gmail.com
|
|
15
|
+
executables:
|
|
16
|
+
- cryptomania
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- bin/cryptomania
|
|
21
|
+
- config/environment.rb
|
|
22
|
+
- lib/app/crypto_list.rb
|
|
23
|
+
- lib/app/invested_crypto.rb
|
|
24
|
+
- lib/app/player.rb
|
|
25
|
+
- lib/app/scrapper.rb
|
|
26
|
+
- lib/cryptomania.rb
|
|
27
|
+
- utility/Crypto_Calculator.rb
|
|
28
|
+
- utility/FancyText.rb
|
|
29
|
+
homepage: https://rubygems.org/gems/cryptomania
|
|
30
|
+
licenses:
|
|
31
|
+
- MIT
|
|
32
|
+
metadata: {}
|
|
33
|
+
post_install_message:
|
|
34
|
+
rdoc_options: []
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: 3.1.2
|
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
requirements: []
|
|
48
|
+
rubygems_version: 3.3.7
|
|
49
|
+
signing_key:
|
|
50
|
+
specification_version: 4
|
|
51
|
+
summary: a crypto gem
|
|
52
|
+
test_files: []
|