Exemplo n.º 1
0
        public PwMatchCommand GenerateLobbyCommand()
        {
            PwMatchCommand command;

            if (Challenge == null)
            {
                command = new PwMatchCommand(PwMatchCommand.ModeType.Attack)
                {
                    Options         = AttackOptions.Select(x => x.ToVoteOption(PwMatchCommand.ModeType.Attack)).ToList(),
                    DeadlineSeconds = (int)GetAttackDeadline().Subtract(DateTime.UtcNow).TotalSeconds,
                    AttackerFaction = AttackingFaction.Shortcut
                };
            }
            else
            {
                command = new PwMatchCommand(PwMatchCommand.ModeType.Defend)
                {
                    Options = new List <PwMatchCommand.VoteOption> {
                        Challenge.ToVoteOption(PwMatchCommand.ModeType.Defend)
                    },
                    DeadlineSeconds  = (int)GetAcceptDeadline().Subtract(DateTime.UtcNow).TotalSeconds,
                    AttackerFaction  = AttackingFaction.Shortcut,
                    DefenderFactions = GetDefendingFactions(Challenge).Select(x => x.Shortcut).ToList()
                };
            }
            return(command);
        }
Exemplo n.º 2
0
        public PwMatchCommand GenerateLobbyCommand()
        {
            PwMatchCommand command = null;

            try
            {
                if (GlobalConst.PlanetWarsMode != PlanetWarsModes.Running)
                {
                    return(new PwMatchCommand(PwMatchCommand.ModeType.Clear));
                }

                if (Challenge == null)
                {
                    command = new PwMatchCommand(PwMatchCommand.ModeType.Attack)
                    {
                        Options         = AttackOptions.Select(x => x.ToVoteOption(PwMatchCommand.ModeType.Attack)).ToList(),
                        Deadline        = GetAttackDeadline(),
                        DeadlineSeconds = (int)GetAttackDeadline().Subtract(DateTime.UtcNow).TotalSeconds,
                        AttackerFaction = AttackingFaction.Shortcut
                    }
                }
                ;
                else
                {
                    command = new PwMatchCommand(PwMatchCommand.ModeType.Defend)
                    {
                        Options = new List <PwMatchCommand.VoteOption> {
                            Challenge.ToVoteOption(PwMatchCommand.ModeType.Defend)
                        },
                        Deadline         = GetAcceptDeadline(),
                        DeadlineSeconds  = (int)GetAcceptDeadline().Subtract(DateTime.UtcNow).TotalSeconds,
                        AttackerFaction  = AttackingFaction.Shortcut,
                        DefenderFactions = GetDefendingFactions(Challenge).Select(x => x.Shortcut).ToList()
                    }
                };
            }
            catch (Exception ex)
            {
                Trace.TraceError("PlanetWars {0}: {1}", nameof(GenerateLobbyCommand), ex);
            }
            return(command);
        }