예제 #1
0
        public static async Task RemovePlayerFromCombat(CombatInstance inst, UserAccount player)
        {
            var team = inst.GetTeam(player);

            inst.Players.Remove(player);

            var       turnskip = false;
            BasicCard skipCard = null;

            foreach (BasicCard card in player.ActiveCards)
            {
                //Remove any markers corresponding to the cards to be removed from combat
                var turnnum = inst.CardList.IndexOf(card);
                foreach (BasicCard card2 in inst.CardList)
                {
                    for (int i = card2.Markers.Count - 1; i >= 0; i--)
                    {
                        if (card2.Markers[i].OriginTurnNum == turnnum)
                        {
                            card2.Markers.RemoveAt(i);
                        }
                    }
                }

                inst.CardList.Remove(card);

                if (turnnum <= inst.TurnNumber)
                {
                    inst.TurnNumber--;
                }
                if (card.IsTurn)
                {
                    turnskip = true;
                    skipCard = card;
                }
            }

            inst.GetTeam(player).Members.Remove(player);
            player.ResetCombatFields(inst.IsDuel);

            await inst.PassiveUpdatePlayerLeft();

            await MessageHandler.UserForfeitsCombat(inst.Location, player);

            if (inst.IsDuel)
            {
                await CheckTeamElimination(inst, team);
            }

            if (turnskip)
            {
                await SkipTurn(inst, skipCard);
            }

            SaveInstances();
        }