public static SpelerSessie CreateSpelerSessie(string spelerNaam, ISimulatieSpeler strategie)
 {
     SpelerSessie sessie = new SpelerSessie(spelerNaam);
     Speler speler = new SpelerCPU(strategie);
     sessie.SetSpeler(speler);
     return sessie;
 }
        public ISpelerSessie CreateSessie(string spelerNaam, ISimulatieSpeler strategie)
        {
            SpelerSessie sessie;

            if (sessie1 != null && sessie2 != null)
                throw new ApplicationException("geen plek meer!");

            if (sessie1 == null)
            {
                sessie = CreateSpelerSessie(spelerNaam, strategie);
                sessie1 = sessie;
            }
            else
            {
                sessie = CreateSpelerSessie(spelerNaam, strategie);
                sessie2 = sessie;

                //CreateSpel(sessie1, sessie2);

            }
            return sessie;
        }
 public SimulationFailException(ISimulatieSpeler strategie, string message)
     : base(message)
 {
     this.strategie = strategie;
 }
 //private int totalScore=0;
 public SimulatedPlayer(string naam, ISimulatieSpeler strategy)
 {
     this.naam = naam;
     this.strategy = strategy;
 }
 private static SpelerSessie CreateSpelerSessie(string spelerNaam, ISimulatieSpeler strategie)
 {
     return SpelFactory.CreateSpelerSessie(spelerNaam, strategie);
 }
Exemplo n.º 6
0
        private ISpelBeurt BepaalBeurtMetTimeOut(ISpelStatus status, ISimulatieSpeler speler, int millisecondsToWait)
        {
            DoWorkNeedsTimeoutDelegate deleg = new DoWorkNeedsTimeoutDelegate(speler.BepaalBeurt);

            IAsyncResult ar = deleg.BeginInvoke(status, null, new object());

            if (!ar.AsyncWaitHandle.WaitOne(millisecondsToWait, false))
            {
                throw new SimulationFailException(speler, "TimeOut");
            }
            else
            {
                return deleg.EndInvoke(ar);
            }
        }
Exemplo n.º 7
0
 public SpelerCPU(ISimulatieSpeler simulatieStrategie)
 {
     this.simulatieStrategie = simulatieStrategie;
     this.naam = simulatieStrategie.Naam;
 }