Exemplo n.º 1
0
    public static void Tick(World model, WorldView view)
    {
        while (model.events.Count > 0)
        {
            BaseEvent e = model.events.Dequeue();
            e.Execute(model, view);
        }

        if (model.player != null)
        {
            if (view.playerView == null)
            {
                view.playerView = CreatePlayerView(model.player);
            }
            view.playerView.transform.position = model.player.pos.Vector3();
            view.playerView.transform.forward  = Vector3.Lerp(view.playerView.transform.forward, model.player.dir.Vector3(), Time.deltaTime * Config.VIEW_LERP);
        }

        foreach (BulletView bulletView in view.bulletViews.Values)
        {
            Bullet bullet = model.bullets[bulletView.id];
            bulletView.transform.position = Vector3.Lerp(bulletView.transform.position, (bullet.pos + bullet.dir * bullet.speed).Vector3(), Time.deltaTime * Config.VIEW_LERP * 2.5f);
            bulletView.transform.forward  = Vector3.Lerp(bulletView.transform.forward, bullet.dir.Vector3(), Time.deltaTime * Config.VIEW_LERP);
        }

        foreach (BanditView banditView in view.banditViews.Values)
        {
            Bandit bandit = model.bandits[banditView.id];
            banditView.transform.position = Vector3.Lerp(banditView.transform.position, bandit.pos.Vector3(), Time.deltaTime * Config.VIEW_LERP * 0.5f);
            banditView.transform.forward  = Vector3.Lerp(banditView.transform.forward, bandit.dir.Vector3(), Time.deltaTime * Config.VIEW_LERP);
        }
    }
Exemplo n.º 2
0
        public override LocationDefinition DoAction()
        {
            LocationDefinition returnData = GameState.CurrentLocation;

            Battle battle = new Battle();
            Mob    mob;
            Random rand = new Random();
            int    temp = 0;

            temp = rand.Next(1, 3);
            if (temp == 1)
            {
                mob = new Skeleton();
            }
            else
            {
                mob = new Bandit();
            }

            mob.Scale();
            Console.Clear();
            battle.DoBattle(GameState.Hero, mob);
            //Eventually going to remove this and have an option to rest
            //in the inn to reset your health. Otherwise you'll have to rely
            //on potions to reset your health
            GameState.Hero.ResetHealth();

            //Commented this out for a smoother experience. The battle code contains
            //a clear screen so there may be no need for double clear screen
            //will check to verify later
            //this.ClearScreen();

            return(returnData);
        }
Exemplo n.º 3
0
    /// <summary>
    ///
    /// </summary>
    void Start()
    {
        // get all available positions
        for (int i = 0; i < m_spawnPositions.Count; i++)
        {
            Transform spawnTransform = m_spawnPositions[i];
            m_availableSpawnPositions.Add(spawnTransform);
        }

        // spawn bandits
        for (int i = 0; i < m_numberToSpawn; i++)
        {
            // pick a random spawn point
            int       randomIndex    = Random.Range(0, m_availableSpawnPositions.Count);
            Transform spawnTransform = m_availableSpawnPositions[randomIndex];
            m_availableSpawnPositions.RemoveAt(randomIndex); // position no longer available

            // spawn bandit
            GameObject bandit = Instantiate(m_banditPrefab, spawnTransform);
            m_bandits.Add(bandit);

            // inject bandit spawner dependency into bandit
            Bandit banditScript = bandit.GetComponent <Bandit>();
            banditScript.SetBanditSpawner(this);
            banditScript.SetFireTime(Mathf.Lerp(m_fireTimeRange.x, m_fireTimeRange.y, i / (float)m_numberToSpawn));
        }
    }
