Skip to content

Adding team games#72

Open
jshemas wants to merge 13 commits intomasterfrom
doubles
Open

Adding team games#72
jshemas wants to merge 13 commits intomasterfrom
doubles

Conversation

@jshemas
Copy link
Copy Markdown
Owner

@jshemas jshemas commented Oct 24, 2013

Things done so far:

  • able to add team
  • able to look up a single team
  • able to team matches
  • able to delete match
  • able to delete team

@jshemas
Copy link
Copy Markdown
Owner Author

jshemas commented Oct 25, 2013

Poking around in the code and notice that model/Match.js is using players as a ref. This is a problem because when a team is added the winners is a team id not a player id.

Should fix that before this PR is merged.

Edit: this has been fixed with 949ef4d

@tandrewnichols
Copy link
Copy Markdown
Contributor

It was done because it's expedient, since you can just add .populate('winner loser') when you query matches. But it was obviously not chosen with team games in mind. If we change that, we'll have to change all the .populate() calls as well.

@jshemas
Copy link
Copy Markdown
Owner Author

jshemas commented Oct 28, 2013

Blah. That really messes up what i'm trying to do. I'm trying to think of a way to solve this without making a new model for match.

@jshemas
Copy link
Copy Markdown
Owner Author

jshemas commented Oct 28, 2013

Okay. If we add winnerTeam and loserTeam to match model which references teams ID, this should work.

@jshemas
Copy link
Copy Markdown
Owner Author

jshemas commented Oct 28, 2013

Okay, updated match delete to work with teams games. I'm going to do some of the front end work in this PR while I wait for a code review.

@tandrewnichols
Copy link
Copy Markdown
Contributor

Do you think it's possible (or maybe a better way to ask this, what is the effort level) to just make winner and loser an array of player ids? If you've got a separate Team schema, this isn't possible (or at least, it's not easy), but I'm wondering if we could just check the length of the array to know if it's a solo game or team game. I'm pretty sure .populate() will expand arrays . . . I should probably look at what you've done though before I go too far down this rabbit hole.

Comment thread app/routes/match.js
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.

Does this work for null values? Like, if it's a team game, winner and loser will be empty, right? Maybe (for clarity) we want to separate these out, so that you only ever get regular matches OR team matches, but not a mix of both. Something like Match.prototype.teamMatch?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yes, this works on NULL values. The reason I don't want to separate the logic out, is because I thought it would make it overly complicated. ((match.js is all ready hard to understand in some places))

Maybe i'll add a comment or two where .populate are

@tandrewnichols
Copy link
Copy Markdown
Contributor

Looks good - though I don't understand why winnerTeam and loserTeam are arrays. But other than that (and maybe even with that), I think this is ready. 👍 :shipit:

@jshemas
Copy link
Copy Markdown
Owner Author

jshemas commented Oct 29, 2013

Updated the code. winnerTeam and loserTeam should not be arrays. And delete match has been cleaned up a bit.

Since I have almost all of the front-end work done in this PR, I think i'm going to try and finished it before this is merge.

@danielxhenson
Copy link
Copy Markdown

I know this has been inactive for a while, but I'm curious if the team ability is functioning?

@jshemas
Copy link
Copy Markdown
Owner Author

jshemas commented Oct 31, 2016

@danielxhenson I believe it was mostly working. I think there was still one or two bugs with the scoring. Feel free to fork it and see if it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants