Robson » Code Viewer
- Path: code/dealcard.txt
- Lines: 44
- Size: 1.34kB
// deals a random card to the player// written to be used from a player wandvoid main(){ // handle to the player object oPC = GetPCSpeaker(); // variable for storing the card name string sCard; // select the rank of the card switch (Random(13)) { // start at two, ace is always highest case 0: sCard = "Two"; break; case 1: sCard = "Three"; break; case 2: sCard = "Four"; break; case 3: sCard = "Five"; break; case 4: sCard = "Six"; break; case 5: sCard = "Seven"; break; case 6: sCard = "Eight"; break; case 7: sCard = "Nine"; break; case 8: sCard = "Ten"; break; case 9: sCard = "Jack"; break; case 10: sCard = "Queen"; break; case 11: sCard = "King"; break; case 12: sCard = "Ace"; break; } // i.e. "ace of hearts" or "seven of diamonds" sCard += " of "; // select the suit of the card switch (Random(4)) { // suits always go in alphabetical order case 0: sCard += "Clubs"; break; case 1: sCard += "Diamonds"; break; case 2: sCard += "Hearts"; break; case 3: sCard += "Spades"; break; } // make the pc say what card they were given AssignCommand(oPC, SpeakString(GetName(oPC) + " was dealt the " + sCard + "."));}