投稿されたすべてのコード

Visual Basic クラスが使えないときでもオブジェクト指向する

Const psnName=0
Const psnAge=1
Const psnHeight=2

Function NewPerson(name,age,height)
	Dim this(2)
	this(psnName)=name
	this(psnAge)=age
	this(psnHeight)=height
	NewPerson=this
End Function

Sub NewRefPerson(byRef this,name,age,height)
	ReDim this(2)
	this(psnName)=name
	this(psnAge)=age
	this(psnHeight)=height
End Sub

Sub printStat(this)
	WScript.Echo Join(Array( _
		"Name: ",this(psnName)," ", _
		"Age: ",this(psnAge)," ", _
		"Height: ",this(psnHeight) _
	),"")
End Sub

Dim bob
bob=NewPerson("Bob",23,168.2)
printStat bob

Dim kate
NewRefPerson kate,"Kate",14,145.6
printStat kate

TEXT 七並べプレイログ

/---------------------------------------/
/                 七並べ                /
/---------------------------------------/


◇◇◇◇◇◇▲◇◇◇◇◇◇
◇◇◇◇◇◇7◇◇◇◇◇◇
◇◇◇◇◇◇▼◇◇◇◇◇◇
◇◇◇◇◇◇7◇◇◇◇◇◇
◇◇◇◇◇◇◆◇◇◇◇◇◇
◇◇◇◇◇◇7◇◇◇◇◇◇
◇◇◇◇◇◇■◇◇◇◇◇◇
◇◇◇◇◇◇7◇◇◇◇◇◇

【Player】Cards: 13 Pass: 3
▲6[▲8]▲J▼2▼3▼4▼5▼8▼9▼J▼K◆J■6PS:3
◇◇◇◇◇◇▲▲◇◇◇◇◇
◇◇◇◇◇◇78◇◇◇◇◇
◇◇◇◇◇◇▼◇◇◇◇◇◇
◇◇◇◇◇◇7◇◇◇◇◇◇
◇◇◇◇◇◇◆◇◇◇◇◇◇
◇◇◇◇◇◇7◇◇◇◇◇◇
◇◇◇◇◇◇■◇◇◇◇◇◇
◇◇◇◇◇◇7◇◇◇◇◇◇

俺の切り札!! >「▲8」

【CPU 1】Cards: 12 Pass: 3
これでも食らいなっ >「◆8」

【CPU 2】Cards: 11 Pass: 3
これでも食らいなっ >「▲9」

【CPU 3】Cards: 12 Pass: 3
これでも食らいなっ >「■8」

◇◇◇◇◇◇▲▲▲◇◇◇◇
◇◇◇◇◇◇789◇◇◇◇
◇◇◇◇◇◇▼◇◇◇◇◇◇
◇◇◇◇◇◇7◇◇◇◇◇◇
◇◇◇◇◇◇◆◆◇◇◇◇◇
◇◇◇◇◇◇78◇◇◇◇◇
◇◇◇◇◇◇■■◇◇◇◇◇
◇◇◇◇◇◇78◇◇◇◇◇

【Player】Cards: 12 Pass: 3
▲6▲J▼2▼3▼4▼5[▼8]▼9▼J▼K◆J■6PS:3
◇◇◇◇◇◇▲▲▲◇◇◇◇
◇◇◇◇◇◇789◇◇◇◇
◇◇◇◇◇◇▼▼◇◇◇◇◇
◇◇◇◇◇◇78◇◇◇◇◇
◇◇◇◇◇◇◆◆◇◇◇◇◇
◇◇◇◇◇◇78◇◇◇◇◇
◇◇◇◇◇◇■■◇◇◇◇◇
◇◇◇◇◇◇78◇◇◇◇◇

俺の切り札!! >「▼8」

【CPU 1】Cards: 11 Pass: 3
これでも食らいなっ >「■9」

【CPU 2】Cards: 10 Pass: 3
これでも食らいなっ >「▲10」

【CPU 3】Cards: 11 Pass: 3
これでも食らいなっ >「▼6」

◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
◇◇◇◇◇▼▼▼◇◇◇◇◇
◇◇◇◇◇678◇◇◇◇◇
◇◇◇◇◇◇◆◆◇◇◇◇◇
◇◇◇◇◇◇78◇◇◇◇◇
◇◇◇◇◇◇■■■◇◇◇◇
◇◇◇◇◇◇789◇◇◇◇

【Player】Cards: 11 Pass: 3
▲6▲J▼2▼3▼4▼5[▼9]▼J▼K◆J■6PS:3
◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
◇◇◇◇◇▼▼▼▼◇◇◇◇
◇◇◇◇◇6789◇◇◇◇
◇◇◇◇◇◇◆◆◇◇◇◇◇
◇◇◇◇◇◇78◇◇◇◇◇
◇◇◇◇◇◇■■■◇◇◇◇
◇◇◇◇◇◇789◇◇◇◇

俺の切り札!! >「▼9」

【CPU 1】Cards: 10 Pass: 3
これでも食らいなっ >「◆9」

【CPU 2】Cards: 9 Pass: 3
これでも食らいなっ >「◆6」

【CPU 3】Cards: 10 Pass: 3
これでも食らいなっ >「■10」

◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
◇◇◇◇◇▼▼▼▼◇◇◇◇
◇◇◇◇◇6789◇◇◇◇
◇◇◇◇◇◆◆◆◆◇◇◇◇
◇◇◇◇◇6789◇◇◇◇
◇◇◇◇◇◇■■■■◇◇◇
◇◇◇◇◇◇78910◇◇◇

【Player】Cards: 10 Pass: 3
▲6▲J▼2▼3▼4[▼5]▼J▼K◆J■6PS:3
◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
◇◇◇◇▼▼▼▼▼◇◇◇◇
◇◇◇◇56789◇◇◇◇
◇◇◇◇◇◆◆◆◆◇◇◇◇
◇◇◇◇◇6789◇◇◇◇
◇◇◇◇◇◇■■■■◇◇◇
◇◇◇◇◇◇78910◇◇◇

俺の切り札!! >「▼5」

【CPU 1】Cards: 9 Pass: 3
パスー (残り2回)

【CPU 2】Cards: 8 Pass: 3
これでも食らいなっ >「◆5」

【CPU 3】Cards: 9 Pass: 3
これでも食らいなっ >「▼10」

◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
◇◇◇◇▼▼▼▼▼▼◇◇◇
◇◇◇◇5678910◇◇◇
◇◇◇◇◆◆◆◆◆◇◇◇◇
◇◇◇◇56789◇◇◇◇
◇◇◇◇◇◇■■■■◇◇◇
◇◇◇◇◇◇78910◇◇◇

【Player】Cards: 9 Pass: 3
▲6▲J▼2▼3[▼4]▼J▼K◆J■6PS:3
◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
◇◇◇▼▼▼▼▼▼▼◇◇◇
◇◇◇45678910◇◇◇
◇◇◇◇◆◆◆◆◆◇◇◇◇
◇◇◇◇56789◇◇◇◇
◇◇◇◇◇◇■■■■◇◇◇
◇◇◇◇◇◇78910◇◇◇

