private ToolStripMenuItem CreateSelectRoleMenuItem() { var menuItem = new ToolStripMenuItem { Text = "Select role" }; SalemUtil.GetRoleGroups().ForEach(rg => menuItem.DropDownItems.Add(CreateRoleGroupMenuItem(rg))); return(menuItem); }
private void TestGameToolStripMenuItem_Click(object sender, EventArgs e) { _game.LoadGameIntoUI(null, "Ranked"); CreateDummyMessages(10); SalemUtil.MoveTimeForward(); CreateDummyMessages(5); SalemUtil.MoveTimeForward(); CreateDummyMessages(30); SalemUtil.MoveTimeForward(); SalemUtil.MoveTimeForward(); CreateDummyMessages(30); }
public Game(ChatBox chatBox, PlayersBox playersBox, RosterBox rosterBox, ListBox listBox) { _chatBox = chatBox; _playersBox = playersBox; _rosterBox = rosterBox; _listBox = listBox; _uiActionPerMessageType.Add(ServerMessageType.Chat, _chatBox.Add); _uiActionPerMessageType.Add(ServerMessageType.LocalPlayerReport, LoadGameIntoUI); SalemUtil.StartReadingMessage(); var timer = new Timer { Interval = _timerInterval }; timer.Tick += new EventHandler(TimerTick); timer.Start(); }
public void LoadGameIntoUI(List <Player> players, string rosterName) { if (players == null) { players = SalemUtil.CreateDummyPlayers(); } _chatBox.Clear(); _listBox.Items.Clear(); _roster = SalemUtil.GetRoster(rosterName); _roster.Players = players; _playersBox.LoadPlayers(players); _rosterBox.LoadRoster(_roster); players.AddUpdateAction(_roster.DoUpdate); players.AddUpdateAction(_playersBox.DoUpdate); players.AddUpdateAction(_rosterBox.DoUpdate); players.AddUpdateAction(_chatBox.DoUpdate); }
private void ClearToolStripMenuItem_Click(object sender, EventArgs e) { var players = SalemUtil.GetPlayers(); }
private void NewGameToolStripMenuItem_Click(object sender, EventArgs e) { SalemUtil.ResetToStartOfLastGame(); }
public VoteVerdictMessage(byte[] bytes) : base(bytes) { Time = SalemUtil.GetGameTime(); Player = GetPlayer(PlayerNumberIndex); Verdict = Bytes.Length > VoteVerdictIndex ? Bytes[VoteVerdictIndex].GetVoteVerdict() : VoteVerdict.Unknown; }
private void Claim(object sender, EventArgs e) => _player.Claim(SalemUtil.GetRole(((ToolStripMenuItem)sender).Text));
public override void Process() => Player?.Claim(SalemUtil.GetRole("Mayor"), true);
public ChatMessage(byte[] bytes) : base(bytes) { Time = SalemUtil.GetGameTime(); Player = GetPlayer(PlayerNumberIndex); CleanText = GetTextAt(TextStartIndex); }
protected Role GetRole(int playerRoleIndex) => Bytes.Length > playerRoleIndex?SalemUtil.GetRole(Bytes[playerRoleIndex]) : null;
protected Player GetPlayer(int playerNumberIndex) => Bytes.Length > playerNumberIndex?SalemUtil.GetPlayer(Bytes[playerNumberIndex]) : null;
private void TimerTick(object sender, EventArgs e) => SalemUtil.GetNewMessages().ForEach(HandleServerMessage);
public void LoadGameIntoUI(ServerMessage message) => LoadGameIntoUI(SalemUtil.GetPlayers().OrderBy(p => p.Number).ToList(), _defaultRosterName);