| Body |
cobaltvector
 Dungeonkeeper
3/27/2010 11:16:34 PM
PostID: 346939
|
I've created a series of iscript functions that will allow people to draw from a deck of 54 cards (52 + 2 Jokers). The deck keeps track of the cards dealt by putting their values into the table. The results are displayed graphically, but you can also mouse over each card to get a text display.
To use these functions you will first need to create a Card Table. This prevents the sharing of decks.
To do this simply create a table with two columns. Name the first column "Cards" and the second column "Used?". Leave out the quotes when naming your columns.
Next, simply run the following function; you can even just post the iscript in the same board as the table you created: (1094.Create_Deck table_XXX) Where XXX is the topic ID of the Table thread you created.
With your deck created, you can now use the 1094.Draw_Cards and 1094.Shuffle functions.
1094.Draw_Cards takes 2 parameters the first is the number of cards drawn, the second is the table ID of your Card Table. The maximum number of cards that can be drawn has been limited to 8.
Example:
<iscript>(1094.Draw_Cards 3 table_31338)</iscript>
Results in:
The Deck will automatically reshuffle (reinitialize) when it's out of cards, but you can also shuffle the deck manually by using the (1094.Shuffle) function. This function only takes one parameter, the table ID of the deck to be shuffled.
Example:
<iscript>(1094.Shuffle table_31338)</iscript>
Results in:
Shuffled!
Through a little modification these Iscript functions can be modified to suit other purposes. For instance, it could be used to draw "Magic the Gathering" cards or display a graphic for die rolls. I'm curious to see if anyone comes up with a clever modification.
The code is probably not completely optimized, so if anyone has any suggestions for improvement I'll gladly take them. The functions used are all shared, so the code should be visible to all who browse.
The functions used are (Create_Deck) (Draw_Card) (Card_Track) (Get_Card) (Redraw) (Shuffle) -- Nothing easy is ever simple.
This post last edited on 3/28/2010 6:57:38 PM
|
cobaltvector
 Dungeonkeeper
3/27/2010 11:21:01 PM
PostID: 346940
|
You can experiment with the functions without actually creating a table by simply putting in table_31338 as the table ID#. -- Nothing easy is ever simple.
|
AlchemicFox
 Monsterkeeper
