public async Task ShowLossAsync() { await UIPlatform.ShowMessageAsync("Sorry, you lost"); GameGoing = false; await this.SendGameOverAsync(); }
public async Task EndTurnAsync(bool didPlay, bool validSets) { if (SingleInfo !.PlayerCategory == EnumPlayerCategory.Self) { _model !.TempSets !.EndTurn(); _model.PlayerHand1 !.EndTurn(); if (BasicData.IsXamarinForms) { await Task.Delay(700); //try 30 to start with. } //await UIPlatform.ShowMessageAsync("Ending Turn"); } if (validSets == false) { if (SingleInfo.PlayerCategory == EnumPlayerCategory.Self) { await UIPlatform.ShowMessageAsync("Failed to rearrange the sets. Therefore, you have to draw 3 tiles if any are left"); } await ResetAsync(); } _model !.MainSets1 !.EndTurn(); if (BasicData !.MultiPlayer) { if (SingleInfo.PlayerCategory == EnumPlayerCategory.Self) { await Network !.SendAllAsync("finished", didPlay); } else { Check !.IsEnabled = true; return; } } await FinishedAsync(didPlay); }
public async Task MakeMoveAsync(int space) { if (space < 127) { if (SingleInfo !.CanSendMessage(BasicData !) == true) { await Network !.SendAllAsync("space", space); } } await GameBoard1 !.MakeMoveAsync(space, this); if (GameBoard1.WillMissNextTurn(this) == true) { SingleInfo !.MissNextTurn = true; if (SingleInfo.PlayerCategory == EnumPlayerCategory.Self) { await UIPlatform.ShowMessageAsync("Miss next turn for falling in a pit"); } if (PlayerList.Any(Items => Items.MissNextTurn == true) == false) { throw new BasicBlankException("Did fall. Find out what happened"); } } if (space < 127) { await EndTurnAsync(); //decided to end turn automatically now. } }
private async Task PublicPiles_PileClickedAsync(int index) { if (SaveRoot !.GameStatus == EnumStatusList.DiscardAll) { await UIPlatform.ShowMessageAsync("Sorry; you must discard all your cards"); return; } int decks = CardSelected(out EnumCardType types, out int discardNum); if (decks == 0 && types == EnumCardType.IsNone) { await UIPlatform.ShowMessageAsync("Sorry, there was nothing selected"); return; } if (decks == 0) { throw new BasicBlankException("Nothing selected but the type was not none"); } bool rets = IsValidMove(index, decks); if (rets == false) { await UIPlatform.ShowMessageAsync("Illegal Move"); return; } await PlayOnPileAsync(index, decks, types, discardNum); }
private async Task NewDiscardClickAsync(int deck) { if (_mainGame !.CanProcessDiscard(out bool pickUp, ref deck, out string message) == false) { await UIPlatform.ShowMessageAsync(message); return; } if (pickUp == true) { var thisCol = _model.DiscardList1 !.DiscardListSelected(deck); if (thisCol.Count > 1) { var newCol = _mainGame.AppendDiscardList(thisCol); if (_mainGame.CardContainsRummy(deck, newCol) == false) { await UIPlatform.ShowMessageAsync("Sorry, cannot pick up more than one card because either invalid rummy or no card left for discard"); return; } } if (_gameContainer.BasicData !.MultiPlayer == true) { await _gameContainer.Network !.SendAllAsync("pickupfromdiscard", deck); } await _mainGame.PickupFromDiscardAsync(deck); return; } await _gameContainer.SendDiscardMessageAsync(deck); await _mainGame.DiscardAsync(deck); }
public async Task DrawCardAsync() { if (HasPlayedCard()) { await UIPlatform.ShowMessageAsync("Sorry, you must choose to either play the cards or put them back before drawing another card"); return; } bool wasEnd = DeckPile !.IsEndOfDeck(); if (wasEnd) { var thisCol = _model !.Discard !.DiscardList(); if (_model.Discard.PileEmpty() == false) { thisCol.Add(_model.Discard.GetCardInfo()); } if (_model.CurrentPile !.PileEmpty() == false) { thisCol.Add(_model.CurrentPile.GetCardInfo()); } _model.CurrentPile.ClearCards(); _model.Discard.ClearCards(); _model.DeckPile.OriginalList(thisCol); } var thisCard = _model !.DeckPile.DrawCard(); if (_model.CurrentPile !.PileEmpty()) { _model.CurrentPile.AddCard(thisCard); }
private async Task HandList_ObjectClickedAsync(CardInfo payLoad, int index) { if (_gameContainer.CanGiveCard(payLoad) == false) { if (_basicData.IsXamarinForms) { return; } await UIPlatform.ShowMessageAsync("Sorry, the card cannot be given as a clue because its not part of the prediction"); return; } payLoad.IsSelected = true; if (_gameContainer.Test.NoAnimations == false) { await _gameContainer.Delay.DelaySeconds(.25); } var tempPlayer = _gameContainer !.PlayerList !.GetWhoPlayer(); if (_gameContainer.BasicData !.MultiPlayer) { await _gameContainer.Network !.SendToParticularPlayerAsync("cluegiven", payLoad.Deck, tempPlayer.NickName); } CommandContainer !.ManuelFinish = true; payLoad.IsSelected = false; _gameContainer.SaveRoot !.GameStatus = EnumClueStatusList.EndTurn; if (_gameContainer.BasicData.MultiPlayer == false) { throw new BasicBlankException("Computer should have never had this"); } _gameContainer.Check !.IsEnabled = true; //to wait for them to end turn. }
public async Task LayDownSetsAsync() { if (_mainGame !.SaveRoot !.PlayerWentOut > 0) { bool lats = await _mainGame.CanLaterLayDownAsync(); if (lats == false) { return; } var thisCol1 = _mainGame.ListValidSets(); await ProcessValidSetsAsync(thisCol1); return; } bool rets = _mainGame.HasInitialSet(); if (rets == false) { await UIPlatform.ShowMessageAsync("Sorry, you do not have the valid sets needed to go out"); return; } var thisCol2 = _mainGame.ListValidSets(); await ProcessValidSetsAsync(thisCol2); }
private async Task MoveSpaceAsync(int space) { if (_gameContainer.Test.DoubleCheck) { _gameContainer.TempClicked = space; _gameBoard.RepaintBoard(); return; } if (_gameBoard.CanMoveToSpace(space) == false) { if (_basicData.IsXamarinForms) { return; } await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (_mainGame.SaveRoot.MovesLeft == 0) { if (_basicData.IsXamarinForms) { return; } await UIPlatform.ShowMessageAsync("No Moves Left. Try Rolling The Dice"); return; } if (_mainGame.BasicData.MultiPlayer) { await _mainGame.Network !.SendAllAsync("space", space); } _gameBoard.MoveToSpace(space); await _mainGame.ContinueMoveAsync(); }
public async Task CribAsync() { int manys = Hand1.HowManySelectedObjects; if (manys == 0) { await UIPlatform.ShowMessageAsync("Must choose cards"); return; } if (manys != 2) { await UIPlatform.ShowMessageAsync("Must choose 2 cards for crib"); return; } var thisList = Hand1.ListSelectedObjects(true); if (Hand1.HandList.Count == 6) { throw new BasicBlankException("Did not remove cards before starting to put to crib"); } _mainGame.RemoveTempCards(thisList); _mainGame.CardsToCrib(thisList); if (DeckPile.IsEndOfDeck()) { await UIPlatform.ShowMessageAsync("Game Over. Check Results"); await _mainGame.SendGameOverAsync(); //NewGameVisible = true; //i think. //_mainGame.GameGoing = false; } }
public async Task PlayerPileClickedAsync(MilkRunPlayerItem thisPlayer, PileInfo pileData) { int newDeck = _model !.PlayerHand1 !.ObjectSelected(); if (newDeck == 0) { await UIPlatform.ShowMessageAsync("Sorry, must choose a card to play"); return; } if (SaveRoot !.CardsDrawn < 2) { await UIPlatform.ShowMessageAsync("Sorry, must draw the 2 cards first before playing"); return; } int index = thisPlayer.Id; if (CanMakeMove(index, newDeck, pileData.Pile, pileData.Milk) == false) { await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (BasicData !.MultiPlayer == true) { SendPlay thisSend = new SendPlay(); thisSend.Deck = newDeck; thisSend.Player = index; thisSend.Milk = pileData.Milk; thisSend.Pile = pileData.Pile; await Network !.SendAllAsync("play", thisSend); } await ProcessPlayAsync(index, newDeck, pileData.Pile, pileData.Milk); }
protected override async Task ProtectedAfterRollingAsync() { SingleInfo !.Score += _model !.Cup !.DiceList.Sum(Items => Items.Value); if (SaveRoot !.IsFaceOff == true) { if (PlayerList.Any(Items => Items.IsFaceOff == true && Items.Score == 0)) { WhoTurn = await PlayerList !.CalculateWhoTurnAsync(); await StartNewTurnAsync(); return; } await ExtendedFaceOffAsync(); return; } SingleInfo.NumberOfRolls++; if (SingleInfo.Score > 21) { await UIPlatform.ShowMessageAsync($"{SingleInfo.NickName} is out for going over 21"); await EndTurnAsync(); return; } await ContinueTurnAsync(); //if they get 21, they are responsible for ending turn. }
protected override async Task <bool> HasOtherAsync(int pile) { if (GlobalClass.Stock !.ObjectSelected() == 0) { return(await base.HasOtherAsync(pile)); } int wastes = _thisMod !.WastePiles1 !.OneSelected(); if (wastes > -1) { await UIPlatform.ShowMessageAsync("Cannot choose both from the waste and the stock"); return(true); } var thisCard = GlobalClass.Stock.HandList.GetSpecificItem(GlobalClass.Stock.ObjectSelected()); if (_thisMod.WastePiles1.CanAddSingleCard(pile, thisCard) == false) { await UIPlatform.ShowMessageAsync("Illegal move"); return(true); } _thisMod.WastePiles1.AddSingleCard(pile, thisCard); GlobalClass.Stock.HandList.RemoveObjectByDeck(thisCard.Deck); return(true); }
private async Task AnalyzeFaceOffAsync() { int tempTurn = WhoWonFaceOff(); if (tempTurn == 0) { await UIPlatform.ShowMessageAsync("There was a tie during the faceoff. Therefore; the faceoff is being done again"); ClearFaceOff(); await _gameContainer.EndTurnAsync !.Invoke(); return; } _gameContainer.WhoTurn = tempTurn; _gameContainer.SingleInfo = _gameContainer.PlayerList !.GetWhoPlayer(); await UIPlatform.ShowMessageAsync($"{_gameContainer.SingleInfo.NickName} has won the face off"); ClearFaceOff(); _gameContainer.SaveRoot !.IsFaceOff = false; if (_delegates.LoadMainGameAsync == null) { throw new BasicBlankException("Nobody is handling the load main screen. Rethink"); } await _delegates.LoadMainGameAsync.Invoke(); await _gameContainer.StartNewTurnAsync !.Invoke(); }
private async Task ReshuffleMailAsync(DeckRegularDict <MailCard> list) { await UIPlatform.ShowMessageAsync("Mail is being reshuffled"); _gameContainer.SaveRoot !.MailListLeft = list; _gameContainer.SaveRoot.OutCards.RemoveAllOnly(items => items.Deck <= 24); }
public static async Task MessageGameOverAsync(this MinesweeperMainGameClass game, string message) { await UIPlatform.ShowMessageAsync(message); //rethink about anything else. await game.SendGameOverAsync(); }
protected override async Task ProcessDiscardClickedAsync() { if (_mainGame !.SingleInfo !.MainHandList.Count == 0 && _mainGame.SingleInfo.DefenseList.Count == 0) { throw new BasicBlankException("There are no cards from hand or defense list. Therfore; should have disabled the pile"); } if (_mainGame.SingleInfo.DefensePile !.HandList.HasSelectedObject() == true) { if (_mainGame.SingleInfo.DefenseList.All(items => items.IsSelected == false)) { await UIPlatform.ShowMessageAsync("If you choose one card from defense, you must choose all cards"); return; } if (_mainGame.BasicData !.MultiPlayer == true) { await _mainGame.Network !.SendAllAsync("throwawaydefense"); } await _mainGame !.ThrowAwayDefenseCardsAsync(); return; } if (_mainGame.BasicData !.MultiPlayer == true) { await _mainGame.Network !.SendAllAsync("throwawayallcardsfromhand"); } await _mainGame !.ThrowAwayAllCardsFromHandAsync(); }
private async Task YourDefensePile_BoardClickedAsync() { if (_gameContainer !.OtherTurn > 0) { return; } if (_mainGame !.SingleInfo !.MainHandList.HasSelectedObject() == false) { return; } if (_mainGame.SingleInfo.DefenseList.HasSelectedObject() == true) { await UIPlatform.ShowMessageAsync("Cannot choose any defense cards on the board to add more defense cards"); return; } var tempDefenseList = _mainGame.SingleInfo.MainHandList.GetSelectedItems(); if (await _mainGame.CanPlayDefenseCardsAsync(tempDefenseList) == false) { return; } if (_mainGame.BasicData !.MultiPlayer == true) { await _mainGame.Network !.SendAllAsync("addtodefense", tempDefenseList.GetDeckListFromObjectList()); } tempDefenseList.UnselectAllObjects(); await _mainGame.AddCardsToDefensePileAsync(tempDefenseList); //hopefully this is correct. }
private async Task MainDefense1_BoardClickedAsync() { if (_gameContainer !.OtherTurn == 0) { throw new BasicBlankException("Should not have allowed the click for main defense because not the other turn to defend themselves"); } if (_mainGame !.SingleInfo !.MainHandList.HasSelectedObject() == false && _mainGame.SingleInfo.DefenseList.HasSelectedObject() == false) { await UIPlatform.ShowMessageAsync("Must choose at least a card from defense or at least a card from hand"); return; } if (_mainGame.SingleInfo.MainHandList.HasSelectedObject() && _mainGame.SingleInfo.DefenseList.HasSelectedObject()) { await UIPlatform.ShowMessageAsync("Cannot choose cards from both from hand and from defense piles"); return; } bool fromHand; DeckRegularDict <RegularSimpleCard> tempDefenseList; if (_mainGame.SingleInfo.MainHandList.HasSelectedObject()) { fromHand = true; tempDefenseList = _mainGame.SingleInfo.MainHandList.GetSelectedItems(); } else { fromHand = false; tempDefenseList = _mainGame.SingleInfo.DefenseList.GetSelectedItems(); if (tempDefenseList.Any(items => items.Color == EnumColorList.Red)) { throw new BasicBlankException("No red attack cards should have even been put to defense pile"); } } if (await _mainGame.CanPlayDefenseCardsAsync(tempDefenseList) == false) { return; } if (_model.MainDefense1 !.CanAddDefenseCards(tempDefenseList) == false) { await UIPlatform.ShowMessageAsync("This defense is not enough to prevent a goal from the attacker"); return; } if (_mainGame.BasicData !.MultiPlayer == true) { var deckList = tempDefenseList.GetDeckListFromObjectList(); if (fromHand == true) { await _mainGame.Network !.SendAllAsync("defensehand", deckList); } else { await _mainGame.Network !.SendAllAsync("defenseboard", deckList); } } tempDefenseList.UnselectAllObjects(); await _mainGame.PlayDefenseCardsAsync(tempDefenseList, fromHand); }
protected override async Task ProcessDiscardClickedAsync() { var thisList = _model.PlayerHand1 !.ListSelectedObjects(); if (thisList.Count != 2) { await UIPlatform.ShowMessageAsync("Must select 2 cards to throw away"); return; } if (_mainGame !.IsValidMove(thisList) == false) { await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (_mainGame.BasicData !.MultiPlayer == true) { SendPair thisPair = new SendPair(); thisPair.Card1 = thisList.First().Deck; thisPair.Card2 = thisList.Last().Deck; await _mainGame.Network !.SendAllAsync("processplay", thisPair); } await _mainGame.ProcessPlayAsync(thisList.First().Deck, thisList.Last().Deck); }
public async Task PlayCardAsync() { int decks = _model.PlayerHand1.ObjectSelected(); if (decks == 0) { await UIPlatform.ShowMessageAsync("Must choose a card to play"); return; } var thisCard = _mainGame.SingleInfo !.MainHandList.GetSpecificItem(decks); if (_mainGame.CanPlayCard(thisCard) == false) { await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (_mainGame.BasicData !.MultiPlayer) { await _mainGame.Network !.SendAllAsync("playcard", decks); } CommandContainer !.ManuelFinish = true; await _mainGame.PlayCardAsync(thisCard); }
public async Task AddToReserveAsync() { if (GlobalClass.MainModel !.ReservePiles1 !.HowManyCards >= 8) { await UIPlatform.ShowMessageAsync("There can only be 8 cards to reserve. Therefore, cannot add any more cards to reserve"); return; } if (GlobalClass.MainModel.ReservePiles1.ObjectSelected() > 0) { await UIPlatform.ShowMessageAsync("There is already a card selected. Unselect the card first before adding a card to reserve"); return; } if (_thisMod !.WastePiles1 !.OneSelected() == -1) { await UIPlatform.ShowMessageAsync("There is no card selected to add to reserve"); return; } var thisCard = _thisMod.WastePiles1.GetCard(); GlobalClass.MainModel !.ReservePiles1.AddCard(thisCard); _thisMod.WastePiles1.RemoveSingleCard(); }
public override async Task SubmitAsync() { if (_model.Keeper1 !.HowManySelectedObjects > 0) { await UIPlatform.ShowMessageAsync("Cannot select any keeper cards because you have to give the cards from your hand"); _model.UnselectAllCards(); return; } if (_model.Goal1 !.ObjectSelected() > 0) { await UIPlatform.ShowMessageAsync("Cannot select any goal cards because you have to give the cards from your hand"); _model.UnselectAllCards(); return; } int howMany = _gameContainer.IncreaseAmount() + 1; if (_model.PlayerHand1 !.HowManySelectedObjects == howMany || _model.PlayerHand1.HowManySelectedObjects == _model.PlayerHand1.HandList.Count) { var thisList = _model.PlayerHand1.ListSelectedObjects(true); await _processes.GiveCardsForTaxationAsync(thisList); return; } if (howMany > _model.PlayerHand1.HandList.Count) { howMany = _model.PlayerHand1.HandList.Count; } await UIPlatform.ShowMessageAsync($"Must give {howMany} not {_model.PlayerHand1.HowManySelectedObjects} cards"); _model.UnselectAllCards(); }
public async Task FreeSelectedAsync(int pile) { if (_thisMod !.WastePiles1 !.OneSelected() == -1) { if (_freepile !.OneSelected == pile) { _freepile.SelectUnselectCard(pile); return; } if (_freepile.OneSelected > -1) { await UIPlatform.ShowMessageAsync("Illegal move"); return; } if (_freepile.HasCard(pile) == false) { await UIPlatform.ShowMessageAsync("Illegal move"); return; } _freepile.SelectUnselectCard(pile); return; } if (_freepile !.HasCard(pile)) { await UIPlatform.ShowMessageAsync("Illegal move"); return; } var thisCard = _thisMod.WastePiles1.GetCard(); _freepile.AddCardToPile(pile, thisCard); _thisMod.WastePiles1.RemoveSingleCard(); }
async Task ISayUnoProcesses.ProcessUnoAsync(bool saiduno) { _gameContainer.AlreadyUno = true; if (_gameContainer.SingleInfo !.CanSendMessage(_gameContainer.BasicData !) == true) { await _gameContainer.Network !.SendAllAsync("uno", saiduno); } if (saiduno == false) { if (_gameContainer.SingleInfo !.PlayerCategory == EnumPlayerCategory.Self) { await UIPlatform.ShowMessageAsync("You had one card left. However, you did not say uno. Therefore, you have to draw 2 cards"); } _gameContainer.LeftToDraw = 2; await _gameContainer.DrawAsync !.Invoke(); return; } if (_gameContainer.SingleInfo !.PlayerCategory != EnumPlayerCategory.Self) { await UIPlatform.ShowMessageAsync($"Uno From {_gameContainer.SingleInfo.NickName}"); } if (_gameContainer.DoFinishAsync == null) { throw new BasicBlankException("Nobody is handling the dofinishasync. Rethink"); } if (_gameContainer.CloseSaidUnoAsync == null) { throw new BasicBlankException("Nobody is closing uno screen. Rethink"); } await _gameContainer.CloseSaidUnoAsync.Invoke(); await _gameContainer.DoFinishAsync.Invoke(); }
private async Task DiscardPiles_PileClickedAsync(int index, BasicPileInfo <FlinchCardInformation> thisPile) { int playerDeck = _model !.PlayerHand1 !.ObjectSelected(); if (playerDeck > 0) { if (_mainGame !.SaveRoot !.GameStatus == EnumStatusList.FirstOne && _mainGame.SaveRoot.PlayerFound == 0) { await UIPlatform.ShowMessageAsync("Sorry; cannot discard one because you need either a one or else pass on this turn"); _mainGame.UnselectAllCards(); return; } if (_model.DiscardPiles !.CanAddToDiscardFlinch(index) == false) { await UIPlatform.ShowMessageAsync("Sorry, cannot discard here because there is an empty one that has to be used first"); return; } await _mainGame !.AddToDiscardAsync(index, playerDeck); return; } if (_model.DiscardPiles !.HasCard(index) == false) { return; } if (_model.DiscardPiles.PileList ![index].IsSelected == true)
private async Task MoveRoomAsync(int room) { if (_gameBoard.CanMoveToRoom(room) == false) { if (_basicData.IsXamarinForms) { return; } await UIPlatform.ShowMessageAsync("Illegal Move"); return; } if (_mainGame !.SaveRoot !.GameStatus == EnumClueStatusList.MoveSpaces && _gameContainer.CurrentCharacter !.PreviousRoom > 0) { if (_basicData.IsXamarinForms) { return; } await UIPlatform.ShowMessageAsync("Sorry, since you rolled, you cannot go into a room"); return; } if (_gameContainer.BasicData !.MultiPlayer) { await _gameContainer.Network !.SendAllAsync("room", room); } _gameContainer.SaveRoot.MovesLeft = 0; _gameBoard.MoveToRoom(room); _gameContainer.SaveRoot.GameStatus = EnumClueStatusList.MakePrediction; //hopefully this is it. }
public async Task ShowInfoLastAsync() { if (_lastMovie == null) { throw new BasicBlankException("Cannot show last info because was nothing. Rethink"); } await UIPlatform.ShowMessageAsync($"The Last Movie You Need To Watch Was {_lastMovie.Title}"); }
public async Task ScoreDescriptionAsync() { if (ItemSelected == -1) { throw new BasicBlankException("Nothing Selected"); } var text = GetDescriptionText(); await UIPlatform.ShowMessageAsync(text); }
public async Task GiveUpAsync() { await UIPlatform.ShowMessageAsync("Sorry you are giving up"); await this.SendGameOverAsync(); //hopefully this works. //Aggregator.ShowSolution(); //does not care who responds to showing solution. //i propose a new view model for the solution part. }