Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b1e2c8e
Add move_number to games table
Se7enB2st Jul 29, 2016
5418744
En Passant first attempt
Se7enB2st Jul 29, 2016
00755cc
Add first_turn logic to game model
Se7enB2st Jul 30, 2016
ff0f3b7
integrate end_turn! into move! & pass all tests
Se7enB2st Jul 30, 2016
d8db2ed
add end_turn! tests in game_spec.rb and pass all tests
Se7enB2st Jul 30, 2016
3fc6f00
En Passsant Logic 2nd attempt
Se7enB2st Jul 30, 2016
4bad9e0
refactor en passant logics
Se7enB2st Jul 30, 2016
11ad23c
add en_passant left and right pawn logic
Se7enB2st Jul 31, 2016
2dab1d0
refactor En Passant Logic & Working in console
Se7enB2st Jul 31, 2016
728cb71
unit tests for En_Passant? logic
Se7enB2st Jul 31, 2016
3d78eb0
refactor en passant RSpec tests
Se7enB2st Jul 31, 2016
30efba2
remove duplicate files
Se7enB2st Jul 31, 2016
cbdc2e8
Add move_number to games table
Se7enB2st Jul 29, 2016
681a00f
En Passant first attempt
Se7enB2st Jul 29, 2016
00ee14c
Add first_turn logic to game model
Se7enB2st Jul 30, 2016
b7d4f74
integrate end_turn! into move! & pass all tests
Se7enB2st Jul 30, 2016
b9d8175
add end_turn! tests in game_spec.rb and pass all tests
Se7enB2st Jul 30, 2016
f64eeb4
En Passsant Logic 2nd attempt
Se7enB2st Jul 30, 2016
666acce
refactor en passant logics
Se7enB2st Jul 30, 2016
6b1ba61
add en_passant left and right pawn logic
Se7enB2st Jul 31, 2016
68ce476
refactor En Passant Logic & Working in console
Se7enB2st Jul 31, 2016
08b4406
unit tests for En_Passant? logic
Se7enB2st Jul 31, 2016
2f3b195
refactor en passant RSpec tests
Se7enB2st Jul 31, 2016
a19fa07
remove duplicate files
Se7enB2st Jul 31, 2016
97fd6df
resolve merge conflict
Se7enB2st Aug 6, 2016
43aa66d
fix end_turn! error
Se7enB2st Aug 6, 2016
1883571
add Ethan's LinkedIn to README
Se7enB2st Aug 6, 2016
80a9573
Integrate pawn capture logic and resolve merge conflicts
Se7enB2st Aug 6, 2016
63194d8
merge en_passant into capture
Se7enB2st Aug 6, 2016
2c09cd3
add en passant capture logic
Se7enB2st Aug 6, 2016
4a2b24a
fix Rubocop errors
Se7enB2st Aug 6, 2016
d8c230a
Fix merge conflict
Se7enB2st Aug 6, 2016
db950b6
En Passant Capture logic now working with move! logic
Se7enB2st Aug 7, 2016
9d9af53
fix merge conflicts
Se7enB2st Aug 7, 2016
775dd87
Fix Rubocop errors
Se7enB2st Aug 7, 2016
50c24f8
fix merge conflicts & add test for non-pawn piece
Se7enB2st Aug 8, 2016
0e1383f
fix merge conflicts due to check logic implementation
Se7enB2st Aug 8, 2016
8adf4ee
clean up database
Se7enB2st Aug 9, 2016
463a9ee
refactor En Passant logic
Se7enB2st Aug 9, 2016
d4ca87d
Merge branch 'master' into En_Passant
chadbaum Aug 9, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ Contributors

