The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need a more efficient function
Author Message
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #7
RE: I need a more efficient function
Right, I know what you mean now (considering how your script originally was). But after reading Shir's suggestion, sorting your cart types using numbers 1 - 52 that 'mess' of an array will be gone if you were to use TAGs, guaranteed. You can use a function to read your hand, shuffle the cards, let me think up a simple script quick:
Code:
[function f_poker_shuffle]
while !(<dlocal.y>==52)
local.x=<eval {1 52}>
if !(<local.x.<dlocal.x>>)
  if (<isempty <tag.poker.hand.shuffled>>)
   tag.poker.hand.shuffled=<local.x>
  else
   tag.poker.hand.shuffled=<tag.poker.hand.shuffled>,<local.x>
  endif
  local.y += 1
endif
endwhile

[function f_poker_pass_card]
//argn1 = cards
//argn2 = uid of game host
if (<argn1>)
for x 1 <argn1>
  if (<isempty <tag.poker.hand>>)
   tag.poker.hand=<uid.<argn2>.f_poker_retrieve_card <uid.<argn2>.tag0.poker.hand.shuffled>>
  else
   tag.poker.hand=<tag.poker.hand>,<uid.<argn2>.f_poker_retrieve_card <uid.<argn2>.tag0.poker.hand.shuffled>>
  endif
endfor
endif

[function f_poker_retrieve_card]
if (<tag0.poker.hand.shufffled>)
tag.poker.hand.shuffled=
for x 1 <eval <args> +-1> //eliminate the first card from the array, restore the tag.
  if(<isempty <tag.poker.hand.shuffled>>)
   tag.poker.hand.shuffled=<argv[<local.x>]>
  else
   tag.poker.hand.shuffled=<tag.poker.hand.shuffled>,<argv[<local.x>]>
  endif
endfor
return <argv[0]> //the first card in the array (after shuffling)
else
return '' //no tag, no return
endif

So if you were to sort your card names by 1 - 52 in a defname, as an example you can retrieve the card name by number like
Code:
<serv.def.Poker_Card<card #1-52>_Name
<serv.def.Poker_Card<card #1-52>_Name_Short

Cards are also sorted by suite, example Spades are more than Hearts are more than Clubs are more than Diamonds. So sorting it out in number you can simplify this by dividing your deck by 4 suites.
Code:
if (<card #> <= 52) && (<card #> >= <eval 52 - <eval 52 /4>>)
//spades
elseif (<card #> < <eval 52 - <eval 52 /4>>) && (<card #> >= <eval 52 - <eval <eval 52 /4> *2>>)
//hearts
elseif (<card #> < <eval 52 - <eval <eval 52 /4> *2>) && (<card #> >= <eval 52 - <eval <eval 52 /4> *3>>)
//clubs
else
//diamonds
endif

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
(This post was last modified: 07-11-2012 09:32 AM by Skul.)
07-11-2012 09:26 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Messages In This Thread
RE: I need a more efficient function - Skul - 07-11-2012 09:26 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)