public int CardToPlay(CrazyEightsSaveInfo saveroot) { CrazyEightsPlayerItem player = saveroot.PlayerList.GetWhoPlayer(); DeckRegularDict <RegularSimpleCard> list = player.MainHandList.Where(x => x.Value != EnumCardValueList.Eight && x.Suit == saveroot.CurrentSuit).ToRegularDeckDict(); if (list.Count != 0) { return(list.GetRandomItem().Deck); } list = player.MainHandList.Where(x => x.Value != EnumCardValueList.Eight && x.Value == saveroot.CurrentNumber).ToRegularDeckDict(); if (list.Count == 1) { return(list.Single().Deck); } if (list.Count != 0) { return(FindBestCard(list)); } list = player.MainHandList.Where(x => x.Value == EnumCardValueList.Eight).ToRegularDeckDict(); if (list.Count != 0) { return(list.GetRandomItem().Deck); } return(0);//0 means needs to draw. }
Task IHandleAsync <LoadEventModel> .HandleAsync(LoadEventModel message) { GamePackageViewModelBinder.ManuelElements.Clear(); //often times i have to add manually. CrazyEightsSaveInfo save = cons !.Resolve <CrazyEightsSaveInfo>(); //usually needs this part for multiplayer games. _score !.LoadLists(save.PlayerList); _playerHandWPF !.LoadList(_model.PlayerHand1 !, ts.TagUsed); // i think _discardGPile !.Init(_model.Pile1 !, ts.TagUsed); // may have to be here (well see) _discardGPile.StartListeningDiscardPile(); // its the main one. _deckGPile !.Init(_model.Deck1 !, ts.TagUsed); // try here. may have to do something else as well (?) _deckGPile.StartListeningMainDeck(); return(this.RefreshBindingsAsync(_aggregator)); }