* [Aleks Gorbenko](mailto:aleksedgorbenko@gmail.com) | [GitHub](https://github.com/aleksgorbenko) | [LinkedIn](https://uk.linkedin.com/in/aleks-gorbenko-web-developer) | [Portfolio](https://aleksgorbenko.github.io/) | [Blog](https://aleksgorbenko.com)

* [Ethan He](mailto:ethanhe.dev@gmail.com) | [GitHub](https://github.com/Se7enB2st)
* [Ethan He](mailto:ethanhe.dev@gmail.com) | [GitHub](https://github.com/Se7enB2st) |
[LinkedIn](https://www.linkedin.com/in/ethan-he)
9 changes: 9 additions & 0 deletions app/models/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Game < ActiveRecord::Base
after_save :create_players!

def populate!
first_turn!
populate_left_black_half!
populate_right_black_half!
populate_black_pawns!
Expand All @@ -16,6 +17,10 @@ def populate!
populate_right_white_half!
end

def end_turn!
increment!(:turn)
end

def check?(color)
king = king(color)
enemy_pcs(color).each do |p|
Expand Down Expand Up @@ -96,4 +101,8 @@ def create_piece(type, color, x_pos, y_pos)
color: 'black', game_id: id)
end
end

def first_turn!
update(turn: 1)
end
end
50 changes: 49 additions & 1 deletion app/models/pawn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Pawn < Piece
# takes place by moving forward. Check, and checkmate logic
# are not implemented yet and thus ignored.
def valid_move?(x, y)
return true if fwd_diagonal_attack?(x, y)
return true if fwd_diagonal_attack?(x, y) || en_passant_capture?(x, y)
moved ? one_fwd_move?(x, y) : first_fwd_move?(x, y) && !fwd_attack?(x, y)
end

Expand All @@ -20,6 +20,49 @@ def promote!(new_type)

private

# En Passant Logic:
# 1)target pawn just moved 2 space forward
# 2)only capture within the next turn
# 3)can only capture by opponent's pawn

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what step 3 means. En Passant does not require that the ONLY piece available to capture the victim be the pawn, only that the pawn COULD have captured it in the first space on the previous turn.

# 4)opponent pawn must be on the left or right of target piece's y axis

# En Passant Capture logic
def en_passant_capture?(x, y)
return true if en_passant_possible?(x, y) || en_passant_y_diff?(x, y)
end

# Return false if victim piece is nil or same color
# Return true if victim piece's y axis difference is equal to 1
def en_passant_y_diff?(x, y)
victim = last_moved_piece
return false if victim.nil? || victim.color == color

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last moved piece will be always opponents piece, so victim.color == color validation seems to be unnecessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since turn base logic is not implemented yet, this is needed at this point. Will refactor this method turn base logic is added in separate PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't turn-based logic completely implemented in this PR? Turn in game model, start turn at 1, increment turn at end of every successful move.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It about 50% done in this PR, same color can move multiple turns in a row in this PR. I am working on the other half right now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this, Is the turn logic being implemented in this PR then? We definitely require turn logic for a valid en passant

return true if x == victim.x_position &&
(y == victim.y_position - 1 || y == victim.y_position + 1)
end

# Return false if last move piece is nil (Start of game)
# Return false last moved piece is not pawn or its y axis difference is !2
# Check both both adjacent side of pawn
# If any have valid En Passant pawn piece, return true
def en_passant_possible?(x, y)
return false if last_moved_piece.nil?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this guard clause if last_moved_piece returning nil in the next line will cause that to return false anyway?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is require for edge case, where at first turn there is no last moved piece.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that, but why do you need this guard clause? If the statement returns nil, it will be handled by next statement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would cause an error in the next statement since you can't call any method on nil object.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guards should be as close to the error as possible so as to guarantee that the error is caught in the right spot & reduce the need for logic duplication.

return false unless last_moved_piece.y_distance(y) == 2 &&
type == 'Pawn'

@chadbaum chadbaum Aug 9, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, you moved y_distance to a public method and are now invoking it on the last_moved_piece, which would be the pawn victim. But if you pass in the coordinate of where pawn is going to "attack" as the coordinate behind where the victim is now, I don't see how this logic could work. If victim is at 3,3 and aggressor pawn is at 4,3, calling this method on 3,2 which is where aggressor pawn would 'attack' would fail this check. It would resolve as:

abs(victim.y_position - y)
abs(3 - 0)
abs(3)
3

EDIT: Are you intending on passing in the coords of where the victim is or the tile in which pawn is attacking?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent of this method is to pass the coordinates of where victim piece is at.

I just refactor the method; now it works with y_distance(y) == 2.
This method now will only pass if victim piece is pawn and moved two space forward in the last turn.

[valid_en_passant_pawn?(x, y, true), valid_en_passant_pawn?(x, y, false)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this bit should be also made more readable

@Se7enB2st Se7enB2st Aug 9, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method refactor version of following methods:

def valid_en_passant_pawn?(x, y)
     return false unless valid_passant_pawn_left?(x, y)
     return false unless valid_passant_pawn_right?(x. y)
     false
  end

   def valid_passant_pawn_left?(x, y)
     left_piece = find_piece(x - 1, y)
     return false if left_piece.nil?
     return true if left_piece.type == 'Pawn' && side_piece.color != color
     false
   end

   def valid_passant_pawn_right?(x, y)
     right_piece = find_piece(x + 1, y)
     return false if right_piece.nil?
     return true if right_piece.type == 'Pawn' && side_piece.color != color
     false
   end

.include?(true)
end

# Check for any adjacent piece
# Return false if none if found
# Return true if opponent's pawn is found
def valid_en_passant_pawn?(x, y, adjacent)
adjacent_piece = occupant_piece(x + (adjacent ? 1 : -1), y)
return false if adjacent_piece.nil?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this guard clause.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to remove this line, but it causes the method to return Nil class error.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what the adjacent parameter is doing? I see you passing true and false between these 2 methods but they are not commented.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just because a pawn is adjacent to another pawn does not make it a valid en passant victim so I think the name and return of this method are misleading. What makes it valid is this PLUS the victim having moved 2 spaces forward last turn.

@Se7enB2st Se7enB2st Aug 9, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method checks if there is any valid pawn adjacent to the victim pawn(include? true or false). If any of adjacent side have a valid pawn, it will return true. A separate method check if the pawn moved 2 space forward in the last turn.

This was the rafactored version of following methods:

def valid_en_passant_pawn?(x, y)
return false unless valid_passant_pawn_left?(x, y)
return false unless valid_passant_pawn_right?(x. y)
false
end

def valid_passant_pawn_left?(x, y)
left_piece = find_piece(x - 1, y)
return false if left_piece.nil?
return true if left_piece.type == 'Pawn' && side_piece.color != color
false
end

def valid_passant_pawn_right?(x, y)
right_piece = find_piece(x + 1, y)
return false if right_piece.nil?
return true if right_piece.type == 'Pawn' && side_piece.color != color
false
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the other method you are referring to that checks the 2 spaces forward. IMO this logic should all be one method, it is really hard to follow otherwise.

return true if adjacent_piece.type == 'Pawn' &&
adjacent_piece.color != color
false
end

# Returns true if the coordinates provided are 1 tile forward
# from the piece's origin and no capture occured.
def one_fwd_move?(x, y)
Expand Down Expand Up @@ -63,4 +106,9 @@ def fwd_diagonal_attack?(x, y)
y_position - 1
end
end

# Find the last moved piece by subtracting current move number - 1
def last_moved_piece
game.pieces.find_by(turn_last_moved: game.turn - 1)
end
end
19 changes: 10 additions & 9 deletions app/models/piece.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ def move!(x, y)
return false unless enemy?(victim)
capture!(victim)
end
update(x_position: x, y_position: y, moved: true)
update(x_position: x, y_position: y, moved: true,
turn_last_moved: game.turn)
game.end_turn!
# if checked_king(white_king)
# elsif checked_king(black_king)
# end

true
end

# Compares a piece's y_position with the
# coordinate provided and returns the
# distance between the two.
def y_distance(new_y_coordinate)
(y_position - new_y_coordinate).abs
end

# All validation assumes white player is on the
# 6-7 rows of the array, and black player is on
# 0-1 rows of the array.
Expand Down Expand Up @@ -61,13 +69,6 @@ def x_distance(new_x_coordinate)
(x_position - new_x_coordinate).abs
end

# Compares a piece's y_position with the
# coordinate provided and returns the
# distance between the two.
def y_distance(new_y_coordinate)
(y_position - new_y_coordinate).abs
end

# Returns true if the coordinates provided
# are different from the piece's starting
# position.
Expand Down
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#Application.rb
require File.expand_path('../boot', __FILE__)

require 'rails/all'
Expand Down
4 changes: 3 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Production.rb
StoicChess::Application.configure do
config.action_mailer.default_url_options = { host: 'stoicchess-teamstoic.herokuapp.com' }
config.action_mailer.default_url_options =
{ host: 'stoicchess-teamstoic.herokuapp.com' }
# Settings specified here will take precedence over those in
# config/application.rb.

Expand Down
4 changes: 3 additions & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#test.rb
StoicChess::Application.configure do
# Settings specified here will take precedence over those in
# config/application.rb.
Expand All @@ -19,7 +20,8 @@

# Configure static asset server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
config.public_file_server.headers =
{ 'Cache-Control' => 'public, max-age=3600' }

# Show full error reports and disable caching.
config.consider_all_requests_local = true
Expand Down
6 changes: 4 additions & 2 deletions config/initializers/backtrace_silencers.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Be sure to restart your server when you modify this file.

# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# You can add backtrace silencers for libraries that you're using
# but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }

# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# You can also remove all the silencers if you're trying to debug a problem
# that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
4 changes: 3 additions & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
# :subdomain], so for authenticating a user, both parameters
# are required.
#
# Remember that those parameters are used only when authenticating and not when retrieving from session. If you need permissions, you should implement that in a before filter.
# Remember that those parameters are used only when authenticating
# and not when retrieving from session. If you need permissions,
# you should implement that in a before filter.
#
# You can also supply a hash where the value is a boolean
# determining whether
Expand Down
5 changes: 4 additions & 1 deletion config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@

# Make sure your secret_key_base is kept private
# if you're sharing your code publicly.
StoicChess::Application.config.secret_key_base = 'b02af4ed78836e0a007c890e7f38df540669ad77d076cffe3899647bfbfd000e5e5080fc5841fff22763a5ce871d3f4f077b4c2693f964cdd67c0da25d6fad29'
StoicChess::Application.config.secret_key_base =
'b02af4ed78836e0a007c890e7f38df540669ad77d076cff
e3899647bfbfd000e5e5080fc5841fff22763a5ce871d3f4
f077b4c2693f964cdd67c0da25d6fad29'
3 changes: 2 additions & 1 deletion config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Be sure to restart your server when you modify this file.

StoicChess::Application.config.session_store :cookie_store, key: '_StoicChess_session'
StoicChess::Application.config.session_store :cookie_store, key:
'_StoicChess_session'
3 changes: 2 additions & 1 deletion config/initializers/wrap_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.

# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
# Enable parameter wrapping for JSON. You can disable this by setting
# :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20160629091417_devise_create_users.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#devise auto migration
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
Expand Down
3 changes: 2 additions & 1 deletion db/migrate/20160712160707_create_games.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# game model
class CreateGames < ActiveRecord::Migration
def change
create_table :games do |t|
t.string :winning_player
t.string :game_status

t.integer :counter
t.integer :turn
t.integer :user_id
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20160719140518_add_moved_to_pieces.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# add moved to pieces table
class AddMovedToPieces < ActiveRecord::Migration[5.0]
def change
add_column :pieces, :moved, :boolean, default: false
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20160729214941_add_move_number_to_games.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMoveNumberToGames < ActiveRecord::Migration[5.0]
def change
add_column :games, :move_number, :integer
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160730005057_add_en_passant_to_games.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddEnPassantToGames < ActiveRecord::Migration[5.0]
def change
add_column :games, :en_passant, :boolean, default: false
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160730144006_change_turn_type_to_string.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeTurnTypeToString < ActiveRecord::Migration[5.0]
def change
change_column :games, :turn, :string
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddLastMovedPieceToPiecesTable < ActiveRecord::Migration[5.0]
def change
add_column :pieces, :last_moved_piece, :integer
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160809143920_remove_en_passant_from_game.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveEnPassantFromGame < ActiveRecord::Migration[5.0]
def change
remove_column :games, :en_passant, :boolean
end
end
6 changes: 6 additions & 0 deletions db/migrate/20160809145214_change_turn_from_games.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class ChangeTurnFromGames < ActiveRecord::Migration[5.0]
def change
remove_column :games, :turn, :integer
remove_column :games, :move_number, :integer
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160809150350_add_turn_to_games.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddTurnToGames < ActiveRecord::Migration[5.0]
def change
add_column :games, :turn, :integer
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeLastMovedPieceFromPieces < ActiveRecord::Migration[5.0]
def change
rename_column :pieces, :last_moved_piece, :turn_last_moved
end
end
11 changes: 6 additions & 5 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160806192848) do
ActiveRecord::Schema.define(version: 20160809151435) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -19,9 +19,9 @@
t.string "winning_player"
t.string "game_status"
t.integer "counter"
t.integer "turn"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "turn"
end

create_table "pieces", force: :cascade do |t|
Expand All @@ -31,11 +31,12 @@
t.integer "y_position"
t.integer "game_id"
t.integer "player_id"
t.boolean "captured", default: false
t.boolean "checkmate", default: false
t.boolean "captured", default: false
t.boolean "checkmate", default: false
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "moved", default: false
t.boolean "moved", default: false
t.integer "turn_last_moved"
end

create_table "players", force: :cascade do |t|
Expand Down
22 changes: 22 additions & 0 deletions spec/models/game_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,40 @@
it 'should give us 32 pieces upon board population' do
expect(game.pieces.count).to eq 32
end

it 'should give me the last x position of population' do
expect(game.pieces.last.x_position).to eq 7
end

it 'should give me the last y position of population' do
expect(game.pieces.last.y_position).to eq 7
end

it 'should give me the last piece of the population as the King' do
expect(game.pieces.last.type).to eq 'Rook'
end

it 'should give me the last pieces color' do
expect(game.pieces.last.color).to eq 'white'
end

it 'should show turn as 1' do
expect(game.turn).to eq 1
end

describe 'end_turn!' do
it 'should increment turn by 1 once the turn ended' do
game.end_turn!

expect(game.turn).to eq 2
end
end

describe 'first_turn' do
it 'should show turn as 1' do
expect(game.turn).to eq 1
end
end
end

describe 'check?' do
Expand Down
Loading