俺の切り札!! >「▼4」

【CPU 1】Cards: 9 Pass: 2
これでも食らいなっ >「◆10」

【CPU 2】Cards: 7 Pass: 3
これでも食らいなっ >「■J」

【CPU 3】Cards: 8 Pass: 3
これでも食らいなっ >「◆4」

◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
◇◇◇▼▼▼▼▼▼▼◇◇◇
◇◇◇45678910◇◇◇
◇◇◇◆◆◆◆◆◆◆◇◇◇
◇◇◇45678910◇◇◇
◇◇◇◇◇◇■■■■■◇◇
◇◇◇◇◇◇78910J◇◇

【Player】Cards: 8 Pass: 3
▲6▲J▼2[▼3]▼J▼K◆J■6PS:3
◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
◇◇▼▼▼▼▼▼▼▼◇◇◇
◇◇345678910◇◇◇
◇◇◇◆◆◆◆◆◆◆◇◇◇
◇◇◇45678910◇◇◇
◇◇◇◇◇◇■■■■■◇◇
◇◇◇◇◇◇78910J◇◇

俺の切り札!! >「▼3」

【CPU 1】Cards: 8 Pass: 2
これでも食らいなっ >「◆3」

【CPU 2】Cards: 6 Pass: 3
パスー (残り2回)

【CPU 3】Cards: 7 Pass: 3
パスー (残り2回)

◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
◇◇▼▼▼▼▼▼▼▼◇◇◇
◇◇345678910◇◇◇
◇◇◆◆◆◆◆◆◆◆◇◇◇
◇◇345678910◇◇◇
◇◇◇◇◇◇■■■■■◇◇
◇◇◇◇◇◇78910J◇◇

【Player】Cards: 7 Pass: 3
▲6▲J[▼2]▼J▼K◆J■6PS:3
◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
◇▼▼▼▼▼▼▼▼▼◇◇◇
◇2345678910◇◇◇
◇◇◆◆◆◆◆◆◆◆◇◇◇
◇◇345678910◇◇◇
◇◇◇◇◇◇■■■■■◇◇
◇◇◇◇◇◇78910J◇◇

俺の切り札!! >「▼2」

【CPU 1】Cards: 7 Pass: 2
これでも食らいなっ >「▼A」

【CPU 2】Cards: 6 Pass: 2
パスー (残り1回)

【CPU 3】Cards: 7 Pass: 2
パスー (残り1回)

◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
▼▼▼▼▼▼▼▼▼▼◇◇◇
A2345678910◇◇◇
◇◇◆◆◆◆◆◆◆◆◇◇◇
◇◇345678910◇◇◇
◇◇◇◇◇◇■■■■■◇◇
◇◇◇◇◇◇78910J◇◇

【Player】Cards: 6 Pass: 3
▲6▲J[▼J]▼K◆J■6PS:3
◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
▼▼▼▼▼▼▼▼▼▼▼◇◇
A2345678910J◇◇
◇◇◆◆◆◆◆◆◆◆◇◇◇
◇◇345678910◇◇◇
◇◇◇◇◇◇■■■■■◇◇
◇◇◇◇◇◇78910J◇◇

俺の切り札!! >「▼J」

【CPU 1】Cards: 6 Pass: 2
これでも食らいなっ >「■Q」

【CPU 2】Cards: 6 Pass: 1
これでも食らいなっ >「■K」

【CPU 3】Cards: 7 Pass: 1
パスー (残り0回)

◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
▼▼▼▼▼▼▼▼▼▼▼◇◇
A2345678910J◇◇
◇◇◆◆◆◆◆◆◆◆◇◇◇
◇◇345678910◇◇◇
◇◇◇◇◇◇■■■■■■■
◇◇◇◇◇◇78910JQK

【Player】Cards: 5 Pass: 3
▲6▲J▼K◆J■6[PS:3]
◇◇◇◇◇◇▲▲▲▲◇◇◇
◇◇◇◇◇◇78910◇◇◇
▼▼▼▼▼▼▼▼▼▼▼◇◇
A2345678910J◇◇
◇◇◆◆◆◆◆◆◆◆◇◇◇
◇◇345678910◇◇◇
◇◇◇◇◇◇■■■■■■■
◇◇◇◇◇◇78910JQK

残りパスは2回です。

【CPU 1】Cards: 5 Pass: 2
これでも食らいなっ >「◆2」

【CPU 2】Cards: 5 Pass: 1
これでも食らいなっ >「◆A」

▲▲▲◇◇◇▲▲▲▲◇◇▲
A23◇◇◇78910◇◇K
▼▼▼▼▼▼▼▼▼▼▼◇◇
A2345678910J◇◇
◆◆◆◆◆◆◆◆◆◆◇◇◇
A2345678910◇◇◇
■■◇◇■◇■■■■■■■
A2◇◇5◇78910JQK

CPU 3> もうだめ...

▲▲▲◇◇◇▲▲▲▲◇◇▲
A23◇◇◇78910◇◇K
▼▼▼▼▼▼▼▼▼▼▼◇◇
A2345678910J◇◇
◆◆◆◆◆◆◆◆◆◆◇◇◇
A2345678910◇◇◇
■■◇◇■◇■■■■■■■
A2◇◇5◇78910JQK

【Player】Cards: 5 Pass: 2
▲6[▲J]▼K◆J■6PS:2
▲▲▲◇◇◇▲▲▲▲▲◇▲
A23◇◇◇78910J◇K
▼▼▼▼▼▼▼▼▼▼▼◇◇
A2345678910J◇◇
◆◆◆◆◆◆◆◆◆◆◇◇◇
A2345678910◇◇◇
■■◇◇■◇■■■■■■■
A2◇◇5◇78910JQK

俺の切り札!! >「▲J」

【CPU 1】Cards: 4 Pass: 2
これでも食らいなっ >「▼Q」

【CPU 2】Cards: 4 Pass: 1
パスー (残り0回)

▲▲▲◇◇◇▲▲▲▲▲◇▲
A23◇◇◇78910J◇K
▼▼▼▼▼▼▼▼▼▼▼▼◇
A2345678910JQ◇
◆◆◆◆◆◆◆◆◆◆◇◇◇
A2345678910◇◇◇
■■◇◇■◇■■■■■■■
A2◇◇5◇78910JQK

【Player】Cards: 4 Pass: 2
▲6▼K◆J■6[PS:2]
▲▲▲◇◇◇▲▲▲▲▲◇▲
A23◇◇◇78910J◇K
▼▼▼▼▼▼▼▼▼▼▼▼◇
A2345678910JQ◇
◆◆◆◆◆◆◆◆◆◆◇◇◇
A2345678910◇◇◇
■■◇◇■◇■■■■■■■
A2◇◇5◇78910JQK

残りパスは1回です。

【CPU 1】Cards: 3 Pass: 2
これでも食らいなっ >「▲Q」

▲▲▲▲◇◇▲▲▲▲▲▲▲
A234◇◇78910JQK
▼▼▼▼▼▼▼▼▼▼▼▼◇
A2345678910JQ◇
◆◆◆◆◆◆◆◆◆◆◇◆◆
A2345678910◇QK
■■■◇■◇■■■■■■■
A23◇5◇78910JQK

