示例#1
0
        internal ArenaDraftData()
        {
            this.Deck = new List <Triton.Game.Abstraction.EntityDef>();
            DraftDisplay display = DraftDisplay.Get();

            if (display.m_chosenHero != null)
            {
                this.Hero = new Triton.Game.Abstraction.Actor(display.m_chosenHero);
            }
            this.Choices = new List <Triton.Game.Abstraction.Actor>();
            foreach (DraftDisplay.DraftChoice choice in display.m_choices)
            {
                this.Choices.Add(new Triton.Game.Abstraction.Actor(choice.m_actor));
            }
            DefLoader    loader  = DefLoader.Get();
            DraftManager manager = DraftManager.Get();

            foreach (CollectionDeckSlot slot in manager.m_draftDeck.m_slots)
            {
                for (int i = 0; i < slot.Count; i++)
                {
                    this.Deck.Add(new Triton.Game.Abstraction.EntityDef(loader.GetEntityDef(slot.CardID)));
                }
            }
            this.Wins   = manager.m_wins;
            this.Losses = manager.m_losses;
        }
示例#2
0
        public ActionResult Join(string guid)
        {
            DraftManager            draftManager            = new DraftManager(_context);
            DraftInviteManager      draftInviteManager      = new DraftInviteManager(_context);
            DraftParticipantManager draftParticipantManager = new DraftParticipantManager(_context);
            DraftInvite             draftInvite             = draftInviteManager.Get(guid);
            UserManager             userManager             = new UserManager(_context);
            User user = userManager.GetCurrentUser(User.Identity.GetUserId());

            if (draftInvite == null)
            {
                throw new Exception();
            }
            else
            {
                Draft draft = draftManager.Get(draftInvite.DraftId);

                draftInvite.Accepted = true;
                draftInvite.Active   = false;
                draftInviteManager.Update(draftInvite);

                draftParticipantManager.Add(new DraftParticipant()
                {
                    DraftId       = draftInvite.DraftId,
                    UserId        = user.UserId,
                    User          = user,
                    Name          = HttpContext.User.Identity.Name,
                    DraftPosition = draft.DraftParticipants.Count + 1
                });
            }

            return(RedirectToAction("Index"));
        }
 public void ChooseThisCard()
 {
     if (!GameUtils.IsAnyTransitionActive())
     {
         Log.Arena.Print(string.Format("Client chooses: {0} ({1})", this.m_actor.GetEntityDef().GetName(), this.m_actor.GetEntityDef().GetCardId()), new object[0]);
         if (this.m_actor.GetEntityDef().IsHero())
         {
             DraftDisplay.Get().OnHeroClicked(this.m_cardChoice);
         }
         else
         {
             this.m_chosen = true;
             DraftManager.Get().MakeChoice(this.m_cardChoice);
         }
     }
 }
 private void Awake()
 {
     s_instance = this;
     if (this.m_scrollbar != null)
     {
         this.m_scrollbar.Enable(false);
         this.m_scrollbar.AddTouchScrollStartedListener(new UIBScrollable.OnTouchScrollStarted(this.OnTouchScrollStarted));
     }
     this.m_cardsContent.SetInArena(true);
     this.m_cardsContent.RegisterCardTilePressListener(new DeckTrayCardListContent.CardTilePress(this.OnCardTilePress));
     this.m_cardsContent.RegisterCardTileOverListener(new DeckTrayCardListContent.CardTileOver(this.OnCardTileOver));
     this.m_cardsContent.RegisterCardTileOutListener(new DeckTrayCardListContent.CardTileOut(this.OnCardTileOut));
     this.m_cardsContent.RegisterCardTileReleaseListener(new DeckTrayCardListContent.CardTileRelease(this.OnCardTileRelease));
     this.m_cardsContent.RegisterCardCountUpdated(new DeckTrayCardListContent.CardCountChanged(this.OnCardCountUpdated));
     DraftManager.Get().RegisterDraftDeckSetListener(new DraftManager.DraftDeckSet(this.OnDraftDeckInitialized));
 }
示例#5
0
        public ActionResult Index()
        {
            DraftManager draftManager = new DraftManager(_context);
            UserManager  userManager  = new UserManager(_context);
            User         user         = userManager.GetCurrentUser(User.Identity.GetUserId());

            if (user == null)
            {
                throw new Exception("No user found;");
            }

            List <Draft> drafts = draftManager.Get(user);

            ViewData["CurrentUserId"] = user.UserId;

            return(View(drafts));
        }
示例#6
0
        public ActionResult Edit(int id)
        {
            DraftManager draftManager = new DraftManager(_context);
            UserManager  userManager  = new UserManager(_context);
            User         user         = userManager.GetCurrentUser(User.Identity.GetUserId());
            Draft        draft        = draftManager.Get(id) ?? throw new Exception("No draft found.");

            return(View(new EditDraftViewModel()
            {
                Draft = draft,
                NewDraftInvite = new DraftInvite()
                {
                    Active = true, DraftId = draft.DraftId
                },
                NewDraftParticipant = new DraftParticipant()
                {
                    DraftPosition = draft.DraftParticipants.Count + 1, DraftId = draft.DraftId
                },
                Leagues = user.Leagues
            }));
        }
示例#7
0
        public ActionResult Room(int id)
        {
            DraftManager     draftManager     = new DraftManager(_context);
            DraftPickManager draftPickManager = new DraftPickManager(_context);
            PlayerManager    playerManager    = new PlayerManager(_context);
            TradeManager     tradeManager     = new TradeManager(_context);

            Draft            draft      = draftManager.Get(id);
            List <DraftPick> draftPicks = draftPickManager.Get(draft);

            List <Player> players = playerManager.Get(draft.League);

            foreach (var draftPick in draftPicks)
            {
                players.Remove(draftPick.Player);
            }

            //int currentPick = (draftPicks != null && draftPicks.Count > 0) ?
            //    draftPicks.Count + 1 :
            //    1;

            int  currentPick         = 1;
            int  currentRound        = 1;
            bool draftPicksAscending = true;

            if (draftPicks != null)
            {
                for (int i = 0; i < draftPicks.Count; i++)
                {
                    if (draftPicksAscending && currentPick < draft.Teams)
                    {
                        currentPick = currentPick + 1;
                    }
                    else if (draftPicksAscending && currentPick == draft.Teams)
                    {
                        currentRound        = currentRound + 1;
                        draftPicksAscending = false;
                    }
                    else if (!draftPicksAscending && currentPick > 1)
                    {
                        currentPick = currentPick - 1;
                    }
                    else if (!draftPicksAscending && currentPick == 1)
                    {
                        currentRound        = currentRound + 1;
                        draftPicksAscending = true;
                    }
                }
            }

            return(View(new DraftRoomViewModel()
            {
                Draft = draft,
                DraftPicks = draftPicks,
                Players = players,
                CurrentRound = currentRound,
                CurrentPick = currentPick,
                DraftPickAscending = draftPicksAscending,
                SelectedPlayerId = 0
            }));
        }