代码拉取完成,页面将自动刷新
同步操作将从 吕焱飞/zuul 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import java.util.*;
/**
* This class is the main class of the "World of Zuul" application.
* "World of Zuul" is a very simple, text based adventure game. Users
* can walk around some scenery. That's all. It should really be extended
* to make it more interesting!
*
* To play this game, create an instance of this class and call the "play"
* method.
*
* This main class creates and initialises all the others: it creates all
* rooms, creates the parser and starts the game. It also evaluates and
* executes the commands that the parser returns.
*
* @author Michael Kölling and David J. Barnes
* @version 2016.02.29
*/
public class Game
{
private Parser parser;
private Room currentRoom;
private Food bag = null;
private Food bag1 = null;
private int gj = 10;
private int fy = 10;
private Player player;
private boolean y = false;
private int strength = 100;
private int bosshurt = 40;
/**
* Create the game and initialise its internal map.
*/
public Game()
{
createRooms();
parser = new Parser();
player = new Player();
}
/**
* Create all the rooms and link their exits together.
*/
private void createRooms()
{
Room myc, syc, yyc, ztz, mgdw, lyc, xlzd, zjzg, wyc, chd;
// create the rooms
myc = new Room("木叶村",new Food("一乐拉面",50));
syc = new Room("你来到砂隐村,你的伙伴我爱罗见你任务在身给你了一袋兵粮丸", new Food("兵粮丸",30));
yyc = new Room("这里是音隐村,没想到木叶叛徒大蛇丸早已身居于此,他使用了通灵术击退了你,让你失去70点查克拉!",70);
xlzd = new Room("修炼之地,刚刚你目睹了卡卡西和宇智波鼬的战斗,在他们走后你可以捡用过的忍具-手里剑", new Food("手里剑",0));
mgdw = new Room("你来到了终极之谷,但是飞天到贼偷走了你的10点伤害");
lyc = new Room("到了雷影村,在这里你与到了身上都存在尾兽的奇拉比学会了-九尾狐衣 你选择可以使用它", new Food("九尾狐衣",0));
ztz = new Room("你在途中看到了鹿丸和吃货丁次在一起旅行友好的丁次给你了一串三色丸子", new Food("三色丸子",40));
zjzg = new Room("蘑菇地窝,这些蘑菇看起来很好吃你是否要吃一吃", new Food("蘑菇",-20));
wyc = new Room("到达了雾影村,从这里打听到自来也现在正在。彩虹谷写亲热天堂");
chd = new Room("彩虹谷,你找到了自来也,并于他发生了战斗");
// initialise room exits
myc.setExit("north", syc);
syc.setExit("west", yyc);
syc.setExit("south", myc);
syc.setExit("north", ztz);
yyc.setExit("east", syc);
ztz.setExit("south", syc);
ztz.setExit("north", zjzg);
zjzg.setExit("north", mgdw);
zjzg.setExit("south", ztz);
zjzg.setExit("west", xlzd);
zjzg.setExit("east", lyc);
xlzd.setExit("east", zjzg);
mgdw.setExit("south", zjzg);
lyc.setExit("west", zjzg);
mgdw.setExit("east", wyc);
wyc.setExit("west", mgdw);
lyc.setExit("north", wyc);
wyc.setExit("south", lyc);
wyc.setExit("north", chd);
chd.setExit("south", wyc);
currentRoom = myc; // start game outside
}
/**
* Main play routine. Loops until end of play.
*/
public void play()
{
printWelcome();
// Enter the main command loop. Here we repeatedly read commands and
// execute them until the game is over.
boolean finished = false;
while (! finished) {
Command command = parser.getCommand();
finished = processCommand(command);
}
System.out.println("谢谢参与! ありがとうございます");
}
/**
* Print out the opening message for the player.
*/
private void printWelcome()
{
System.out.println();
System.out.println("这里是火影忍者世界!一个忍者云集的天堂,当然也十分危险。");
System.out.println("火影给你了一个特别的任务打败自来也");
System.out.println("你是来自木叶村的下忍漩涡鸣人。接下来你要面对艰险的任务");
System.out.println("输入“help”你就可以查看你的火影任务卡上面写着完成任务的方法");
System.out.println("提示:查克拉就是你的能量");
System.out.println();
System.out.println("你到了" + currentRoom.getDescription());
currentRoom.printExits();
}
/**
* Given a command, process (that is: execute) the command.
* @param command The command to be processed.
* @return true If the command ends the game, false otherwise.
*/
private boolean processCommand(Command command)
{
boolean wantToQuit = false;
if(command.isUnknown()) {
System.out.println("我不知道你什么意思。。。。");
return false;
}
Word commandWord = command.getCommandWord();
switch(commandWord){
case HELP:
printHelp();
break;
case GO:
goRoom(command);
player.step();
strength-=10;
System.out.println("查克拉:"+strength+",攻击力:"+gj+",防御力:"+fy);
break;
case QUIT:
wantToQuit = quit(command);
break;
case LOOK:
Food food = currentRoom.getFood();
if(food != null){
System.out.println("这里有" + food.getName());
}
else{
System.out.println("这里没有任何痕迹。");
}
break;
case PICK:
Food food1 = currentRoom.getFood();
if(food1.getName()=="兵粮丸"){
if(bag==null){
bag=food1;
System.out.println("你捡起了"+ food1.getName());
}
else
System.out.println("道具包满了");
}
else if(food1.getName()=="一乐拉面"){
if(bag1==null){
bag1=food1;
System.out.println("你捡起了"+ food1.getName());
}
else
System.out.println("你的忍者包满了");
}
else if(food1.getName()=="蘑菇"){
if(bag1==null){
bag1=food1;
System.out.println("你捡起了"+ food1.getName());
}
else
System.out.println("你的忍者包满了");
}
else if(food1.getName()=="三色丸子"){
if(bag1==null){
bag1=food1;
System.out.println("你捡起了"+ food1.getName());
}
else
System.out.println("你的忍者包满了");
}
else if(food1.getName()=="九尾狐衣"){
gj+=10;
fy+=20;
System.out.println("你的攻击力增加了10,防御力增加了20");
}
else if(food1.getName()=="手里剑"){
gj+=30;
fy+=0;
System.out.println("你的攻击力增加了30,防御力增加了0");
}
break;
case EAT:
if(bag != null){
System.out.println("你吃了" + bag.getName());
player.eat(bag.getName());
strength+=bag.getEnergy();
if(strength>100)
strength=100;
bag=null;
}
else if(bag1 != null){
System.out.println("你吃了" + bag1.getName());
player.eat(bag1.getName());
strength+=bag1.getEnergy();
if(strength>100)
strength=100;
bag1=null;
}
else{
System.out.println("你没有可以补充查克拉的食物了。");
}
System.out.println("查克拉:"+strength+",攻击力:"+gj+",防御力:"+fy);
break;
case CHECK:
if(bag != null){
System.out.println("你的道具包里有" + bag.getName());
}
else{
System.out.println("你的道具包里只有空气。");
}
if(bag1 != null){
System.out.println("你的忍者包里有" + bag1.getName());
}
else{
System.out.println("你的忍者包空空如也。");
}
break;
case SEE:
System.out.println("查克拉:"+strength+",攻击力:"+gj+",防御力:"+fy);
}
if(currentRoom.getDescription()=="彩虹谷,你找到了自来也,并于他发生了战斗"){
for(int bossblood=150;bossblood>=0;){
if(bossblood<0) bossblood=0;
bossblood-=gj;
System.out.println("自来也剩余的血量:"+bossblood+",boss的攻击力:"+bosshurt);
if(bosshurt>fy){
strength = strength-bosshurt+fy;
System.out.println("查克拉:"+strength+",攻击力:"+gj+",防御力:"+fy);
}
}
if(strength>0){
System.out.println("你打败了自来也完成了任务,顺利回归");
wantToQuit = true;
}
}
if(strength<=0){
if(strength<=0)
System.out.println("你的查克拉耗尽死了");
wantToQuit = true;
}
if(currentRoom.getDescription()=="你来到了终极之谷,但是飞天到贼偷走了你的10点伤害"){
gj=gj-10;
System.out.println("你的伤害减10");
}
return wantToQuit;
}
// implementations of user commands:
/**
* Print out some help information.
* Here we print some stupid, cryptic message and a list of the
* command words.
*/
private void printHelp()
{
System.out.println("火影任务卡");
System.out.println("你需要学会仙术");
System.out.println("这一路会有很多阻碍");
System.out.println("这里有你的任务行动准则");
System.out.println("祝你好运");
Word[] words = Word.values();
for(int i=0;i<words.length;i++){
System.out.print(words[i].getCommandWord()+" ");
System.out.println();
}
}
/**
* Try to go in one direction. If there is an exit, enter
* the new room, otherwise print an error message.
*/
private void goRoom(Command command)
{
if(!command.hasSecondWord()) {
System.out.println("去哪儿?");
return;
}
String direction = command.getSecondWord();
// Try to leave current room.
Room nextRoom = currentRoom.goNext(direction);
if(nextRoom == null){
System.out.println("这里受到了封印不能进入");
}
else {
currentRoom = nextRoom;
strength-=currentRoom.getHurt();
System.out.println("你在" + currentRoom.getDescription());
currentRoom.printExits();
}
}
/**
* "Quit" was entered. Check the rest of the command to see
* whether we really quit the game.
* @return true, if this command quits the game, false otherwise.
*/
private boolean quit(Command command)
{
if(command.hasSecondWord()) {
System.out.println("Quit what?");
return false;
}
else {
return true; // signal that we want to quit
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。