internal async Task DrawActionCard(Game game, int count) { EventData <int> drawCount = new EventData <int>() { data = count }; await game.EventSystem.Call(EventEnum.BeforDrawActionCard, game.ActivePlayerSeat(), this, drawCount); List <ActionCard> drawedCards = new List <ActionCard>(); for (int i = 0; i < drawCount.data; i++) { if (game.ActionDeck.Count == 0)//如果没有行动牌了 { //就把行动弃牌堆洗入行动牌堆 game.ActionDeck.AddRange(game.UsedActionDeck); game.UsedActionDeck.Clear(); game.Reshuffle(game.ActionDeck); } ActionCard card = game.ActionDeck[0]; ActionCards.Add(card); drawedCards.Add(card); game.ActionDeck.Remove(card); card.Owner = this; card.OnDraw(game, this); } await game.EventSystem.Call(EventEnum.DrawActionCard, game.ActivePlayerSeat(), this, drawedCards); }
/// <summary> /// 失去一张行动牌 /// 注意不进弃牌堆 /// </summary> /// <param name="game"></param> /// <param name="cards"></param> internal async Task DropActionCard(Game game, List <int> cards, bool goUsedPile = false, bool ifPassive = false) { if (ifPassive) { EventData <bool> dropData = new EventData <bool>(true); //被动丢牌抛出一个事件 await game.EventSystem.Call(EventEnum.BeforePassiveDropActionCard, game.GetSeat(this), game, this, dropData); if (!dropData.data) { //这次丢牌被取消了 return; } } List <ActionCard> data = new List <ActionCard>(); foreach (var cardId in cards) { ActionCard card = ActionCards.Find(x => x.Id == cardId); ActionCards.Remove(card); if (goUsedPile) { game.UsedActionDeck.Add(card); } data.Add(card); card.OnDrop(game, this); card.Owner = null; } await game.EventSystem.Call(EventEnum.DropActionCard, game.GetSeat(this), this, data); }
public async Task DrawActionCard(Game game, int count) { EventData <int> drawCount = new EventData <int>() { data = count }; await game.EventSystem.Call(EventEnum.BeforDrawActionCard, game.ActivePlayerSeat(), this, drawCount); List <ActionCard> drawedCards = new List <ActionCard>(); for (int i = 0; i < drawCount.data; i++) { if (game.ActionDeck.Count == 0)//如果没有行动牌了 { //就把行动弃牌堆洗入行动牌堆 List <ActionCard> usedCards = new List <ActionCard>(game.UsedActionDeck); game.ActionDeck.AddRange(usedCards); await game.EventSystem.Call(EventEnum.AfterAddCard, game.GetSeat(this), game, null, game.ActionDeck, usedCards); game.UsedActionDeck.Clear(); await game.EventSystem.Call(EventEnum.AfterRemoveCard, game.GetSeat(this), game, null, game.UsedActionDeck, usedCards); game.Reshuffle(game.ActionDeck); } ActionCard card = game.ActionDeck[0]; game.ActionDeck.Remove(card); await AddActionCards(game, new List <ActionCard>() { card }); drawedCards.Add(card); } await game.EventSystem.Call(EventEnum.DrawActionCard, game.ActivePlayerSeat(), this, drawedCards); }
internal Task UseActionCard(Game game, FreeUse useInfo) { if (useInfo.SkillId < 0) { //正常用卡 ActionCard card = ActionCards.Find(x => x.Id == useInfo.CardId); if (card == null) { return(Task.CompletedTask); } return(card.DoEffect(game, useInfo)); } else { Skill skill = Hero.Skills.Find(x => SkillHelper.getId(x) == useInfo.SkillId); if (skill != null) { return(skill.DoEffect(game, useInfo)); } else { throw new System.Exception($"玩家不持有的技能:{useInfo.SkillId}"); } } }
public virtual bool isValidTarget(Game game, FreeUse useWay, ActionCard card, out string invalidInfo) { invalidInfo = string.Empty; return(true); }