-
Notifications
You must be signed in to change notification settings - Fork 2
Createjoin game #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Createjoin game #64
Changes from all commits
ee144ae
22ff3af
4c707c4
75d8461
97e708b
6918138
7bb01a0
9caee9c
86d6898
6f7fced
292c6c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ body { | |
| } | ||
|
|
||
| .new-account { | ||
| padding-top: 45px; | ||
| padding-top: 20px; | ||
| } | ||
|
|
||
| .team-profile { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,14 @@ def checkmate_coords(x, y) | |
| end | ||
| end | ||
|
|
||
| def white | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These helpers seem unnecessary and are ambiguously named
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was my understand that the way we have our model set up, these are necessary to populate one "player" on the board and all the color pieces they come with...
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, these were already defined. What was the change here then?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to make the methods public so I could access them. |
||
| players.find_by(color: 'white') | ||
| end | ||
|
|
||
| def black | ||
| players.find_by(color: 'black') | ||
| end | ||
|
|
||
| private | ||
|
|
||
| # Generates all avilable coords around the current | ||
|
|
@@ -100,14 +108,6 @@ def populate_right_white_half! | |
| create_piece('Rook', 'white', 7, 7) | ||
| end | ||
|
|
||
| def white | ||
| players.find_by(color: 'white') | ||
| end | ||
|
|
||
| def black | ||
| players.find_by(color: 'black') | ||
| end | ||
|
|
||
| def create_piece(type, color, x_pos, y_pos) | ||
| if color == 'white' | ||
| white.pieces.create(type: type, x_position: x_pos, y_position: y_pos, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class AddUsernameToUsers < ActiveRecord::Migration[5.0] | ||
| def change | ||
| add_column :users, :username, :string | ||
| end | ||
| end |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this doing? IIRC there isn't aNVMwhiteattribute on gameUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is performing three db writes + a read, and is inefficient. The game should be created and populated with the player all in one fell swoop.