Github
The upcoming team project is determined to add new features based on the 'Console Text RPG' on last week. Before to implement the feature, we have to discuss the details. Each team member have the different results. Among them, my result is elected with the good classification of the script. Even the result has developed to my own flavor, this is good for using 'Git'. Trimming some features, I made the base of team project pretty well. The game contains these features.
Player
could be only one from the game. So I made it to the singleton. Items
owned by Player
has the feature of hierachy, which can be affected to the Equipable items
.Shop
also sell the items which is loaded from the ItemList.csv
fileChoice
method. The attached script has complex condition on while
, which will be addressed on the Q & A
session public static int Choice(int min, int max, int cutmin = -1, int cutmax = -1)
{
// 1 3 (-1 -1 ) 4
string in_str = Console.ReadLine();
int choice;
while(!int.TryParse(in_str, out choice) || !(choice >= min && choice <=max) || ((cutmin==-1&&cutmax==-1)?false:(choice >= cutmin && choice <= cutmax)))
{
if(cutmin == -1 && cutmax == -1)
{
Console.SetCursorPosition(5, 22);
Console.WriteLine("원하시는 행동을 입력해주세요 ({0} ~ {1}중에서 골라주세요)",min, max);
}
else
{
Console.SetCursorPosition(5, 22);
Console.WriteLine("{0} ~ {1} 제외한 {2} ~ {3}중에서 골라주세요,",cutmin,cutmax,min, max);
}
Console.SetCursorPosition(5, 23);
Console.Write(">>");
Console.SetCursorPosition(8, 23);
in_str = Console.ReadLine();
}
return choice;
}
With the base on the project, we discussed each role of the project. In order to avoid the confilcts when merging the result via git, the classification was done with the files.
Battle.cs
)MonsterList.csv
& Monster.cs
)ItemList.csv
,Item.cs
& Quest.cs
)Player.cs
& Skill.cs
)After the decision of role, we have to build the flow of the game. Since the game is based on the Console Text RPG of last project, we simply made game flow chart and properties for the battle like below figure.
Q. When the condition is written like the below script, it doesn't work well. What is the error and How to solve it?
while(false || false || true?false:true)
{
...
}
A. The error could be occur from the Ternary operator
. When the script is running, the compiler understood this like below flow
while( (false || false || true?)false:true)
{
...
}
If you want to make the script to work normally, you should wrap up the ternary condition like (false || (true?false:true))