Example #1
0
        public static async Task die(this IEnumerable <Card> cards, THHGame game, Dictionary <Card, DeathEventArg.Info> infoDic)
        {
            List <THHPlayer> remainPlayerList = new List <THHPlayer>(game.players);
            await game.triggers.doEvent(new DeathEventArg()
            {
                infoDic = infoDic
            }, arg =>
            {
                infoDic = arg.infoDic;
                foreach (var pair in infoDic)
                {
                    Card card = pair.Key;
                    if (!game.players.Any(p => p.field.Contains(card) || p.master == card))
                    {
                        continue;
                    }
                    THHPlayer player = game.players.FirstOrDefault(p => p.master == card);
                    if (player != null)
                    {
                        remainPlayerList.Remove(player);
                        game.logger.log(player + "失败");
                    }
                    else
                    {
                        pair.Value.player.field.moveTo(game, card, pair.Value.player.grave);
                        game.logger.log(card + "阵亡");
                    }
                }
                return(Task.CompletedTask);
            });

            if (remainPlayerList.Count != game.players.Length)
            {
                if (remainPlayerList.Count > 0)
                {
                    await game.gameEnd(remainPlayerList.ToArray());
                }
                else
                {
                    await game.gameEnd(new THHPlayer[0]);
                }
            }
        }
Example #2
0
        public static async Task die(this IEnumerable <Card> cards, THHGame game)
        {
            List <THHPlayer> remainPlayerList = new List <THHPlayer>(game.players);
            await game.triggers.doEvent(new DeathEventArg()
            {
                infoDic = cards.ToDictionary(c => c, c => default(DeathEventArg.Info))
            }, onDie);

            Task onDie(DeathEventArg arg)
            {
                Dictionary <Card, DeathEventArg.Info> infoDic = new Dictionary <Card, DeathEventArg.Info>();

                foreach (var card in arg.infoDic.Keys)
                {
                    if (card.pile.name == PileName.MASTER)//英雄阵亡
                    {
                        infoDic.Add(card, new DeathEventArg.Info()
                        {
                            player   = card.getOwner(),
                            position = card.pile.indexOf(card)
                        });
                        remainPlayerList.Remove(card.getOwner());
                        game.logger.log(card.getOwner() + "失败");
                    }
                    else if (card.pile.name == PileName.FIELD)//随从阵亡
                    {
                        infoDic.Add(card, new DeathEventArg.Info()
                        {
                            player   = card.getOwner(),
                            position = card.pile.indexOf(card)
                        });
                        card.pile.moveTo(game, card, card.getOwner().grave);
                        game.logger.log(card + "阵亡");
                    }
                    else if (card.pile.name == PileName.ITEM)//装备摧毁
                    {
                        infoDic.Add(card, new DeathEventArg.Info()
                        {
                            player   = card.getOwner(),
                            position = card.pile.indexOf(card)
                        });
                        card.pile.moveTo(game, card, card.getOwner().grave);
                        game.logger.log(card + "摧毁");
                    }
                }
                arg.infoDic = infoDic;
                return(Task.CompletedTask);
            }

            if (remainPlayerList.Count != game.players.Length)
            {
                if (remainPlayerList.Count > 0)
                {
                    await game.gameEnd(remainPlayerList.ToArray());
                }
                else
                {
                    await game.gameEnd(new THHPlayer[0]);
                }
            }
        }