async Task IRotateTradeHandProcesses.TradeHandAsync(int selectedIndex) { if (_gameContainer.SingleInfo !.CanSendMessage(_gameContainer.BasicData !)) { await _gameContainer.Network !.SendAllAsync("tradehands", selectedIndex); } int player = _actionContainer.GetPlayerIndex(selectedIndex); if (player == _gameContainer.WhoTurn) { throw new BasicBlankException("Cannot pick yourself"); } _actionContainer.SetUpGoals(); _gameContainer.SingleInfo = _gameContainer.PlayerList !.GetWhoPlayer(); var oldList = _gameContainer.SingleInfo.MainHandList.ToRegularDeckDict(); var thisPlayer = _gameContainer.PlayerList[player]; var newList = thisPlayer.MainHandList.ToRegularDeckDict(); _gameContainer.SingleInfo.MainHandList.ReplaceRange(newList); thisPlayer.MainHandList.ReplaceRange(oldList); int myID = _gameContainer.PlayerList.GetSelf().Id; if (player == myID || _gameContainer.WhoTurn == myID) { _gameContainer.SingleInfo = _gameContainer.PlayerList.GetSelf(); _gameContainer.SortCards !(); } _gameContainer.SingleInfo = _gameContainer.PlayerList.GetWhoPlayer(); _gameContainer !.CurrentAction = null; await _processes.AnalyzeQueAsync(); }
async Task IEverybodyOneProcesses.EverybodyGetsOneAsync(CustomBasicList <int> thisList, int selectedIndex) { if (_gameContainer.SingleInfo !.CanSendMessage(_gameContainer.BasicData !)) { CustomBasicList <int> sendList = new CustomBasicList <int>(); sendList.AddRange(thisList); sendList.Add(selectedIndex); await _gameContainer.Network !.SendAllAsync("everybodygetsone", sendList); } int player = _actionContainer.GetPlayerIndex(selectedIndex); var newList = thisList.Select(items => new PreviousCard { Deck = items, Player = player }).ToCustomBasicList(); _gameContainer !.EverybodyGetsOneList.AddRange(newList); int oldCount = _gameContainer.TempActionHandList.Count; _gameContainer.TempActionHandList.RemoveGivenList(thisList, System.Collections.Specialized.NotifyCollectionChangedAction.Remove); _actionContainer.SetUpGoals(); if (_gameContainer.TempActionHandList.Count == oldCount) { throw new BasicBlankException("Did not remove from temphand"); } if (_gameContainer.CanLoadEverybodyGetsOne() == false) { await LastCardsForEverybodyGetsOneAsync(); return; } await _processes.AnalyzeQueAsync(); }
public async Task GiveCardsAsync() { CustomBasicList <int> thisList; if (ActionContainer.TempHand !.AutoSelect == HandObservable <FluxxCardInformation> .EnumAutoType.SelectOneOnly) { if (ActionContainer.TempHand.ObjectSelected() == 0) { await UIPlatform.ShowMessageAsync("Must choose a card to give to a player"); return; } thisList = new CustomBasicList <int>() { ActionContainer.TempHand.ObjectSelected() }; await BasicActionLogic.ShowMainScreenAgainAsync(); await FluxxEvent.ChoseForEverybodyGetsOneAsync(thisList, ActionContainer.IndexPlayer); return; } if (ActionContainer.TempHand.HowManySelectedObjects > 2) { await UIPlatform.ShowMessageAsync("Cannot choose more than 2 cards to give to player"); return; } int index = ActionContainer.GetPlayerIndex(ActionContainer.IndexPlayer); int howManySoFar = GameContainer.EverybodyGetsOneList.Count(items => items.Player == index); howManySoFar += ActionContainer.TempHand.HowManySelectedObjects; int extras = GameContainer.IncreaseAmount(); int mosts = extras + 1; if (howManySoFar > mosts) { await UIPlatform.ShowMessageAsync($"Cannot choose more than 2 cards each for the player. So far; you chose {howManySoFar} cards."); return; } var finalList = ActionContainer.TempHand.ListSelectedObjects(); thisList = finalList.GetDeckListFromObjectList(); await BasicActionLogic.ShowMainScreenAgainAsync(); await FluxxEvent.ChoseForEverybodyGetsOneAsync(thisList, ActionContainer.IndexPlayer); }
public static int UseTake(FluxxGameContainer gameContainer, ActionContainer actionContainer, int selectedIndex) { var index = actionContainer.GetPlayerIndex(selectedIndex); var tempPlayer = gameContainer.PlayerList ![index];