我的基于文字的游戏出了什么问题?

时间:2016-04-04 13:40:51

标签: java

所以我正在制作一个基于文本的游戏,当我运行游戏并选择我的班级(骑士,法师或弓箭手)时,它会给我100,100,100。

怎么了?

代码

import java.util.Scanner;

public class AdventureText {
  public static void main(String[] main) {

    String namePlr;
    String classPlr;
    int healthPlr;
    int magickaPlr;
    int staminaPlr;
    int maxHealthPlr;
    int maxMagickaPlr;
    int maxStaminaPlr;

    instructions();

    Scanner in = new Scanner(System.in);     //Reader

    console("What is your name?");
    namePlr = in.nextLine();

    console("What class are you? Knight, Mage or Archer?");
    classPlr = in.nextLine();

    if (classPlr == "Knight") {     
      healthPlr = 200;
      magickaPlr = 100;
      staminaPlr = 150;
      maxHealthPlr = 200;
      maxMagickaPlr = 100;
      maxStaminaPlr = 150;
      console("Your stats are");
      console("Max Health: " + maxHealthPlr);
      console("Max Magicka: " + maxMagickaPlr);
      console("Max Stamina: " + maxStaminaPlr);         
    } else if (classPlr == "Mage") {         
      healthPlr = 100;
      magickaPlr = 200;
      staminaPlr = 150;
      maxHealthPlr = 100;
      maxMagickaPlr = 200;
      maxStaminaPlr = 150;
      console("Your stats are");
      console("Max Health: " + maxHealthPlr);
      console("Max Magicka: " + maxMagickaPlr);
      console("Max Stamina: " + maxStaminaPlr);      
    } else if (classPlr == "Archer") {          
      healthPlr = 150;
      magickaPlr = 100;
      staminaPlr = 200;
      maxHealthPlr = 150;
      maxMagickaPlr = 100;
      maxStaminaPlr = 200;    
      console("Your stats are");
      console("Max Health: " + maxHealthPlr);
      console("Max Magicka: " + maxMagickaPlr);
      console("Max Stamina: " + maxStaminaPlr);
    } else {
      console("Oh, you are nobody. So...");
      console("Brawler suits you");
      healthPlr = 100;
      magickaPlr = 100;
      staminaPlr = 100;
      maxHealthPlr = 100;
      maxMagickaPlr = 100;
      maxStaminaPlr = 100;      
      console("Your stats are");
      console("Max Health: " + maxHealthPlr);
      console("Max Magicka: " + maxMagickaPlr);
      console("Max Stamina: " + maxStaminaPlr);
    }

  }
  public static void console(String write) {

    System.out.println(write);

  }
  public static void instructions() {

    console("Hello and welcome to Adventure Text.");
    console("WARNING: This game is caps sensitive. Always start input line with a capital letter!!!");

  }

}

0 个答案:

没有答案