- Where Developers Learn, Share, & Build Careers
I have followed the C # code and is it possible to convert an easy to javascript? I need this to run 100% of the browser.
As I understand that anangam does not exist and can be replaced with a string instead. In short, a class deck holds an array of witch cards, the class card has some properties, including ranks, symbols, etc. and also has a shuffle function.
I hope no one has to change all the code here, but how can I do this as an indicator.
Public Enum Suites {Club, Diamond, Heart, Spade}; Public class card {public suit suit; Public full value; Public string text; Public intercourse HCP; Public card () {} public card (suite_ suite, int-value, int_HCP, string_text) {suit = _suit; Value = _value; HCP = _HCP; Text = _text; }}; Public square deck {public card [] card = new card [52]; Public deck () {card [0] = new card (suit.pad, 14, 4, "A"); Card [1] = new card (suit.pad, 13, 3, "K"); Card [2] = new card (suit.pad, 12, 2, "Q"); Card [3] = New card (Suit Paid, 11, 1, "J"); Card [4] = New card (suit.pad, 10, 0, "T"); Card [5] = new card (suit.pad, 9, 0, "9"); Card [6] = new card (suit.pad, 8, 0, "8"); Card [7] = new card (suit.pad, 7, 0, "7"); Card [8] = new card (suit.pad, 6, 0, "6"); Card [9] = new card (suit.pad, 5, 0, "5"); Card [10] = new card (suit.pad, 4, 0, "4"); Card [11] = new card (suit.pad, 3, 0, "3"); Card [12] = new card (suit.pad, 2, 0, "2"); Card [13] = New card (suit.Hart, 14, 4, "A"); Card [14] = New card (suit.Hart, 13, 3, "K"); Card [15] = New card (suit.Hart, 12, 2, "Q"); Card [16] = New card (suit.Hart, 11, 1, "J"); Card [17] = New card (suit.Hart, 10, 0, "T"); Card [18] = New card (suit.Hart, 9, 0, "9"); Card [19] = new card (suit.hart, 8, 0, "8"); Card [20] = New card (suit.Hart, 7, 0, "7"); Card [21] = New card (suit.Hart, 6, 0, "6"); Card [22] = New card (suit.Hart, 5, 0, "5"); Card [23] = new card (suit.hart, 4, 0, "4"); Card [24] = New card (suit.Hart, 3, 0, "3"); Card [25] = new card (suit.hart, 2, 0, "2"); Card [26] = New card (suit.Dimond, 14, 4, "A"); Card [27] = New card (suit, demand, 13, 3, "K"); Card [28] = new card (suit diamond, 12, 2, "Q"); Card [29] = New card (suit. Demond, 11, 1, "J"); Card [30] = New card (suite. Demond, 10, 0, "T"); Card [31] = new card (suit diamond, 9, 0, "9"); Card [32] = New card (Suite Diamond, 8, 0, "8"); Card [33] = new card (suit diamond, 7, 0, "7"); Card [34] = new card (suit demand, 6, 0, "6"); Card [35] = new card (suit diamond, 5, 0, "5"); Card [36] = new card (suit demand, 4, 0, "4"); Card [37] = New card (suite. Demond, 3, 0, "3"); Card [38] = new card (suit demand, 2, 0, "2"); Card [3 9] = new card (suit.club, 14, 4, "A"); Card [40] = New card (suite.club, 13, 3, "K"); Card [41] = New card (suite.club, 12, 2, "Q"); Card [42] = New card (suite.club, 11, 1, "J"); Card [43] = new card (suite.club, 10, 0, "t"); Card [44] = new card (suit.clubs, 9, 0, "9"); Card [45] = new card (suite.club, 8, 0, "8"); Card [46] = new card (suite.club, 7, 0, "7"); Card [47] = New card (suite.club, 6, 0, "6"); Card [48] = New card (suite.club, 5, 0, "5"); Card [49] = new card (suite.club, 4, 0, "4"); Card [50] = new card (suit.club, 3, 0, "3"); Card [51] = New card (suite.club, 2, 0, "2"); } Public Zero Shuffle (Random R) {for (int n = card. Lang - 1; n> gt; 0) -n) {int k = r.Next (n + 1); Card temporary = card [n]; Card [n] = card [of]; Card [k] = temporary; }}};
Enums can be converted to hash : var suite = {Club: 0, Diamond: 1, Heart: 2, Spade: 4}; Dead is simple: Function card (suite, value, HCP, Lesson) {this.suit = suit; This.value = value; This HCP = HCP; This.text = text; } << Code> and deck also: function deck () {this.cards = [new card (suit.hart, 14, 4 "A"), new card (suit, heart, 13, 3 "of"), // ...]; } then add deck to resize : Deck.prototype.shuffle = function ( )) {This.cards.sort (function () {return 0.5 - Math.random ()}); };
Comments
Post a Comment