なんとなく書いたHSPプログラム

sdim longRange@Chess,,5,5 longRange@Chess(0,0)="\& […]

sdim longRange@Chess,,5,5 longRange@Chess(0,0)="\& […]

  • タグ:
  • タグはありません
sdim longRange@Chess,,5,5
longRange@Chess(0,0)="\"," ","|"," ","/"
longRange@Chess(0,1)=" ","\","|","/"," "
longRange@Chess(0,2)="―","―","*","―","―"
longRange@Chess(0,3)=" ","/","|","\"," "
longRange@Chess(0,4)="/"," ","|"," ","\"

#module Chess __name,__type,virtual_attack
	#define super(%1) \
		__name=%1 :\
		virtual_attack=*override_attack
	return

	#modcfunc name
		return __name
	#modfunc set_name str _name
		__name=_name:return
	#modcfunc type
		return __type
	#modfunc set_type str _type
		__type=_type:return

	#modfunc local attack int _x,int _y
		x=_x:y=_y
		gosub virtual_attack: return
	#define global attack(%1,%2=ginfo_cx,%3=ginfo_cy) attack@Chess %1,%2,%3

	#deffunc local attackCore str _type,array range
		margin=23

		repeat length2(range)
			xnt=cnt
			repeat length(range)
				if xnt=2 & cnt=2 {
					pos x,y
					mes _type
				}
				else:if range(xnt,cnt) {
					pos x+(xnt-2)*margin,y+(cnt-2)*margin
					if range(xnt,cnt)=2 {
						mes longRange(xnt,cnt)
					}
					else {
						mes "☆"
					}
				}
			loop
		loop
	return
#global


#module Fu __name,__type,virtual_attack
	#define new(%1,%2) dimtype %1,5: newmod %1,Fu,%2
	#define news(%1,%2) newmod %1,Fu,%2
	#modinit str _name
		__type="歩"
		super@Chess _name
	return

	*override_attack
		dim range,5,5
		range(0,0)=0,0,0,0,0
		range(0,1)=0,0,1,0,0
		range(0,2)=0,0,5,0,0
		range(0,3)=0,0,0,0,0
		range(0,4)=0,0,0,0,0
		attackCore@Chess __type@Chess,range
	return
#global

#module Kyosha __name,__type,virtual_attack
	#define new(%1,%2) dimtype %1,5: newmod %1,Kyosha,%2
	#define news(%1,%2) newmod %1,Kyosha,%2
	#modinit str _name
		__type="香"
		super@Chess _name
	return

	*override_attack
		dim range,5,5
		range(0,0)=0,0,2,0,0
		range(0,1)=0,0,2,0,0
		range(0,2)=0,0,5,0,0
		range(0,3)=0,0,0,0,0
		range(0,4)=0,0,0,0,0
		attackCore@Chess __type@Chess,range
	return
#global

#module Kema __name,__type,virtual_attack
	#define new(%1,%2) dimtype %1,5: newmod %1,Kema,%2
	#define news(%1,%2) newmod %1,Kema,%2
	#modinit str _name
		__type="桂"
		super@Chess _name
	return

	*override_attack
		dim range,5,5
		range(0,0)=0,1,0,1,0
		range(0,1)=0,0,0,0,0
		range(0,2)=0,0,5,0,0
		range(0,3)=0,0,0,0,0
		range(0,4)=0,0,0,0,0
		attackCore@Chess __type@Chess,range
	return
#global

#module Ginsho __name,__type,virtual_attack
	#define new(%1,%2) dimtype %1,5: newmod %1,Ginsho,%2
	#define news(%1,%2) newmod %1,Ginsho,%2
	#modinit str _name
		__type="銀"
		super@Chess _name
	return

	*override_attack
		dim range,5,5
		range(0,0)=0,0,0,0,0
		range(0,1)=0,1,1,1,0
		range(0,2)=0,0,5,0,0
		range(0,3)=0,1,0,1,0
		range(0,4)=0,0,0,0,0
		attackCore@Chess __type@Chess,range
	return
#global

