#runtime "hsp3cl" #cmpopt varinit 1 ;トランプカードモジュール #module TrumpCard name,suit,power #modinit int _suit,int _power suitStrs="JO","▲","▼","◆","■" powerStrs="KR","A","2","3","4","5","6","7","8","9","10","J","Q","K" name=suitStrs(_suit)+powerStrs(_power) power=_power suit=_suit return #modcfunc tcName return name #modcfunc tcPower return power #modcfunc tcSuit return suit #global ;トランプの束モジュール #module Trump co,i,deck,countMax,hash #define new(%1) dimtype %1,5:newmod %1,Trump #modinit randomize #define deckDefine \ suits= \ 1,1,1,1,1, 1,1,1,1,1, 1,1,1, \ 2,2,2,2,2, 2,2,2,2,2, 2,2,2, \ 3,3,3,3,3, 3,3,3,3,3, 3,3,3, \ 4,4,4,4,4, 4,4,4,4,4, 4,4,4, \ 0,0 :\ powers= \ 1,2,3,4,5, 6,7,8,9,10, 11,12,13, \ 1,2,3,4,5, 6,7,8,9,10, 11,12,13, \ 1,2,3,4,5, 6,7,8,9,10, 11,12,13, \ 1,2,3,4,5, 6,7,8,9,10, 11,12,13, \ 0,0 deckDefine foreach suits newmod deck,TrumpCard,suits(cnt),powers(cnt) loop foreach deck hash(cnt)=cnt loop count=length(deck) repeat count r=rnd(count) tmp=hash(cnt) hash(cnt)=hash(r) hash(r)=tmp loop gosub*trumpIter return *trumpIter for i,0,length(suits) newlab co,1:return _card=deck(hash(i)) next return #modcfunc trpCount return count #modfunc local trpNext var card gosub co card=_card return #define global trpNext(%1,%2) dimtype %2,5:trpNext@Trump %1,%2 #global ;プレイヤーモジュール #module Player deck,deckNo,pass #define new(%1) newmod %1,Player #modinit deckNo=0 pass=3 return #modfunc plSetCard var card deck(deckNo)=card deckNo++ return #modfunc plDeleteCard str cardName foreach deck if tcName(deck.cnt)=cardName { delID=cnt repeat deckNo-delID-1 deck(delID+cnt)=deck(delID+cnt+1) loop deckNo-- break } loop return #modfunc plDeck array _deck if deckNo!=0 { dimtype _deck,5,deckNo repeat deckNo _deck(cnt)=deck(cnt) loop } else { dim _deck } return #global ;トランプの場モジュール #module TrumpBoard board,cardCnt #define new(%1) dimtype %1,5:newmod %1,TrumpBoard #modfunc tbUseCard var _player,var card board(cardCnt)=card plDeleteCard _player,tcName(card) cardCnt++ return #modfunc tbViewBoard foreach board mes tcName(board.cnt)+" ",1 loop return #global ;メイン処理 #module Program #uselib "crtdll" #cfunc getch "_getch" #cfunc kbhit "_kbhit" ;カーソルの移動 #defcfunc move int _ch,int max if _ch=$4b :cursol-- ;左 if _ch=$4d :cursol++ ;右 if cursol<0 :cursol=0 if max-1<cursol :cursol=max-1 return cursol ;カーソルの表示 #deffunc cursolShow array items,int csl dim slct,length(items) slct(csl)=1 s="" foreach items if slct(cnt): s+=strf("[%s]",items(cnt)): else: s+=strf(" %s ",items(cnt)) loop mes strf("%s\r",s),1 return #deffunc main new@Trump trp new@TrumpBoard board dimtype p,5,4 repeat 4 new@Player p loop repeat trpCount(trp) trpNext trp,card plSetCard p(cnt\4),card loop dimtype deck,5 *selectLoop foreach p plDeck p(cnt),deck if vartype(deck)!=5: goto*exitSelect mes "【Player "+(cnt+1)+"】" sdim items foreach deck items(cnt)=tcName(deck.cnt) loop cursol=0 cursolShow items,cursol repeat if kbhit() { ch=getch() if ch=$0d { mes "" break } if ch=$e0 { cursolShow items,move(getch(),length(items)) } } loop mes strf("SelectedItem: %s",items(cursol)) tbUseCard board,p(cnt),deck(cursol) mes "" loop goto*selectLoop *exitSelect mes "【USED CARDS】" tbViewBoard board return #global main