Exemplo n.º 4
0
    void Start()
    {
        Bandit testNPC = new Bandit();

        EntityManager.AddEntity(testNPC);
        EntityManager.LoadChunk(new Vec2i(0, 0));
    }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //TODO set up humaniod and player class
            //TODO set up weapon and sword class

            Player craig = new Player("Craig", 12, 4, 4, 4, 6, 1);
            Bandit b1 = new Bandit("EvilMark", 14, 6, 4, 3, 6, 2);
            Sword s1 = new Sword("Super Sword",4, 3, 2);
            Sword s2 = new Sword("Excalibur", 1, 2, 3);
            Weapon w1 = new Weapon("dave",6, 100, 20);
            Sword banditSword = new Sword("MarksSword", 5, 8, 3);

            craig.addWeapon(s1);
            craig.addWeapon(s2);
            craig.addWeapon(w1);
            b1.addWeapon(banditSword);

            craig.useWeapon(s1);
            craig.useWeapon(s2);
            craig.useWeapon(w1);
            craig.showInventory();

            b1.useWeapon(banditSword);
            b1.showInventory();
        }
Exemplo n.º 6
0
    public override void CollectObservations()
    {
        var bandit = Random.Range(0, bandits.Length);

        currentBandit = bandits[bandit];
        AddVectorObs(bandit);
    }
Exemplo n.º 7
0
        private void CreateNpcs()
        {
            if (GameData.npcs == null)
            {
                GameData.npcs = new List <Npc>();

                GameObject villageGirlObject = (GameObject)Instantiate(Resources.Load(VillageGirl.NpcPrefabPath, typeof(GameObject)));
                Npc        villageGirl       = new VillageGirl(-1f, 1f, 8f, villageGirlObject);
                villageGirl.NpcObject.transform.position = new Vector3(villageGirl.PositionX, villageGirl.PositionY, villageGirl.PositionZ);

                GameObject nakovObject = (GameObject)Instantiate(Resources.Load(Nakov.NpcPrefabPath, typeof(GameObject)));
                Npc        nakov       = new Nakov(0f, 1f, 22f, nakovObject);
                nakov.NpcObject.transform.position = new Vector3(nakov.PositionX, nakov.PositionY, nakov.PositionZ);

                GameObject banditObject = (GameObject)Instantiate(Resources.Load(Bandit.NpcPrefabPath, typeof(GameObject)));
                Npc        bandit       = new Bandit(0f, 1f, 15f, banditObject);
                bandit.NpcObject.transform.position = new Vector3(bandit.PositionX, bandit.PositionY, bandit.PositionZ);

                GameData.npcs.Add(villageGirl);
                GameData.npcs.Add(nakov);
                GameData.npcs.Add(bandit);
            }
            else
            {
                foreach (var npc in GameData.npcs)
                {
                    GameObject newNpcObject = (GameObject)Instantiate(Resources.Load(npc.PrefabPath, typeof(GameObject)));
                    npc.NpcObject = newNpcObject;
                    npc.NpcObject.transform.position =
                        new Vector3(npc.PositionX, npc.PositionY, npc.PositionZ);
                }
            }
        }
Exemplo n.º 8
0
        private void OkayBtn_Click(object sender, EventArgs e)
        {
            Test.Play();
            Continue = true;
            if (MainPlayer.EntityStats.charHP <= 0)
            {
                MainPlayerSprite.Destroy();
                Close();
            }
            if (EnemySlime != null)
            {
                if (EnemySlime.EntityStats.charHP <= 0)
                {
                    EnemySprite.Destroy();
                    EnemySlime = new Slime();
                }
            }
            if (EnemyBandit != null)
            {
                if (EnemyBandit.EntityStats.charHP <= 0)
                {
                    EnemySprite.Destroy();
                    EnemyBandit = new Bandit();
                }
            }

            OkayBtn.Visible = false;
        }
