Skip to content

Commit 28c7e9a

Browse files
feat: enhance user prompts and improve console output handling
1 parent 0bb541a commit 28c7e9a

2 files changed

Lines changed: 73 additions & 37 deletions

File tree

src/AkizukiForest/AkizukiForest.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
<Pack>True</Pack>
1717
<PackagePath>\</PackagePath>
1818
</None>
19+
20+
<None Include="..\..\content\**\*">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</None>
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="AliceProject.AnovSyntax" Version="0.2.0" />
1927
</ItemGroup>
2028

2129
</Project>

src/AkizukiForest/Program.cs

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Xml.Linq;
1+
using AnovSyntax;
2+
using System.Xml.Linq;
23

34
namespace AkizukiForest;
45

@@ -11,7 +12,9 @@ static int Main(string[] args)
1112

1213
Console.WriteLine("# Akizuki Forest #");
1314
Console.WriteLine("");
14-
Console.WriteLine("Hint: Ctrl+Cでいつでも終了できます。");
15+
Console.ForegroundColor = ConsoleColor.Green;
16+
Console.WriteLine("Hint: Ctrl+C でいつでも終了できます。");
17+
Console.ResetColor();
1518
Console.WriteLine("");
1619

1720
// 終了時に文字色をもとに戻す
@@ -43,11 +46,15 @@ static int Main(string[] args)
4346
Console.WriteLine("セーブデータが見つかりました。");
4447
Console.ResetColor();
4548

46-
Console.Write("セーブデータを読み込みますか? (N/y): ");
49+
Console.Write("セーブデータを読み込みますか? (Y/n): ");
4750

4851
command = Console.ReadLine();
4952
Console.WriteLine("");
50-
if (command?.ToLower() == "y" || command?.ToLower() == "yes")
53+
if (command?.ToLower() == "n" || command?.ToLower() == "no")
54+
{
55+
Console.WriteLine("セーブデータを読み込まず、開始します。");
56+
}
57+
else
5158
{
5259
Console.WriteLine("セーブデータを読み込みます。");
5360
Console.WriteLine("");
@@ -64,17 +71,13 @@ static int Main(string[] args)
6471
Console.WriteLine("ロードが失敗しました。");
6572
}
6673
}
67-
else
68-
{
69-
Console.WriteLine("セーブデータを読み込まず、開始します。");
70-
}
7174
Console.ReadLine();
7275
}
7376

