这里的代码基本上用于根据骰子的滚动来决定字符串。其中有很多陈述,我确实需要一些帮助来减少这种情况。我在网上看了一些方法,但不太适合。
public String generatePassageSection(){
int roll = roll();
if(roll<=2 && roll>=1)
{
return "passage goes straight for 10 feet.";
}
else if(roll<=5 && roll>=3)
{
return "passage ends in door to a chamber.";
}
else if(roll<=7 && roll>=6)
{
return "door to right (main passage continues straight for 10 ft)";
}
else if(roll<=9 && roll>=8)
{
return "door to left (main passage continues straight for 10 ft)";
}
else if(roll<=11 && roll>=10)
{
return "passage turns to left and continues for 10 ft";
}
else if(roll<=13 && roll>=12)
{
return "passage turns to right and continues for 10 ft";
}
else if(roll<=16 && roll>=14)
{
return "passage ends in door to chamber";
}
else if(roll==17)
{
return "Stairs, (passage continues straight for 10 ft)";
}
else if (roll<=19 && roll>=18)
{
return "Dead end";
}
else if(roll==20)
{
return "Wandering Monster (passage continues straight for 10 ft)";
}
else
{
return null;
}
大话西游666
郎朗坤
子衿沉夜
相关分类