Microsoft Small Basic

Program Listing: QVR556
'準備
XP = 0
Level = 1
LvUp = 60
Elementype[1]="HP"'Elementypeじゃなくてhighstatus。
Extra[1]=30'ボーナス量
Losestatus[1]="DMG"'不得意なステータス
low[1]=10'不得意なステータスが減る量
Elementype[2]="DMG"
Extra[2]=10
Losestatus[2]="DEF"
low[2]=4
Elementype[3]="MP"
Extra[3]=5
Losestatus[3]="HP"
low[3]=20
Elementype[4]="DEF"
Extra[4]=4
Losestatus[4]="HEAL"
low[4]=3
Elementype[5]="HEAL"
Extra[5]=3
Losestatus[5]="MP"
low[5]=6
Status["HP"]=100'Elementypeで得意ステータスの名前にしちゃったからこの方がわかりやすい
Status["DMG"]=25'デフォルトステータス
Status["MP"]=15
Status["DEF"]=10
Status["HEAL"]=6
enemys[1][1]="スライム"'配列の数値の一番目は開放する条件(フラグ)、二番目は同じ条件を持つ中での番号
unlock[1][1]=2'対応するものを倒したときに立てるフラグ
EXP[1][1]=20'対応するものを倒したときに獲得する経験値
enestatus[1][1]["HP"]=35
enestatus[1][1]["DMG"]=8
enestatus[1][1]["MP"]=0
enestatus[1][1]["DEF"]=5
enestatus[1][1]["HEAL"]=0
enemys[1][2]="ウサギ"
unlock[1][2]=3
EXP[1][2]=35
enestatus[1][2]["HP"]=40
enestatus[1][2]["DMG"]=15
enestatus[1][2]["MP"]=5
enestatus[1][2]["DEF"]=8
enestatus[1][2]["HEAL"]=2
enemys[2][1]="狼"
EXP[2][1]=70
enestatus[2][1]["HP"]=50
enestatus[2][1]["DMG"]=25
enestatus[2][1]["MP"]=5
enestatus[2][1]["DEF"]=10
enestatus[2][1]["HEAL"]=5
unlock[2][1]=4
enemys[3][1]="熊"
unlock[3][1]=4
EXP[3][1]=120
enestatus[3][1]["HP"]=60
enestatus[3][1]["DMG"]=40
enestatus[3][1]["MP"]=10
enestatus[3][1]["DEF"]=15
enestatus[3][1]["HEAL"]=5
enemys[4][1]="トラ"
unlock[4][1]=4
EXP[4][1]=200
enestatus[4][1]["HP"]=75
enestatus[4][1]["DMG"]=60
enestatus[4][1]["MP"]=15
enestatus[4][1]["DEF"]=22
enestatus[4][1]["HEAL"]=7
enemys[4][2]="毒蛇"
unlock[4][2]=5
EXP[4][2]=215
enestatus[4][2]["HP"]=75
enestatus[4][2]["DMG"]=70
enestatus[4][2]["MP"]=5
enestatus[4][2]["DEF"]=15
enestatus[4][2]["HEAL"]=3
enemys[5][1]="八岐大蛇"
unlock[5][1]=5
EXP[5][1]=320
enestatus[5][1]["HP"]=100
enestatus[5][1]["DMG"]=100
enestatus[5][1]["MP"]=10
enestatus[5][1]["DEF"]=20
enestatus[5][1]["HEAL"]=4
unlock_list[1]=1
'ステータス設定
TextWindow.ForegroundColor="yellow"
TextWindow.WriteLine("得意ステータスを選んでください")
TextWindow.ForegroundColor="White"
TextWindow.WriteLine("1.HP")
TextWindow.WriteLine("2.攻撃力")
TextWindow.WriteLine("3.魔力")
TextWindow.WriteLine("4.防御")
TextWindow.WriteLine("(その他).回復力")
Your_element=TextWindow.ReadNumber()'Your_elementじゃなくてYour_statusの方が近い
Set_status()'当てはまらない数値なら回復力に直してステータス変動
TextWindow.WriteLine("初期ステータス")
For count=1 To Array.GetItemCount(Status)'ステータス表示
change=Elementype[count]
TextWindow.WriteLine(change+":"+Status[change])
EndFor
TextWindow.WriteLine("レベルアップまでの経験値:"+(LvUp-XP))
Program.Delay(3000)'これないとステータスが見れない
'バトル
choose:
meslength = 0
TextWindow.Clear()
TextWindow.ForegroundColor="green"
TextWindow.WriteLine("戦う相手を選んでください")
TextWindow.ForegroundColor="Red"
Write_enemys()
For count=1 To Array.GetItemCount(Status)
change=Elementype[count]
data[change]=Status[change]
enemydata[change]=enestatus[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]][change]
EndFor
Battle_start:
Showdata()
Program.Delay(1000)
TextWindow.CursorTop=8+Array.GetItemCount(Status)+meslength
TextWindow.ForegroundColor="Red"
TextWindow.WriteLine("1.攻撃")
TextWindow.ForegroundColor="green"
TextWindow.WriteLine("2.回復(MP5消費)")
TextWindow.ForegroundColor="White"
Move=TextWindow.ReadNumber()
While Move<>1 And Move<>2
Move=TextWindow.ReadNumber()
EndWhile
If Move=1 Then
If data["DMG"]>enemydata["DEF"] Then
enemydata["HP"]=enemydata["HP"]-(data["DMG"]-enemydata["DEF"])
meslength=meslength+1
Message[meslength] = enemys[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]]+"に"+(data["DMG"]-enemydata["DEF"])+"のダメージを与えた!"
Color[meslength] = "green"
Else
meslength=meslength+1
Message[meslength] = "攻撃が効かない!"
Color[meslength] = "Red"
EndIf
Else
If data["MP"]>=5 Then
data["HP"]=data["HP"]+data["HEAL"]
data["MP"]=data["MP"]-5
meslength=meslength+1
Message[meslength] = data["HEAL"]+"回復した!"
Color[meslength] = "green"
Else
TextWindow.WriteLine("魔力が足りません。")
Program.Delay(1000)
Goto Battle_start
EndIf
EndIf
Showdata()
Myturn=0
Goto Check
Return:
Program.Delay(1000)
If Math.GetRandomNumber(5) And enemydata["MP"]>=5 Then
enemydata["HP"]=enemydata["HP"]+enemydata["HEAL"]
enemydata["MP"]=enemydata["MP"]-5
meslength=meslength+1
Message[meslength] = enemys[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]]+"は"+enemydata["HEAL"]+"回復した!"
Color[meslength] = "White"
Else
If enemydata["DMG"]>data["DEF"] Then
data["HP"]=data["HP"]-(enemydata["DMG"]-data["DEF"])
meslength=meslength+1
Message[meslength] = enemydata["DMG"]-data["DEF"]+"のダメージ!"
Color[meslength] = "White"
Else
meslength=meslength+1
Message[meslength] = enemys[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]]+"の攻撃はこちらに効いていない!"
Color[meslength] = "green"
EndIf
EndIf
Myturn=1
Check:
If data["HP"]>0 And enemydata["HP"]>0 Then
If Myturn=1 Then
Goto Battle_start
Else
Goto Return
EndIf
Else
meslength=meslength+1
If data["HP"]>0 Then
Message[meslength]=enemys[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]]+"を倒した!"
Else
Message[meslength]="あなたは倒れた・・・"
EndIf
Showdata()
If data["HP"]>0 Then
unlock_list[Array.GetItemCount(unlock_list)+1]=unlock[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]]
XP=XP+EXP[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]]
TextWindow.ForegroundColor="green"
TextWindow.Write(EXP[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]])
TextWindow.ForegroundColor="White"
TextWindow.Write("の経験値を獲得")
If XP>=LvUp Then
LvUp=LvUp*(Level+4)
Level=Level+1
XP = 0
TextWindow.WriteLine("!")
TextWindow.ForegroundColor="yellow"
TextWindow.WriteLine("レベルアップ!次のレベルまで"+LvUp+"XP!")
Status["HP"]=Status["HP"]+10*Level
Status["DMG"]=Status["DMG"]+3*Level
Status["MP"]=Status["MP"]+2*Level
Status["DEF"]=Status["DEF"]+1*Level
Status["HEAL"]=Status["HEAL"]+1*Level
Program.Delay(2000)
TextWindow.Clear()
TextWindow.WriteLine("現在ステータス")
TextWindow.ForegroundColor="White"
For count=1 To Array.GetItemCount(Status)
change=Elementype[count]
TextWindow.WriteLine(change+":"+Status[change])
EndFor
Else
TextWindow.WriteLine("、次のレベルまで"+(LvUp-XP)+"XP。")
EndIf
EndIf
TextWindow.PauseWithoutMessage()
Goto choose
EndIf
'サブルーチン
Sub Set_status
If Your_element<1 Or Your_element>4 Or Math.Remainder(Your_element,1)<>0 Then
Your_element=Array.GetItemCount(Elementype)
EndIf
change=Elementype[Your_element]
Status[change]=Status[change]+Extra[Your_element]
change=Losestatus[Your_element]
Status[change]=Status[change]-low[Your_element]
EndSub