7477
switch (section)
7578
{
7679
case 0:
77-
Section0();
80+
InitialSettings();
7881
break;
7982

8083
case 1:
@@ -100,9 +103,9 @@ static int Main(string[] args)
100103

101104
return 0;
102105

103-
void Section0()
106+
void InitialSettings()
104107
{
105-
// ## "0.anov" ##
108+
AnovReader("0.anov");
106109

107110
// アイテム選択処理
108111
bool selectingItem = true;
@@ -138,18 +141,11 @@ void ItemSelection(string _itemName, ref int _item, ref int _itemEach, int _item
138141
}
139142
}
140143

141-
Console.WriteLine($"手榴弾{itemBom}個、弾丸{itemBullet}個、医療品{itemMedicine}個でよろしいですか? (N/y): ");
142-
144+
Console.WriteLine($"手榴弾{itemBom}個、弾丸{itemBullet}個、医療品{itemMedicine}個でよろしいですか? (Y/n): ");
145+
143146
command = Console.ReadLine();
144147
Console.WriteLine("");
145-
if (command?.ToLower() == "y" || command?.ToLower() == "yes")
146-
{
147-
selectingItem = false;
148-
// 現時点では、弾丸のセット数を記録しているため、弾数表記に変更
149-
itemBullet *= 10;
150-
Console.WriteLine("");
151-
}
152-
else
148+
if (command?.ToLower() == "n" || command?.ToLower() == "no")
153149
{
154150
WarningConsole("もう一度設定します。");
155151
// アイテム数の初期化
@@ -158,7 +154,12 @@ void ItemSelection(string _itemName, ref int _item, ref int _itemEach, int _item
158154
itemBullet = 0;
159155
itemMedicine = 0;
160156
}
161-
Console.WriteLine("");
157+
else
158+
{
159+
selectingItem = false;
160+
// 現時点では、弾丸のセット数を記録しているため、弾数表記に変更
161+
itemBullet *= 10;
162+
}
162163
}
163164

164165
Section1();
@@ -168,7 +169,7 @@ void Section1()
168169
{
169170
section = 1;
170171

171-
// ## "1.anov" ##
172+
AnovReader("1.anov");
172173

173174
where = false;
174175
while (where == false)
@@ -225,7 +226,7 @@ void Section2()
225226
{
226227
section = 2;
227228

228-
// ## "2.anov" ##
229+
AnovReader("2.anov");
229230

230231
where = false;
231232
while (where == false)
@@ -392,7 +393,7 @@ void Section3()
392393
}
393394
}
394395

395-
// ## "3.anov" ##
396+
AnovReader("3.anov");
396397

397398
// 強制戦闘のため、自動回復
398399
komari.HP = (komari.HP >= 260) ? komari.HP : 260;
@@ -407,7 +408,7 @@ void Section6()
407408
{
408409
section = 6;
409410

410-
// ## "4.anov" ##
411+
AnovReader("4.anov");
411412

412413
// 下の階に行くか、上の階に行くかで大きく√分岐
413414
// 天空世界の頂上到達√…天空世界の結末(たまたま地下洞窟と天空世界でつながってしまったことなど)を明かす
@@ -434,7 +435,7 @@ void Section6()
434435
where = true;
435436
// 天空ルート(戦闘(ボス戦)後に神が現れて現世に戻らせてくれる)
436437

437-
// ## "4.1.1.anov" ##
438+
AnovReader("4.1.1.anov");
438439

439440
// ボス戦
440441
enemy.HP = 1000;
@@ -446,11 +447,11 @@ void Section6()
446447
// 戦闘開始
447448
Buttle();
448449

449-
// ## "4.1.2.anov" ##
450+
AnovReader("4.1.2.anov");
450451

451452
komari.Luck += 5;
452453

453-
// ## "4.1.3.anov" ##
454+
AnovReader("4.1.3.anov");
454455

455456
Console.WriteLine("");
456457
Console.WriteLine("END: 天界の青空 (通常ルート1)");
@@ -463,7 +464,7 @@ void Section6()
463464
where = true;
464465
// 地上ルート (地下の場所に関する文献を読める。また、魔導書かワープ装置か何かで現世に戻る。)
465466

466-
// ## "4.2.anov" ##
467+
AnovReader("4.2.anov");
467468

468469
// 探索ターン
469470
// 最短√…机のメモを読む→本棚からメモに書いてある題名の本を探す→斜め読み→地上世界へ戻る魔法→終了 (神には遭遇しない)
@@ -494,7 +495,7 @@ void Section6()
494495
{
495496
// 机のメモ帳を見ているときの処理
496497

497-
// ## "4.2.1.anov" ##
498+
AnovReader("4.2.1.anov");
498499

499500
which = true;
500501
}
@@ -534,7 +535,7 @@ void Section6()
534535
case "3":
535536
where = true;
536537

537-
// ## "3.3.anov" ##
538+
AnovReader("3.3.anov");
538539

539540
Console.WriteLine("");
540541
Console.WriteLine("END: 森の泉 (隠しルート)");
@@ -561,16 +562,15 @@ void Section6()
561562
// (未来になって航空隊2人の名前が決まっても、決まっていなかった時代のストーリーということで未来になっても上記と同じ考察が可能。))
562563
if (komari.Luck >= 8)
563564
{
564-
// ## "5.0.anov" ##
565+
AnovReader("5.0.anov");
565566
}
566567

567-
Console.WriteLine("開発");
568-
Console.WriteLine("プログラム: Lemon73 (Ivy Cafeteria)");
568+
Console.WriteLine("# 開発 #");
569569
Console.WriteLine("シナリオ: Lemon73 (Ivy Cafeteria)");
570-
Console.WriteLine("");
570+
Console.WriteLine("プログラム: Lemon73 (Ivy Cafeteria)");
571571
Console.WriteLine("ベース: .NET 8.0 (Console) (Microsoft)");
572572
Console.WriteLine("");
573-
Console.WriteLine("終了です。お疲れさまでした。");
573+
Console.WriteLine("ゲームクリアです!遊んでいただき、ありがとうございました。");
574574
Console.ReadLine();
575575
// 裏話…手榴弾を実装したのは、実はトンネル内にふさがっているところがあって、そこを爆破して進んでいくためだったんだけど、
576576
// トンネルの話が長くなりすぎてつまらなかったから辞めた。だから、攻撃と逃げるときの両方で使えるくらいしかメリットはない
@@ -579,6 +579,34 @@ void Section6()
579579
// 難易度調整はミスった (簡単すぎた) かも (だからといって今から調整するのも面倒)
580580
}
581581

582+
// Alice System
583+
void AnovReader(string filePath)
584+
{
585+
filePath = Path.Combine(AppContext.BaseDirectory, "story", filePath);
586+
587+
if (!File.Exists(filePath))
588+
{
589+
Console.WriteLine($"ファイル\"{filePath}\"が見つかりません。");
590+
Console.ReadLine();
591+
return;
592+
}
593+
594+
using (StreamReader sr = new(filePath))
595+
{
596+
while (!sr.EndOfStream)
597+
{
598+
string? line = sr.ReadLine();
599+
if (line == "")
600+
Console.ReadLine();
601+
else if (line is not null)
602+
Console.WriteLine(Anov.Read(line));
603+
}
604+
Console.ReadLine();
605+
}
606+
607+
return;
608+
}
609+
582610
// 誤った入力
583611
void InvalidInput()
584612
{

0 commit comments

Comments
 (0)