CPU 2> もうだめ...

▲▲▲▲◇◇▲▲▲▲▲▲▲
A234◇◇78910JQK
▼▼▼▼▼▼▼▼▼▼▼▼◇
A2345678910JQ◇
◆◆◆◆◆◆◆◆◆◆◇◆◆
A2345678910◇QK
■■■◇■◇■■■■■■■
A23◇5◇78910JQK

【Player】Cards: 4 Pass: 1
▲6[▼K]◆J■6PS:1
▲▲▲▲◇◇▲▲▲▲▲▲▲
A234◇◇78910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◇◆◆
A2345678910◇QK
■■■◇■◇■■■■■■■
A23◇5◇78910JQK

俺の切り札!! >「▼K」

【CPU 1】Cards: 2 Pass: 2
パスー (残り1回)

▲▲▲▲◇◇▲▲▲▲▲▲▲
A234◇◇78910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◇◆◆
A2345678910◇QK
■■■◇■◇■■■■■■■
A23◇5◇78910JQK

【Player】Cards: 3 Pass: 1
▲6[◆J]■6PS:1
▲▲▲▲◇◇▲▲▲▲▲▲▲
A234◇◇78910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◆◆◆
A2345678910JQK
■■■◇■◇■■■■■■■
A23◇5◇78910JQK

俺の切り札!! >「◆J」

【CPU 1】Cards: 2 Pass: 1
パスー (残り0回)

▲▲▲▲◇◇▲▲▲▲▲▲▲
A234◇◇78910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◆◆◆
A2345678910JQK
■■■◇■◇■■■■■■■
A23◇5◇78910JQK

【Player】Cards: 2 Pass: 1
▲6■6[PS:1]
▲▲▲▲◇◇▲▲▲▲▲▲▲
A234◇◇78910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◆◆◆
A2345678910JQK
■■■◇■◇■■■■■■■
A23◇5◇78910JQK

残りパスは0回です。

▲▲▲▲▲◇▲▲▲▲▲▲▲
A2345◇78910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◆◆◆
A2345678910JQK
■■■■■◇■■■■■■■
A2345◇78910JQK

CPU 1> もうだめ...

▲▲▲▲▲◇▲▲▲▲▲▲▲
A2345◇78910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◆◆◆
A2345678910JQK
■■■■■◇■■■■■■■
A2345◇78910JQK

【Player】Cards: 2 Pass: 0
[▲6]■6
▲▲▲▲▲▲▲▲▲▲▲▲▲
A2345678910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◆◆◆
A2345678910JQK
■■■■■◇■■■■■■■
A2345◇78910JQK

俺の切り札!! >「▲6」

▲▲▲▲▲▲▲▲▲▲▲▲▲
A2345678910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◆◆◆
A2345678910JQK
■■■■■◇■■■■■■■
A2345◇78910JQK

【Player】Cards: 1 Pass: 0
[■6]
▲▲▲▲▲▲▲▲▲▲▲▲▲
A2345678910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◆◆◆
A2345678910JQK
■■■■■■■■■■■■■
A2345678910JQK

俺の切り札!! >「■6」

Player Congratulations!!

▲▲▲▲▲▲▲▲▲▲▲▲▲
A2345678910JQK
▼▼▼▼▼▼▼▼▼▼▼▼▼
A2345678910JQK
◆◆◆◆◆◆◆◆◆◆◆◆◆
A2345678910JQK
■■■■■■■■■■■■■
A2345678910JQK


【Game Result】
Player: 1位
CPU 1: GameOver...
CPU 2: GameOver...
CPU 3: GameOver...

HSP 全自動七並べ

#cmpopt varinit 1

;トランプカードモジュール
suitStrs@TrumpCard="▲","▼","◆","■","JO"
powerStrs@TrumpCard="A","2","3","4","5","6","7","8","9","10","J","Q","K","KR"
#module TrumpCard name,suit,power
	#modcfunc tcName
		return name
	#modcfunc tcPower
		return power
	#modcfunc tcSuit
		return suit

	#define news(%1,%2,%3) newmod %1,TrumpCard,%2,%3
	#modinit int _suit,int _power
		name=suitStrs(_suit)+powerStrs(_power)
		power=_power
		suit=_suit
	return
#global

;トランプの束モジュール
#module TrumpDeck co,i,deck,count,hash
	#modcfunc tdCount
		return count

	#define new(%1) dimtype %1,5:newmod %1,TrumpDeck
	#modinit
		randomize
		#define deckDefine \
			suits= \
				0,0,0,0,0, 0,0,0,0,0, 0,0,0, \
				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*/ :\
			powers= \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12, \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12, \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12, \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12 \
				/*,13,13*/
		deckDefine
		foreach suits
			news@TrumpCard deck,suits(cnt),powers(cnt)
			hash(cnt)=cnt
		loop
		count=length(deck)

		newlab co,1:return
		gosub*trumpIter
	return

	#modfunc tdShuffle
		foreach deck
			r=rnd(count)
			tmp=hash(cnt)
			hash(cnt)=hash(r)
			hash(r)=tmp
		loop
	return

	*trumpIter
		for i,0,length(suits)
			_card=deck(hash(i))
			newlab co,1:return
		next
	return

	#modfunc local tdNext var card
		gosub co
		card=_card
	return
	#define global tdNext(%1,%2) dimtype %2,5:tdNext@TrumpDeck %1,%2
#global

;プレイヤーモジュール
#module Player deck,cardCnt,pass,isGameOut,name,selectCardFn
	#modcfunc plName
		return name
	#modcfunc plCardCnt
		return cardCnt
	#modcfunc plPass
		return pass
	#modfunc plRefDeck array _deck
		if cardCnt!=0 {
			dimtype _deck,5,cardCnt
			repeat cardCnt
				_deck(cnt)=deck(cnt)
			loop
		}
		else: dim _deck
	return

	#define news(%1,%2) newmod %1,Player,%2
	#modinit str _name
		super@Player thismod,_name
		selectCardFn=*selectCard
	return

	#modfunc local super str _name
		name=_name
		cardCnt=0
		pass=1
		isGameOut=1
	return

	#modfunc plSortDeck
		repeat cardCnt
			i=cnt
			repeat cardCnt-i
				n=i+cnt
				#define ctype sortValue(%1) tcSuit(deck(%1))*13+tcPower(deck(%1))
				if sortValue(n)<sortValue(i) {
					tmp=deck(i)
					deck(i)=deck(n)
					deck(n)=tmp
				}
			loop
		loop
	return

	#modfunc plAddCard var card
		deck(cardCnt)=card
		cardCnt++
	return

	#modfunc plRemoveCard str cardName
		repeat cardCnt
			if tcName(deck.cnt)=cardName {
				delID=cnt
				repeat cardCnt-delID-1
					deck(delID+cnt)=deck(delID+cnt+1)
				loop
				cardCnt--
				break
			}
		loop
	return

	#modcfunc plExistCard str cardName
		existCard=-1
		repeat cardCnt
			if tcName(deck.cnt)=cardName {
				existCard=cnt
				break
			}
		loop
	return existCard

	#modfunc plUsePass
		pass--
	return

	#modfunc plGameOut
		isGameOut=0
	return

	#modfunc plSelectCard var _field,int _index
		field=_field:index=_index
		gosub selectCardFn
	return

	*selectCard
		;カード選択処理
	return
