play_GOT 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +46 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/run +5 -0
- data/bin/setup +8 -0
- data/config/environment.rb +11 -0
- data/lib/play_GOT/api.rb +23 -0
- data/lib/play_GOT/cli.rb +132 -0
- data/lib/play_GOT/house.rb +30 -0
- data/lib/play_GOT/player.rb +205 -0
- data/lib/play_GOT/rock_paper_scissors.rb +54 -0
- data/lib/play_GOT/version.rb +3 -0
- data/play_GOT.gemspec +45 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a233598b869648c5fb69e7efaa7db84beba92cf503d8307109eec948f7965699
|
4
|
+
data.tar.gz: 36016aa251cfab25688166ba5007e9131740893616a206256e389680334dfc1a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a12d5678e3c567db80b89a372f8e2b18b7a53b5767a0ef5ea6c26025876378b55740d12e9c5f33c7b2b74ba04d4aff32a4d9a94294fe25cc31d28e281afe24c9
|
7
|
+
data.tar.gz: 668276fbab690957fbc07488cb3d9db784615725e40d937db23854ac6a7911f5a58b96028650a72980098f04da05e4daf5f50e67e6a61d44020382d5deec82ec
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at 'sophieqgu@gmail.com'. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
play_GOT (0.1.0)
|
5
|
+
colorize
|
6
|
+
json
|
7
|
+
rest-client
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
coderay (1.1.2)
|
13
|
+
colorize (0.8.1)
|
14
|
+
domain_name (0.5.20180417)
|
15
|
+
unf (>= 0.0.5, < 1.0.0)
|
16
|
+
http-cookie (1.0.3)
|
17
|
+
domain_name (~> 0.5)
|
18
|
+
json (2.2.0)
|
19
|
+
method_source (0.9.2)
|
20
|
+
mime-types (3.2.2)
|
21
|
+
mime-types-data (~> 3.2015)
|
22
|
+
mime-types-data (3.2019.0331)
|
23
|
+
netrc (0.11.0)
|
24
|
+
pry (0.12.2)
|
25
|
+
coderay (~> 1.1.0)
|
26
|
+
method_source (~> 0.9.0)
|
27
|
+
rake (10.5.0)
|
28
|
+
rest-client (2.0.2)
|
29
|
+
http-cookie (>= 1.0.2, < 2.0)
|
30
|
+
mime-types (>= 1.16, < 4.0)
|
31
|
+
netrc (~> 0.8)
|
32
|
+
unf (0.1.4)
|
33
|
+
unf_ext
|
34
|
+
unf_ext (0.0.7.6)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
bundler (~> 2.0)
|
41
|
+
play_GOT!
|
42
|
+
pry
|
43
|
+
rake (~> 10.0)
|
44
|
+
|
45
|
+
BUNDLED WITH
|
46
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 'Sophie Gu'
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# PlayGOT
|
2
|
+
|
3
|
+
This is a simple CLI role-playing game based on the popular HBO series Game of Thrones. Select your own House, find your allies, conquer your enemies, and claim secret weapons along the way to help you take the throne!
|
4
|
+
|
5
|
+
Write your own GOT legend today.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'play_GOT'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install play_GOT
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
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.
|
26
|
+
|
27
|
+
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).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/'sophieqgu'/play_GOT. 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.
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
36
|
+
|
37
|
+
## Code of Conduct
|
38
|
+
|
39
|
+
Everyone interacting in the PlayGOT project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/'sophieqgu'/play_GOT/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require_relative "../config/environment"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
#require "pry"
|
11
|
+
#Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/run
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "rest-client"
|
2
|
+
require "json"
|
3
|
+
require "pry"
|
4
|
+
require "colorize"
|
5
|
+
|
6
|
+
require_relative "../lib/play_GOT/version"
|
7
|
+
require_relative "../lib/play_GOT/cli"
|
8
|
+
require_relative "../lib/play_GOT/api"
|
9
|
+
require_relative "../lib/play_GOT/house"
|
10
|
+
require_relative "../lib/play_GOT/player"
|
11
|
+
require_relative "../lib/play_GOT/rock_paper_scissors"
|
data/lib/play_GOT/api.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
class PlayGOT::API
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
url = "https://anapioficeandfire.com/api/houses?hasTitles=true&hasWords=true&hasAncestralWeapons=true"
|
5
|
+
@response = JSON.parse(RestClient.get(url))
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
def create_houses
|
10
|
+
@response.each do |house|
|
11
|
+
house_attributes = {
|
12
|
+
:name => house["name"],
|
13
|
+
:region => house["region"],
|
14
|
+
:words => house["words"],
|
15
|
+
:titles => house["titles"],
|
16
|
+
:ancestral_weapons => house["ancestralWeapons"]
|
17
|
+
}
|
18
|
+
PlayGOT::House.new(house_attributes)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
data/lib/play_GOT/cli.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
class PlayGOT::CLI
|
2
|
+
attr_accessor :you, :turn
|
3
|
+
|
4
|
+
def start
|
5
|
+
puts "When you play the Game of Thrones, you win or you die."
|
6
|
+
|
7
|
+
initiate_player
|
8
|
+
|
9
|
+
PlayGOT::API.new.create_houses
|
10
|
+
|
11
|
+
choose_house
|
12
|
+
|
13
|
+
@turn = 0
|
14
|
+
continue
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def initiate_player
|
19
|
+
puts "Who are you, stranger?".light_red
|
20
|
+
|
21
|
+
@you = PlayGOT::Player.new
|
22
|
+
|
23
|
+
puts "Welcome, #{@you.name.light_green}, to the land of Westeros."
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def choose_house
|
28
|
+
puts "Your destiny awaits. Lo and behold.".light_red
|
29
|
+
|
30
|
+
@you.choose_house
|
31
|
+
|
32
|
+
puts "You've chosen the #{@you.house.name.light_green}. Great and glorious it is.\n'#{@you.house.words.light_green}' it chants.\nIn #{@you.house.region.gsub("The", "the").light_green} it resides."
|
33
|
+
puts "No one doubts it for being the #{@you.house.titles.join(", ").light_green}.\nLet #{@you.house.ancestral_weapons.join(" and ").light_green} be your secret weapon."
|
34
|
+
puts "\nAre you sure about your choice? Type Y or YES to continue or anything else to choose again.".light_red
|
35
|
+
|
36
|
+
confirm = gets.upcase.strip
|
37
|
+
|
38
|
+
if confirm == "Y" || confirm == "YES"
|
39
|
+
puts "Glory to your name #{@you.name.light_green}, Lord of the #{@you.house.name.light_green}. Winter is coming and the night is long. It's time to gather your soldiers."
|
40
|
+
else
|
41
|
+
choose_house
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def rules
|
47
|
+
puts "\nTo win the Game of Thrones you must do the following: "
|
48
|
+
puts "1 - Survive the Winter that sweeps through Westeros randomly.".blue
|
49
|
+
puts "2 - Conquer all your enemies or turn them into your allies. ".blue
|
50
|
+
puts "Your #{'stamina'.light_green} determines your probability of surviving the Winter. Each additional ally adds another 5 percent chance of survival. Each lost battle decreases 5 percent."
|
51
|
+
puts "Your #{'tactic'.light_green} determines your probability of fleeing from an enemy. Some secret weapons may increase your chance of success."
|
52
|
+
puts "Your #{'loyalty'.light_green} determines your probability of winning over an ally. Some secret weapons may increase your chance of persuasion."
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def menu
|
57
|
+
@turn += 1
|
58
|
+
|
59
|
+
if @turn % 5 == 0
|
60
|
+
@you.survive_winter
|
61
|
+
end
|
62
|
+
|
63
|
+
puts "What do you want to do?".light_red
|
64
|
+
puts "1 - Read the rules of the game.\n2 - View your current status.\n3 - Go find an ally.\n4 - Go attack an enemy.\n5 - Read about secret weapons.\n6 - Exit the game."
|
65
|
+
|
66
|
+
input = gets.strip
|
67
|
+
|
68
|
+
case input
|
69
|
+
when "1"
|
70
|
+
rules
|
71
|
+
continue
|
72
|
+
when "2"
|
73
|
+
@you.status
|
74
|
+
continue
|
75
|
+
when "3"
|
76
|
+
@you.select_enemy
|
77
|
+
@you.make_ally
|
78
|
+
continue
|
79
|
+
when "4"
|
80
|
+
@you.select_enemy
|
81
|
+
@you.fight
|
82
|
+
continue
|
83
|
+
when "5"
|
84
|
+
puts "The module is being secretly developed. Coming soon!"
|
85
|
+
continue
|
86
|
+
when "6"
|
87
|
+
exit
|
88
|
+
else
|
89
|
+
puts "You've spoken something mystical that I don't understand.".light_red
|
90
|
+
menu
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
def continue
|
96
|
+
puts "\nWhen you are ready, press any key to continue.".light_red
|
97
|
+
|
98
|
+
input = gets.strip
|
99
|
+
|
100
|
+
if @you.enemies.size > 0
|
101
|
+
menu
|
102
|
+
else
|
103
|
+
win
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def win
|
109
|
+
puts "All hail your Grace, #{@you.name.light_green} of #{@you.house.name.light_green}, First of Your Name, King of the Andals and the First Men, Lord of the Six Kingdoms, and Protector of the Realm."
|
110
|
+
|
111
|
+
puts "\nWesteros is yours. May your rule long and prosperous, and your name remembered forever.".blue
|
112
|
+
|
113
|
+
puts "\nUntil next time.\n".light_red
|
114
|
+
|
115
|
+
exit!
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
def exit
|
120
|
+
puts "Are you sure you want to leave? Type Y or YES to confirm or anything else to go back to the menu.".light_red
|
121
|
+
|
122
|
+
confirm = gets.strip.upcase
|
123
|
+
|
124
|
+
if confirm == "Y" || confirm == "YES"
|
125
|
+
puts "Goodbye, #{@you.name.light_green}. See you next time in the Game of Thrones."
|
126
|
+
exit!
|
127
|
+
else
|
128
|
+
menu
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class PlayGOT::House
|
2
|
+
attr_accessor :name, :region, :words, :titles, :ancestral_weapons
|
3
|
+
@@all = []
|
4
|
+
@@chosen = {}
|
5
|
+
|
6
|
+
def initialize(house_attributes)
|
7
|
+
house_attributes.each do |k, v|
|
8
|
+
self.send("#{k}=", v)
|
9
|
+
end
|
10
|
+
@@all << self
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def self.all
|
15
|
+
@@all
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def self.list_all
|
20
|
+
self.all.each.with_index(1) do |h, i|
|
21
|
+
puts "#{i} - #{h.name}".blue
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def self.find(i)
|
27
|
+
@@chosen = self.all[i - 1]
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
class PlayGOT::Player
|
2
|
+
attr_accessor :name, :house, :secret_weapons, :stamina, :tactic, :loyalty, :allies, :defeated, :enemies, :chosen
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@name = gets.strip
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
def choose_house
|
10
|
+
puts "Choose a number from the list of great houses and swear your allegience: ".light_red
|
11
|
+
PlayGOT::House.list_all
|
12
|
+
|
13
|
+
input = gets.strip.to_i
|
14
|
+
|
15
|
+
if (1..PlayGOT::House.all.size).to_a.include?(input)
|
16
|
+
@house = PlayGOT::House.find(input)
|
17
|
+
@secret_weapons = @house.ancestral_weapons
|
18
|
+
@stamina = 50
|
19
|
+
@tactic = 50
|
20
|
+
@loyalty = 50
|
21
|
+
@allies = []
|
22
|
+
@defeated = []
|
23
|
+
@enemies = PlayGOT::House.all - [@house]
|
24
|
+
|
25
|
+
case @house.name
|
26
|
+
when "House Hightower of the Hightower"
|
27
|
+
@tactic += 10
|
28
|
+
when "House Lannister of Casterly Rock"
|
29
|
+
@stamina -= 5
|
30
|
+
@tactic += 15
|
31
|
+
when "House Mormont of Bear Island"
|
32
|
+
@stamina += 5
|
33
|
+
@tactic -= 5
|
34
|
+
@loyalty += 10
|
35
|
+
when "House Royce of Runestone"
|
36
|
+
@stamina += 5
|
37
|
+
@tactic += 5
|
38
|
+
when "House Stark of Winterfell"
|
39
|
+
@tactic -= 5
|
40
|
+
@loyalty += 15
|
41
|
+
when "House Targaryen of King's Landing"
|
42
|
+
@stamina += 15
|
43
|
+
@loyalty -= 5
|
44
|
+
when "House Tarly of Horn Hill"
|
45
|
+
@tactic += 5
|
46
|
+
@loyalty += 5
|
47
|
+
end
|
48
|
+
else
|
49
|
+
puts "You've spoken something mystical that I don't understand.".light_red
|
50
|
+
choose_house
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def status
|
56
|
+
puts "Your name is #{@name.light_green}, Lord of the #{@house.name.light_green}."
|
57
|
+
puts "You possess #{@secret_weapons.join(", ").light_green}, ancestral weapon from your House and your allies."
|
58
|
+
puts "Your stats are: [stamina: #{@stamina.to_s.light_green}, tactic: #{@tactic.to_s.light_green}, loyalty: #{@loyalty.to_s.light_green}]."
|
59
|
+
|
60
|
+
if @allies.size > 0
|
61
|
+
allies = @allies.collect {|a| a.name}
|
62
|
+
puts "\nYour current allies are: #{allies.join(", ").light_green}."
|
63
|
+
else
|
64
|
+
puts "\nYou currently have no allies. Go and make one.".blue
|
65
|
+
end
|
66
|
+
|
67
|
+
if @defeated.size > 0
|
68
|
+
defeated = @defeated.collect {|d| d.name}
|
69
|
+
puts "\nYou have defeated: #{defeated.join(", ").light_green}."
|
70
|
+
end
|
71
|
+
|
72
|
+
if @enemies.size > 0
|
73
|
+
enemies = @enemies.collect {|e| e.name}
|
74
|
+
puts "\nYour current enemies are: #{enemies.join(", ").light_green}. Conquer all of them or turn them into your allies."
|
75
|
+
else
|
76
|
+
puts "\nYou've destroyed all your enemies. The Throne is yours!".blue
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
def select_enemy
|
82
|
+
puts "Who's on your mind?".light_red
|
83
|
+
|
84
|
+
@enemies.each.with_index(1) do |e, i|
|
85
|
+
puts "#{i} - #{e.name}".blue
|
86
|
+
end
|
87
|
+
|
88
|
+
input = gets.strip.to_i
|
89
|
+
|
90
|
+
if (1..@enemies.size).to_a.include?(input)
|
91
|
+
@chosen = @enemies[input - 1]
|
92
|
+
else
|
93
|
+
puts "You've spoken something mystical that I don't understand.".light_red
|
94
|
+
select_enemy
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
def make_ally
|
100
|
+
puts "You are about to approach the #{@chosen.name.light_green}. Your #{'loyalty'.light_green} determines your probability of winning over an ally. Your current chance of success is #{@loyalty.to_s.light_green}%. Ready to roll the dice?"
|
101
|
+
|
102
|
+
continue
|
103
|
+
|
104
|
+
roll_dice = rand(100)
|
105
|
+
|
106
|
+
if roll_dice < @loyalty
|
107
|
+
puts "LUCK IS ON YOUR SIDE, #{@name.light_green}. You've made a new ally, #{@chosen.name.light_green}."
|
108
|
+
|
109
|
+
@stamina += 5
|
110
|
+
@allies << @chosen
|
111
|
+
@enemies.delete(@chosen)
|
112
|
+
@secret_weapons << @chosen.ancestral_weapons
|
113
|
+
|
114
|
+
puts "Your #{'stamina'.light_green} now increases to #{@stamina.to_s.light_green}%. You've gained weapon #{@chosen.ancestral_weapons.join(" and ").light_green}. You have one less enemy."
|
115
|
+
else
|
116
|
+
fight_or_flee
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
def fight_or_flee
|
122
|
+
puts "TOO LATE! #{@chosen.name.light_green} has prepared to attack. Are you ready to fight? Or you can try to flee."
|
123
|
+
puts "1 - fight\n2 - flee".blue
|
124
|
+
|
125
|
+
input = gets.strip
|
126
|
+
|
127
|
+
case input
|
128
|
+
when "1"
|
129
|
+
fight
|
130
|
+
when "2"
|
131
|
+
flee
|
132
|
+
else
|
133
|
+
puts "You've spoken something mystical that I don't understand.".light_red
|
134
|
+
fight_or_flee
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
def fight
|
140
|
+
puts "You are going into battle with #{@chosen.name.light_green}. Rally your soldiers!"
|
141
|
+
|
142
|
+
game = PlayGOT::RockPaperScissors.new
|
143
|
+
|
144
|
+
if game.your_score == 3
|
145
|
+
puts "Congratulations! You've defeated #{@chosen.name.light_green}. Your men are singing your name. You are one step closer to the Throne!"
|
146
|
+
@defeated << @chosen
|
147
|
+
@enemies.delete(@chosen)
|
148
|
+
else
|
149
|
+
@stamina -= 5
|
150
|
+
puts "You lost in the battle with #{@chosen.name.light_green}. Your #{"stamina".light_green} now decreases to #{@stamina.to_s.light_green}%."
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
def flee
|
156
|
+
puts "Your #{'tactic'.light_green} determines your probability of fleeing from an enemy. Your current chance of success is #{@tactic.to_s.light_green}%. Ready to roll the dice?"
|
157
|
+
|
158
|
+
continue
|
159
|
+
|
160
|
+
roll_dice = rand(100)
|
161
|
+
|
162
|
+
if roll_dice < @tactic
|
163
|
+
puts "THAT WAS CLOSE! You've dodged a spear. Now lay low and make your way back to the camp."
|
164
|
+
else
|
165
|
+
puts "AMBUSH! You are cornered. Your enemies are close.\nFight is your only way out. Fight in the name of your House!"
|
166
|
+
|
167
|
+
continue
|
168
|
+
|
169
|
+
fight
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
def survive_winter
|
175
|
+
puts "Winter is coming. He brings the storm. When the snows fall and the white winds blow, Nothing burns like the cold.\n"
|
176
|
+
|
177
|
+
puts "\nEvery man must die. But first he must live.\n".blue
|
178
|
+
|
179
|
+
puts "Your #{'stamina'.light_green} determines your probability of surviving the Winter. Your current chance of success is #{@stamina.to_s.light_green}%. Can you survive the night?"
|
180
|
+
|
181
|
+
continue
|
182
|
+
|
183
|
+
roll_dice = rand(100)
|
184
|
+
|
185
|
+
if roll_dice < @stamina
|
186
|
+
puts "YOU'VE MADE IT. He retreated. Now stay safe. CONSTANT VIGILANCE!\n".blue
|
187
|
+
else
|
188
|
+
puts "He is too powerful. You cannot withstand.\n"
|
189
|
+
|
190
|
+
puts "\nYour men brought you back to #{@house.region.gsub("The", "the").light_green}. You people say, 'Brave as #{@name.light_green}, Lord of the #{@house.name.light_green}. He's the only one who has fought the Night.'"
|
191
|
+
|
192
|
+
puts "\nNever forget what you are, for surely the world will not. See you next time in the Game of Thrones.\n".blue
|
193
|
+
|
194
|
+
exit!
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
def continue
|
200
|
+
puts "\nWhen you are ready, press any key to continue.".light_red
|
201
|
+
|
202
|
+
input = gets.strip
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class PlayGOT::RockPaperScissors
|
2
|
+
attr_accessor :your_score, :enemy_score, :your_move, :enemy_move, :round
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
puts "This is a simple game of Rock, Paper, Scissors. Best 3 out of 5."
|
6
|
+
@your_score = 0
|
7
|
+
@enemy_score = 0
|
8
|
+
@round = 1
|
9
|
+
|
10
|
+
until @your_score == 3 || @enemy_score == 3
|
11
|
+
|
12
|
+
rock_paper_scissors
|
13
|
+
|
14
|
+
puts "Your move: #{@your_move.light_green}\nEnemy move: #{@enemy_move.light_green}"
|
15
|
+
|
16
|
+
if @your_move == "Rock" && @enemy_move == "Scissors" || @your_move == "Paper" && @enemy_move == "rock" || @your_move == "Scissors" && @enemy_move == "Paper"
|
17
|
+
@your_score += 1
|
18
|
+
puts "You win!\nYour Score: #{@your_score.to_s.light_green}\nEnemy Score:#{@enemy_score.to_s.light_green}"
|
19
|
+
|
20
|
+
elsif @your_move == @enemy_move
|
21
|
+
puts "Draw! No point is awarded."
|
22
|
+
|
23
|
+
else
|
24
|
+
@enemy_score += 1
|
25
|
+
puts "You lose!\nYour Score: #{your_score.to_s.light_green}\nEnemy Score:#{enemy_score.to_s.light_green}"
|
26
|
+
end
|
27
|
+
|
28
|
+
@round += 1
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def rock_paper_scissors
|
35
|
+
puts "Round #{@round.to_s.light_green} - Choose your move: Rock, Paper or Scissors?"
|
36
|
+
puts "1 - Rock\n2 - Paper\n3 - Scissors".blue
|
37
|
+
|
38
|
+
input = gets.strip
|
39
|
+
@enemy_move = ["Rock", "Paper", "Scissors"].sample
|
40
|
+
|
41
|
+
case input
|
42
|
+
when "1"
|
43
|
+
@your_move = "Rock"
|
44
|
+
when "2"
|
45
|
+
@your_move = "Paper"
|
46
|
+
when "3"
|
47
|
+
@your_move = "Scissors"
|
48
|
+
else
|
49
|
+
puts "You've spoken something mystical that I don't understand.".light_red
|
50
|
+
rock_paper_scissors
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/play_GOT.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "play_GOT/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "play_GOT"
|
8
|
+
spec.version = PlayGOT::VERSION
|
9
|
+
spec.authors = ["'Sophie Gu'"]
|
10
|
+
spec.email = ["'sophieqgu@gmail.com'"]
|
11
|
+
|
12
|
+
spec.summary = %q{A CLI role-playing game based on Game of Thrones.}
|
13
|
+
spec.description = %q{This is a simple CLI role-playing game based on the popular HBO series Game of Thrones. Select your own House, find your allies, conquer your enemies, and claim secret weapons along the way to help you take the throne! Write your own GOT legend today.}
|
14
|
+
spec.homepage = "https://github.com/sophieqgu/play_GOT"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://www.rubygems.org"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/sophieqgu/play_GOT"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/sophieqgu/play_GOT"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "pry"
|
42
|
+
spec.add_dependency "rest-client"
|
43
|
+
spec.add_dependency "json"
|
44
|
+
spec.add_dependency "colorize"
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: play_GOT
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "'Sophie Gu'"
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: colorize
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: This is a simple CLI role-playing game based on the popular HBO series
|
98
|
+
Game of Thrones. Select your own House, find your allies, conquer your enemies,
|
99
|
+
and claim secret weapons along the way to help you take the throne! Write your own
|
100
|
+
GOT legend today.
|
101
|
+
email:
|
102
|
+
- "'sophieqgu@gmail.com'"
|
103
|
+
executables: []
|
104
|
+
extensions: []
|
105
|
+
extra_rdoc_files: []
|
106
|
+
files:
|
107
|
+
- ".gitignore"
|
108
|
+
- CODE_OF_CONDUCT.md
|
109
|
+
- Gemfile
|
110
|
+
- Gemfile.lock
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/console
|
115
|
+
- bin/run
|
116
|
+
- bin/setup
|
117
|
+
- config/environment.rb
|
118
|
+
- lib/play_GOT/api.rb
|
119
|
+
- lib/play_GOT/cli.rb
|
120
|
+
- lib/play_GOT/house.rb
|
121
|
+
- lib/play_GOT/player.rb
|
122
|
+
- lib/play_GOT/rock_paper_scissors.rb
|
123
|
+
- lib/play_GOT/version.rb
|
124
|
+
- play_GOT.gemspec
|
125
|
+
homepage: https://github.com/sophieqgu/play_GOT
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata:
|
129
|
+
allowed_push_host: https://www.rubygems.org
|
130
|
+
homepage_uri: https://github.com/sophieqgu/play_GOT
|
131
|
+
source_code_uri: https://github.com/sophieqgu/play_GOT
|
132
|
+
changelog_uri: https://github.com/sophieqgu/play_GOT
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubygems_version: 3.0.3
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: A CLI role-playing game based on Game of Thrones.
|
152
|
+
test_files: []
|