Skip to content

Commit

Permalink
Added "add voter sunflower" button, so we can add resizable voter gro…
Browse files Browse the repository at this point in the history
…ups.
  • Loading branch information
paretoman committed Aug 16, 2019
1 parent ffb3e07 commit b2e7dde
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Binary file added play/img/plus_sunflower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 19 additions & 7 deletions play/js/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,11 @@ function Arena(arenaName, model) {
self.plusCandidate = new Plus(model)
self.plusOneVoter = new Plus(model)
self.plusVoterGroup = new Plus(model)
self.plusXVoterGroup = new Plus(model)
self.plusCandidate.isPlusCandidate = true
self.plusOneVoter.isPlusOneVoter = true
self.plusVoterGroup.isPlusVoterGroup = true
self.plusXVoterGroup.isPlusXVoterGroup = true
self.trashes = new Trashes(model)
self.modify = new Modify(model)
}
Expand All @@ -430,6 +432,7 @@ function Arena(arenaName, model) {
self.plusCandidate.init()
self.plusOneVoter.init()
self.plusVoterGroup.init()
self.plusXVoterGroup.init()
self.trashes.init()
self.modify.init()
}
Expand All @@ -446,19 +449,23 @@ function Arena(arenaName, model) {
self.isPlusCandidate = false
self.isPlusOneVoter = false
self.isPlusVoterGroup = false
self.isPlusXVoterGroup = false

self.init = function() {
self.y = model.size - 20
var between = 40
if (self.isPlusCandidate) {
self.x = model.size - between * 3.5
self.x = model.size - between * 4.5
var srcPlus = "play/img/plusCandidate.png"
} else if (self.isPlusOneVoter) {
self.x = model.size - between * 2.5
self.x = model.size - between * 3.5
var srcPlus = "play/img/plusOneVoter.png"
} else if (self.isPlusVoterGroup) {
self.x = model.size - between * 1.5
self.x = model.size - between * 2.5
var srcPlus = "play/img/plusVoterGroup.png"
} else if (self.isPlusXVoterGroup) {
self.x = model.size - between * 1.5
var srcPlus = "play/img/plus_sunflower.png"
}
// if (Loader) {
// if (Loader.assets[srcPlus]) {
Expand Down Expand Up @@ -529,16 +536,19 @@ function Arena(arenaName, model) {
model.onAddCandidate()
}
return n
} else if (self.isPlusOneVoter || self.isPlusVoterGroup) {
} else if (self.isPlusOneVoter || self.isPlusVoterGroup || self.isPlusXVoterGroup) {
if (self.isPlusOneVoter) {
var n = new SingleVoter(model)
} else if (self.isPlusVoterGroup) {
} else if (self.isPlusVoterGroup || self.isPlusXVoterGroup) {
var n = new GaussianVoters(model)
}
n.x = self.x
n.y = self.y
// n.x_voters = true
n.disk = 1
if (self.isPlusXVoterGroup) {
n.x_voters = true
} else {
n.disk = 1
}
var max = 0
for (var i = 0; i < model.voters.length; i++) {
var a = model.voters[i].vid
Expand Down Expand Up @@ -953,6 +963,7 @@ function Arena(arenaName, model) {
self.draggables.push(self.plusCandidate)
self.draggables.push(self.plusOneVoter)
self.draggables.push(self.plusVoterGroup)
self.draggables.push(self.plusXVoterGroup)
for (var i=0; i<self.trashes.t.length; i++) {
self.draggables.push(self.trashes.t[i])
}
Expand Down Expand Up @@ -1448,6 +1459,7 @@ function Arena(arenaName, model) {
self.plusCandidate.draw(self.ctx,self)
self.plusOneVoter.draw(self.ctx,self)
self.plusVoterGroup.draw(self.ctx,self)
self.plusXVoterGroup.draw(self.ctx,self)
self.trashes.t[0].draw(self.ctx,self)
}
}
Expand Down

0 comments on commit b2e7dde

Please sign in to comment.