#global

;AIプレイヤーモジュール
#module AIPlayer deck,cardCnt,pass,isGameOut,name,selectCardFn
	#define ctype pl(%1) %1@Player
	#define field field@Player
	#define index index@Player

	#define news(%1,%2) newmod %1,AIPlayer,%2
	#modinit str _name
		super@Player thismod,_name
		selectCardFn=*selectCard
	return

	*selectCard
		if 1!pl(isGameOut): return
		if 1!svCheckPlayNext(field,thismod) {
			svGameOver field,thismod,index
			svView field
			mes pl(name)+"> もうだめ...\n"
			wait 100
			return
		}

		mes strf("【%s】Cards: %d Pass: %d",pl(name),pl(cardCnt),pl(pass))
		sdim items
		repeat pl(cardCnt)
			items(cnt)=tcName(pl(deck).cnt)
		loop
		if 0<pl(pass): items(pl(cardCnt))="PS:"+pl(pass)
		s=""
		foreach items
			s+=items(cnt)+","
		loop
		mes s

		wait 100

		passCharge=0
		while 1
			cursol=rnd(length(items))

			if 0<pl(pass) & length(items)-1=cursol {
				if passCharge<5 {
					passCharge++
					_continue
				}
				pl(pass)--
				mes strf("パスー (残り%d回)\n",pl(pass))
				_break
			}
			else:if svTryUseCard(field,thismod,pl(deck).cursol) {
				mes strf("これでも食らいなっ >「%s」\n",items(cursol))
				if pl(cardCnt)=0 {
					mes pl(name)+"> おっさき~\n"
					svGameClear field,thismod,index
				}
				_break
			}
			else :_continue
		wend
	return
#global

;トランプの場モジュール
#module TrumpField deck,cardCnt
	#define new(%1) dimtype %1,5:newmod %1,TrumpField
	#modfunc tfUseCard var _player,var card
		deck(cardCnt)=card
		plRemoveCard _player,tcName(card)
		cardCnt++
	return

	#define global tfSortField(%1) plSortDeck %1

	#modfunc tfView
		foreach deck
			mes tcName(deck.cnt)+" ",1
		loop
	return
#global

;七並べの列モジュール
#module SevensLine cardLine
	#const jokerIndex 13
	#const sevenIndex 6
	#modfunc slRefCardLine array _cardLine
		dimtype _cardLine,5,length(cardLine)
		foreach cardLine
			_cardLine(cnt)=cardLine(cnt)
		loop
	return

	#define news(%1) newmod %1,SevensLine
	#modinit
		dim cardLine,13
		cardLine(sevenIndex)=1
	return

	#modcfunc rangeMin
		i=sevenIndex
		repeat sevenIndex
			i--
			if cardLine(i)=0: break
		loop
	return i

	#modcfunc rangeMax
		i=sevenIndex
		repeat sevenIndex,sevenIndex
			i++
			if cardLine(i)=0: break
		loop
	return i

	#modcfunc slCheckUseCard int power
		switch power
			case jokerIndex
				return 1
			case rangeMin(thismod)
			case rangeMax(thismod)
				return 1
		swend
	return 0
	
	#modfunc slUseCard int power
		cardLine(power)=1
	return
#global

;七並べモジュール
#module Sevens field,cardCnt,lines,rank,clearCnt
	#define new(%1,%2) dimtype %1,5:newmod %1,Sevens,%2
	#modinit array players
		dimtype lines,5,4
		repeat length(lines)
			news@SevensLine lines
		loop

		dimtype deck,5
		dimtype cardSevens,5,4
		repeat 4
			cardSevenName=suitStrs@TrumpCard(cnt)+powerStrs@TrumpCard(6)
			foreach players
				cardSevenIndex=plExistCard(players.cnt,cardSevenName)
				if -1<cardSevenIndex {
					plRefDeck players(cnt),deck
					tfUseCard thismod,players(cnt),deck(cardSevenIndex)
					break
				}
			loop
		loop
		dim rank,length(players)
		clearCnt=0
	return

	#define svUseCard(%1,%2) \
		slUseCard lines(tcSuit(%2)),tcPower(%2) :\
		tfUseCard thismod,%1,%2

	#define ctype svCheckUseCard(%1) \
		slCheckUseCard(lines(tcSuit(%1)),tcPower(%1))

	#modcfunc svTryUseCard var _player,var card
		if 1!svCheckUseCard(card): return 0
		svUseCard _player,card
	return 1

	#modcfunc svCheckPlayNext var _player
		if 0<plPass(_player): return 1
		dimtype deck,5
		plRefDeck _player,deck
		isPlayGame=0
		foreach deck
			if svCheckUseCard(deck.cnt) {
				isPlayGame=1
				break
			}
		loop
	return isPlayGame

	#modfunc svGameClear var _player,int index
		clearCnt++
		rank(index)=clearCnt
		plGameout _player
	return

	#modfunc svGameOver var _player,int index
		rank(index)=-1
		dimtype deck,5
		plRefDeck _player,deck
		foreach deck
			svUseCard _player,deck(cnt)
		loop
		plGameout _player
	return

	#modcfunc svCheckGameEnd
		isGameEnd=1
		foreach rank
			if rank(cnt)=0 {
				isGameEnd=0
				break
			}
		loop
	return isGameEnd

	#modfunc svView
		dim cardLine,13
		s=""
		foreach lines
			i=cnt
			ss=""
			slRefCardLine lines(i),cardLine
			repeat 13
				if cardLine(cnt) {
					s+=suitStrs@TrumpCard(i)
					ss+=powerStrs@TrumpCard(cnt)
				}
				else {
					s+="◇"
					ss+="◇"
				}
			loop
			s+="\n"+ss+"\n"
		loop
		color $FF,$FF,$FF
		boxf 20,20,500,180
		color $FF,0,0
		pos 20,20
		mes s
	return

	#modfunc svResult array players
		mes "\n【Game Result】"
		foreach rank
			if 0<rank(cnt): rankStr=strf("%d位",rank.cnt): else: rankStr="GameOver..."
			mes strf("%s: %s",plName(players.cnt),rankStr)
		loop
	return
#global

;メイン処理
#module Program
	#deffunc main
		color $FF,0,0
		mes "【全自動七並べ】"

		new@TrumpDeck trp
		tdShuffle trp

		dimtype p,5,4
		;news@Player p,"Player"
		repeat length(p),1
			news@AIPlayer p,"CPU "+cnt
		loop
		repeat tdCount(trp)
			tdNext trp,card
			plAddCard p(cnt\4),card
		loop
		foreach p
			plSortDeck p(cnt)
		loop

		new@Sevens field,p

		dimtype deck,5
		*selectLoop
			pos 0,0
			color $FF,$FF,$FF
			boxf 0,20,ginfo_sizex,ginfo_sizey
			color $FF,0,0

			pos 10,180
			foreach p
				posx=ginfo_cx:posy=ginfo_cy
				svView field
				pos posx,posy
				plSelectCard p(cnt),field,cnt
				if svCheckGameEnd(field): goto*exitSelect
			loop
			wait 100
		goto*selectLoop
		*exitSelect

		pos 0,0
		color $FF,$FF,$FF
		boxf 0,20,ginfo_sizex,ginfo_sizey
		color 0,0,0

		svView field
		svResult field,p
	return
