Esempio n. 1
0
        public static CardVm Map(CardDm dm)
        {
            var vm = new CardVm
            {
                Id       = dm.Id,
                Name     = dm.Name,
                Cmc      = dm.Cmc,
                Cost     = dm.Cost,
                Legality = new CardLegalityVm
                {
                    Commander = dm.Legality.Commander,
                    Legacy    = dm.Legality.Legacy,
                    Modern    = dm.Legality.Modern,
                    Standard  = dm.Legality.Standard,
                    Vintage   = dm.Legality.Vintage
                },
                Power     = dm.Power,
                Toughness = dm.Toughness,
                RulesText = dm.RulesText,
                StoreUrl  = dm.StoreUrl,
                Url       = dm.Url,
                Types     = dm.Types,
                SubTypes  = dm.SubTypes,
                Colors    = dm.Colors,
                Sets      = MapSets(dm.Sets).ToList()
            };

            return(vm);
        }
Esempio n. 2
0
        protected void OnClickCardControl()
        {
            if (CardVm != null)
            {
                CardVm.StartItem(null);
            }

            StateHasChanged();
        }
Esempio n. 3
0
        public async Task PlayCard(string gameId, CardVm card, List <AnnouncementVm> announcementVms)
        {
            try
            {
                var validPlay = this.belotGameManager.PlayCard(gameId, card, announcementVms, this.Context.ConnectionId);

                if (validPlay == -1)
                {
                    return;
                }

                await this.UpdateTabelState(gameId);

                await this.UpdateIndividualPlayerStates(gameId, "Play");

                if (this.belotGameManager.Games[gameId].ShouldCloseHand)
                {
                    Thread.Sleep(4000);

                    this.belotGameManager.Games[gameId].CloseHand();
                    await this.UpdateTabelState(gameId);

                    await this.UpdateIndividualPlayerStates(gameId, "GameStart");
                }

                if (this.belotGameManager.Games[gameId].TableState.ActionRequied == "ViewScoreRound")
                {
                    Thread.Sleep(10000);
                    this.belotGameManager.NextRound(gameId);

                    await this.UpdateTabelState(gameId);

                    await this.UpdateIndividualPlayerStates(gameId, "GameStart");
                }

                if (this.belotGameManager.Games[gameId].TableState.ActionRequied == "ViewScoreGame")
                {
                    Thread.Sleep(15000);
                    this.belotGameManager.NextGameInSet(gameId);

                    await this.UpdateTabelState(gameId);

                    await this.UpdateIndividualPlayerStates(gameId, "GameStart");
                }
            }
            catch (Exception ex)
            {
                var s = 4;
            }
        }
Esempio n. 4
0
        public static void DrawCard(CardVm card)
        {
            if (card == null)
            {
                return;
            }

            Console.WriteLine($"{card.Name}: {card.Cost}");
            Console.WriteLine($"Types: {string.Join(", ", card.Types)} | SubTypes: {string.Join(", ", card.SubTypes)}");
            Console.WriteLine($"Rules Text: {card.RulesText}");
            if (card.Types.Contains("creature"))
            {
                Console.WriteLine($"Power: {card.Power} | Toughness: {card.Toughness}");
            }
            Console.WriteLine();
        }
Esempio n. 5
0
        public static List <string> GetCardColors(CardVm card)
        {
            System.Console.WriteLine("Getting deck colors");
            var colorList = ExtractColorsFromString(card.Cost);

            colorList.AddRange(ExtractColorsFromString(card.RulesText));

            colorList = colorList.Distinct().ToList();

            System.Console.WriteLine("Found these colors:");
            foreach (var color in colorList)
            {
                System.Console.WriteLine(color);
            }

            return(colorList);
        }
Esempio n. 6
0
        public async Task InitializeGameHub()
        {
            gameHubConnection = new HubConnectionBuilder()
                                .WithUrl(ServerAddress + "/belotHub")
                                .Build();

            gameHubConnection.On <PlayerStateVm, string>(ChannelConstants.PlayerStateChange, async(ps, eventName) =>
            {
                this.playerState    = ps;
                this.cardToBePlayed = null;
                Console.WriteLine("PlayerStateChange");
                Console.WriteLine(eventName);

                if (eventName == null)
                {
                }
                //Console.WriteLine(ps.ActionRequired);
                else if (eventName == "GameStart")
                {
                    //Console.WriteLine("GameStart State Update");
                }
                else if (eventName.Contains("Deal"))
                {
                    //Console.WriteLine(JsonConvert.SerializeObject(ps));
                }
                else if (eventName.Contains("Play"))
                {
                    //Console.WriteLine(JsonConvert.SerializeObject(ps));
                }
                else if (eventName.Contains("ViewScore"))
                {
                    //Console.WriteLine("ViewScore");
                    //Console.WriteLine(JsonConvert.SerializeObject(ps));
                }

                if (playerState != null)
                {
                    if (playerState.ActionRequired == "Wait")
                    {
                        return;
                    }
                    else if (playerState.ActionRequired == "Bidding")
                    {
                        Thread.Sleep(1000);
                        await this.Announce(playerState.PossibleBids[0]);
                    }
                    else if (playerState.ActionRequired == "ConfirmDeal")
                    {
                        Thread.Sleep(1000);
                        await this.Deal();
                    }
                    else if (playerState.ActionRequired == "PlayCard")
                    {
                        Thread.Sleep(1000);
                        await this.PlayCard();
                    }
                }
            });

            gameHubConnection.On <JoinGameRes>(ChannelConstants.JoinGameAnswer, (res) =>
            {
                Console.WriteLine("JoinRespons");
                Console.WriteLine(res.Success);
            });

            gameHubConnection.On <TableStateVm>(ChannelConstants.TableUpdate, (tu) =>
            {
                Console.WriteLine("TableUpdate");
                this.tableStateVm = tu;

                if (tu.ActionRequied == "ViewScore")
                {
                    Console.WriteLine("ViewScore - Table Update");
                    Console.WriteLine(JsonConvert.SerializeObject(tu));
                }
            });


            await gameHubConnection.StartAsync();

            var joinReq = new JoinGameReq()
            {
                PlayerName = this.UserId,
                GameName   = this.GameName,
                Seat       = int.Parse(this.Seat)
            };

            Thread.Sleep(int.Parse(this.Seat) * 500);
            await gameHubConnection.SendAsync("JoinGame", joinReq);
        }
Esempio n. 7
0
        public int PlayCard(string gameId, CardVm cardVm, List <AnnouncementVm> announcements, string playerId)
        {
            var result = this.Games[gameId].PlayCard(cardVm, announcements, playerId);

            return(result);
        }