]> git.cworth.org Git - empires-server/commitdiff
Remove a positive vote for a prompt when adding a negative vote
authorCarl Worth <cworth@cworth.org>
Sun, 28 Jun 2020 22:04:00 +0000 (15:04 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 28 Jun 2020 22:04:00 +0000 (15:04 -0700)
This is important to do here because the current client interface
doesn't let a player see a prompt again after adding a negative vote,
(so they wouldn't know their positive vote was still there nor could
they remove it themself).

empathy.js

index 50d18d59dce942115f19d5852df191c49ae601d3..7b1e9a1a7e79815a4d6c581f22562056bbb27f04 100644 (file)
@@ -598,10 +598,14 @@ class Prompt {
   }
 
   toggle_vote_against(player_name) {
-    if (this.votes_against.find(v => v === player_name))
+    if (this.votes_against.find(v => v === player_name)) {
       this.votes_against = this.votes_against.filter(v => v !== player_name);
-    else
+    } else {
       this.votes_against.push(player_name);
+      /* When voting against, we also remove any vote _for_ the same
+       * prompt. */
+      this.votes = this.votes.filter(v => v !== player_name);
+    }
   }
 }