public void processVoting() { if (voteSession == null) { if (voteCooldown > 0) { voteCooldown -= 1; return; } Person proposer = null; foreach (Person p in people) { if (p.state == Person.personState.enthralled) { continue; } if (proposer == null) { proposer = p; } else { int myDelta = map.turn - p.lastVoteProposalTurn; int theirDelta = map.turn - proposer.lastVoteProposalTurn; if (myDelta > theirDelta) { proposer = p; } } } if (proposer != null) { proposer.lastVoteProposalTurn = map.turn; VoteIssue issue = proposer.proposeVotingIssue(); if (issue == null) { return; } bool positive = true; int priority = (this.hasEnthralled()) ? 1 : 3; string msg = this.getName() + " now voting on " + issue.ToString(); World.staticMap.addMessage(msg, priority, positive); //Otherwise, on with voting for this new thing voteSession = new VoteSession(); voteSession.issue = issue; voteSession.timeRemaining = map.param.society_votingDuration; if (World.logging && logbox != null) { logbox.takeLine("Starting voting on " + voteSession.issue.ToString()); } if (this.hasEnthralled()) { voteSession.assignVoters(); VoteOption optionChoice = null; foreach (VoteOption opt in voteSession.issue.options) { if (opt.votesFor.Contains(proposer)) { optionChoice = opt; break; } } string str = proposer.getFullName() + " has proposed a measure to be voted on by the nobles of " + this.getName() + ".\nThey are voting " + optionChoice.info(issue); map.world.prefabStore.popImgMsg(str, "Voting issue: " + issue.getLargeDesc()); } } } else { if (voteSession.issue.stillValid(map) == false) { voteSession = null; World.log("Vote session no longer valid"); return; } if (voteSession.timeRemaining > 0) { voteSession.timeRemaining -= 1; return; } voteSession.assignVoters(); double topVote = 0; VoteOption winner = null; foreach (VoteOption option in voteSession.issue.options) { if (option.votingWeight > topVote || winner == null) { winner = option; topVote = option.votingWeight; } voteSession.issue.changeLikingForVotes(option, voteSession.issue); } if (World.logging && logbox != null) { logbox.takeLine("End voting on " + voteSession.issue.ToString()); } if (World.logging && logbox != null) { logbox.takeLine(" Winning option: " + winner.info()); } if (this.hasEnthralled()) { string str = "Chosen outcome: " + winner.info(voteSession.issue); str += "\nVotes for: "; foreach (Person p in winner.votesFor) { str += p.getFullName() + ", "; } str = str.Substring(0, str.Length - 2); map.world.prefabStore.popImgMsg(str, "Voting concluded. Issue: " + voteSession.issue.getLargeDesc()); } voteSession.issue.implement(winner); if (voteSession.issue is VoteIssue_AssignLandedTitle == false) { billsSinceLastSettlementAssignment += 1; } else { billsSinceLastSettlementAssignment = 0; } voteSession = null; } }
public void processVoting() { if (voteSession == null) { if (voteCooldown > 0) { voteCooldown -= 1; return; } Person proposer = null; foreach (Person p in people) { if (p.state == Person.personState.enthralled) { continue; } if (proposer == null) { proposer = p; } else { int myDelta = map.turn - p.lastVoteProposalTurn; int theirDelta = map.turn - proposer.lastVoteProposalTurn; if (myDelta > theirDelta) { proposer = p; } } } if (proposer != null) { proposer.lastVoteProposalTurn = map.turn; VoteIssue issue = proposer.proposeVotingIssue(); if (issue == null) { return; } bool positive = true; int priority = (this.hasEnthralled()) ? 1 : 3; string msg = this.getName() + " now voting on " + issue.ToString(); World.staticMap.addMessage(msg, priority, positive); //Otherwise, on with voting for this new thing voteSession = new VoteSession(); voteSession.issue = issue; voteSession.timeRemaining = map.param.society_votingDuration; } } else { if (voteSession.issue.stillValid(map) == false) { voteSession = null; World.log("Vote session no longer valid"); return; } if (voteSession.timeRemaining > 0) { voteSession.timeRemaining -= 1; return; } voteSession.assignVoters(); double topVote = 0; VoteOption winner = null; foreach (VoteOption option in voteSession.issue.options) { if (option.votingWeight > topVote || winner == null) { winner = option; topVote = option.votingWeight; } voteSession.issue.changeLikingForVotes(option); } voteSession.issue.implement(winner); voteSession = null; } }