anakhi 0.1.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/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/anakhi.gemspec +34 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/.DS_Store +0 -0
- data/lib/anakhi.rb +84 -0
- data/lib/anakhi/board.rb +131 -0
- data/lib/anakhi/player.rb +53 -0
- data/lib/anakhi/version.rb +3 -0
- metadata +103 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 01d0aa83c1fb888bd96120195686a224368218e3
|
|
4
|
+
data.tar.gz: a9924caefedecdafa3794e31432e770cc1866bda
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 056ef6a6b6e04e9f9a43add74c6716711c1a02642b7e1d09302e60416ee3e313ddb2102b41ca48e4ab0546e2616d45851a318ad7b3f2fb0873cbbae2bb990316
|
|
7
|
+
data.tar.gz: c6663bb060d499e90bbf1cd80ababc85325dd82ea1342167408a8ae15d73c473176085088ea08ec1db4449996acfc3dd4c5b2d999ecff8bac5b9c15ec4a60b7f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
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 alyss.noland@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/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Alyss Noland
|
|
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,43 @@
|
|
|
1
|
+
# Anakhi
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/anakhi`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'anakhi'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install anakhi
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
+
|
|
31
|
+
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).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/anakhi. 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.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
40
|
+
|
|
41
|
+
## Code of Conduct
|
|
42
|
+
|
|
43
|
+
Everyone interacting in the Anakhi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/anakhi/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/anakhi.gemspec
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "anakhi/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "anakhi"
|
|
8
|
+
spec.version = Anakhi::VERSION
|
|
9
|
+
spec.authors = ["Alyss Noland"]
|
|
10
|
+
spec.email = ["alyss.noland@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{TicTacToe Gem Project from Viking Code School}
|
|
13
|
+
spec.description = %q{TicTacToe Gem Project from Viking Code School}
|
|
14
|
+
spec.homepage = "https://github.com/PreciselyAlyss/ananki"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
if spec.respond_to?(:metadata)
|
|
18
|
+
# We modified this to point to Rubygems:
|
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
20
|
+
else
|
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
|
26
|
+
end
|
|
27
|
+
spec.bindir = "exe"
|
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
29
|
+
spec.require_paths = ["lib"]
|
|
30
|
+
|
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
34
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "anakhi"
|
|
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/setup
ADDED
data/lib/.DS_Store
ADDED
|
Binary file
|
data/lib/anakhi.rb
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require "anakhi/version"
|
|
2
|
+
require "anakhi/player"
|
|
3
|
+
require "anakhi/board"
|
|
4
|
+
|
|
5
|
+
module Anakhi
|
|
6
|
+
class TicTacToe
|
|
7
|
+
# initialize
|
|
8
|
+
def initialize
|
|
9
|
+
# set up the board
|
|
10
|
+
@board = Board.new
|
|
11
|
+
|
|
12
|
+
# set up the players
|
|
13
|
+
@player_x = Player.new("Madame X", :x, @board)
|
|
14
|
+
@player_y = Player.new("Mister Y", :y, @board)
|
|
15
|
+
|
|
16
|
+
# assign the starting player
|
|
17
|
+
@current_player = @player_x
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# play
|
|
21
|
+
def play
|
|
22
|
+
|
|
23
|
+
# loop infinitely
|
|
24
|
+
loop do
|
|
25
|
+
# call the board rendering method
|
|
26
|
+
@board.render
|
|
27
|
+
|
|
28
|
+
# ask for coordinates from the current player
|
|
29
|
+
@current_player.get_coordinates
|
|
30
|
+
|
|
31
|
+
# check if game is over
|
|
32
|
+
break if check_game_over
|
|
33
|
+
|
|
34
|
+
# switch players
|
|
35
|
+
switch_players
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# check_game_over?
|
|
40
|
+
def check_game_over
|
|
41
|
+
# check for victory
|
|
42
|
+
# check for draw
|
|
43
|
+
check_victory || check_draw
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# check_victory?
|
|
47
|
+
def check_victory
|
|
48
|
+
# IF Board says current player's piece has
|
|
49
|
+
# a winning_combination?
|
|
50
|
+
if @board.winning_combination?(@current_player.piece)
|
|
51
|
+
# then output a victory message
|
|
52
|
+
puts "Congratulations #{@current_player.name}, you win!"
|
|
53
|
+
true
|
|
54
|
+
else
|
|
55
|
+
false
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# check_draw?
|
|
60
|
+
def check_draw
|
|
61
|
+
# If Board says we've filled up
|
|
62
|
+
if @board.full?
|
|
63
|
+
# display draw message
|
|
64
|
+
puts "Bummer, you've drawn..."
|
|
65
|
+
true
|
|
66
|
+
else
|
|
67
|
+
false
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# switch_players
|
|
72
|
+
def switch_players
|
|
73
|
+
if @current_player == @player_x
|
|
74
|
+
@current_player = @player_y
|
|
75
|
+
else
|
|
76
|
+
@current_player = @player_x
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
t = TicTacToe.new
|
|
83
|
+
t.play
|
|
84
|
+
end
|
data/lib/anakhi/board.rb
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Maintains game board state
|
|
2
|
+
class Board
|
|
3
|
+
# initialize board
|
|
4
|
+
def initialize
|
|
5
|
+
# set up blank data structure
|
|
6
|
+
@board = Array.new(3){Array.new(3)}
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# render
|
|
10
|
+
def render
|
|
11
|
+
puts
|
|
12
|
+
# loop through data structure
|
|
13
|
+
@board.each do |row|
|
|
14
|
+
row.each do |cell|
|
|
15
|
+
# display an existing marker if any, else blank
|
|
16
|
+
cell.nil? ? print("-") : print(cell.to_s)
|
|
17
|
+
end
|
|
18
|
+
puts
|
|
19
|
+
end
|
|
20
|
+
puts
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# add_piece
|
|
25
|
+
def add_piece(coords, piece)
|
|
26
|
+
# IF piece_location_valid?
|
|
27
|
+
if piece_location_valid?(coords)
|
|
28
|
+
# place piece
|
|
29
|
+
@board[coords[0]][coords[1]] = piece
|
|
30
|
+
true
|
|
31
|
+
else
|
|
32
|
+
false
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# piece_location_valid?
|
|
37
|
+
def piece_location_valid?(coords)
|
|
38
|
+
# Is the placement within_valid_coordinates?
|
|
39
|
+
if within_valid_coordinates?(coords)
|
|
40
|
+
# Are the piece coordinates_available?
|
|
41
|
+
coordinates_available?(coords)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# within_valid_coordinates?
|
|
46
|
+
def within_valid_coordinates?(coords)
|
|
47
|
+
# UNLESS piece coords are in the acceptible range
|
|
48
|
+
if (0..2).include?(coords[0]) && (0..2).include?(coords[1])
|
|
49
|
+
true
|
|
50
|
+
else
|
|
51
|
+
# display an error message
|
|
52
|
+
puts "Piece coordinates are out of bounds"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# coordinates_available?
|
|
57
|
+
def coordinates_available?(coords)
|
|
58
|
+
# UNLESS piece coords are not occupied
|
|
59
|
+
if @board[coords[0]][coords[1]].nil?
|
|
60
|
+
true
|
|
61
|
+
else
|
|
62
|
+
# display error message
|
|
63
|
+
puts "There is already a piece there!"
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# winning_combination?
|
|
68
|
+
def winning_combination?(piece)
|
|
69
|
+
# is there a winning_diagonal?
|
|
70
|
+
# or winning_vertical?
|
|
71
|
+
# or winning_horizontal? for that piece?
|
|
72
|
+
winning_diagonal?(piece) ||
|
|
73
|
+
winning_horizontal?(piece) ||
|
|
74
|
+
winning_vertical?(piece)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# winning_diagonal?
|
|
78
|
+
def winning_diagonal?(piece)
|
|
79
|
+
# check if specified piece has a triplet across diagonals
|
|
80
|
+
diagonals.any? do |diag|
|
|
81
|
+
diag.all?{|cell| cell == piece }
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# winning_vertical?
|
|
86
|
+
def winning_vertical?(piece)
|
|
87
|
+
# check if specified piece has a triplet across verticals
|
|
88
|
+
verticals.any? do |vert|
|
|
89
|
+
vert.all?{|cell| cell == piece }
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# winning_horizontal?
|
|
94
|
+
def winning_horizontal?(piece)
|
|
95
|
+
# check if specified piece has a triplet across horizontals
|
|
96
|
+
horizontals.any? do |horz|
|
|
97
|
+
horz.all?{|cell| cell == piece }
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# diagonals
|
|
102
|
+
def diagonals
|
|
103
|
+
# return the diagonal pieces
|
|
104
|
+
[[ @board[0][0],@board[1][1],@board[2][2] ],[ @board[2][0],@board[1][1],@board[0][2] ]]
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# verticals
|
|
108
|
+
def verticals
|
|
109
|
+
# return the vertical pieces
|
|
110
|
+
@board
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# horizontals
|
|
114
|
+
def horizontals
|
|
115
|
+
# return the horizontal pieces
|
|
116
|
+
horizontals = []
|
|
117
|
+
3.times do |i|
|
|
118
|
+
horizontals << [@board[0][i],@board[1][i],@board[2][i]]
|
|
119
|
+
end
|
|
120
|
+
horizontals
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# full?
|
|
124
|
+
def full?
|
|
125
|
+
# does every square contain a piece?
|
|
126
|
+
@board.all? do |row|
|
|
127
|
+
row.none?(&:nil?)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Manages all player-related functionality
|
|
2
|
+
class Player
|
|
3
|
+
attr_accessor :name, :piece
|
|
4
|
+
|
|
5
|
+
# initialize
|
|
6
|
+
def initialize(name = "Mystery_Player", piece, board)
|
|
7
|
+
# Set marker type (e.g. X or O)
|
|
8
|
+
raise "Piece must be a Symbol!" unless piece.is_a?(Symbol)
|
|
9
|
+
@name = name
|
|
10
|
+
@piece = piece
|
|
11
|
+
@board = board
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# get_coordinates
|
|
15
|
+
def get_coordinates
|
|
16
|
+
# loop infinitely
|
|
17
|
+
loop do
|
|
18
|
+
# ask_for_coordinates
|
|
19
|
+
coords = ask_for_coordinates
|
|
20
|
+
|
|
21
|
+
# IF validate_coordinates_format is true
|
|
22
|
+
if validate_coordinates_format(coords)
|
|
23
|
+
# IF piece can be placed on Board
|
|
24
|
+
if @board.add_piece(coords, @piece)
|
|
25
|
+
# break the loop
|
|
26
|
+
break
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# ask_for_coordinates
|
|
34
|
+
def ask_for_coordinates
|
|
35
|
+
# Display message asking for coordinates
|
|
36
|
+
puts "#{@name}(#{@piece}), enter your coordinates in the form x,y:"
|
|
37
|
+
# pull coordinates from command line
|
|
38
|
+
gets.strip.split(",").map(&:to_i)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# validate_coordinates_format
|
|
42
|
+
def validate_coordinates_format(coords)
|
|
43
|
+
# UNLESS coordinates are in the proper format
|
|
44
|
+
if coords.is_a?(Array) && coords.size == 2
|
|
45
|
+
true
|
|
46
|
+
else
|
|
47
|
+
# display error message
|
|
48
|
+
# Note that returning `nil` acts falsy!
|
|
49
|
+
puts "Your coordinates are in the improper format!"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: anakhi
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alyss Noland
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-07-02 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: '1.15'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.15'
|
|
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: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description: TicTacToe Gem Project from Viking Code School
|
|
56
|
+
email:
|
|
57
|
+
- alyss.noland@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".rspec"
|
|
64
|
+
- ".travis.yml"
|
|
65
|
+
- CODE_OF_CONDUCT.md
|
|
66
|
+
- Gemfile
|
|
67
|
+
- LICENSE.txt
|
|
68
|
+
- README.md
|
|
69
|
+
- Rakefile
|
|
70
|
+
- anakhi.gemspec
|
|
71
|
+
- bin/console
|
|
72
|
+
- bin/setup
|
|
73
|
+
- lib/.DS_Store
|
|
74
|
+
- lib/anakhi.rb
|
|
75
|
+
- lib/anakhi/board.rb
|
|
76
|
+
- lib/anakhi/player.rb
|
|
77
|
+
- lib/anakhi/version.rb
|
|
78
|
+
homepage: https://github.com/PreciselyAlyss/ananki
|
|
79
|
+
licenses:
|
|
80
|
+
- MIT
|
|
81
|
+
metadata:
|
|
82
|
+
allowed_push_host: https://rubygems.org
|
|
83
|
+
post_install_message:
|
|
84
|
+
rdoc_options: []
|
|
85
|
+
require_paths:
|
|
86
|
+
- lib
|
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
requirements: []
|
|
98
|
+
rubyforge_project:
|
|
99
|
+
rubygems_version: 2.4.5.1
|
|
100
|
+
signing_key:
|
|
101
|
+
specification_version: 4
|
|
102
|
+
summary: TicTacToe Gem Project from Viking Code School
|
|
103
|
+
test_files: []
|