3/27/2010 11:32:52 PM
PostID: 346944
|
hmm.... keep getting this when attempting to create a deck.
Script Error! Integrity.IScript.IScriptException: Data Error: You do not have viewing permissions for table table_31280 Source: ((TableRow table_31280 #row)) at Integrity.IScript.IScriptParser.DoParse(String str, Object context, Scope s) at Integrity.IScript.IScriptParser.Parse(String str, Object context, Scope s) Currently holding the rank of "Dooly appointed Federal Mahshall"
This post last edited on 3/27/2010 11:33:14 PM
|
cobaltvector
 Dungeonkeeper
3/28/2010 11:49:17 AM
PostID: 347001
|
That's simple to fix. I just have to change the viewing permission for the master deck. I was wondering if that would be necessary but I couldn't test it unless I setup another RPM account for myself. Discovering the that permissions are looked at during the iscript is a good thing, since it means that a GM can setup decks that can't be tampered with.
I opened up the viewing permissions for that thread so it should work now. -- Nothing easy is ever simple.
|
cobaltvector
 Dungeonkeeper
3/28/2010 11:54:43 AM
PostID: 347002
|
You should get something like this as a result of running the Create_Deck function:
(8dcd785d-563d-4dfc-8a5f-7dc5271ea5c2 94e3a9d9-9c14-4ce2-855f-2381939456e8 f55d49e8-8014-4448-88cb-be0ec4aa997f c88163a2-c0a1-43e9-b7db-326c53e83aae 2f8f40da-d301-48bb-bfdc-368167e713ec 802d8cde-0688-4c40-8c60-2867d7c081aa 3f6e9953-e22d-40c7-9daa-499eec65c0df 7d2ca8b4-2c6b-44b0-b82a-ca8cc3d889dc a31893b1-19ad-4bac-a48c-59fa86fa03e9 da84bfe5-5ef4-482b-8d34-98f77926af18 30d86035-aa52-476f-89a5-8d880cd2cf13 073c403d-5ace-4c6d-a578-602c6d36eea4 13e49e95-e39c-48be-b26d-2f2dd7ef56c2 c2273e99-2290-4bdd-bec4-f8f07a4dab1a 84e97c13-af05-4013-8b6e-29aa1c432b2a 95f16fa1-eb5e-425c-8e5d-ea52ee7d141d 11a50ce3-6ce6-4fae-8c20-4c52def51d77 23d6c6c0-3ac3-4e56-9ef2-ea7ab215dee7 af37c78e-603c-4dc9-ab17-f55c84088dce fa5279d7-754a-474d-a410-00b5a8ebea92 8810642a-2992-405b-aed2-df914a889a63 8c79940e-fbd6-4cfc-953f-19b4e06ef235 c9105ddd-c2ae-429b-90d2-c4fe0e29827c 53ca007b-d1d5-40b8-bd6b-527c2849509d 21d8c50a-e8a8-4ecf-a7a7-3a3944e557b2 f9f6b228-1103-45d3-a3d9-2c517cfa088e 1d8a4b55-b378-4672-9beb-94a521e95bd1 5e94d78b-4c9e-482c-80a2-a4de72e16c60 b502ae28-d9a5-4db4-a325-cf9b9d77032c b742929d-6d93-4915-ab5e-13c034cf1c3e 69a96c62-52c7-450e-ac88-6915271edf17 5330762f-f73c-4437-b59c-4935feb2e554 b6e16f21-7998-42dc-9e0c-6764cb7fe1f1 1c71cbbe-a3bd-4ce4-92f6-d7b3d80dfa9a 5589d32f-e63f-4432-8578-0081ea7f8b08 10b6d99d-1562-4574-acc4-5b7596a7013a 5e037d0c-aaa2-4620-b93f-36f6c4177ba0 0e2b56f2-eb1c-4885-bc6f-93346f5846ab 422d1c1b-3a78-4227-b959-60c2c5e34dcb 8399ea5e-fbaf-4f55-ac3a-a8ff4ce17d3a 4c38046d-b55c-404e-a527-6df953f9ea53 d7e2adca-ea76-49a4-bc5e-ad29331f67e2 0c6c2153-f972-4731-982c-5941d3f6e1f9 c5e99f65-8c17-4d32-96fe-204257db05a5 9fce5218-6d27-4b7f-ba72-d92ed95c8ae7 b282194e-3a8e-435f-9ffb-bd14643e2bbd f1c35d21-a59b-4fda-a448-0ceacb21f086 f859b912-ed70-453c-b33f-1a06aa3d8a86 6fc5f640-08eb-4312-8b78-6cf1d5d26e9d c923ae44-8d2b-4903-bab2-60d9eaf62429 c4e79016-b7aa-495c-9134-79624c609a2f 529ba2de-594a-4ff3-90c3-91b5b9f7a252 028b57b8-a797-4aa5-a2a8-51abe055dbea 30d045ab-d095-49fa-9bbb-eb03996d67f6 e70b17f5-cb32-43a1-8543-eb314bcab6f5)
Afterwords the Card Table should be filled. You may need to refresh the page that your Card Table is on to view the completed deck, especially if you run this script in a thread other than your Card Table.
-- Nothing easy is ever simple.
This post last edited on 3/28/2010 11:58:02 AM
|
AlchemicFox
 Monsterkeeper
3/28/2010 1:16:35 PM
PostID: 347017
|
When trying to access the Table I made last night I get
Index was outside the bounds of the array. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.
Source Error:
Line 198: Line 199: Line 200: <%# RPGUtility.ResolveSmartTags(ctype(container.dataitem, DataRowView)("Body"), dr, ctype(page, BasePage).cuser, ctype(container.dataitem, DataRowView)("UserID")) %> Line 201: <%# PostEdit(container.dataitem) %> Line 202:
Source File: d:\hshome\bobthj\roleplaymarket.com\controls\thread.ascx Line: 200
Stack Trace:
[IndexOutOfRangeException: Index was outside the bounds of the array.] Integrity.RolePlayMarket.RPGUtility.ResolveTag(String tag, String contents) +1872 Integrity.RolePlayMarket.RPGUtility.QualifyTag(String tag, String text) +713 Integrity.RolePlayMarket.RPGUtility.ResolveSmartTags(String text, Object context, WebBaseUser cuser, Int32 pstr) +290 ASP.Thread.__DataBind__control8(Object sender, EventArgs e) in d:\hshome\bobthj\roleplaymarket.com\controls\thread.ascx:200 System.Web.UI.Control.OnDataBinding(EventArgs e) +66 System.Web.UI.Control.DataBind() +26 System.Web.UI.Control.DataBind() +86 System.Web.UI.Control.DataBind() +86 System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex, Int32 dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem, DataGridColumn[] columns, TableRowCollection rows, PagedDataSource pagedDataSource) +169 System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean useDataSource) +1403 System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +48 System.Web.UI.WebControls.BaseDataList.DataBind() +23 Integrity.WebControls.PowerGrid.DataBind() +6202 System.Web.UI.Control.DataBind() +86 ASP.Thread.Page_Load() in d:\hshome\bobthj\roleplaymarket.com\controls\thread.ascx:62 System.Web.Util.ArglessEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +10 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Page.ProcessRequestMain() +750
When I make a new table and run the iscript Create_Deck, I get
Index was outside the bounds of the array. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.
Source Error:
Line 120: util.ctxt = dr Line 121: dim body1 as String = util.QualifyTag("roll", body.text) Line 122: body1 = util.QualifyTag("iscript", body1) Line 123: body1 = util.QualifyTag("gen", body1) Line 124: dh.AddParameter("UserID", cuser.userID)
Source File: d:\hshome\bobthj\roleplaymarket.com\controls\thread.ascx Line: 122
Stack Trace:
[IndexOutOfRangeException: Index was outside the bounds of the array.] Integrity.RolePlayMarket.RPGUtility.ResolveTag(String tag, String contents) +1872 Integrity.RolePlayMarket.RPGUtility.QualifyTag(String tag, String text) +713 ASP.Thread.NewPost(Object sender, EventArgs e) in d:\hshome\bobthj\roleplaymarket.com\controls\thread.ascx:122 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1292
Is this just me? Currently holding the rank of "Dooly appointed Federal Mahshall"
|
Jeeeeoker
 Haggler
