public void receiveMessage(string message) { if (message == "PASSED") { if (myName == candidate) { currGovt = GOVT.Chancellor; Console.WriteLine("You are now the Chancellor!"); } else { Console.WriteLine("Vote for " + candidate + " passed"); } } else if (message == "FAILED") { Console.WriteLine("Vote for " + candidate + " failed"); candidate = null; } else if (message == "END") { resolveRound(); } else { int index = message.IndexOf(' '); string command = message.Substring(0, index); string args = message.Substring(index + 1); handleCommand(command, args); } }
private void resolveRound() { switch (currGovt) { case GOVT.Chancellor: currGovt = GOVT.PrevChancellor; break; case GOVT.President: currGovt = GOVT.PrevPresident; break; default: currGovt = GOVT.Spectator; break; } Console.WriteLine("Round end. My role: " + currGovt.ToString()); }
private void handleCommand(string command, string args) { switch (command) { case "ROLE": updateRole(args); break; case "START": Console.WriteLine("Start Round"); if (myName == args) { Console.WriteLine("I am the President!"); currGovt = GOVT.President; } currPresident = args; startRound(); break; case "VOTE": promptVote(args); break; case "POLICY": promptPolicy(args); break; case "POWER": promptPower(args); break; } }