From 14113339f9cbe6cd5ecdd6554d2478f45339c27e Mon Sep 17 00:00:00 2001 From: Yomi Eluwande Date: Wed, 26 Jul 2017 01:40:51 +0100 Subject: [PATCH] Removed complex conditionals --- src/components/Home.vue | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/components/Home.vue b/src/components/Home.vue index 7bf57dd..1709669 100644 --- a/src/components/Home.vue +++ b/src/components/Home.vue @@ -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})