コード例 #1
0
ファイル: ASCIIInterface.java プロジェクト: shadrx/cluedo
  @Override
  public Optional<Suggestion> requestPlayerSuggestion(Player player, Room room) {
    char userWantsToMakeSuggestion = '\0';

    while (userWantsToMakeSuggestion != 'Y' && userWantsToMakeSuggestion != 'N') {
      this.out.println("Do you want to make an suggestion (Y/N)?");
      this.out.println("Your cards are: " + player.cards);
      userWantsToMakeSuggestion = this.scanner.next().charAt(0);
    }

    if (userWantsToMakeSuggestion == 'Y') {
      this.out.printf("You suggest it was done in the %s, by: \n", room);

      Stream<String> suspects =
          Arrays.stream(CluedoCharacter.values()).map(CluedoCharacter::toString);
      CluedoCharacter suspect = CluedoCharacter.values()[this.selectOptionFromList(suspects)];

      this.out.println("with the ");

      Stream<String> weapons = Arrays.stream(Weapon.values()).map(Weapon::toString);
      Weapon weapon = Weapon.values()[this.selectOptionFromList(weapons)];

      return Optional.of(new Suggestion(suspect, weapon, room));

    } else {
      return Optional.empty();
    }
  }
コード例 #2
0
ファイル: GameCanvas.java プロジェクト: shadrx/cluedo
  private void drawPlayer(
      Graphics g,
      Location<Float> location,
      CluedoCharacter character,
      double step,
      boolean drawTransparent) {

    double diameter = step * PlayerDiameterRatio;

    final double characterBorderRatio = 1.2f;

    g.setColor(new Color(0.f, 0.f, 0.f, drawTransparent ? 0.2f : 1.f)); // Draw the black outline
    g.fillOval(
        round(location.x - diameter * characterBorderRatio / 2),
        round(location.y - diameter * characterBorderRatio / 2),
        round(diameter * characterBorderRatio),
        round(diameter * characterBorderRatio));

    // Draw the character.
    g.setColor(
        new Color(
            character.colour().getRed(),
            character.colour().getGreen(),
            character.colour().getBlue(),
            drawTransparent ? 50 : 255));
    g.fillOval(
        round(location.x - diameter / 2),
        round(location.y - diameter / 2),
        round(diameter),
        round(diameter));
  }
コード例 #3
0
ファイル: ASCIIInterface.java プロジェクト: shadrx/cluedo
  @Override
  public Optional<Suggestion> requestPlayerAccusation(Player player) {
    char userWantsToMakeAccusation = '\0';

    while (userWantsToMakeAccusation != 'Y' && userWantsToMakeAccusation != 'N') {
      this.out.println("Do you want to make an accusation (Y/N)?");
      userWantsToMakeAccusation = this.scanner.next().charAt(0);
    }

    if (userWantsToMakeAccusation == 'Y') {
      this.out.println("Choose your suspect:");

      Stream<String> suspects =
          Arrays.stream(CluedoCharacter.values())
              .filter(e -> !player.cards.contains(e))
              .map(CluedoCharacter::toString);
      CluedoCharacter suspect = CluedoCharacter.values()[this.selectOptionFromList(suspects)];

      this.out.println("Choose your weapon:");

      Stream<String> weapons =
          Arrays.stream(Weapon.values())
              .filter(e -> !player.cards.contains(e))
              .map(Weapon::toString);
      Weapon weapon = Weapon.values()[this.selectOptionFromList(weapons)];

      this.out.println("Choose your room:");

      Stream<String> rooms =
          Arrays.stream(Room.values()).filter(e -> !player.cards.contains(e)).map(Room::toString);
      Room room = Room.values()[this.selectOptionFromList(rooms)];

      return Optional.of(new Suggestion(suspect, weapon, room));

    } else {
      return Optional.empty();
    }
  }