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
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #11
RE: I need a more efficient function
This is my concept of card create and higher rank check:

PHP Code:
[DEFNAME CARDS]
SYMBOL.1 A
SYMBOL.2 K
SYMBOL.3 Q
SYMBOL.4 J
SYMBOL.5 10
SYMBOL.6 9
SYMBOL.7 8
SYMBOL.8 7
SYMBOL.9 6
SYMBOL.10 5
SYMBOL.11 4
SYMBOL.12 3
SYMBOL.13 2

SUIT.1 s
SUIT.2 h
SUIT.3 d
SUIT.4 c

[FUNCTION CARDCREATE]
IF !<
dTAG.CARDS>
 
TAG.CARDS 1
ELSE
 
TAG.CARDS ++
ENDIF
LOCAL.SYMBOL <DEF.SYMBOL.<R1,13>>
LOCAL.SUIT <DEF.SUIT.<R1,4>>
TAG.CARD.<dTAG.CARDS> <dTAG.CARDS>,<QVAL <ISNUM <LOCAL.SYMBOL>>?<dLOCAL.SYMBOL>:<LOCAL.SYMBOL>><LOCAL.SUIT>,<QVAL <ISNUM <LOCAL.SYMBOL>>?<dLOCAL.SYMBOL>:<LOCAL.SYMBOL>>,<LOCAL.SUIT>
WHILE 
STRMATCH(*<GETARGVX 2,<TAG.CARD.<dTAG.CARDS>>>*,<TAG.MYCARDS>)
 
LOCAL.SYMBOL <DEF.SYMBOL.<R1,13>>
 
LOCAL.SUIT <DEF.SUIT.<R1,4>>
 
TAG.CARD.<dTAG.CARDS> <dTAG.CARDS>,<QVAL <ISNUM <LOCAL.SYMBOL>>?<dLOCAL.SYMBOL>:<LOCAL.SYMBOL>><LOCAL.SUIT>,<QVAL <ISNUM <LOCAL.SYMBOL>>?<dLOCAL.SYMBOL>:<LOCAL.SYMBOL>>,<LOCAL.SUIT>
ENDWHILE
IF <
ISEMPTY <TAG.MYCARDS>>
 
TAG.MYCARDS <GETARGVX 2,<TAG.CARD.<dTAG.CARDS>>>
ELSE
 
TAG.MYCARDS .= ,<GETARGVX 2,<TAG.CARD.<dTAG.CARDS>>>
ENDIF
SERV.@,,1 CARD ADDED <GETARGVX 2,<TAG.CARD.<dTAG.CARDS>>>
SERV.@,,1 MY DECK <TAG.MYCARDS>

[FUNCTION 
RESETCARDS]
TAG.CARDS
TAG
.MYCARDS
FOR 1 52
 TAG
.CARD.<dLOCAL._FOR>
ENDFOR
SYSMESSAGE @,,1 CARDS RESETED!
RETURN 
1

[FUNCTION CHECKCARD]
IF <
dARGV> != 2
 SYSMESSAGE 
@026,,1 You must type the cards number.
 
SYSMESSAGE @026,,1 Syntax: .CheckCard "CardNumber 1","CardNumber 2" without quotes
 SYSMESSAGE 
@026,,1 Example: .CheckCard 1,2 will check card 1 and 2
 
RETURN 0
ENDIF
SERV.@044,,<GETARGVX 2,<TAG.CARD.<ARGV[0]>>> <GETARGVX 2,<TAG.CARD.<ARGV[1]>>>
FOR 
1 4
 
IF STRMATCH(*<GETARGVX 4,<TAG.CARD.<ARGV[0]>>>*,<DEF.SUIT.<dLOCAL._FOR>>)
  
LOCAL.CARD.1.SUIT <dLOCAL._FOR>
 ENDIF
 IF 
STRMATCH(*<GETARGVX 4,<TAG.CARD.<ARGV[1]>>>*,<DEF.SUIT.<dLOCAL._FOR>>)
  
LOCAL.CARD.2.SUIT <dLOCAL._FOR>
 ENDIF
ENDFOR
FOR 
1 13
 LOCAL
.SYMBOL <GETARGVX 3,<TAG.CARD.<ARGV[0]>>>
 IF 
STRMATCH(*<QVAL <ISNUM <LOCAL.SYMBOL>>?<dLOCAL.SYMBOL>:<LOCAL.SYMBOL>>*,*<DEF.SYMBOL.<dLOCAL._FOR>>*)
  
LOCAL.CARD.1.SYMBOL <dLOCAL._FOR>
 ENDIF                                         
 
LOCAL.SYMBOL <GETARGVX 3,<TAG.CARD.<ARGV[1]>>>
 IF 
STRMATCH(*<QVAL <ISNUM <LOCAL.SYMBOL>>?<dLOCAL.SYMBOL>:<LOCAL.SYMBOL>>*,*<DEF.SYMBOL.<dLOCAL._FOR>>*)
  
LOCAL.CARD.2.SYMBOL <dLOCAL._FOR>
 ENDIF
ENDFOR
IF <
dLOCAL.CARD.1.SYMBOL> < <dLOCAL.CARD.2.SYMBOL>
 
SYSMESSAGE @035,,1 CARD 1 HIGHER
 
RETURN 
ELIF 
<dLOCAL.CARD.1.SYMBOL> > <dLOCAL.CARD.2.SYMBOL>
 
SYSMESSAGE @035,,1 CARD 2 HIGHER
 
RETURN 
ELIF 
<dLOCAL.CARD.1.SYMBOL> == <dLOCAL.CARD.2.SYMBOL>
 IF <
dLOCAL.CARD.1.SUIT> < <dLOCAL.CARD.2.SUIT>
  
SYSMESSAGE @035,,1 CARD 1 HIGHER
  
RETURN 
 ELIF 
<dLOCAL.CARD.1.SUIT> > <dLOCAL.CARD.2.SUIT>
  
SYSMESSAGE @035,,1 CARD 2 HIGHER
  
RETURN 
 
ELSE
  
SYSMESSAGE @026,,1 SAME CARD!
  RETURN 
0
 
ENDIF
ENDIF
RETURN 

I know one more efficient card create method using the full defnames like yours, RanXerox.
Creating cards just use .cardcreate
Checking cards, .checkcard "card number 1","card number 2" without quotes
To reset your deck, .resetcards

Testing, use 5 times .cardcreate
Use .checkcard [1-5],[1-5]

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
09-18-2012 12:06 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


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