#global
main

HSP CUI七並べ On AI

#runtime "hsp3cl"
#cmpopt varinit 1

;トランプカードモジュール
suitStrs@TrumpCard="▲","▼","◆","■","JO"
powerStrs@TrumpCard="A","2","3","4","5","6","7","8","9","10","J","Q","K","KR"
#module TrumpCard name,suit,power
	#modcfunc tcName
		return name
	#modcfunc tcPower
		return power
	#modcfunc tcSuit
		return suit

	#define news(%1,%2,%3) newmod %1,TrumpCard,%2,%3
	#modinit int _suit,int _power
		name=suitStrs(_suit)+powerStrs(_power)
		power=_power
		suit=_suit
	return
#global

;トランプの束モジュール
#module TrumpDeck co,i,deck,count,hash
	#modcfunc tdCount
		return count

	#define new(%1) dimtype %1,5:newmod %1,TrumpDeck
	#modinit
		randomize
		#define deckDefine \
			suits= \
				0,0,0,0,0, 0,0,0,0,0, 0,0,0, \
				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*/ :\
			powers= \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12, \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12, \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12, \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12 \
				/*,13,13*/
		deckDefine
		foreach suits
			news@TrumpCard deck,suits(cnt),powers(cnt)
			hash(cnt)=cnt
		loop
		count=length(deck)

		newlab co,1:return
		gosub*trumpIter
	return

	#modfunc tdShuffle
		foreach deck
			r=rnd(count)
			tmp=hash(cnt)
			hash(cnt)=hash(r)
			hash(r)=tmp
		loop
	return

	*trumpIter
		for i,0,length(suits)
			_card=deck(hash(i))
			newlab co,1:return
		next
	return

	#modfunc local tdNext var card
		gosub co
		card=_card
	return
	#define global tdNext(%1,%2) dimtype %2,5:tdNext@TrumpDeck %1,%2
#global

;プレイヤーモジュール
#module Player deck,cardCnt,pass,isGameOut,name,selectCardFn
	#modcfunc plName
		return name
	#modcfunc plCardCnt
		return cardCnt
	#modcfunc plPass
		return pass
	#modfunc plRefDeck array _deck
		if cardCnt!=0 {
			dimtype _deck,5,cardCnt
			repeat cardCnt
				_deck(cnt)=deck(cnt)
			loop
		}
		else: dim _deck
	return

	#define news(%1,%2) newmod %1,Player,%2
	#modinit str _name
		super@Player thismod,_name
		selectCardFn=*selectCard
	return

	#modfunc local super str _name
		name=_name
		cardCnt=0
		pass=3
		isGameOut=1
	return

	#modfunc plSortDeck
		repeat cardCnt
			i=cnt
			repeat cardCnt-i
				n=i+cnt
				#define ctype sortValue(%1) tcSuit(deck(%1))*13+tcPower(deck(%1))
				if sortValue(n)<sortValue(i) {
					tmp=deck(i)
					deck(i)=deck(n)
					deck(n)=tmp
				}
			loop
		loop
	return

	#modfunc plAddCard var card
		deck(cardCnt)=card
		cardCnt++
	return

	#modfunc plRemoveCard str cardName
		repeat cardCnt
			if tcName(deck.cnt)=cardName {
				delID=cnt
				repeat cardCnt-delID-1
					deck(delID+cnt)=deck(delID+cnt+1)
				loop
				cardCnt--
				break
			}
		loop
	return

	#modcfunc plExistCard str cardName
		existCard=-1
		repeat cardCnt
			if tcName(deck.cnt)=cardName {
				existCard=cnt
				break
			}
		loop
	return existCard

	#modfunc plUsePass
		pass--
	return

	#modfunc plGameOut
		isGameOut=0
	return

	#uselib "crtdll"
	#cfunc getch "_getch"
	#cfunc kbhit "_kbhit"

	;カーソルの移動
	#defcfunc local move int _ch,int _csl,int max
		csl=_csl
		if _ch=$4b :csl-- ;左
		if _ch=$4d :csl++ ;右
		if csl<0 :csl=0
		if max-1<csl :csl=max-1
	return csl

	;カーソルの表示
	#deffunc local 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

	#modfunc plSelectCard var _field,int _index
		field=_field:index=_index
		gosub selectCardFn
	return

	*selectCard
		if 1!isGameOut: return
		if 1!svCheckPlayNext(field,thismod) {
			svGameOver field,thismod,index
			svView field
			mes name+" GameOver...\n"
			return
		}

		mes strf("【%s】Cards: %d Pass: %d",name,cardCnt,pass)
		sdim items
		repeat cardCnt
			items(cnt)=tcName(deck.cnt)
		loop
		if 0<pass: items(cardCnt)="PS:"+pass

		while 1
			cursol=0
			cursolShow@Player items,cursol
			repeat
				if kbhit() {
					ch=getch()
					if ch=$0d {
						mes ""
						break
					}
					if ch=$e0 {
						cursol=move@Player(getch(),cursol,length(items))
						cursolShow@Player items,cursol
					}
				}
			loop

			if 0<pass & length(items)-1=cursol {
				pass--
				svView field
				mes strf("残りパスは%d回です。\n",pass)
				_break
			}
			else:if svTryUseCard(field,thismod,deck(cursol)) {
				svView field
				mes strf("俺の切り札!! >「%s」\n",items(cursol))
				if cardCnt=0 {
					mes name+" Congratulations!!\n"
					svGameClear field,thismod,index
				}
				_break
			}
			else {
				mes "そのカードは出せないのじゃ…\n"
				_continue
			}
		wend
	return
#global

;AIプレイヤーモジュール
#module AIPlayer deck,cardCnt,pass,isGameOut,name,selectCardFn
	#define ctype pl(%1) %1@Player
	#define field field@Player
	#define index index@Player

	#define news(%1,%2) newmod %1,AIPlayer,%2
	#modinit str _name
		super@Player thismod,_name
		selectCardFn=*selectCard
	return

	*selectCard
		if 1!pl(isGameOut): return
		if 1!svCheckPlayNext(field,thismod) {
			svGameOver field,thismod,index
			svView field
			mes pl(name)+"> もうだめ...\n"
			return
		}

		mes strf("【%s】Cards: %d Pass: %d",pl(name),pl(cardCnt),pl(pass))
		sdim items
		repeat pl(cardCnt)
			items(cnt)=tcName(pl(deck).cnt)
		loop
		if 0<pl(pass): items(pl(cardCnt))="PS:"+pl(pass)

		mes "考え中...\r",1
		wait 100

		passCharge=0
		while 1
			cursol=rnd(length(items))

			if 0<pl(pass) & length(items)-1=cursol {
				if passCharge<5 {
					passCharge++
					_continue
				}
				pl(pass)--
				mes strf("パスー (残り%d回)\n",pl(pass))
				_break
			}
			else:if svTryUseCard(field,thismod,pl(deck).cursol) {
				mes strf("これでも食らいなっ >「%s」\n",items(cursol))
				if pl(cardCnt)=0 {
					mes pl(name)+"> おっさき~\n"
					svGameClear field,thismod,index
				}
				_break
			}
			else :_continue
		wend
	return
