private async Task effect(Game game, FreeUse useWay) { Player target = game.GetPlayer(useWay.PlayersId[0]); Player user = game.GetPlayer(useWay.PlayerId); await target.ChangeSize(game, -1, this, Owner); Player now = target; while (true) { ChooseSomeCardResponse chooseSomeCardResponse = (ChooseSomeCardResponse)await game.WaitAnswer(new ChooseSomeCardRequest() { Count = 1, PlayerId = now.Id, TimeOut = game.RequestTime, EnoughOnly = false }); if (chooseSomeCardResponse.Cards.Count == 0) { break; } else { Player nowTarget = now == user ? target : user; await nowTarget.ChangeSize(game, -1, this, Owner); now = nowTarget; } } }
public override async Task DoEffect(Game game, FreeUse useWay) { ActionCard source = game.GetCard(useWay.Source[0]) as ActionCard; Player player = game.GetPlayer(useWay.PlayerId); Player target = game.GetPlayer(useWay.PlayersId[0]); await target.ChangeSize(game, -1, source, player); Player now = target; while (true) { ChooseSomeCardResponse chooseSomeCardResponse = (ChooseSomeCardResponse)await game.WaitAnswer(new ChooseSomeCardRequest() { Count = 1, PlayerId = now.Id, TimeOut = game.RequestTime, EnoughOnly = false }); if (chooseSomeCardResponse.Cards.Count == 0) { break; } else { Player nowTarget = now == player ? target : player; await now.discard(game, chooseSomeCardResponse.Cards); await nowTarget.ChangeSize(game, -1, source, now); now = nowTarget; } } }
internal async Task NewTurn(Player player) { ActivePlayer = player; int seat = Players.IndexOf(player); await EventSystem.Call(EventEnum.TurnStart, seat, this); await player.DrawEventCard(this); await player.DrawActionCard(this, 1); await EventSystem.Call(EventEnum.ActionStart, seat, this); while (true) { Log.Debug($"玩家{player.Id}出牌中"); Response response = await WaitAnswer(new FreeUseRequest() { PlayerId = player.Id }.SetTimeOut(TurnTime)); if (response is EndFreeUseResponse) { break; } else { await(response as FreeUse).HandleAction(this); //await EventSystem.Call(EventEnum.CardUsed, ActivePlayerSeat()); } } await EventSystem.Call(EventEnum.ActionEnd, seat, this); var chooseDirectionResponse = (ChooseDirectionResponse) await WaitAnswer(new ChooseDirectionRequest() { PlayerId = player.Id }.SetTimeOut(RequestTime)); await player.UseEventCard(this, chooseDirectionResponse); int max = await player.HandMax(this); if (player.ActionCards.Count > max) { ChooseSomeCardResponse chooseSomeCardResponse = (ChooseSomeCardResponse) await WaitAnswer(new ChooseSomeCardRequest() { PlayerId = player.Id, Count = player.ActionCards.Count - max }.SetTimeOut(RequestTime)); await player.DropActionCard(this, chooseSomeCardResponse.Cards, true); } await EventSystem.Call(EventEnum.afterDiscardPhase, seat, this, player); await EventSystem.Call(EventEnum.TurnEnd, seat, this); }
public override async Task DoEffect(Game game, FreeUse useWay) { Player player = game.GetPlayer(useWay.PlayerId); Player targetPlayer = game.GetPlayer(useWay.PlayersId[0]); ActionCard source = game.GetCard(useWay.Source[0]) as ActionCard; TakeChoiceResponse takeChoice = await game.WaitAnswer(new TakeChoiceRequest() { Infos = new List <string>() { "+1", "-1" }, PlayerId = useWay.PlayerId, RequsetInfo = "社群规模±1" }.SetTimeOut(game.RequestTime)) as TakeChoiceResponse; if (takeChoice.Index == 0) { await game.ChangeSize(1, source); } else { await game.ChangeSize(-1, source); } ChooseSomeCardResponse chooseCard = await game.WaitAnswer(new ChooseSomeCardRequest() { Count = player.ActionCards.Count, EnoughOnly = false, PlayerId = useWay.PlayerId, RequsetInfo = "选择X张牌给予目标玩家,你与其影响力+X" }.SetTimeOut(game.RequestTime)) as ChooseSomeCardResponse; List <ActionCard> cards = new List <ActionCard>(chooseCard.Cards.Select(id => player.ActionCards.Find(c => c.Id == id))); await player.DropActionCard(game, chooseCard.Cards); await player.AddActionCards(game, cards); await player.ChangeSize(game, cards.Count, source, player); await targetPlayer.ChangeSize(game, cards.Count, source, player); }
public override async Task DoEffect(Game game, FreeUse useWay) { ActionCard source = game.GetCard(useWay.Source[0]) as ActionCard; List <Player> crowdfunders = new List <Player>() { game.GetPlayer(useWay.PlayerId) }; Task <Response>[] tasks = await game.waitAnswerAll(new List <Player>(game.Players.Where(p => p.Id != useWay.PlayerId)), p => game.WaitAnswer(new ChooseSomeCardRequest() { AllPlayerRequest = true, Count = 1, EnoughOnly = false, PlayerId = p.Id, RequsetInfo = "是否丢弃手牌成为众筹者?" }.SetTimeOut(game.RequestTime))); foreach (var task in tasks) { ChooseSomeCardResponse response = task.Result as ChooseSomeCardResponse; if (response.Cards.Count > 0) { crowdfunders.Add(game.GetPlayer(response.PlayerId)); } } if (crowdfunders.Count == game.Players.Count) { return; } if (crowdfunders.Count > 0) { foreach (Player player in crowdfunders) { await player.ChangeSize(game, 1, source, game.GetPlayer(useWay.PlayerId)); } } if (crowdfunders.Count > 1) { TakeChoiceResponse response = await game.WaitAnswer(new TakeChoiceRequest() { PlayerId = useWay.PlayerId, Infos = new List <string>() { "+" + crowdfunders.Count, "-" + crowdfunders.Count } }.SetTimeOut(game.RequestTime)) as TakeChoiceResponse; if (response.Index == 0) { await game.ChangeSize(crowdfunders.Count, source); } else { await game.ChangeSize(-crowdfunders.Count, source); } } if (crowdfunders.Count > 2) { foreach (Player player in crowdfunders) { await player.DrawActionCard(game, 1); } } }
internal async Task NewTurn(Player player) { Log.Debug("玩家" + player.Id + "回合开始"); ActivePlayer = player; int seat = Players.IndexOf(player); await EventSystem.Call(EventEnum.TurnStart, seat, this, player); await player.DrawEventCard(this); await player.DrawActionCard(this, 1); await EventSystem.Call(EventEnum.ActionStart, seat, this); while (true) { Response response = await WaitAnswer(new FreeUseRequest() { PlayerId = player.Id }.SetTimeOut(TurnTime)); if (response is EndFreeUseResponse) { break; } else { await(response as FreeUse).HandleAction(this); //await EventSystem.Call(EventEnum.CardUsed, ActivePlayerSeat()); } } await EventSystem.Call(EventEnum.ActionEnd, seat, this); //事件处理阶段 ChooseDirectionResponse chooseDirectionResponse; if (player.avoidSetEvent) { chooseDirectionResponse = (ChooseDirectionResponse) await WaitAnswer(new ChooseDirectionRequest() { PlayerId = player.Id, CanSet = false }.SetTimeOut(RequestTime)); player.avoidSetEvent = true; } else { chooseDirectionResponse = (ChooseDirectionResponse) await WaitAnswer(new ChooseDirectionRequest() { PlayerId = player.Id, CanSet = true }.SetTimeOut(RequestTime)); } await player.UseEventCard(this, chooseDirectionResponse); int max = await player.HandMax(this); if (player.ActionCards.Count > max) { ChooseSomeCardResponse chooseSomeCardResponse = (ChooseSomeCardResponse) await WaitAnswer( new ChooseSomeCardRequest() { PlayerId = player.Id, Count = player.ActionCards.Count - max, RequsetInfo = "回合结束,丢弃多余手牌" }.SetTimeOut(RequestTime) ); await player.DropActionCard(this, chooseSomeCardResponse.Cards, true); } await EventSystem.Call(EventEnum.afterDiscardPhase, seat, this, player); await EventSystem.Call(EventEnum.TurnEnd, seat, this); }