Skip to content

Commit

Permalink
Removed complex conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomi Eluwande authored Jul 26, 2017
1 parent 9ace8c0 commit 1411333
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,24 +239,10 @@
this.playerdata.two.score += 10
}
} else {
if (this.playerdata.one.score < 10 && this.playerdata.two.score === 0) {
if (this.userid === 1) {
this.playerdata.one.score = 0
} else if (this.userid === 2) {
this.playerdata.two.score = 0
}
} else if (this.playerdata.two.score < 10 && this.playerdata.one.score === 0) {
if (this.userid === 1) {
this.playerdata.one.score = 0
} else if (this.userid === 2) {
this.playerdata.two.score = 0
}
} else {
if (this.userid === 1 && this.playerdata.one.score > 0) {
this.playerdata.one.score -= 10
} else if (this.userid === 2 && this.playerdata.two.score > 0) {
this.playerdata.two.score -= 10
}
if (this.userid === 1) {
this.playerdata.one.score = Math.max(0, this.playerdata.one.score -= 10)
} else if (this.userid === 2) {
this.playerdata.two.score = Math.max(0, this.playerdata.two.score -= 10)
}
}
channel.trigger('client-send', {data: this.playerdata})
Expand Down

0 comments on commit 1411333

Please sign in to comment.