#global

;トランプの場モジュール
#module TrumpField deck,cardCnt
	#define new(%1) dimtype %1,5:newmod %1,TrumpField
	#modfunc tfUseCard var _player,var card
		deck(cardCnt)=card
		plRemoveCard _player,tcName(card)
		cardCnt++
	return

	#define global tfSortField(%1) plSortDeck %1

	#modfunc tfView
		foreach deck
			mes tcName(deck.cnt)+" ",1
		loop
	return
#global

;七並べの列モジュール
#module SevensLine cardLine
	#const jokerIndex 13
	#const sevenIndex 6
	#modfunc slRefCardLine array _cardLine
		dimtype _cardLine,5,length(cardLine)
		foreach cardLine
			_cardLine(cnt)=cardLine(cnt)
		loop
	return

	#define news(%1) newmod %1,SevensLine
	#modinit
		dim cardLine,13
		cardLine(sevenIndex)=1
	return

	#modcfunc rangeMin
		i=sevenIndex
		repeat sevenIndex
			i--
			if cardLine(i)=0: break
		loop
	return i

	#modcfunc rangeMax
		i=sevenIndex
		repeat sevenIndex,sevenIndex
			i++
			if cardLine(i)=0: break
		loop
	return i

	#modcfunc slCheckUseCard int power
		switch power
			case jokerIndex
				return 1
			case rangeMin(thismod)
			case rangeMax(thismod)
				return 1
		swend
	return 0
	
	#modfunc slUseCard int power
		cardLine(power)=1
	return
#global

;七並べモジュール
#module Sevens field,cardCnt,lines,rank,clearCnt
	#define new(%1,%2) dimtype %1,5:newmod %1,Sevens,%2
	#modinit array players
		dimtype lines,5,4
		repeat length(lines)
			news@SevensLine lines
		loop

		dimtype deck,5
		dimtype cardSevens,5,4
		repeat 4
			cardSevenName=suitStrs@TrumpCard(cnt)+powerStrs@TrumpCard(6)
			foreach players
				cardSevenIndex=plExistCard(players.cnt,cardSevenName)
				if -1<cardSevenIndex {
					plRefDeck players(cnt),deck
					tfUseCard thismod,players(cnt),deck(cardSevenIndex)
					break
				}
			loop
		loop
		dim rank,length(players)
		clearCnt=0
	return

	#define svUseCard(%1,%2) \
		slUseCard lines(tcSuit(%2)),tcPower(%2) :\
		tfUseCard thismod,%1,%2

	#define ctype svCheckUseCard(%1) \
		slCheckUseCard(lines(tcSuit(%1)),tcPower(%1))

	#modcfunc svTryUseCard var _player,var card
		if 1!svCheckUseCard(card): return 0
		svUseCard _player,card
	return 1

	#modcfunc svCheckPlayNext var _player
		if 0<plPass(_player): return 1
		dimtype deck,5
		plRefDeck _player,deck
		isPlayGame=0
		foreach deck
			if svCheckUseCard(deck.cnt) {
				isPlayGame=1
				break
			}
		loop
	return isPlayGame

	#modfunc svGameClear var _player,int index
		clearCnt++
		rank(index)=clearCnt
		plGameout _player
	return

	#modfunc svGameOver var _player,int index
		rank(index)=-1
		dimtype deck,5
		plRefDeck _player,deck
		foreach deck
			svUseCard _player,deck(cnt)
		loop
		plGameout _player
	return

	#modcfunc svCheckGameEnd
		isGameEnd=1
		foreach rank
			if rank(cnt)=0 {
				isGameEnd=0
				break
			}
		loop
	return isGameEnd

	#modfunc svView
		dim cardLine,13
		s=""
		foreach lines
			i=cnt
			ss=""
			slRefCardLine lines(i),cardLine
			repeat 13
				if cardLine(cnt) {
					s+=suitStrs@TrumpCard(i)
					ss+=powerStrs@TrumpCard(cnt)
				}
				else {
					s+="◇"
					ss+="◇"
				}
			loop
			s+="\n"+ss+"\n"
		loop
		mes s
	return

	#modfunc svResult array players
		mes "\n【Game Result】"
		foreach rank
			if 0<rank(cnt): rankStr=strf("%d位",rank.cnt): else: rankStr="GameOver..."
			mes strf("%s: %s",plName(players.cnt),rankStr)
		loop
	return
#global

;メイン処理
#module Program
	#deffunc main
		repeat 100
			mes ""
		loop