Sub Write_enemys
i=0
For a=1 To Array.GetItemCount(enemys)
For b=1 To Array.GetItemCount(enemys[a])
If Array.ContainsValue(unlock_list,a) Then
i=i+1
Shortcut_key_A[i]=a'この敵の条件フラグ
Shortcut_key_B[i]=b'同じ条件の中での順番
TextWindow.WriteLine(i+"."+enemys[a][b])
EndIf
EndFor
EndFor
Getnumber=TextWindow.ReadNumber()
While i Getnumber=TextWindow.ReadNumber()
EndWhile
TextWindow.ForegroundColor="Red"
AddText="VS."+enemys[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]]'あえて一気に表示させない
For i=Text.GetLength(AddText) To 1 Step -1'AddTextの文を下から1文字ずつ表示していく
TextWindow.Clear()
TextWindow.Write(Text.GetSubTextToEnd(AddText,i))
Program.Delay(100)'これがないと一気に表示してしまう
EndFor
Program.Delay(2000)
EndSub

Sub Showdata
TextWindow.Clear()
TextWindow.WriteLine("Level:"+Level)
TextWindow.CursorTop=4
TextWindow.ForegroundColor="green"
TextWindow.Write("あなたのステータス")
Length[0]=TextWindow.CursorLeft
TextWindow.WriteLine("")
For count=1 To Array.GetItemCount(Status)
change=Elementype[count]
Length[count]=Text.GetLength(change+":"+data[change])
TextWindow.WriteLine(change+":"+data[change]+"/"+Status[change])
EndFor
TextWindow.CursorTop=4
CursorLeft = Length[0]+4
TextWindow.CursorLeft=CursorLeft
TextWindow.ForegroundColor="red"
TextWindow.WriteLine(enemys[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]]+"のステータス")
For count=1 To Array.GetItemCount(Status)
change=Elementype[count]
TextWindow.CursorLeft=CursorLeft
TextWindow.WriteLine(change+":"+enemydata[change]+"/"+enestatus[Shortcut_key_A[Getnumber]][Shortcut_key_B[Getnumber]][change])
EndFor
TextWindow.WriteLine("")
For count=1 To meslength
TextWindow.ForegroundColor = Color[count]
TextWindow.WriteLine(Message[count])
EndFor
EndSub