-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.cs
114 lines (96 loc) · 2.89 KB
/
node.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Text;
namespace TextGame
{
class node
{
//consists of:
//display
//store options somehow
public string Name;
public string Body;
List<option> Options;
public node()
{
Options = new List<option>();
}
public option GetOption(int OptionIndex)
{
if (OptionIndex < 0 || OptionIndex >= Options.Count)
{
return null;
}
else
{
return Options[OptionIndex];
}
}
public void AddOption(option a_option)
{
Options.Add(a_option);
}
public void AddModifiers(option an_option, List<string> List_of_Modifiers_In_Sentence_Form)
{
}
public int Display(statistics stats)
{
string[] DisplayStrings = Body.Split("\\n");
char[] dashStringArr = new char[Console.WindowWidth];
for (int i = 0; i < Console.WindowWidth; i++)
dashStringArr[i] = '-';
Console.WriteLine("\n");
Console.WriteLine(new string(dashStringArr));
for (int i = 0; i < DisplayStrings.Length; i++)
{
string DisplayString = DisplayStrings[i];
int len = DisplayString.Length;
while (len > 0)
{
if (len > Console.WindowWidth)
{
Console.WriteLine(DisplayString.Substring(0, Console.WindowWidth));
DisplayString = DisplayString.Substring(Console.WindowWidth);
}
else
{
Console.SetCursorPosition((Console.WindowWidth - DisplayString.Length) / 2, Console.CursorTop);
Console.WriteLine(DisplayString);
}
len -= Console.WindowWidth;
}
}
Console.WriteLine();
int counter = 0;
foreach (option o in Options)
{
if (o == null)
{
continue;
}
else if (o.CanDisplay(stats))
{
counter++;
Console.WriteLine($"({counter}): {o.text}");
}
else
{
continue;
}
}
return counter;
}
public override string ToString()
{
string retval = "";
retval += Name + ", ";
retval += Body;
foreach (option x in Options)
{
retval += ", " + x;
}
return retval;
}
}
}