Exemplo n.º 9
0
 public override bool DoesContextAllowForUse(IItemOfInterest targetObject)
 {
     if (base.DoesContextAllowForUse(targetObject))
     {
         Bandit bandit = null;
         if (targetObject.worlditem.Is <Bandit> (out bandit) && !bandit.WillAssociateWithPlayer)
         {
             return(false);
         }
         Character character = null;
         if (targetObject.worlditem.Is <Character> (out character))
         {
             if (character.IsDead || character.IsStunned)
             {
                 Debug.Log("Can't barter with dead characters");
                 return(false);
             }
             else if (targetObject.worlditem.Is <Hostile> ())
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
    public void AddMonster()
    {
        monsterCount = int.Parse(selectedMonsterNumber.text);
        if (monsterCount > 0)
        {
            int monsterCountTemp = monsters.Count;
            for (int i = 0; i < monsterCount; i++)
            {
                GameObject monsterTemp = Instantiate(monsterTemplate, gameObject.transform);
                if (selectedMonster == "Wolf")
                {
                    Wolf wolf = new Wolf();
                    wolf.MonsterData(i + monsterCountTemp);
                    monsterTemp.GetComponent <MonsterDataLoad>().monster = wolf;
                }
                else if (selectedMonster == "Bandit")
                {
                    Bandit bandit = new Bandit();
                    bandit.MonsterData(i + monsterCountTemp);
                    monsterTemp.GetComponent <MonsterDataLoad>().monster = bandit;
                }
                monsterTemplates.Add(monsterTemp);

                monsters.Add(monsterTemp.GetComponent <MonsterDataLoad>().monster);
            }
        }
        selectedMonsterNumber.text = "";
    }
        public void LoadBandit(Bandit bandit)
        {
            var banditTexture = _content.Load <Texture2D>("Bandit/bandit_attack");

            bandit.LoadAllFrames(
                CharacterAction.Fight,
                banditTexture,
                numberOfColumns: 7,
                numberOfRows: 1,
                dimensions: new Vector2(80, 80));

            banditTexture = _content.Load <Texture2D>("Bandit/bandit_attack");

            bandit.LoadAllFrames(
                CharacterAction.Die,
                banditTexture,
                numberOfColumns: 7,
                numberOfRows: 1,
                dimensions: new Vector2(80, 80));

            banditTexture = _content.Load <Texture2D>("Bandit/bandit_run");

            bandit.LoadAllFrames(
                CharacterAction.Walk,
                banditTexture,
                numberOfColumns: 8,
                numberOfRows: 1,
                dimensions: new Vector2(80, 80));
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            Warrior Madigan = new Warrior("Madigan", 3, 15);

            Bandit Sebastian = new Bandit("Sebastian", 1, 5);
            Bandit Clyde     = new Bandit("Clyde", 2, 8);

            Knight Leeroy = new Knight("Leeroy Jenkins", 3, 12);
            Knight Seth   = new Knight("Seth McFarlane", 5, 15);

            Dragon BlackDrag = new Dragon("Black Dragon", 7, 20, 2);
            Dragon RedDrag   = new Dragon("Red Dragon", 8, 20, 3);
            Dragon GoldDrag  = new Dragon("Gold Dragon", 10, 25, 4);

            Story.BeforeBandits();
            Battle.WithBandit(Madigan, Sebastian);
            Battle.WithBandit(Madigan, Clyde);

            Madigan.LevelUp();

            Story.BeforeKnights();
            Battle.WithKnight(Madigan, Leeroy);
            Battle.WithKnight(Madigan, Seth);

            Madigan.LevelUp();

            Story.BeforeDragons();
            Battle.WithDragon(Madigan, BlackDrag);
            Battle.WithDragon(Madigan, RedDrag);
            Battle.WithDragon(Madigan, GoldDrag);

            Story.TheEnd();
        }
Exemplo n.º 13
0
        public async Task <DTOs.Notification> Invite(DTOs.JoinApp request)
        {
            var bandit = await banditRepository.FindByEmail(request.GuestEmail);

            if (bandit != null)
            {
                throw new InvalidOperationException(Strings.EmailAlreadyUsed.Format(request.GuestEmail));
            }

            var host = await banditRepository.Get(request.Host.Id);

            if (host == null)
            {
                throw new NotFoundException("Bandit", request.Host.Id);
            }

            bandit = Bandit
                     .Create("New Bandit", request.GuestEmail);

            var message = Notifications.JoinApp(host.Name);

            await notifications.Send(message, to : bandit);

            return(new DTOs.Notification
            {
                To = request.GuestEmail,
                Title = message.Title,
                Content = message.Body
            });
        }
        public async Task <Notification> Remove(int id)
        {
            var notification = await dbContext
                               .Set <Entities.Notification>()
                               .Include(n => n.Bandit)
                               .FirstOrDefaultAsync(n => n.Id == id);

            if (notification == null)
            {
                return(null);
            }

            var bandit = Bandit.Create(notification.Bandit.Id,
                                       notification.Bandit.Name,
                                       notification.Bandit.Email);

            var notif = Notification.For(
                notification.Id,
                bandit,
                notification.Title,
                notification.Body);

            dbContext
            .Set <Entities.Notification>()
            .Remove(notification);

            await dbContext.SaveChangesAsync();

            return(notif);
        }
Exemplo n.º 15
0
    public static World CloneWorldWithoutBullets(World original)
    {
        World clone = new World();

        clone.tickNum             = original.tickNum;
        clone.player.pos          = original.player.pos;
        clone.player.dir          = original.player.dir;
        clone.nextBanditSpawnTick = original.nextBanditSpawnTick;
        clone.wind         = original.wind;
        clone.nextBanditId = original.nextBanditId;
        clone.nextBulletId = original.nextBulletId;

        foreach (var originalBandit in original.bandits.Values)
        {
            Bandit b = new Bandit();
            b.id       = originalBandit.id;
            b.isActive = originalBandit.isActive;
            b.pos      = originalBandit.pos;
            b.dir      = originalBandit.dir;
            b.distance = originalBandit.distance;
            clone.bandits.Add(b.id, b);
        }

        return(clone);
    }
Exemplo n.º 16
0
    /// <summary>
    ///
    /// </summary>
    void Update()
    {
        if (UmpireControl.isGameStarted && !m_isGameStarted)
        {
            for (int i = 0; i < m_bandits.Count; i++)
            {
                // show the bandit
                GameObject bandit = m_bandits[i];
                bandit.SetActive(true);

                // start the bandit's countdown
                Bandit banditScript = bandit.GetComponent <Bandit>();
                banditScript.StartFireCountdown();
            }

            m_isGameStarted = true;
        }

        if (m_bandits.Count == 0 && !m_isGameFinished)
        {
            UmpireControl umpire = FindObjectOfType <UmpireControl>();
            umpire.gameSuccess();

            float reactionTime = UmpireControl.reactionTimer;

            if (HighscoreManager.GetHighscore("Mexican Standoff") > reactionTime)
            {
                HighscoreManager.SetHighscore("Mexican Standoff", reactionTime);
            }

            umpire.ShowHighscore(HighscoreManager.GetHighscore("Mexican Standoff"));

            m_isGameFinished = true;
        }
    }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            //TODO set up humaniod and player class
            //TODO set up weapon and sword class

            Player craig       = new Player("Craig", 12, 4, 4, 4, 6, 1);
            Bandit b1          = new Bandit("EvilMark", 14, 6, 4, 3, 6, 2);
            Sword  s1          = new Sword("Super Sword", 4, 3, 2);
            Sword  s2          = new Sword("Excalibur", 1, 2, 3);
            Weapon w1          = new Weapon("dave", 6, 100, 20);
            Sword  banditSword = new Sword("MarksSword", 5, 8, 3);

            craig.addWeapon(s1);
            craig.addWeapon(s2);
            craig.addWeapon(w1);
            b1.addWeapon(banditSword);

            craig.useWeapon(s1);
            craig.useWeapon(s2);
            craig.useWeapon(w1);
            craig.showInventory();

            b1.useWeapon(banditSword);
            b1.showInventory();
        }
Exemplo n.º 18
0
        public void AddBandit(Character bandit)
        {
            Bandit b = bandit.worlditem.GetOrAdd <Bandit> ();

            b.ParentCamp         = this;
            bandit.TerritoryBase = this;
            SpawnedBandits.SafeAdd(bandit);
        }
Exemplo n.º 19
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        player = GameObject.FindGameObjectWithTag("Main").transform;

        rb = animator.GetComponent <Rigidbody2D>();

        hb = animator.GetComponent <Bandit>();
    }
Exemplo n.º 20
0
 public BandidData(Bandit bandit)
 {
     this.init         = bandit.init;
     this.totalActions = bandit.totalActions;
     this.count        = bandit.count;
     this.score        = bandit.score;
     this.UCB1scores   = bandit.UCB1scores;
     this.numActions   = bandit.numActions;
 }
Exemplo n.º 21
0
    public static BanditView CreateBanditView(Bandit bandit)
    {
        BanditView banditView = Object.Instantiate(Resources.Load <BanditView>("Prefabs/Views/BanditView"));

        banditView.id = bandit.id;
        banditView.transform.localScale = Vector3.one * bandit.radius * 2f;
        banditView.transform.position   = bandit.pos.Vector3();
        banditView.transform.forward    = bandit.dir.Vector3();
        return(banditView);
    }
Exemplo n.º 22
0
        public void TestBandit()
        {
            Bandit EnemyBandit = new Bandit();

            EnemyBandit.GenerateName();
            EnemyBandit.GenerateSkills();
            EnemyBandit.GenerateStats();
            EnemyBandit.GenerateArmor();
            EnemyBandit.GenerateWeapon();
            Assert.IsTrue(EnemyBandit.EntityName == "");
        }
Exemplo n.º 23
0
    // Start is called before the first frame update
    void Start()
    {
        // init players
        // TODO get players from player select scene, for now hard coded to 2 players and 2 enemies
        players = new List <PlayerClassBase>();
        for (int i = 1; i < Meta.CURRENTPLAYERS + 1; i++)
        {
            PlayerClassBase player = new Barbarian($"{i}", statusPrefab);  // todo this loop stupid, there are other classes (soon)
            player.Init();
            players.Add(player);
        }

        // set turn order
        // TODO for now just all players then all enemies
        currentPlayer = players[0];
        currentTurn   = new Tuple <string, int>(PLAYERS, 0); // access with currentTurn.Item1 and currentTurn.Item2
        Debug.Log($"Current player is {currentTurn.Item2}");

        phaseIndex = 0;

        // init enemies TODO make dynamic
        enemies = new List <EnemyBase>();
        EnemyBase e1 = new Bandit("1");

        enemies.Add(e1);
        enemies[0].Init();
        EnemyBase e2 = new Bandit("2");

        enemies.Add(e2);
        enemies[1].Init();

        SetupUi();

        lookCard    = 0;
        deselectedY = hand1.transform.position.y;
        selectedY   = deselectedY + cardLift;
        last_select = Time.time;
        last_play   = Time.time;

        for (int i = 0; i < Meta.MAX_HAND_SIZE; i++)
        {
            // find the card, set it inactive
            GameObject hcard = GameObject.Find($"Hand{i + 1}");
            GameObject hcd   = hcard.transform.Find("CardDesc").gameObject;
            hcd.GetComponent <MeshRenderer>().enabled = false;

            GameObject hcn = hcard.transform.Find("CardName").gameObject;
            hcn.GetComponent <MeshRenderer>().enabled = false;

            GameObject hcc = hcard.transform.Find("CardCost").gameObject;
            hcc.GetComponent <MeshRenderer>().enabled = false;
            hcard.GetComponent <Renderer>().enabled   = false;
        }
    }
Exemplo n.º 24
0
        public async Task <Band> Get(int id)
        {
            var dbBand = await dbContext
                         .Set <Entities.Band>()
                         .Include(b => b.Boss)
                         .ThenInclude(b => b.Bandit)
                         .Include(b => b.Members)
                         .ThenInclude(bm => bm.Bandit)
                         .Include(b => b.Members)
                         .ThenInclude(bm => bm.Scoring)
                         .Include(b => b.Rounds)
                         .ThenInclude(r => r.Sheriff)
                         .ThenInclude(rm => rm.Member)
                         .ThenInclude(bm => bm.Bandit)
                         .FirstOrDefaultAsync(b => b.Id == id);

            if (dbBand == null)
            {
                return(null);
            }

            var boss = Bandit.Create(dbBand.Boss.Bandit.Id, dbBand.Boss.Bandit.Name, dbBand.Boss.Bandit.Email);
            var band = Band.Create(dbBand.Id, dbBand.Name, boss);

            foreach (var dbMember in dbBand.Members)
            {
                if (dbMember.Bandit.Id == band.Boss.Bandit.Id)
                {
                    band.Members.Add(band.Boss);
                    continue;
                }

                var bandit = Bandit.Create(dbMember.Bandit.Id, dbMember.Bandit.Name, dbMember.Bandit.Email);
                var member = BandMember.From(bandit, band);

                var score = dbMember.Scoring.ToModel();
                member.Scoring.Add(score);

                band.Members.Add(member);
            }

            foreach (var dbRound in dbBand.Rounds)
            {
                var dbBandit = dbRound.Sheriff.Member.Bandit;
                var bandit   = Bandit.Create(dbBandit.Id, dbBandit.Name, dbBandit.Email);

                var sheriff = BandMember.From(bandit, band);
                var round   = Round.Create(dbRound.Id, dbRound.Name, dbRound.Place, dbRound.DateTime, sheriff, Enumerable.Empty <BandMember>());

                band.Rounds.Add(round);
            }

            return(band);
        }
Exemplo n.º 25
0
    // Start is called before the first frame update
    void Start()
    {
        rnd = new System.Random();
        betaDistribution = new BetaDistribution();

        bandits = new Bandit[numberOfBandits];

        for (int i = 0; i < numberOfBandits; i++)
        {
            bandits[i] = new Bandit(rnd.NextDouble());
        }
    }
Exemplo n.º 26
0
        public async Task Send(Message message, Bandit to)
        {
            var email = new EmailMessage
            {
                ToAddresses = new List <EmailAddress> {
                    to.Email
                },
                Subject = message.Title,
                Content = message.Body
            };

            await emailService.Send(email);
        }
Exemplo n.º 27
0
    public static void SpawnBandit(World model)
    {
        Bandit b = new Bandit();

        b.id  = model.nextBanditId;
        b.pos = new Position(UnityEngine.Random.insideUnitCircle.normalized * Config.SPAWN_RANGE);
        b.dir = (model.player.pos - b.pos).Normalize();
        model.bandits.Add(b.id, b);

        model.nextBanditId++;

        model.events.Enqueue(new BanditAddedEvent(b.id));
    }
Exemplo n.º 28
0
    // Start is called before the first frame update
    void Start()
    {
        EntityFaction bandits = new EntityFaction("Bandits!");

        for (int i = 0; i < 5; i++)
        {
            Vector2 pos = GameManager.RNG.RandomVector2(15, 25);
            Bandit  b   = new Bandit();
            b.SetEntityFaction(bandits);
            b.MoveEntity(Vec2i.FromVector2(pos));
            EntityManager.Instance.LoadEntity(b);
        }
    }
Exemplo n.º 29
0
 public void Execute(World model, WorldView view)
 {
     if (model.bandits.ContainsKey(id))
     {
         Bandit     bandit     = model.bandits[id];
         BanditView banditView = ViewService.GetBanditViewWithId(view, id);
         if (banditView != null)
         {
             banditView.UpdateHP(bandit.hp);
         }
         AudioController.Instance.PlaySound(AudioController.Sound.DamageBandit);
     }
 }
Exemplo n.º 30
0
        public Enemy(Vector2 position, string enemyState)
        {
            Position       = position;
            FuturePosition = position;  // make the unit not move when spawned.
            Velocity       = new Vector2(1f, 1f);

            EnemyAI = new AI(this, "Enemy");

            if (enemyState == "Bandit")
            {
                EnemyState = new Bandit(this);
            }
        }
Exemplo n.º 31
0
        public async Task <DTOs.BanditDetails> Create(DTOs.CreateBandit request)
        {
            var bandit = await banditRepository.FindByEmail(request.Email);

            if (bandit != null)
            {
                throw new InvalidOperationException(Strings.EmailAlreadyUsed.Format(request.Email));
            }

            bandit = Bandit.Create(request.Name, request.Email);
            bandit = await banditRepository.Add(bandit);

            return(bandit.ToDtoDetails());
        }
Exemplo n.º 32
0
        private void InitBanditRepo()
        {
            //Create the alternatives used in the bandit
            var blueButton = new Models.PurchaseButton(@"#4983FF", @"Blue button");
            var redButton = new Models.PurchaseButton(@"#974037", @"Red button");

            var buttons = new List<Models.PurchaseButton>();
            buttons.Add(blueButton);
            buttons.Add(redButton);

            //Very naive repo implementation... just use the cache.
            HttpContext.Current.Cache.Remove(@"alternatives");
            HttpContext.Current.Cache.Add(@"alternatives", buttons, null, Cache.NoAbsoluteExpiration, new TimeSpan(1, 0, 0), CacheItemPriority.Normal, null);

            //If you want to track diagnostic info across requests (like for the status page), keep this around, like in a singleton...
            Bandit<PurchaseButton> bandit = new Bandit<PurchaseButton>(new WidgetRepo(), true);
            HttpContext.Current.Cache.Add(@"bandit", bandit, null, Cache.NoAbsoluteExpiration, new TimeSpan(1, 0, 0), CacheItemPriority.Normal, null);
        }
Exemplo n.º 33
0
 public void DefaultConstructor_NoDiagnostics()
 {
     Bandit<FakeListrun> b = new Bandit<FakeListrun>(_fakeListrunRepository);
     Assert.IsNull(b.Diagnostics);
 }
Exemplo n.º 34
0
 public void InitConstructor_False_NoDiagnostics()
 {
     Bandit<FakeListrun> b = new Bandit<FakeListrun>(_fakeListrunRepository, false);
     Assert.IsNull(b.Diagnostics);
 }
Exemplo n.º 35
0
 public void CollectDiagnostics_DefaultConstructor_False()
 {
     Bandit<FakeListrun> b = new Bandit<FakeListrun>(_fakeListrunRepository);
     Assert.IsFalse(b.CollectDiagnostics);
 }
Exemplo n.º 36
0
 public void InitConstructor_True_Diagnostics()
 {
     Bandit<FakeListrun> b = new Bandit<FakeListrun>(_fakeListrunRepository, true);
     Assert.IsNotNull(b.Diagnostics);
 }
Exemplo n.º 37
0
 public void Play_NoAlternativesInRepository()
 {
     Bandit<EmptyAlternative> b = new Bandit<EmptyAlternative>(this._emptyRepository);
     EmptyAlternative alternative = b.Play();
 }
Exemplo n.º 38
0
 private void InitBandit()
 {
     this._repo = CreateRepo();
     this._bandit = new Bandit<ConstantRewardAlternative>(this._repo, true);
 }
Exemplo n.º 39
0
 public void CollectDiagnostics_InitConstructor_True()
 {
     Bandit<FakeListrun> b = new Bandit<FakeListrun>(_fakeListrunRepository, true);
     Assert.IsTrue(b.CollectDiagnostics);
 }
Exemplo n.º 40
0
 public void Constructor_NullRepository()
 {
     var b = new Bandit<EmptyAlternative>(this._nullRepository);
 }