mes {"
/---------------------------------------/
/                 七並べ                /
/---------------------------------------/

"}

		new@TrumpDeck trp
		tdShuffle trp

		dimtype p,5,4
		news@Player p,"Player"
		repeat length(p)-1,1
			news@AIPlayer p,"CPU "+cnt
		loop
		repeat tdCount(trp)
			tdNext trp,card
			plAddCard p(cnt\4),card
		loop
		foreach p
			plSortDeck p(cnt)
		loop

		new@Sevens field,p

		dimtype deck,5
		*selectLoop
			svView field
			foreach p
				plSelectCard p(cnt),field,cnt
				if svCheckGameEnd(field): goto*exitSelect
			loop
		goto*selectLoop
		*exitSelect

		svResult field,p
	return
#global
main

HSP CUI七並べ

#runtime "hsp3cl"
#cmpopt varinit 1

;トランプカードモジュール
suitStrs@TrumpCard="▲","▼","◆","■","JO"
powerStrs@TrumpCard="A","2","3","4","5","6","7","8","9","10","J","Q","K","KR"
#module TrumpCard name,suit,power
	#modcfunc tcName
		return name
	#modcfunc tcPower
		return power
	#modcfunc tcSuit
		return suit

	#define news(%1,%2,%3) newmod %1,TrumpCard,%2,%3
	#modinit int _suit,int _power
		name=suitStrs(_suit)+powerStrs(_power)
		power=_power
		suit=_suit
	return
#global

;トランプの束モジュール
#module TrumpDeck co,i,deck,count,hash
	#modcfunc tdCount
		return count

	#define new(%1) dimtype %1,5:newmod %1,TrumpDeck
	#modinit
		randomize
		#define deckDefine \
			suits= \
				0,0,0,0,0, 0,0,0,0,0, 0,0,0, \
				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*/ :\
			powers= \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12, \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12, \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12, \
				0,1,2,3,4,5, 6,7,8,9,10, 11,12 \
				/*,13,13*/
		deckDefine
		foreach suits
			news@TrumpCard deck,suits(cnt),powers(cnt)
			hash(cnt)=cnt
		loop
		count=length(deck)

		newlab co,1:return
		gosub*trumpIter
	return

	#modfunc tdShuffle
		foreach deck
			r=rnd(count)
			tmp=hash(cnt)
			hash(cnt)=hash(r)
			hash(r)=tmp
		loop
	return

	*trumpIter
		for i,0,length(suits)
			_card=deck(hash(i))
			newlab co,1:return
		next
	return

	#modfunc local tdNext var card
		gosub co
		card=_card
	return
	#define global tdNext(%1,%2) dimtype %2,5:tdNext@TrumpDeck %1,%2
#global

;プレイヤーモジュール
#module Player deck,cardCnt,pass,isGameOut,name
	#modcfunc plName
		return name
	#modcfunc plCardCnt
		return cardCnt
	#modcfunc plPass
		return pass
	#modcfunc plIsGameOut
		return isGameOut
	#modfunc plRefDeck array _deck
		if cardCnt!=0 {
			dimtype _deck,5,cardCnt
			repeat cardCnt
				_deck(cnt)=deck(cnt)
			loop
		}
		else: dim _deck
	return

	#define news(%1,%2) newmod %1,Player,%2
	#modinit str _name
		name=_name
		cardCnt=0
		pass=0;3
		isGameOut=1
	return

	#modfunc plSortDeck
		repeat cardCnt
			i=cnt
			repeat cardCnt-i
				n=i+cnt
				#define ctype sortValue(%1) tcSuit(deck(%1))*13+tcPower(deck(%1))
				if sortValue(n)<sortValue(i) {
					tmp=deck(i)
					deck(i)=deck(n)
					deck(n)=tmp
				}
			loop
		loop
	return

	#modfunc plAddCard var card
		deck(cardCnt)=card
		cardCnt++
	return

	#modfunc plRemoveCard str cardName
		repeat cardCnt
			if tcName(deck.cnt)=cardName {
				delID=cnt
				repeat cardCnt-delID-1
					deck(delID+cnt)=deck(delID+cnt+1)
				loop
				cardCnt--
				break
			}
		loop
	return

	#modcfunc plExistCard str cardName
		existCard=-1
		repeat cardCnt
			if tcName(deck.cnt)=cardName {
				existCard=cnt
				break
			}
		loop
	return existCard

	#modfunc plUsePass
		pass--
	return

	#modfunc plGameOut
		isGameOut=0
	return
#global

;トランプの場モジュール
#module TrumpField deck,cardCnt
	#define new(%1) dimtype %1,5:newmod %1,TrumpField
	#modfunc tfUseCard var _player,var card
		deck(cardCnt)=card
		plRemoveCard _player,tcName(card)
		cardCnt++
	return

	#define global tfSortField(%1) plSortDeck %1

	#modfunc tfView
		foreach deck
			mes tcName(deck.cnt)+" ",1
		loop
	return
#global

;七並べの列モジュール
#module SevensLine cardLine
	#const jokerIndex 13
	#const sevenIndex 6
	#modfunc slRefCardLine array _cardLine
		dimtype _cardLine,5,length(cardLine)
		foreach cardLine
			_cardLine(cnt)=cardLine(cnt)
		loop
	return

	#define news(%1) newmod %1,SevensLine
	#modinit
		dim cardLine,13
		cardLine(sevenIndex)=1
	return

	#modcfunc rangeMin
		i=sevenIndex
		repeat sevenIndex
			i--
			if cardLine(i)=0: break
		loop
	return i

	#modcfunc rangeMax
		i=sevenIndex
		repeat sevenIndex,sevenIndex
			i++
			if cardLine(i)=0: break
		loop
	return i

	#modcfunc slCheckUseCard int power
		switch power
			case jokerIndex
				return 1
			case rangeMin(thismod)
			case rangeMax(thismod)
				return 1
		swend
	return 0
	
	#modfunc slUseCard int power
		cardLine(power)=1
	return
#global

;七並べモジュール
#module Sevens field,cardCnt,lines,rank,clearCnt
	#define new(%1,%2) dimtype %1,5:newmod %1,Sevens,%2
	#modinit array players
		dimtype lines,5,4
		repeat length(lines)
			news@SevensLine lines
		loop

		dimtype deck,5
		dimtype cardSevens,5,4
		repeat 4
			cardSevenName=suitStrs@TrumpCard(cnt)+powerStrs@TrumpCard(6)
			foreach players
				cardSevenIndex=plExistCard(players.cnt,cardSevenName)
				if -1<cardSevenIndex {
					plRefDeck players(cnt),deck
					tfUseCard thismod,players(cnt),deck(cardSevenIndex)
					break
				}
			loop
		loop
		dim rank,length(players)
		clearCnt=0
	return

	#define svUseCard(%1,%2) \
		slUseCard lines(tcSuit(%2)),tcPower(%2) :\
		tfUseCard thismod,%1,%2

	#define ctype svCheckUseCard(%1) \
		slCheckUseCard(lines(tcSuit(%1)),tcPower(%1))

	#modcfunc svTryUseCard var _player,var card
		if 1!svCheckUseCard(card): return 0
		svUseCard _player,card
	return 1

	#modcfunc svCheckPlayNext var _player
		if 0<plPass(_player): return 1
		dimtype deck,5
		plRefDeck _player,deck
		isPlayGame=0
		foreach deck
			if svCheckUseCard(deck.cnt) {
				isPlayGame=1
				break
			}
		loop
	return isPlayGame

	#modfunc svGameClear array players,int index
		clearCnt++
		rank(index)=clearCnt
		plGameout players(index)
	return

	#modfunc svGameOver array players,int index
		rank(index)=-1
		dimtype deck,5
		plRefDeck players(index),deck
		foreach deck
			svUseCard players(index),deck(cnt)
		loop
		plGameout players(index)
	return

	#modcfunc svCheckGameEnd
		isGameEnd=1
		foreach rank
			if rank(cnt)=0 {
				isGameEnd=0
				break
			}
		loop
	return isGameEnd

	#modfunc svView
		dim cardLine,13
		s=""
		foreach lines
			i=cnt
			ss=""
			slRefCardLine lines(i),cardLine
			repeat 13
				if cardLine(cnt) {
					s+=suitStrs@TrumpCard(i)
					ss+=powerStrs@TrumpCard(cnt)
				}
				else {
					s+="◇"
					ss+="◇"
				}
			loop
			s+="\n"+ss+"\n"
		loop
		mes s
	return

	#modfunc svResult array players
		mes ""
		foreach rank
			if 0<rank(cnt): rankStr=strf("%d位",rank.cnt): else: rankStr="GameOver..."
			mes strf("%s: %s",plName(players.cnt),rankStr)
		loop
	return
#global

;メイン処理
#module Program
	#uselib "crtdll"
	#cfunc getch "_getch"
	#cfunc kbhit "_kbhit"

	;カーソルの移動
	#defcfunc move int _ch,int _csl,int max
		csl=_csl
		if _ch=$4b :csl-- ;左
		if _ch=$4d :csl++ ;右
		if csl<0 :csl=0
		if max-1<csl :csl=max-1
	return csl

	;カーソルの表示
	#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
		repeat 100
			mes ""
		loop
mes {"
/---------------------------------------/
/                 七並べ                /
/---------------------------------------/

"}

		new@TrumpDeck trp
		tdShuffle trp

		dimtype p,5,4
		repeat length(p)
			news@Player p,"Player "+(cnt+1)
		loop
		repeat tdCount(trp)
			tdNext trp,card
			plAddCard p(cnt\4),card
		loop
		foreach p
			plSortDeck p(cnt)
		loop

		new@Sevens field,p
		svView field

		dimtype deck,5
		*selectLoop
			foreach p
				if 1!plIsGameOut(p.cnt): continue
				if 1!svCheckPlayNext(field,p.cnt) {
					svGameOver field,p(cnt),cnt
					svView field
					mes plName(p.cnt)+" GameOver...\n"
					continue
				}
				plRefDeck p(cnt),deck

				mes "【"+plName(p.cnt)+"】Pass: "+plPass(p.cnt)
				sdim items
				foreach deck
					items(cnt)=tcName(deck.cnt)
				loop
				if 0<plPass(p.cnt): items(length(items))="PS:"+plPass(p.cnt)

				while 1
					cursol=0
					cursolShow items,cursol
					repeat
						if kbhit() {
							ch=getch()
							if ch=$0d {
								mes ""
								break
							}
							if ch=$e0 {
								cursol=move(getch(),cursol,length(items))
								cursolShow items,cursol
							}
						}
					loop

					if 0<plPass(p.cnt) & length(items)-1=cursol {
						plUsePass p.cnt
						svView field
						mes strf("残りパスは%d回です。\n",plPass(p.cnt))
						_break
					}
					else:if svTryUseCard(field,p(cnt),deck(cursol)) {
						svView field
						mes strf("俺の切り札!! >「%s」\n",items(cursol))
						if plCardCnt(p.cnt)=0 {
							mes plName(p.cnt)+" Congratulations!!"
							svGameClear field,p(cnt),cnt
						}
						_break
					}
					else {
						mes "そのカードは出せないのじゃ…\n"
						_continue
					}
				wend
				if svCheckGameEnd(field): goto*exitSelect
			loop
		goto*selectLoop
		*exitSelect

		svResult field,p
	return
#global
main

HSP CUIでトランプゲーム作りたい

#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

HSP HSPの配列でモジュール変数再現Lite

#module Person
	#enum name=0
	#enum age
	#enum high
	#define ctype new(%1,%2,%3,%4) \
		sdim %1,,3:__new@Person %1,%2,%3,%4
	#deffunc local __new array this,str _name,int _age,double _high
		this.name=_name
		this.age=str(_age)
		this.high=str(_high)
	return

	#defcfunc psName array this
		return this.name

	#defcfunc psAge array this
		return int(this.age)

	#defcfunc psHigh array this
		return double(this.high)
#global

new@Person(bob,"bob",20,170.5)
new@Person(kate,"kate",17,155.2)
mes strf("name:%s age:%d high:%.1fcm",psName(bob),psAge(bob),psHigh(bob))
mes strf("name:%s age:%d high:%.1fcm",psName(kate),psAge(kate),psHigh(kate))

HSP HSPでモジュール変数再現

#module Person
	;int
	#enum age=0
	;str
	#enum name=0
	;double
	#enum high=0
	#define ctype new(%1,%2,%3,%4) \
		i%1=0:s%1="":d%1=0.0:\
		__new@Person %2,%3,%4,%1_i,%1_s,%1_d
	#deffunc local __new str _name,int _age,double _high, \
		array ti,array ts,array td

		ts.name=_name
		ti.age=_age
		td.high=_high
	return

	#defcfunc local psName array ts
		return ts.name
	#define global ctype psName(%1) psName@Person(%1_s)

	#defcfunc local psAge array ti
		return ti.age
	#define global ctype psAge(%1) psAge@Person(%1_i)

	#defcfunc local psHigh array ts
		return ts.high
	#define global ctype psHigh(%1) psHigh@Person(%1_d)
#global

new@Person(bob,"bob",20,170.5)
new@Person(kate,"kate",17,155.2)
mes strf("name:%s age:%d high:%.1fcm",psName(bob),psAge(bob),psHigh(bob))
mes strf("name:%s age:%d high:%.1fcm",psName(kate),psAge(kate),psHigh(kate))

HSP HSPで継承したときのジェネレーターの挙動

#runtime "hsp3cl"

#module Generator co,value,c
	#modcfunc gNext
		gosub co
	return value
#global

#module myGen@Generator co,value,c
	#define ctype g(%1) %1@Generator
	#modinit
		c=0
		newlab co,1:return
		*gLoop
			g(c)++
			g(value)=g(c)
			newlab g(co),1:return
		goto*gLoop
	return
#global

#module Program
	#deffunc main
		newmod g,myGen@Generator
		newmod g2,myGen@Generator
		repeat 100
			mes gNext(g)
			mes gNext(g2)
		loop
	return
#global
main

HSP トランプモジュール

#runtime "hsp3cl"
#cmpopt varinit 1

#module TrumpCard name,power,suit
	#modinit str _name,int _power,int _suit
		name=_name
		power=_power
		suit=_suit
	return

	#modcfunc tcName
		return name
	#modcfunc tcPower
		return power
	#modcfunc tcSuit
		return suit
#global

#module Trump deck,iter,countMax,hash
	#define new(%1) dimtype %1,5:newmod %1,Trump
	#modinit
		randomize
		#define deckDefine names= \
				"SA","S2","S3","S4","S5","S6","S7","S8","S9","S10","SJ","SQ","SK", \
				"HA","H2","H3","H4","H5","H6","H7","H8","H9","H10","HJ","HQ","HK", \
				"CA","C2","C3","C4","C5","C6","C7","C8","C9","C10","CJ","CQ","CK", \
				"DA","D2","D3","D4","D5","D6","D7","D8","D9","D10","DJ","DQ","DK", \
				"JK","jk" :\
			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 :\
			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
		deckDefine
		foreach names
			newmod deck,TrumpCard,names(cnt),powers(cnt),suits(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
		itr=0
	return

	#modcfunc trpCount
		return count

	#modfunc local trpNext var card
		card=deck(hash(iter))
		iter++
	return
	#define global trpNext(%1,%2) dimtype %2,5:trpNext@Trump %1,%2
#global

new@Trump trp
repeat trpCount(trp)
	i=cnt/4
	trpNext trp,card
	if cnt\4=0 {
		p1(i)=card
	}
	else:if cnt\4=1 {
		p2(i)=card
	}
	else:if cnt\4=2 {
		p3(i)=card
	}
	else:if cnt\4=3 {
		p4(i)=card
	}
loop

mes "【Player 1】"
foreach p1
	mes tcName(p1.cnt)+",",1
loop

mes "\n【Player 2】"
foreach p2
	mes tcName(p2.cnt)+",",1
loop

mes "\n【Player 3】"
foreach p3
	mes tcName(p3.cnt)+",",1
loop

mes "\n【Player 4】"
foreach p4
	mes tcName(p4.cnt)+",",1
loop

mes ""
Total Pages: 1 / 7412345102030...最後 »

よく投稿されているコード

タグ

最近投稿されたコード