There's been talk about scripting card games (here, a standard deck of 52 cards), and I think it would be nice to consolidate all functions we would need for all possible card games. This means reusable functions for games (not just limited to Poker).

Since there are two main types of games (suit taking games - easier to script), and hand winning games (pairs, two pairs, straights, etc - harder to script), here's what I propose for functions in order to build such games. Feel free to add / suggest better functions, with the idea that "using these functions will allow anyone to script any kind of card game - not just limited to poker / hearts"

1. A shuffle function

with **two inputs**. These inputs are two (variables) arrays, corresponding to

`SuitArray: 2 3 4 5 6 7 8 9 10 J K Q A 2 3 4 5 .... `

NumArray: C C C ... C D .. D S .. S H .. H

The function SHUFFLES these cards, and gives the shuffled output as two arrays:

`ShuffledSuitArray: ....`

ShuffledNumArray: ....

*The purpose of this function is to shuffle cards randomly. Scripts can be used to "divide" the shuffled cards up according to player.*

2. An "arrangement" function.

Takes two inputs SuitArray and NumArray (both must be of the same length, but not necessarily 52. These would correspond to cards in a 2 player game (26 each) 4 player game (13 each), poker (5 each), etc).

Gives four outputs, namely:

`ArrangedBySuitSuits: C C C D D `

ArrangedBySuitNums: 4 5 6 2 8

ArrangedByNumSuits: 2 4 5 6 8

ArrangedByNumNums: D C C C D

*The purpose of this function is to cater for different type of games, where arranging by numbers / arranging by suits would be more convenient.*

3. A "presentation" function for the above arrangement. Basically, the function takes in any of the above four inputs, and presents the cards to the players in a readable way. This will probably differ based on the type of game

Functions 4-12

With the above three functions, we can now customize our functions. For hand winning games, I suggest scripting the nine functions which correspond to the nine poker hands - Straight Flush, etc ... with the following four inputs - note that this function is NOT restricted to 5 elements in an array. Obviously with checks, eg, can't get a Flush if you had only 3 cards to compare, etc:

`FirstPlayerSuit H H H S S`

FirstPlayerNum 2 5 6 3 6

SecondPlayerSuit: D D D D D

SecondPlayerNum: 4 5 6 7 8

These functions would compare the hands of two players, and output a string with the player which has a higher hand. If neither player has a hand of that type, output null (or NA). Furthermore, make these 9 functions in running order - hopefully for some vnum xxx01 to xxx09 (for games which rely on placing a same poker hand, or one with higher value) - so if a person placed a hand of type 05, we can loop through for 06-09.

With the above 12 functions, we can script most games. For example, if we wanted to script a Poker Game, then we write a comparison function, eg below.

13. A comparison function. Given the arrays of X number of players, and an array PlayerName, eg:

`XerxesSuit H H H S S`

XerxesNum 2 5 6 3 6

TorSuit: D D D D D

TorNum: 4 5 6 7 8

ErwinSuit: C D H S C

ErwinNum: A 2 3 4 5

PlayerName: Xerxes Tor Erwin

run this function together with the previous 9 functions in order to see which player wins.

The logic would be: Run these functions from highest poker hand to lowest poker hand, until one poker hand is found. Compare with all other players to see who has the highest hand. Output the player name.

Any other functions do you think we need?