3/28/2010 3:33:12 PM
PostID: 347029
|
So, when this is worked out, who's up for poker?
|
cobaltvector
 Dungeonkeeper
3/28/2010 7:04:06 PM
PostID: 347056
|
*slaps head*
The Create_Table function needs your table ID as a parameter to operate. I neglected to add this fact to the above post.
Try this: (Create_Deck table_XXX) Where XXX is the id# of the table topic.
Post edited above.
Example:
<iscript>(1094.Create_Deck table_31356)</iscript> The table should end up looking like this: Created Card Table
-- Nothing easy is ever simple.
This post last edited on 4/12/2011 12:38:02 AM
|
AlchemicFox
 Monsterkeeper
3/28/2010 9:32:31 PM
PostID: 347087
|
After checking out the iscript tutorials, that's what I thought it was, but I couldn't be sure. Seems to be working just fine now, thanks. Currently holding the rank of "Dooly appointed Federal Mahshall"
|
BobTHJ
 Owner of the Market
3/29/2010 11:27:03 AM
PostID: 347197
|
Thanks cobaltvector for this useful tool :)
|
AlchemicFox
 Monsterkeeper
3/29/2010 12:35:15 PM
PostID: 347214
|
If one wanted to remove the jokers, will just deleting them off the table work, or would that mess with the script? Currently holding the rank of "Dooly appointed Federal Mahshall"
|
cobaltvector
 Dungeonkeeper
