c# - While the application is open -
i trying implement card game(similar bridge). there bunch of classes represent suit,player,cart,team,etc.
in each round each player throws 4 cards , once 13 cards each player’s hand thrown, can calculate points each team of 2 players collected.
i need tell main form somehow end (better term start new round ) when 52 cards thrown.
i trying implement following pseudo algorithm
while(not cards played) { continue game } calculate each player’s score according collect hand
not sure put while loop. not in form_load.
your question general, here primary reccommendation:
don't put business logic in view class. view should react via method calls/events changes in underlying state. unfortunately, easier in tech built around mvvm/mvc pattern (like wpf).
that being said, create "gamecontroller" class manages game state , holds rules such this. every time card played run through method like:
void checkroundend() { if (cardsplayed == 52) endround(); }
endround
raise event form listened to, or invoke appropriate methods on form reset view next round.
Comments
Post a Comment