Example #1
0
        private ToolStripMenuItem CreateSelectRoleMenuItem()
        {
            var menuItem = new ToolStripMenuItem {
                Text = "Select role"
            };

            SalemUtil.GetRoleGroups().ForEach(rg => menuItem.DropDownItems.Add(CreateRoleGroupMenuItem(rg)));
            return(menuItem);
        }
Example #2
0
 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);
 }
Example #3
0
        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();
        }
Example #4
0
        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);
        }
Example #5
0
 private void ClearToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var players = SalemUtil.GetPlayers();
 }
Example #6
0
 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;
 }
Example #8
0
 private void Claim(object sender, EventArgs e) => _player.Claim(SalemUtil.GetRole(((ToolStripMenuItem)sender).Text));
Example #9
0
 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);
 }
Example #11
0
 protected Role GetRole(int playerRoleIndex) => Bytes.Length > playerRoleIndex?SalemUtil.GetRole(Bytes[playerRoleIndex]) : null;
Example #12
0
 protected Player GetPlayer(int playerNumberIndex) => Bytes.Length > playerNumberIndex?SalemUtil.GetPlayer(Bytes[playerNumberIndex]) : null;
Example #13
0
 private void TimerTick(object sender, EventArgs e) => SalemUtil.GetNewMessages().ForEach(HandleServerMessage);
Example #14
0
 public void LoadGameIntoUI(ServerMessage message) => LoadGameIntoUI(SalemUtil.GetPlayers().OrderBy(p => p.Number).ToList(), _defaultRosterName);