#module Kinsho __name,__type,virtual_attack
	#define new(%1,%2) dimtype %1,5: newmod %1,Kinsho,%2
	#define news(%1,%2) newmod %1,Kinsho,%2
	#modinit str _name
		__type="金"
		super@Chess _name
	return

	*override_attack
		dim range,5,5
		range(0,0)=0,0,0,0,0
		range(0,1)=0,1,1,1,0
		range(0,2)=0,1,5,1,0
		range(0,3)=0,0,1,0,0
		range(0,4)=0,0,0,0,0
		attackCore@Chess __type@Chess,range
	return
#global

#module Kakusho __name,__type,virtual_attack
	#define new(%1,%2) dimtype %1,5: newmod %1,Kakusho,%2
	#define news(%1,%2) newmod %1,Kakusho,%2
	#modinit str _name
		__type="角"
		super@Chess _name
	return

	*override_attack
		dim range,5,5
		range(0,0)=2,0,0,0,2
		range(0,1)=0,2,0,2,0
		range(0,2)=0,0,5,0,0
		range(0,3)=0,2,0,2,0
		range(0,4)=2,0,0,0,2
		attackCore@Chess __type@Chess,range
	return
#global

#module Hisha __name,__type,virtual_attack
	#define new(%1,%2) dimtype %1,5: newmod %1,Hisha,%2
	#define news(%1,%2) newmod %1,Hisha,%2
	#modinit str _name
		__type="飛"
		super@Chess _name
	return

	*override_attack
		dim range,5,5
		range(0,0)=0,0,2,0,0
		range(0,1)=0,0,2,0,0
		range(0,2)=2,2,5,2,2
		range(0,3)=0,0,2,0,0
		range(0,4)=0,0,2,0,0
		attackCore@Chess __type@Chess,range
	return
#global

#module Ryuma __name,__type,virtual_attack
	#define new(%1,%2) dimtype %1,5: newmod %1,Ryuma,%2
	#define news(%1,%2) newmod %1,Ryuma,%2
	#modinit str _name
		__type="馬"
		super@Chess _name
	return

	*override_attack
		dim range,5,5
		range(0,0)=2,0,0,0,2
		range(0,1)=0,2,1,2,0
		range(0,2)=0,1,5,1,0
		range(0,3)=0,2,1,2,0
		range(0,4)=2,0,0,0,2
		attackCore@Chess __type@Chess,range
	return
#global


#module Ryuoh __name,__type,virtual_attack
	#define new(%1,%2) dimtype %1,5: newmod %1,Ryuoh,%2
	#define news(%1,%2) newmod %1,Ryuoh,%2
	#modinit str _name
		__type="龍"
		super@Chess _name
	return

	*override_attack
		dim range,5,5
		range(0,0)=0,0,2,0,0
		range(0,1)=0,1,2,1,0
		range(0,2)=2,2,5,2,2
		range(0,3)=0,1,2,1,0
		range(0,4)=0,0,2,0,0
		attackCore@Chess __type@Chess,range
	return
#global

#module Gyokusho __name,__type,virtual_attack
	#define new(%1,%2) dimtype %1,5: newmod %1,Gyokusho,%2
	#define news(%1,%2) newmod %1,Gyokusho,%2
	#modinit str _name
		__type="玉"
		super@Chess _name
	return

	*override_attack
		dim range,5,5
		range(0,0)=0,0,0,0,0
		range(0,1)=0,1,1,1,0
		range(0,2)=0,1,5,1,0
		range(0,3)=0,1,1,1,0
		range(0,4)=0,0,0,0,0
		attackCore@Chess __type@Chess,range
	return
#global

new@Fu unit,"ポーン"
news@Kyosha unit,"ランス"
news@Kema unit,"ナイト"
news@Ginsho unit,"シルバージェネラル"
news@Kinsho unit,"ゴールドジェネラル"
news@Kakusho unit,"ビショップ"
news@Hisha unit,"ルーク"
news@Ryuma unit,"Pビショップ"
news@Ryuoh unit,"Pルーク"
news@Gyokusho unit,"キング"

foreach unit
	x=cnt\5*120+10
	y=cnt/5*200+10
	pos x+45-strlen(name(unit.cnt))*4.5,y
	mes "【"+name(unit.cnt)+"】"
	attack unit.cnt,x+50,y+70
loop