Beispiel #1
0
            public PwMatchCommand.VoteOption ToVoteOption(PwMatchCommand.ModeType mode)
            {
                var opt = new PwMatchCommand.VoteOption
                {
                    PlanetID   = PlanetID,
                    PlanetName = Name,
                    Map        = Map,
                    Count      = mode == PwMatchCommand.ModeType.Attack ? Attackers.Count : Defenders.Count,
                    Needed     = TeamSize
                };

                return(opt);
            }
Beispiel #2
0
 void AddButtonClick(PwMatchCommand.VoteOption opt, Button but)
 {
     PwMatchCommand.VoteOption opt1 = opt;
     but.Click += (s2, ev) =>
     {
         if (Program.SpringScanner.HasResource(opt1.Map))
         {
             tas.Say(TasClient.SayPlace.User, GlobalConst.NightwatchName, "!" + opt1.PlanetID, true);
         }
         else
         {
             tas.Say(TasClient.SayPlace.Channel, tas.MyUser.Faction, string.Format("wants to play {0}, but lacks the map..", opt1.PlanetID), true);
         }
     };
 }
Beispiel #3
0
        void UpdateGui()
        {
            if (pw != null && !string.IsNullOrEmpty(tas.MyUser.Faction) && tas.MyUser.Level >= GlobalConst.MinPlanetWarsLevel && tas.MyUser.EffectiveElo >= GlobalConst.MinPlanetWarsElo)
            {
                if (pw.Mode == PwMatchCommand.ModeType.Clear)
                {
                    Program.NotifySection.RemoveBar(this);
                }
                else
                {
                    deadline        = DateTime.Now.AddSeconds(pw.DeadlineSeconds);
                    timerLabel.Text = PlasmaShared.Utils.PrintTimeRemaining(pw.DeadlineSeconds);

                    if (pw.Mode == PwMatchCommand.ModeType.Attack)
                    {
                        headerLabel.Text = string.Format("{0} picks a planet to attack", pw.AttackerFaction);

                        foreach (Button c in pnl.Controls.OfType <Button>().ToList())
                        {
                            pnl.Controls.Remove(c);
                        }

                        foreach (PwMatchCommand.VoteOption opt in pw.Options)
                        {
                            Program.Downloader.GetResource(DownloadType.MAP, opt.Map);

                            var but = new Button {
                                Text = string.Format("{0} [{1}/{2}]", opt.PlanetName, opt.Count, opt.Needed), AutoSize = true
                            };
                            Program.ToolTip.SetMap(but, opt.Map);

                            if (pw.AttackerFaction == tas.MyUser.Faction) // NOTE this is for cases where nightwatch self faction info is delayed
                            {
                                AddButtonClick(opt, but);
                            }
                            else
                            {
                                but.Enabled = false;
                            }
                            pnl.Controls.Add(but);
                        }
                    }
                    else if (pw.Mode == PwMatchCommand.ModeType.Defend)
                    {
                        PwMatchCommand.VoteOption opt = pw.Options.First();
                        headerLabel.Text = string.Format("{0} attacks planet {2}, {1} defends",
                                                         pw.AttackerFaction,
                                                         string.Join(",", pw.DefenderFactions),
                                                         opt.PlanetName);

                        foreach (Button c in pnl.Controls.OfType <Button>().ToList())
                        {
                            pnl.Controls.Remove(c);
                        }

                        var but = new Button {
                            Text = string.Format("{0} [{1}/{2}]", opt.PlanetName, opt.Count, opt.Needed), AutoSize = true
                        };
                        Program.ToolTip.SetMap(but, opt.Map);

                        if (pw.DefenderFactions.Contains(tas.MyUser.Faction)) // NOTE this is for cases where nightwatch self faction info is delayed
                        {
                            AddButtonClick(opt, but);
                        }
                        else
                        {
                            but.Enabled = false;
                        }
                        pnl.Controls.Add(but);
                    }

                    Program.NotifySection.AddBar(this);
                }
            }
            else
            {
                Program.NotifySection.RemoveBar(this);
            }
        }