3/30/2010 12:35:39 AM
PostID: 347411
|
Deleting card of the deck would just result in a nil value being returned instead of the card.
However, I've recently modified the code to allow for smaller deck size. You can now enter a third optional parameter that will limit the size of the deck. For instance, if you want to have no Jokers in the deck for a game of "5-card Stud" you would simply use.
(Draw_Cards 5 table_XXXX 52) Where "XXX" is the tableID#
This will remove the last 2 cards from the deck, which happen to be Jokers.
I've kept 54 the default for the third parameter, so if you want both Jokers still in you don't have add anything extra.
Unless there is a demand for it, I'll keep the max deck size at 54. -- Nothing easy is ever simple.
|
AlchemicFox
 Monsterkeeper
3/30/2010 1:55:17 AM
PostID: 347415
|
But changing the cards themselves is as easy as changing the image and the alt text in the table, correct? Say I wanted to replace them with images and names of tarot cards, for instance.
Keeping maximum deck size in mind of course. Currently holding the rank of "Dooly appointed Federal Mahshall"
|
LordOmega
 Distinguished Socialite
3/30/2010 2:18:15 AM
PostID: 347416
|
Could be a useful tool to add some flavor to a game.
The Deck of Many Hands and other magical card items -or- That game of strip poker with your character and some college girls. "10% Luck, 20% Skill, 15% Concentrated Power of Will, 5% Pleasure, 50% Pain. And 100% Reason to Remember the Name."
|
cobaltvector
 Dungeonkeeper
3/30/2010 1:30:37 PM
PostID: 347519
|
The script doesn't care what the card images are, you can replace that with whatever you like.
Even your Pokemon cards, if your the kind of person that's into forcing wildlife to fight for your own personal amusement. What are they teaching kids? -- Nothing easy is ever simple.
|
Jeeeeoker
 Haggler
3/30/2010 5:17:09 PM
PostID: 347557
|
hmm... with enough modifications, one could play Magic the Gathering, using a separate table for each player so they can build their own decks.
Though if the table is just numbers, and somewhere those numbers get attached to images, then it's the image mapping the player would need to store in their sheets...
And you'd need some way of tracking what cards are available to a player so they don't cheat and start duplicating powerful cards.
|
cobaltvector
 Dungeonkeeper
3/30/2010 8:03:56 PM
PostID: 347593
|
As far as cheating, that's preventable if you can get an unbiased third party to store the decks for you. The third party would have to check to see if the cards were actually used each turn, to make certain that someone wasn't drawing from a second deck, but that's actually something that easily done since the function transfers the card "image" into the Used? column of the Deck Table. The "Ref" could simply check the Table each turn to verify that the cards were actually drawn.
You'd need 3 to 4 more columns to the Table. One that stores cards that are in your hand, one that stores what is on the table, one that keeps track of what is actually in the graveyard. You can simply create a function that adds a tapped symbol after the card in the "Table" column to designate that it's tapped or not. A more ambitious attempt would be to create a column that held the image of the tapped card. The function would simply overwrite the tapped image onto your "Table" column as long as there was an image of that card already in present in that column already. You'd also need a function that did the reverse (You could write that ability into the same function; it just adds to the complexity).
Each new column of information would need a new function, fortunately these don't need to interfere with the card drawing function. They would be pretty small as well, simply checking to see if the selected card has been drawn and then modifying the Hand, Table, or Graveyard columns. You'd also need a function that would clean out everything once the game is over.
There might be a simpler way to manage it, but with a card game like Magic you are talking about a lot more information to keep track of. -- Nothing easy is ever simple.
|
AlchemicFox
 Monsterkeeper
3/30/2010 11:02:53 PM
PostID: 347645
|
You just activated my trap card. Currently holding the rank of "Dooly appointed Federal Mahshall"
|
cobaltvector
 Dungeonkeeper
3/31/2010 10:56:47 AM
PostID: 347743
|
*In best Ackbar voice* It's a Trap!!!!! -- Nothing easy is ever simple.
|
cobaltvector
 Dungeonkeeper
4/11/2011 4:12:03 PM
PostID: 396608
|
Welcome To Class Real
|
| page of 2 pages containing 22 items.Items per page: |