Ejemplo n.º 1
0
 /// <summary>
 /// The main base contructor that takes in a <paramref name="config"/>.
 /// </summary>
 /// <param name="config">The <see cref="Configuration"/> to use.</param>
 public Match(Configuration config)
 {
     this.config = config;
     info = new CMatchInfo(Config);
     Events = new EventIterator();
     this.rounds = RoundIterator.CreateRoundIteratorFor(this);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Attaches the <see cref="MatchInfo"/> from a <see cref="Match"/> and attaches the
        /// <see cref="ControllerRegister"/>s given. Initializes an empty list of <see cref="Round.Events"/>
        /// and <see cref="Round.Accolades"/>.
        /// </summary>
        /// <param name="inputRegisters">A variable number of controllers that are involved in this Round.</param>
        /// <param name="matchInfo">Information about the match that determines Round behaviour.</param>
        public Round(MatchInfo matchInfo, List<Register> inputRegisters)
        {
            MatchInfo = matchInfo;

            events = new EventIterator();
            Registers = new List<Register>();
            Remaining = new List<ControllerID>();
            generatedAccolades = new List<Accolade>();
            accoladeGenerator = new AccoladeGenerator(this);

            var newRandom = new Random();
            foreach (var register in inputRegisters)
            {
                Registers.Add(register);
                Remaining.Add(register.ID);
            }
            CurrentTurn = Remaining[newRandom.Next(Remaining.Count)];
        }
Ejemplo n.º 3
0
        private void Init(Configuration conf, params ControllerInformation[] controllersToLoad)
        {
            this.conf = conf;
            //Get the game info from the Configuration.
            //Expecting an exception to be thrown here if a controller isn't compatible with the configured game mode.
            info = new CMatchInfo(conf, controllersToLoad);

            //Create and register the controllers to load.
            GenerateControllers(controllersToLoad);
            RegisterControllers();
            FormOpponents();

            //Configuration setting for the number of rounds this Match will perform.
            roundList = new List<Round>();
            targetRounds = conf.GetValue<int>("mbc_match_rounds");
            roundIteration = -1;
            inProgress = true;

            //Make a thread for this Match.
            runningThread = new Thread(PlayLoop);
            sleepHandle = new AutoResetEvent(false);
            isRunning = false;
            delay = 0;

            //Configuration setting for round playing behaviour, given a number of rounds.
            switch (conf.GetValue<string>("mbc_match_rounds_mode"))
            {
                case "all":
                    roundPlay = PlayMode.AllRounds;
                    break;

                case "first to":
                    roundPlay = PlayMode.FirstTo;
                    break;

                default:
                    conf.SetValue("mbc_match_rounds_mode", "all");
                    break;
            }
        }
Ejemplo n.º 4
0
 public Register(MatchInfo match, ControllerID id)
     : base(match, id)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Passes parameters to the base constructor.
 /// </summary>
 /// <param name="info">The <see cref="MatchInfo"/> from a round to associate with.</param>
 /// <param name="controllers">The <see cref="ControllerUser"/>s to utilize.</param>
 public ClassicRound(MatchInfo info, List<ControllerUser> controllers)
     : base(info, controllers)
 {
     currentState = LogicState.Begin;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Attaches the <see cref="MatchInfo"/> provided by a <see cref="Match"/> and retrieves the list of
 /// <see cref="ControllerUser"/>s that persist in a <see cref="Match"/>.
 /// </summary>
 /// <param name="matchInfo">The <see cref="MatchInfo"/> from a round to associate with.</param>
 /// <param name="controllers">The <see cref="ControllerUser"/>s to utilize.</param>
 public ControlledRound(MatchInfo matchInfo, List<ControllerUser> controllers)
     : base(matchInfo, RegistersFromControllers(controllers))
 {
     Controllers = controllers;
 }